g++ assembly output

Brian Dessent brian@dessent.net
Sun Dec 10 00:56:00 GMT 2006


Yunnat wrote:

> I write in C++ and generate assembly output by g++ -S. Is it possible to
> annotate this output with the original C++ code? E.g. it would be nice to
> get sth like
> 
> % a++;
> inc ax;
> 
> or maybe
> 
> % main.cpp, line 6
> inc ax;

There was just a thread about this on the mailing list in the last few
weeks.  It started with
<http://gcc.gnu.org/ml/gcc-help/2006-11/msg00290.html>.

Note that using the -a assembler option does not work in conjuction with
-S because the assembler is not actually called, so you need to create
the listing as a side effect of compilation.  But that is all explained
in the above thread.

Alternatively, if you build with -g then you can use "objdump -dS
file.o" on any object in your build directory.  This has the advantage
of not having to modify the build with any special options.

Brian



More information about the Gcc-help mailing list