Source-interleaved disassembly from GDB and objdump

痴心易碎 提交于 2019-12-10 18:59:15

问题


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).

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).

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.


回答1:


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.

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.



来源:https://stackoverflow.com/questions/32950799/source-interleaved-disassembly-from-gdb-and-objdump

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!