English 中文(简体)
• 如何利用亚洲开发银行找到一个记忆地址的对应功能
原标题:How to use GDB to find what function a memory address corresponds to
  • 时间:2011-10-03 18:51:55
  •  标签:
  • c++
  • gdb

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  

我如何确定这些记忆地址的功能/准则与否?

最佳回答

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

info symbol addr

打印在地址添加器上储存的编号。 如无正直的编号,则gdb打印出最接近的编号,并从中删除:

(gdb) info symbol 0x54320
_initialize_vx + 396 in section .text

这正好相反。 你们可以凭借自己的地址找到变数或功能的名称。

对于有活力联系的应诉人,也可印制可执行或共享的有文号的图书馆的名称:

(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
问题回答

最初的问题是,如何在亚洲开发银行这样做:

# NOT what you want; note the lack of  * :
(gdb) info symbol 0xfde09edc
blah() + 388 in section .text of /tmp/libblah.so

# IS what you want; note the presence of  * :
(gdb) info line *0xfde09edc
Line 91 of "blah.cc"
   starts at address 0xfde09ebc <blah()+356>
   and ends at 0xfde09ee4 <blah()+396>

www.un.org/Depts/DGACM/index_french.htm

您也可使用<代码>。 悬挂以下国旗的指挥:<代码>/m:

(gdb) disassemble /m 0xfde09edc

......尽管它只字面和<条码>英线<>/条码>准确列出了要求的内容。

假设您的双手资料已解冻g++-g,你可以使用x/获取该信息,我知道该表的工作。

x/<num>xw toprint <num> hexword of memory, and gdb will annotate the左边 with information about what s at the address.





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签