3

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

uj2
  • 2,195
  • 2
  • 20
  • 31

4 Answers4

5

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
  • 33,910
  • 5
  • 73
  • 99
3

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.

1

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
  • 9,154
  • 27
  • 39
1
gcc yourFile.C -S -fverbose-asm

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

Stephen Canon
  • 100,816
  • 18
  • 175
  • 263