目前,我手动浏览info proc mappings
中的内存映射列表,了解地址所处的范围。是不是更方便了?
(gdb) i proc map
process 23912
Mapped address spaces:
Start Addr End Addr Size Offset objfile
0x601000 0x6ce000 0xcd000 0x0 [heap]
0x7fffe6d65000 0x7fffe6d67000 0x2000 0x0 /usr/lib64/libXau.so.6.0.0
0x7fffe6d67000 0x7fffe6f67000 0x200000 0x2000 /usr/lib64/libXau.so.6.0.0
0x7fffe6f67000 0x7fffe6f68000 0x1000 0x2000 /usr/lib64/libXau.so.6.0.0
0x7fffe6f68000 0x7fffe6f69000 0x1000 0x3000 /usr/lib64/libXau.so.6.0.0
0x7fffe6f69000 0x7fffe6f89000 0x20000 0x0 /usr/lib64/libxcb.so.1.1.0
0x7fffe6f89000 0x7fffe7188000 0x1ff000 0x20000 /usr/lib64/libxcb.so.1.1.0
0x7fffe7188000 0x7fffe7189000 0x1000 0x1f000 /usr/lib64/libxcb.so.1.1.0
0x7fffe7189000 0x7fffe718a000 0x1000 0x20000 /usr/lib64/libxcb.so.1.1.0
0x7fffe718a000 0x7fffe718c000 0x2000 0x0 /usr/lib64/libXss.so.1.0.0
0x7fffe718c000 0x7fffe738c000 0x200000 0x2000 /usr/lib64/libXss.so.1.0.0
0x7fffe738c000 0x7fffe738d000 0x1000 0x2000 /usr/lib64/libXss.so.1.0.0
0x7fffe738d000 0x7fffe738e000 0x1000 0x3000 /usr/lib64/libXss.so.1.0.0
...
答案 0 :(得分:2)
你想要info sym
。这里是来自简单程序堆栈中的不同帧:
(gdb) info sym $pc
_fxstat + 20 in section .text of /lib64/libc.so.6
或
(gdb) info sym $pc
std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long) + 422 in section .text of /lib64/libstdc++.so.6
或
(gdb) info sym $pc
main + 25 in section .text of /tmp/q