我正在使用Google的堆检查程序来跟踪内存泄漏。它给我一个堆栈跟踪,例如:
Leak of 21 bytes in 1 objects allocated from:
@ 0xf6088241
@ 0xf60890d2
@ 0xf6089246
@ 0x8054781
@ 0x8054862
@ 0xf684ee76
@ 0xf684f343
@ 0x804be4c
@ 0x80544f6
@ 0xf5e52bb6
@ 0x804b101
如何确定这些内存地址对应的函数/代码行?
发布于 2018-04-11 15:50:49
使用info symbol
gdb命令。
info symbol addr
Print the name of a symbol which is stored at the address addr. If no symbol is stored exactly at addr, gdb prints the nearest symbol and an offset from it:
(gdb) info symbol 0x54320
_initialize_vx + 396 in section .text
This is the opposite of the info address command. You can use it to find out the name of a variable or a function given its address.
For dynamically linked executables, the name of executable or shared library containing the symbol is also printed:
(gdb) info symbol 0x400225
_start + 5 in section .text of /tmp/a.out
(gdb) info symbol 0x2aaaac2811cf
__read_nocancel + 6 in section .text of /usr/lib64/libc.so.6
发布于 2018-04-11 16:13:49
假设你的二进制文件有调试信息g++ -g
,你可能可以x/
用来获取信息,我知道它适用于vtable。
https://stackoverflow.com/questions/-100003858
复制相似问题