GDB-将地址映射到源代码中的行和列 [英] GDB - map address to line and column in source code
问题描述
gcc和clang都具有选项 -gcolumn-info
,其描述方式如下:
Both gcc and clang have option -gcolumn-info
, which is described this way:
将位置列信息发送到DWARF调试信息中,而不仅仅是文件和行.
Emit location column information into DWARF debugging information, rather than just file and line.
我已经使用此选项编译了二进制文件.现在,我有一些说明的地址,并想将其翻译回源文件,行号和列.有没有办法在gdb中做到这一点?还有其他一些工具可以提取此信息吗?
I have compiled my binary with this option. Now I have address of some instruction and want to translate it back to source file, line number and column. Is there a way to do it in gdb? Is there some other tool that can extract this information?
我知道我可以在gdb中使用 info行* 0xabcd1234
来获取源文件和与该地址对应的行,但是它不会显示该列.
I know that I can use info line *0xabcd1234
in gdb to get the source file and line corresponding to that address, but it does not show the column.
推荐答案
在回答我的问题时,我发现了一种使用 lldb
和 image lookup
命令获取信息的方法:
Answering my guestion, I found one way to get the information using lldb
and image lookup
command:
(lldb) image lookup --address 0x134adc
Address: libaaa.so[0x0000000000134adc] (libaaa.so.PT_LOAD[0]..text + 1030908)
Summary: libaaa.so`test() + 272 at test.cpp:1842:124
这篇关于GDB-将地址映射到源代码中的行和列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!