How to see assembly listing of compiler output

Topics for the Eclipse Environment
Post Reply
pholden
Posts: 5
Joined: Thu May 14, 2009 11:29 am

How to see assembly listing of compiler output

Post by pholden »

I would like to see an assembly listing file for some (or all) of the .cpp files in my project to make sure the compiler output will give me adequate performance. Ideally, this would be a mixed listing showing the high level code embedded in the assembly listing, but just the assembly would be OK. I have tried using assembler directives in my gnu C and gnu c++ compiler options (-Wa, aln) and I can see the assembly list going past in the console, but no files are generated. I can't find any further information in the GNU documents provided by NB, and other hints found on the web only show how to use a command line option on a single input file. Is there a way to get assembly listing files from a make?
User avatar
Forrest
Posts: 287
Joined: Wed Apr 23, 2008 10:05 am

Re: How to see assembly listing of compiler output

Post by Forrest »

Try this:

Start a debug build and connect with the debugger. Once in the debug perspective, click on Window->Show View->Other and select Debug->Disassembly. It will pop up a new window the assembler code. At this point, you can even choose to step through assmbler code.
Forrest Stanley
Project Engineer
NetBurner, Inc

NetBurner Learn Articles: http://www.netburner.com/learn
pholden
Posts: 5
Joined: Thu May 14, 2009 11:29 am

Re: How to see assembly listing of compiler output

Post by pholden »

I am aware that I can step through code and look at the dis-assembly window once the project builds completely, and I have hardware to download to, etc. Other tools I have used, such as CodeWarrior and CodeComposer, let you compile and get a dis-assembly listing of a single file without building the entire project or needing hardware. This is somewhat more handy than bulding and downloading the project repeatedly to tune the source code syntax, local vairables vs pointers, case statements vs jump tables, etc. Since it appears that the assembler does have the option to output a mixed listing, I was just hoping there was an easier way.
rhopf1
Posts: 37
Joined: Mon May 12, 2008 5:57 am

Re: How to see assembly listing of compiler output

Post by rhopf1 »

I've poured through the gcc manual a few times, mostly hoping it'd somehow show up but gcc doesn't have a compile through assembly option that I can find. :(
User avatar
lgitlitz
Posts: 331
Joined: Wed Apr 23, 2008 11:43 am
Location: San Diego, CA
Contact:

Re: How to see assembly listing of compiler output

Post by lgitlitz »

Hi,

In the GNU package installed with the NNDK there is a command line tool that prints out the generated disassembly code from an elf file. Open a command window to the directory that contains the project .elf generated from the make. Then type:
m68k-elf-objdump -S Your_Project.elf >AssemblerOutput.txt

This will create a text file in the directory that contains a pretty readable version of assembly in Your_Project.elf. Most of your C/C++ function names and variables will still be used in the code which is nice. If you want to experiment with the other options type:
m68k-elf-objdump -?

-Larry
rnixon
Posts: 833
Joined: Thu Apr 24, 2008 3:59 pm

Re: How to see assembly listing of compiler output

Post by rnixon »

Found one at the following link. Search for "how to make a list file"

http://www.netburner.com/support/techni ... ments.html
pholden
Posts: 5
Joined: Thu May 14, 2009 11:29 am

Re: How to see assembly listing of compiler output

Post by pholden »

Thanks for the suggestions on using the objdump utility. With the -S and -G options, it does provide a useable assembly listing, although the high level source code is not embedded. It even works on individual source files (.od extension) in the project output folder, although jumps will be stubbed since it has not linked. The text file is generated much more quickly for a single file. The listing will give a feeling for how much code is being generated per function, although it looks like downloading and debugging with the disasembly view, as you originally suggested, is the best option overall.
Post Reply