首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何使用gdb查找内存地址对应的功能

如何使用gdb查找内存地址对应的功能
EN

Stack Overflow用户
提问于 2018-04-11 07:13:27
回答 2查看 0关注 0票数 0

我正在使用Google的堆检查程序来跟踪内存泄漏。它给我一个堆栈跟踪,例如:

代码语言:txt
复制
Leak of 21 bytes in 1 objects allocated from:                                                                                                                                                               
    @ 0xf6088241                                                                                                                                                                                               
    @ 0xf60890d2                                                                                                                                                                                               
    @ 0xf6089246                                                                                                                                                                                               
    @ 0x8054781                                                                                                                                                                                                
    @ 0x8054862                                                                                                                                                                                                
    @ 0xf684ee76                                                                                                                                                                                               
    @ 0xf684f343                                                                                                                                                                                               
    @ 0x804be4c                                                                                                                                                                                                
    @ 0x80544f6                                                                                                                                                                                                
    @ 0xf5e52bb6                                                                                                                                                                                               
    @ 0x804b101  

如何确定这些内存地址对应的函数/代码行?

EN

回答 2

Stack Overflow用户

发布于 2018-04-11 15:50:49

使用info symbolgdb命令。

代码语言:javascript
复制
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
票数 0
EN

Stack Overflow用户

发布于 2018-04-11 16:13:49

假设你的二进制文件有调试信息g++ -g,你可能可以x/用来获取信息,我知道它适用于vtable。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/-100003858

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档