lundi 13 juin 2016

[debug] getting valgrind full backtrace when debugging a dynamically loaded library

Little tip:

If you are getting something like this in valgrind while debugging a dynamically loaded library, it is because the symbols from the library have been deleted when the program called dl_close.


==23759==
==23759== HEAP SUMMARY:
==23759== in use at exit: 39,684 bytes in 23 blocks
==23759== total heap usage: 2,433 allocs, 2,410 frees, 6,965,904 bytes allocated
==23759==
==23759== 24 bytes in 1 blocks are definitely lost in loss record 4 of 15
==23759== at 0x402C1BC: malloc (vg_replace_malloc.c:299)
==23759== by 0x4873C87: ???
==23759== by 0x4873DD7: ???
==23759== by 0x48662E5: ???
==23759== by 0x4866324: ???
==23759== by 0x486625D: ???
==23759== by 0x485F5A8: ???
==23759== by 0x485CC73: ???
==23759== by 0x485BCF5: ???
==23759== by 0x804BCE3: setPortParameters() (main.cpp:147)
==23759== by 0x805070D: safeMain(int, char**) (main.cpp:588)
==23759== by 0x8051E8A: main (main.cpp:661)


You need to remove the dl_close call to get a full stack trace.