From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111c93,6373b9200cc9eb65 X-Google-Attributes: gid111c93,public From: Alex Rhomberg Subject: Re: assembly programming on alphas Date: 1999/01/05 Message-ID: <3691CE62.5D564663@ife.ee.ethz.ch>#1/1 X-Deja-AN: 428944772 Content-Transfer-Encoding: 7bit References: <36704B54.55298E9F@xs4all.nl> <36729BEF.36CA000C@frankfurt.netsurf.de> <367BCE26.9DF9792B@moene.indiv.nluug.nl> Content-Type: text/plain; charset=us-ascii X-Trace: 5 Jan 1999 09:33:38 +0100, 129.132.24.209 Organization: Electronics Lab, ETH Zurich, Switzerland MIME-Version: 1.0 Newsgroups: comp.os.linux.alpha Toon Moene wrote: > > Joachim Wesner wrote: > > > Bram wrote: > > > > I've been reading DEC's Assembly Language Programmer's Guide. > > > But I have a couple of questions. > > > > How can I have egcs generate more verbose assembly output? > > > The samples in the guide show the C-source as comments in > > > the assembly file. > > > The output from egcc -S does not give these. > > > To my knowledge, there is no way to have the assembly output mixed with > > the C-source on gcc/egcs. > > Well, I never got around writing this, but the egcc -g -S [other > options] ... command should write the debugging information in the > assembler file, and hence - because the debugging info contains the line > number - it's possible (writing a small C program that reads both the .s > and the .c file) to create a combined file with the assembler code > interspersed with the original C code. Well, one could either write a large C program or a small perl script. This one takes the output of "gcc -g -S" and adds the corresponding source to the line information in the assembler output. I wrote this after just looking at some -S output, so it might be complete crap. It just worked with what I tried ( including code from an include file in a different directory) #!/usr/bin/perl #combines output of gcc -S -g with C source # by Alex Rhomberg #usage: # gcc -S -g --otheroptions blops.c # combasm blops.s while (<>) { chomp; # file name and directory information are in the .stabs line # in double quotes #example: #.stabs "/home/me/progs/tmp/",100,0,0,$Ltext0 #.stabs "blops.c",100,0,0,$Ltext0 #here, I search for .stabs followed by a name, and finally $Ltext if (m|^\.stabs \"(.*)\"[\s\d,]+\$Ltext\d+|) { $name = $1; if ($name =~ m|/$|) { #if the name ends in / it is the working directory chdir $name or die "couldn't chdir to $name"; } else { #otherwise it is the source file, which is read and chomped open CFILE, "$name" or die "couldn't open $name"; @cfile = ; chomp @cfile; close CFILE; } } #line information lines start with .stabn, to numbers and the line number #if such a line is encountered, the source line is added #in optimized code, the same line could appear several times if (/^\s+\.stabn \d+,\d+,(\d+)/) { $_ .= "\t#" . $cfile[$1-1]; } print "$_\n"; } -- _________________________________________________________________ / \ | Alex Rhomberg Tel: +41 1 632 49 18 | | Institut fuer Elektronik Fax: +41 1 632 12 10 | | ETH Zuerich Zentrale: +41 1 632 11 11 | | Gloriastrasse 35 | | 8092 Zuerich email: rhomberg@ife.ee.ethz.ch | \_________________________________________________________________/