tags:

views:

108

answers:

4

When you break into the debugger in VS and open the disassembly window, each assembly 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++.

+3  A: 

Compile your code with gcc -g, then you can disassemble with objdump -S yourfile. this will give you a disassembly interspersed with the source.

Hasturkun
+2  A: 

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.

anon
A: 

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.

ShinTakezou
A: 
gcc yourFile.C -S -fverbose-asm

Not exactly what you're looking for, but more useful than nothing.

Stephen Canon