How to get the symbol name for a memory address in GDB?

后端 未结 5 1956
一整个雨季
一整个雨季 2020-12-12 19:38

For instance, I know that 0x46767f0 belongs to an NSString*, is there any way I can find out what NSString it is to help me find some bugs I\'m after?

5条回答
  •  鱼传尺愫
    2020-12-12 19:54

    I believe you're looking for:

    info symbol 
    

    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.

    Example:

    (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
    

    You can read more about it here.

提交回复
热议问题