Alex Rivera | Logout

How to use GDB to find what function a memory address corresponds to

Asked 2011-10-03T18:51:55.087
47

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                                                                                                                                                                                                
    @ 0x80544f
Edit
Report

1 Answer

2

Assuming your binary has debug information g++ -g you may be able to use x/ to get the info, I know that works for vtables.

x/<num>xw to print <num> hex words of memory, and gdb will annotate the left side with information about what's at the address.

answered 2011-10-03T19:34:53.053

Your Answer