如何使 gdb 在反汇编模型上显示原始的非修改函数名称?
void outputString(const char *str) {
cout << "outputString(const char *str) : " << str << endl;
}
事实证明,
Dump of assembler code for function _Z12outputStringPKc:
0x004013ee <_Z12outputStringPKc+0>: push ebp
0x004013ef <_Z12outputStringPKc+1>: mov ebp,esp
0x004013f1 <_Z12outputStringPKc+3>: sub esp,0x8
0x004013f4 <_Z12outputStringPKc+6>: mov DWORD PTR [esp+4],0x443000
0x004013fc <_Z12outputStringPKc+14>: mov DWORD PTR [esp],0x4463c0
0x00401403 <_Z12outputStringPKc+21>: call 0x43f6e8 <_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc>
0x00401408 <_Z12outputStringPKc+26>: mov edx,DWORD PTR [ebp+8]
0x0040140b <_Z12outputStringPKc+29>: mov DWORD PTR [esp+4],edx
0x0040140f <_Z12outputStringPKc+33>: mov DWORD PTR [esp],eax
0x00401412 <_Z12outputStringPKc+36>: call 0x43f6e8 <_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc>
0x00401417 <_Z12outputStringPKc+41>: mov DWORD PTR [esp+4],0x43e4c8
0x0040141f <_Z12outputStringPKc+49>: mov DWORD PTR [esp],eax
0x00401422 <_Z12outputStringPKc+52>: call 0x42e170 <_ZNSolsEPFRSoS_E>
0x00401427 <_Z12outputStringPKc+57>: leave
0x00401428 <_Z12outputStringPKc+58>: ret
End of assembler dump.
所有的反汇编都只显示了损坏的函数名称,但对于程序员来说,要解密并获取原始函数名称并不容易,因为需要为每个遇到的损坏名称键入 info symbol address
,那么有没有什么方法可以让 gdb 在汇编模型上显示非破坏函数名称?
void outputString(const char *str) {
cout << "outputString(const char *str) : " << str << endl;
}
turns out to be
Dump of assembler code for function _Z12outputStringPKc:
0x004013ee <_Z12outputStringPKc+0>: push ebp
0x004013ef <_Z12outputStringPKc+1>: mov ebp,esp
0x004013f1 <_Z12outputStringPKc+3>: sub esp,0x8
0x004013f4 <_Z12outputStringPKc+6>: mov DWORD PTR [esp+4],0x443000
0x004013fc <_Z12outputStringPKc+14>: mov DWORD PTR [esp],0x4463c0
0x00401403 <_Z12outputStringPKc+21>: call 0x43f6e8 <_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc>
0x00401408 <_Z12outputStringPKc+26>: mov edx,DWORD PTR [ebp+8]
0x0040140b <_Z12outputStringPKc+29>: mov DWORD PTR [esp+4],edx
0x0040140f <_Z12outputStringPKc+33>: mov DWORD PTR [esp],eax
0x00401412 <_Z12outputStringPKc+36>: call 0x43f6e8 <_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc>
0x00401417 <_Z12outputStringPKc+41>: mov DWORD PTR [esp+4],0x43e4c8
0x0040141f <_Z12outputStringPKc+49>: mov DWORD PTR [esp],eax
0x00401422 <_Z12outputStringPKc+52>: call 0x42e170 <_ZNSolsEPFRSoS_E>
0x00401427 <_Z12outputStringPKc+57>: leave
0x00401428 <_Z12outputStringPKc+58>: ret
End of assembler dump.
All the disassemblies show only the manglinged function names,but its not eaiser for programmer to de-mangling and get the original function names with the bother to typing info symbol address
for each mangling name met,so are there any methods that could make gdb show non-mangling function names on assembly model?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以在
(gdb)
提示符下执行maint demangle _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
。手册上说:
不幸的是,它似乎不起作用:
该设置更改了当前的方式函数被打印,但不打印它调用的函数的方式(这就是我假设你想要的)。
我认为这是
GDB
中的错误,请在 中提交错误错误吉拉。更新:
该错误已于 2013 年修复。GDB-10.0 的输出为:
You could do
maint demangle _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
at the(gdb)
prompt.The manual says:
Unfortunately, it doesn't appear to work:
The setting changed how the current function is printed, but not how the functions it calls are printed (which is what I assume you are after).
I think that is a bug in
GDB
, please file a bug in bugzilla.Update:
The bug has been fixed in 2013. With GDB-10.0 the output is:
我不记得曾经为 gdb 找到过自动执行此操作的方法。我总是只是复制并粘贴该符号,然后通过 Linux
c++filt
实用程序运行它来分解。I don't remember ever finding an automatic way for gdb to do it. I always just copied and pasted the symbol and ran it through the Linux
c++filt
utility to demangle.gdb 在反汇编模型上显示原始的非重整函数名称 ::
每次要调试时都必须执行此步骤。
1. 将打印修角设置为开启
2. 设置 print asm-demangle on
否则你可以像 ~/.vimrc 文件一样创建 vim ~/.gdbinit 文件并设置以下步骤,这样你就不需要每次都这样做在 。
1 套打印漂亮
2 设置打印去角
3 设置 print asm-demangle 打开
gdb show the original non-mangling function name on disassembly model ::
you have to do this steps every time whenever you are going to debug.
1. set print demangle on
2. set print asm-demangle on
Else you can create vim ~/.gdbinit file like ~/.vimrc file and set following steps so you no need to do every time on .
1 set print pretty on
2 set print demangle on
3 set print asm-demangle on
要在较新版本的 GDB 中分解任意符号,请输入
demangle xxx
或简短的dem xxx
。例如:
ref: https://sourceware .org/gdb/current/onlinedocs/gdb.html/Debugging-C-Plus-Plus.html
To demangle an arbitrary symbol in newer version of GDB, type
demangle xxx
or shortlydem xxx
.For example:
ref: https://sourceware.org/gdb/current/onlinedocs/gdb.html/Debugging-C-Plus-Plus.html