Closed kownse closed 5 years ago
First, make sure -g
is used in compile.
memleax
has to parse the symbols itself, while libleak
just uses backtrace_symbols(2)
because it's much simpler.
backtrace_symbols(2)
indeed miss some (not all) function names and line numbers, and I do not know the reason. Anyone can tell why?
You may use readelf -s philo
to parse the symbol by address yourself :)
I got more information (function name and offset) with
gcc -rdynamic
option.
It seems to be the right answer. Thanks
-rdynamic
Pass the flag -export-dynamic to the ELF linker, on targets
that support it. This instructs the linker to add all
symbols, not only used ones, to the dynamic symbol table.
This option is needed for some uses of "dlopen" or to allow
obtaining backtraces from within a program.
callstack[1] expires. count=1 size=32/32 alloc=1 free=0 /media/kownse/OS/code/git/libleak/libleak.so(malloc+0x25) [0x7fe382456195] /usr/lib/x86_64-linux-gnu/libstdc++.so.6(_Znwm+0x18) [0x7fe38215e258] ./philo(+0x2a4e) [0x55e3a0623a4e] ./philo(+0x1e98) [0x55e3a0622e98] ./philo(+0x1883) [0x55e3a0622883] ./philo(+0x131a) [0x55e3a062231a]
Please print detail log just like memleax does.