如何使用GDB来找到内存地址对应的什么函数 [英] How to use GDB to find what function a memory address corresponds to

查看:401
本文介绍了如何使用GDB来找到内存地址对应的什么函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用google的堆检查器来跟踪内存泄漏。它给我一个堆栈跟踪,如:

I am using google's heap checker to track down a memory leak. It gives me a stack trace such as:

Leak of 21 bytes in 1 objects allocated from:                                                                                                                                                               
    @ 0xf6088241                                                                                                                                                                                               
    @ 0xf60890d2                                                                                                                                                                                               
    @ 0xf6089246                                                                                                                                                                                               
    @ 0x8054781                                                                                                                                                                                                
    @ 0x8054862                                                                                                                                                                                                
    @ 0xf684ee76                                                                                                                                                                                               
    @ 0xf684f343                                                                                                                                                                                               
    @ 0x804be4c                                                                                                                                                                                                
    @ 0x80544f6                                                                                                                                                                                                
    @ 0xf5e52bb6                                                                                                                                                                                               
    @ 0x804b101  

如何确定什么功能/地址对应于

How do I determine what functions/lines of code these memory addresses correspond to?

推荐答案

使用信息符号 gdb命令。 16检查符号表

Use info symbol gdb command. 16 Examining the Symbol Table.

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

这篇关于如何使用GDB来找到内存地址对应的什么函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆