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,255
  • 2
  • 21
  • 32

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
  • 35,395
  • 6
  • 71
  • 104
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,432
  • 1
  • 29
  • 39
1
gcc yourFile.C -S -fverbose-asm

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

Stephen Canon
  • 103,815
  • 19
  • 183
  • 269