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

前端 未结 3 1929
情话喂你
情话喂你 2021-01-30 22:56

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:                          


        
3条回答
  •  -上瘾入骨i
    2021-01-30 23:10

    The original question asked how to do this in GDB:

    # 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 
       and ends at 0xfde09ee4 
    

    The * is necessary for info line and shouldn't be used for info symbol.

    You can also use the disassemble command with its /m flag:

    (gdb) disassemble /m 0xfde09edc
    

    ... though it's rather verbose and info line gives exactly what was requested.

提交回复
热议问题