From: Alex Rhomberg <rhomberg@ife.ee.ethz.ch>
Subject: Re: assembly programming on alphas
Date: 1999/01/05 [thread overview]
Message-ID: <3691CE62.5D564663@ife.ee.ethz.ch> (raw)
In-Reply-To: 367BCE26.9DF9792B@moene.indiv.nluug.nl
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 <rhomberg@ife.ee.ethz.ch>
#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 = <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 |
\_________________________________________________________________/
next prev parent reply other threads:[~1999-01-05 5:00 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-12-10 5:00 assembly programming on alphas Bram
1998-12-12 5:00 ` Joachim Wesner
1998-12-12 5:00 ` Clifford T. Matthews
1998-12-12 5:00 ` Joachim Wesner
1998-12-19 5:00 ` Toon Moene
1999-01-05 5:00 ` Alex Rhomberg [this message]
1999-01-06 5:00 ` Bram Stolk
1998-12-12 5:00 ` Raymond Doetjes
1998-12-11 5:00 ` Bram
1998-12-12 5:00 ` Bradley DeJong
1998-12-12 5:00 ` Reginald Beardsley
1998-12-16 5:00 ` Paul Repacholi
1998-12-13 5:00 ` dontspam_esci
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox