Hi
I need to debug/trace the workings of pocketsphinx to understand the internals in a better way. I using gdb on MacOs. I cant step inside calls which are part of libpocketsphinx. I have added LD_LIBRARY_PATH to point to /usr/local/lib
What am I doing wrong here ?
TIA
Chetan
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I started a gdb on /usr/local/pocketsphinx_continuous and when I do a 'si' at ps_get_hyp() I see the following output on the console.
<snip>
INFO: ngram_search_fwdflat.c(963): f wdflat 0.22 wall 0.080 xRT</snip>
Breakpoint 4, recognize_from_file () at continuous.c:183
183 hyp = ps_get_hyp(ps, NULL);
(gdb) si
0x00000001000019a5 183 hyp = ps_get_hyp(ps, NULL);
(gdb) n
INFO: ngram_search.c(1253): lattice start node .0 end node .217
INFO: ngram_search.c(1279): Eliminated 2 nodes before end node
INFO: ngram_search.c(1384): Lattice has 875 nodes, 4910 links
INFO: ps_lattice.c(1380): Bestpath score: -4299
INFO: ps_lattice.c(1384): Normalizer P(O) = alpha(:217:280) = -282333
INFO: ps_lattice.c(1441): Joint P(O,S) = -323164 P(S|O) = -40831
INFO: ngram_search.c(875): bestpath 0.01 CPU 0.003 xRT
INFO: ngram_search.c(878): bestpath 0.01 wall 0.003 xRT
184 if (hyp != NULL)
(gdb)
nm on pocketsphinx_continuous shows for ps_get_hyp
0000000100005058 b _ps
U _ps_default_search_args
U _ps_end_utt
U _ps_free
U _ps_get_hyp
I am not an expert using gdb and linking files but isn't there a way to sort of link libpocketsphinx.3.dylib or load symbols into the current gdb session ?
or
should we be linking libpocketsphinx.a at compile time instead ?
Thanks
Chetan
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
There is no problem with pocketsphinx or gdb, you just do not know gdb well yet.
"si" command does not step into function, it steps one assembler instruction but you remain in current frame, so next command "next" simply steps over ps_get_hyp.
To go inside ps_get_hyp use "step" or "s" instruction, not "si".
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
INFO: ngram_search_fwdflat.c(954): 8399 words searched (29/fr)
INFO: ngram_search_fwdflat.c(957): 3889 word transitions (13/fr)
INFO: ngram_search_fwdflat.c(960): fwdflat 0.23 CPU 0.080 xRT
INFO: ngram_search_fwdflat.c(963): fwdflat 0.23 wall 0.081 xRT
Breakpoint 2, recognize_from_file () at continuous.c:183
183 hyp = ps_get_hyp(ps, NULL);
(gdb) s
INFO: ngram_search.c(1250): lattice start node .0 end node .217
INFO: ngram_search.c(1276): Eliminated 2 nodes before end node
INFO: ngram_search.c(1381): Lattice has 875 nodes, 4910 links
INFO: ps_lattice.c(1380): Bestpath score: -4299
INFO: ps_lattice.c(1384): Normalizer P(O) = alpha(:217:280) = -282333
INFO: ps_lattice.c(1441): Joint P(O,S) = -323164 P(S|O) = -40831
INFO: ngram_search.c(872): bestpath 0.01 CPU 0.003 xRT
INFO: ngram_search.c(875): bestpath 0.01 wall 0.003 xRT
184 if (hyp != NULL)
(gdb) l
179 utt_started = TRUE;
If I put a breakpoint to the file where the function ps_get_hyp is present, I get this:
(gdb) b pocketsphinx.c:1219
Cannot access memory at address 0x2ebb0
(gdb)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am able to debug on my linux instance without any problems. I am not sure what the reason is for the problem I am facing on my Macos. I'll update the notes here if I can figure that out.
Thank you.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi
I need to debug/trace the workings of pocketsphinx to understand the internals in a better way. I using gdb on MacOs. I cant step inside calls which are part of libpocketsphinx. I have added LD_LIBRARY_PATH to point to /usr/local/lib
What am I doing wrong here ?
TIA
Chetan
Probably debug symbols in pocketsphinx are stripped during build, it depends how you install it. Install pocketsphinx from source.
Thanks for your response.
I downloaded the pocketsphinx-5prealpha.tar.gz from the download site. Did a configure ; make ; make install
Chetans-MacBook-Pro:pocketsphinx5 supertramp$ echo $LD_LIBRARY_PATH
libpocketsphinx:/usr/local/lib
I started a gdb on /usr/local/pocketsphinx_continuous and when I do a 'si' at ps_get_hyp() I see the following output on the console.
<snip>
INFO: ngram_search_fwdflat.c(963): f wdflat 0.22 wall 0.080 xRT</snip>
Breakpoint 4, recognize_from_file () at continuous.c:183
183 hyp = ps_get_hyp(ps, NULL);
(gdb) si
0x00000001000019a5 183 hyp = ps_get_hyp(ps, NULL);
(gdb) n
INFO: ngram_search.c(1253): lattice start node
.0 end node.217INFO: ngram_search.c(1279): Eliminated 2 nodes before end node
INFO: ngram_search.c(1384): Lattice has 875 nodes, 4910 links
INFO: ps_lattice.c(1380): Bestpath score: -4299
INFO: ps_lattice.c(1384): Normalizer P(O) = alpha(:217:280) = -282333
INFO: ps_lattice.c(1441): Joint P(O,S) = -323164 P(S|O) = -40831
INFO: ngram_search.c(875): bestpath 0.01 CPU 0.003 xRT
INFO: ngram_search.c(878): bestpath 0.01 wall 0.003 xRT
184 if (hyp != NULL)
(gdb)
nm on pocketsphinx_continuous shows for ps_get_hyp
0000000100005058 b _ps
U _ps_default_search_args
U _ps_end_utt
U _ps_free
U _ps_get_hyp
I am not an expert using gdb and linking files but isn't there a way to sort of link libpocketsphinx.3.dylib or load symbols into the current gdb session ?
or
should we be linking libpocketsphinx.a at compile time instead ?
Thanks
Chetan
There is no problem with pocketsphinx or gdb, you just do not know gdb well yet.
"si" command does not step into function, it steps one assembler instruction but you remain in current frame, so next command "next" simply steps over ps_get_hyp.
To go inside ps_get_hyp use "step" or "s" instruction, not "si".
step/s would still not get me inside the function
INFO: ngram_search_fwdflat.c(954): 8399 words searched (29/fr)
INFO: ngram_search_fwdflat.c(957): 3889 word transitions (13/fr)
INFO: ngram_search_fwdflat.c(960): fwdflat 0.23 CPU 0.080 xRT
INFO: ngram_search_fwdflat.c(963): fwdflat 0.23 wall 0.081 xRT
Breakpoint 2, recognize_from_file () at continuous.c:183
183 hyp = ps_get_hyp(ps, NULL);
(gdb) s
INFO: ngram_search.c(1250): lattice start node
.0 end node.217INFO: ngram_search.c(1276): Eliminated 2 nodes before end node
INFO: ngram_search.c(1381): Lattice has 875 nodes, 4910 links
INFO: ps_lattice.c(1380): Bestpath score: -4299
INFO: ps_lattice.c(1384): Normalizer P(O) = alpha(:217:280) = -282333
INFO: ps_lattice.c(1441): Joint P(O,S) = -323164 P(S|O) = -40831
INFO: ngram_search.c(872): bestpath 0.01 CPU 0.003 xRT
INFO: ngram_search.c(875): bestpath 0.01 wall 0.003 xRT
184 if (hyp != NULL)
(gdb) l
179 utt_started = TRUE;
If I put a breakpoint to the file where the function ps_get_hyp is present, I get this:
(gdb) b pocketsphinx.c:1219
Cannot access memory at address 0x2ebb0
(gdb)
I am able to debug on my linux instance without any problems. I am not sure what the reason is for the problem I am facing on my Macos. I'll update the notes here if I can figure that out.
Thank you.
Ok, additionally it seems gdb has issues with clang-compiled software:
https://github.com/Homebrew/homebrew-dupes/issues/221
you'd better try lldb instead
Thanks Nickolay. lldb works just fine.