GCC: Compile to assembly with clarified correspondence to code?
When you break into the debugger in VS and open the disassembly window, each a开发者_运维问答ssembly fragment is displayed below it's corresponding code section (more or less). GCC with -S outputs only the stripped down assembly.
Is there an option in GCC to show some correspondence to the original code?
Source code is C++.
Compile your code with gcc -g
, then you can disassemble with objdump -S yourfile
. this will give you a disassembly interspersed with the source.
If you are asking about debugging, in gdb use the disassemble command with a /m (mixed) flag:
(gdb) disas /m main
would disassemble main with C++ code interspersed with assembler, assuming the code is available and you compiled with the -g flag.
Disassembly the object instead. The code given normally by -S is exactly what gcc generate for your code, without start code or other things that are put together by the linker. Complement: of course having debug infos in the object helps alot.
gcc yourFile.C -S -fverbose-asm
Not exactly what you're looking for, but more useful than nothing.
精彩评论