Menu

Debugging pocketsphinx

Help
2016-08-02
2016-08-04
  • Chetan Ganjihal

    Chetan Ganjihal - 2016-08-02

    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

     
    • Nickolay V. Shmyrev

      Probably debug symbols in pocketsphinx are stripped during build, it depends how you install it. Install pocketsphinx from source.

       
  • Chetan Ganjihal

    Chetan Ganjihal - 2016-08-02

    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 .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

     
    • Nickolay V. Shmyrev

      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".

       
  • Chetan Ganjihal

    Chetan Ganjihal - 2016-08-03

    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 .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)

     
  • Chetan Ganjihal

    Chetan Ganjihal - 2016-08-03

    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.

     
    • Nickolay V. Shmyrev

      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

       
  • Chetan Ganjihal

    Chetan Ganjihal - 2016-08-04

    Thanks Nickolay. lldb works just fine.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.