从GDB和objdump进行源交错的反汇编 [英] Source-interleaved disassembly from GDB and objdump

查看:191
本文介绍了从GDB和objdump进行源交错的反汇编的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的一个(FWIW,ARM)调试会话中,我注意到GDB和 objdump -S 的源交错反汇编输出以一种有趣的方式有所不同: objdump 似乎跳过了单个/一组指令,并显示了从中生成这些指令的源代码行(指令顺序)。另一方面,GDB的反汇编似乎跳过了源代码行,并列出了从该源代码行生成的所有汇编指令(源命令)。

During one of my (FWIW, ARM) debugging sessions I noticed the source-interleaved disassembly output from GDB and objdump -S differ in an interesting way: objdump seems hop through individual/group of instructions and display the source line from which those instructions were generated (instruction order). GDB disassembly, on the other hand, seems to hop through source lines, and lists all assembly instructions generated from that source line (source order).

对于 -O0 代码,两个程序的输出看起来相同。但是,对于优化的代码,GDB的反汇编更为有用,因为它可以一次将所有其他分散的指令收集到一起,因此很容易看到仅由该源代码行生成的内容(显然,在这种情况下,指令地址不会是连续的。)

For an -O0 code, output from both programs would look the same. But, for optimized code, GDB's disassembly is more helpful in that it gathers all those otherwise-scattered instructions in once place, so it's easy to see what is generated by that source line alone (obviously, in this case, instruction addresses wouldn't be continuous).

我认为两种形式在他们自己的角度上都是有帮助的。我的问题是,这两个程序的显示行为是否可配置。 IOW,我可以告诉GDB像 objdump 那样显示,还是告诉 objdump 像GDB那样显示?另外,还有其他工具可以执行此任务吗?

I think both forms are helpful in their own regard. My question is whether the display behaviour of either programs is configurable. IOW, can I tell GDB to display like objdump, or tell objdump to display like GDB? Also, are there other tools that can perform this feat?

TIA。

推荐答案

我不认为有任何方法可以更改 objdump 的行为,但是,最近在 gdb中添加了一个功能使得可以按指令顺序显示交错的源代码。此功能是新功能,尚无任何版本,但是您可以看到此处此处

I don't believe that there's any way to change the behaviour of objdump, however, a feature has recently been added to gdb that makes it possible to display the interleaved source code in instruction order. This feature is so new it's not in any release yet, but you can see the patches here and here.

有了这些补丁,旧标志 / m 仍按程序源代码行顺序反汇编,而新标志 / s 按指令顺序反汇编。长期计划是删除 / m ,因为在某些极端情况下它已损坏,因此认为不值得解决。

With these patches the old flag /m still disassembles in program source line order, while a new flag /s disassembles in instruction order. The long term plan is to remove /m as it is broken in some edge cases, and it was not considered worth fixing.

这篇关于从GDB和objdump进行源交错的反汇编的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆