summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.bin/gprof/alpha.c5
-rw-r--r--usr.bin/gprof/arcs.c80
-rw-r--r--usr.bin/gprof/arm32.c5
-rw-r--r--usr.bin/gprof/dfn.c28
-rw-r--r--usr.bin/gprof/gprof.c158
-rw-r--r--usr.bin/gprof/gprof.h112
-rw-r--r--usr.bin/gprof/hertz.c5
-rw-r--r--usr.bin/gprof/hppa.c18
-rw-r--r--usr.bin/gprof/hppa.h11
-rw-r--r--usr.bin/gprof/i386.c5
-rw-r--r--usr.bin/gprof/lookup.c12
-rw-r--r--usr.bin/gprof/m68k.c5
-rw-r--r--usr.bin/gprof/m88k.c5
-rw-r--r--usr.bin/gprof/mips.c5
-rw-r--r--usr.bin/gprof/ns32k.c5
-rw-r--r--usr.bin/gprof/pmax.c5
-rw-r--r--usr.bin/gprof/powerpc.c5
-rw-r--r--usr.bin/gprof/printgprof.c162
-rw-r--r--usr.bin/gprof/printlist.c11
-rw-r--r--usr.bin/gprof/sparc.c5
-rw-r--r--usr.bin/gprof/tahoe.c7
-rw-r--r--usr.bin/gprof/vax.c7
22 files changed, 331 insertions, 330 deletions
diff --git a/usr.bin/gprof/alpha.c b/usr.bin/gprof/alpha.c
index 7c324ba7883..3928262f763 100644
--- a/usr.bin/gprof/alpha.c
+++ b/usr.bin/gprof/alpha.c
@@ -1,8 +1,8 @@
-/* $OpenBSD: alpha.c,v 1.2 1996/06/26 05:33:46 deraadt Exp $ */
+/* $OpenBSD: alpha.c,v 1.3 2001/03/22 05:18:29 mickey Exp $ */
/* $NetBSD: alpha.c,v 1.1 1995/04/19 07:24:19 cgd Exp $ */
#ifndef lint
-static char rcsid[] = "$OpenBSD: alpha.c,v 1.2 1996/06/26 05:33:46 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: alpha.c,v 1.3 2001/03/22 05:18:29 mickey Exp $";
#endif /* not lint */
#include "gprof.h"
@@ -10,6 +10,7 @@ static char rcsid[] = "$OpenBSD: alpha.c,v 1.2 1996/06/26 05:33:46 deraadt Exp $
/*
* gprof -c isn't currently supported...
*/
+void
findcall( parentp , p_lowpc , p_highpc )
nltype *parentp;
unsigned long p_lowpc;
diff --git a/usr.bin/gprof/arcs.c b/usr.bin/gprof/arcs.c
index d083928f9b9..a958eb7c39d 100644
--- a/usr.bin/gprof/arcs.c
+++ b/usr.bin/gprof/arcs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: arcs.c,v 1.2 1996/06/26 05:33:47 deraadt Exp $ */
+/* $OpenBSD: arcs.c,v 1.3 2001/03/22 05:18:30 mickey Exp $ */
/* $NetBSD: arcs.c,v 1.6 1995/04/19 07:15:52 cgd Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)arcs.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: arcs.c,v 1.2 1996/06/26 05:33:47 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: arcs.c,v 1.3 2001/03/22 05:18:30 mickey Exp $";
#endif
#endif /* not lint */
@@ -54,6 +54,7 @@ int oldcycle;
/*
* add (or just increment) an arc
*/
+void
addarc( parentp , childp , count )
nltype *parentp;
nltype *childp;
@@ -107,6 +108,7 @@ addarc( parentp , childp , count )
*/
nltype **topsortnlp;
+int
topcmp( npp1 , npp2 )
nltype **npp1;
nltype **npp2;
@@ -204,9 +206,8 @@ doarcs()
* Sort the symbol table in reverse topological order
*/
topsortnlp = (nltype **) calloc( nname , sizeof(nltype *) );
- if ( topsortnlp == (nltype **) 0 ) {
- fprintf( stderr , "[doarcs] ran out of memory for topo sorting\n" );
- }
+ if ( topsortnlp == (nltype **) 0 )
+ warnx("[doarcs] ran out of memory for topo sorting");
for ( index = 0 ; index < nname ; index += 1 ) {
topsortnlp[ index ] = &nl[ index ];
}
@@ -231,7 +232,7 @@ doarcs()
*/
doflags();
/*
- * starting from the topological bottom,
+ * starting from the topological bottom,
* propogate children times up to parents.
*/
dotime();
@@ -241,9 +242,8 @@ doarcs()
* and cycle headers.
*/
timesortnlp = (nltype **) calloc( nname + ncycle , sizeof(nltype *) );
- if ( timesortnlp == (nltype **) 0 ) {
- fprintf( stderr , "%s: ran out of memory for sorting\n" , whoami );
- }
+ if ( timesortnlp == (nltype **) 0 )
+ warnx("ran out of memory for sorting");
for ( index = 0 ; index < nname ; index++ ) {
timesortnlp[index] = &nl[index];
}
@@ -257,6 +257,7 @@ doarcs()
return( timesortnlp );
}
+void
dotime()
{
int index;
@@ -267,6 +268,7 @@ dotime()
}
}
+void
timepropagate( parentp )
nltype *parentp;
{
@@ -299,13 +301,12 @@ timepropagate( parentp )
if ( parentp -> cycleno == childp -> cycleno ) {
continue;
}
- if ( parentp -> toporder <= childp -> toporder ) {
- fprintf( stderr , "[propagate] toporder botches\n" );
- }
+ if ( parentp -> toporder <= childp -> toporder )
+ warnx("[propagate] toporder botches");
childp = childp -> cyclehead;
} else {
if ( parentp -> toporder <= childp -> toporder ) {
- fprintf( stderr , "[propagate] toporder botches\n" );
+ warnx("[propagate] toporder botches");
continue;
}
}
@@ -355,6 +356,7 @@ timepropagate( parentp )
}
}
+void
cyclelink()
{
register nltype *nlp;
@@ -380,11 +382,9 @@ cyclelink()
* i.e. it is origin 1, not origin 0.
*/
cyclenl = (nltype *) calloc( ncycle + 1 , sizeof( nltype ) );
- if ( cyclenl == 0 ) {
- fprintf( stderr , "%s: No room for %d bytes of cycle headers\n" ,
- whoami , ( ncycle + 1 ) * sizeof( nltype ) );
- done();
- }
+ if ( cyclenl == 0 )
+ errx(0, "No room for %d bytes of cycle headers",
+ (ncycle + 1) * sizeof(nltype));
/*
* now link cycles to true cycleheads,
* number them, accumulate the data for the cycle
@@ -423,7 +423,7 @@ cyclelink()
/*
* link members to cycle header
*/
- for ( memberp = nlp ; memberp ; memberp = memberp -> cnext ) {
+ for ( memberp = nlp ; memberp ; memberp = memberp -> cnext ) {
memberp -> cycleno = cycle;
memberp -> cyclehead = cyclenlp;
}
@@ -449,6 +449,7 @@ cyclelink()
/*
* analyze cycles to determine breakup
*/
+int
cycleanalyze()
{
arctype **cyclestack;
@@ -485,9 +486,9 @@ cycleanalyze()
done = FALSE;
cyclestack = (arctype **) calloc( size + 1 , sizeof( arctype *) );
if ( cyclestack == 0 ) {
- fprintf( stderr , "%s: No room for %d bytes of cycle stack\n" ,
- whoami , ( size + 1 ) * sizeof( arctype * ) );
- return;
+ warnx("No room for %d bytes of cycle stack" ,
+ (size + 1) * sizeof(arctype *));
+ return (done);
}
# ifdef DEBUG
if ( debug & BREAKCYCLE ) {
@@ -523,9 +524,10 @@ cycleanalyze()
"[doarcs]" , visited , viable , newcycle , oldcycle);
}
# endif DEBUG
- return( done );
+ return (done);
}
+int
descend( node , stkstart , stkp )
nltype *node;
arctype **stkstart;
@@ -557,8 +559,10 @@ descend( node , stkstart , stkp )
if ( ret == FALSE )
return( FALSE );
}
+ return (TRUE);
}
+int
addcycle( stkstart , stkend )
arctype **stkstart;
arctype **stkend;
@@ -602,8 +606,8 @@ addcycle( stkstart , stkend )
clp = (cltype *)
calloc( 1 , sizeof ( cltype ) + ( size - 1 ) * sizeof( arctype * ) );
if ( clp == 0 ) {
- fprintf( stderr , "%s: No room for %d bytes of subcycle storage\n" ,
- whoami , sizeof ( cltype ) + ( size - 1 ) * sizeof( arctype * ) );
+ warnx("No room for %d bytes of subcycle storage" ,
+ sizeof(cltype) + (size - 1) * sizeof(arctype *));
return( FALSE );
}
stkp = stkloc;
@@ -634,6 +638,7 @@ addcycle( stkstart , stkend )
return( TRUE );
}
+void
compresslist()
{
cltype *clp;
@@ -648,7 +653,9 @@ compresslist()
int maxexitcnt;
int maxwithparentcnt;
int maxnoparentcnt;
- char *type;
+# ifdef DEBUG
+ char *type;
+# endif
maxexitcnt = 0;
maxwithparentcnt = 0;
@@ -718,14 +725,14 @@ compresslist()
maxarcp -> arc_childp -> npropcall -= maxarcp -> arc_count;
# ifdef DEBUG
if ( debug & BREAKCYCLE ) {
- printf( "%s delete %s arc: %s (%d) -> %s from %d cycle(s)\n" ,
- "[compresslist]" , type , maxarcp -> arc_parentp -> name ,
- maxarcp -> arc_count , maxarcp -> arc_childp -> name ,
- maxarcp -> arc_cyclecnt );
+ printf("[compresslist] delete %s arc: "
+ "%s (%ld) -> %s from %d cycle(s)\n", type,
+ maxarcp -> arc_parentp -> name, maxarcp -> arc_count,
+ maxarcp -> arc_childp -> name, maxarcp -> arc_cyclecnt);
}
# endif DEBUG
- printf( "\t%s to %s with %d calls\n" , maxarcp -> arc_parentp -> name ,
- maxarcp -> arc_childp -> name , maxarcp -> arc_count );
+ printf("\t%s to %s with %ld calls\n", maxarcp->arc_parentp -> name,
+ maxarcp->arc_childp->name, maxarcp->arc_count);
prev = &cyclehead;
for ( clp = cyclehead ; clp ; ) {
endlist = &clp -> list[ clp -> size ];
@@ -762,6 +769,7 @@ printsubcycle( clp )
}
#endif DEBUG
+void
cycletime()
{
int cycle;
@@ -791,6 +799,7 @@ cycletime()
* propfraction as the sum of fractional parents' propfractions
* and while we're here, sum time for functions.
*/
+void
doflags()
{
int index;
@@ -854,7 +863,7 @@ doflags()
}
} else {
/*
- * it has parents to pass time to,
+ * it has parents to pass time to,
* but maybe someone wants to shut it up
* by puttting it on -E list. (but favor -F over -E)
*/
@@ -881,10 +890,11 @@ doflags()
/*
* check if any parent of this child
* (or outside parents of this cycle)
- * have their print flags on and set the
+ * have their print flags on and set the
* print flag of the child (cycle) appropriately.
* similarly, deal with propagation fractions from parents.
*/
+void
inheritflags( childp )
nltype *childp;
{
@@ -922,7 +932,7 @@ inheritflags( childp )
}
} else {
/*
- * its a member of a cycle, look at all parents from
+ * its a member of a cycle, look at all parents from
* outside the cycle
*/
headp -> printflag = FALSE;
diff --git a/usr.bin/gprof/arm32.c b/usr.bin/gprof/arm32.c
index 89099decc8d..d9b8a0a1eef 100644
--- a/usr.bin/gprof/arm32.c
+++ b/usr.bin/gprof/arm32.c
@@ -1,8 +1,8 @@
-/* $OpenBSD: arm32.c,v 1.2 1996/06/26 05:33:48 deraadt Exp $ */
+/* $OpenBSD: arm32.c,v 1.3 2001/03/22 05:18:30 mickey Exp $ */
/* $NetBSD: arm32.c,v 1.1 1996/04/01 21:51:22 mark Exp $ */
#ifndef lint
-static char rcsid[] = "$OpenBSD: arm32.c,v 1.2 1996/06/26 05:33:48 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: arm32.c,v 1.3 2001/03/22 05:18:30 mickey Exp $";
#endif /* not lint */
#include "gprof.h"
@@ -10,6 +10,7 @@ static char rcsid[] = "$OpenBSD: arm32.c,v 1.2 1996/06/26 05:33:48 deraadt Exp $
/*
* gprof -c isn't currently supported...
*/
+void
findcall( parentp , p_lowpc , p_highpc )
nltype *parentp;
unsigned long p_lowpc;
diff --git a/usr.bin/gprof/dfn.c b/usr.bin/gprof/dfn.c
index 601c674a1c7..303145e396e 100644
--- a/usr.bin/gprof/dfn.c
+++ b/usr.bin/gprof/dfn.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dfn.c,v 1.2 1996/06/26 05:33:49 deraadt Exp $ */
+/* $OpenBSD: dfn.c,v 1.3 2001/03/22 05:18:30 mickey Exp $ */
/* $NetBSD: dfn.c,v 1.5 1995/04/19 07:15:56 cgd Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)dfn.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: dfn.c,v 1.2 1996/06/26 05:33:49 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: dfn.c,v 1.3 2001/03/22 05:18:30 mickey Exp $";
#endif
#endif /* not lint */
@@ -57,6 +57,7 @@ int dfn_depth;
int dfn_counter;
+void
dfn_init()
{
@@ -67,6 +68,7 @@ dfn_init()
/*
* given this parent, depth first number its children.
*/
+void
dfn( parentp )
nltype *parentp;
{
@@ -113,15 +115,14 @@ dfn( parentp )
/*
* push a parent onto the stack and mark it busy
*/
+void
dfn_pre_visit( parentp )
nltype *parentp;
{
dfn_depth += 1;
- if ( dfn_depth >= DFN_DEPTH ) {
- fprintf( stderr , "[dfn] out of my depth (dfn_stack overflow)\n" );
- exit( 1 );
- }
+ if ( dfn_depth >= DFN_DEPTH )
+ errx(1, "[dfn] out of my depth (dfn_stack overflow)" );
dfn_stack[ dfn_depth ].nlentryp = parentp;
dfn_stack[ dfn_depth ].cycletop = dfn_depth;
parentp -> toporder = DFN_BUSY;
@@ -162,6 +163,7 @@ dfn_busy( childp )
/*
* MISSING: an explanation
*/
+void
dfn_findcycle( childp )
nltype *childp;
{
@@ -180,10 +182,8 @@ dfn_findcycle( childp )
break;
}
}
- if ( cycletop <= 0 ) {
- fprintf( stderr , "[dfn_findcycle] couldn't find head of cycle\n" );
- exit( 1 );
- }
+ if ( cycletop <= 0 )
+ errx( 1, "[dfn_findcycle] couldn't find head of cycle");
# ifdef DEBUG
if ( debug & DFNDEBUG ) {
printf( "[dfn_findcycle] dfn_depth %d cycletop %d " ,
@@ -260,10 +260,8 @@ dfn_findcycle( childp )
}
# endif DEBUG
}
- } else if ( childp -> cyclehead != cycleheadp /* firewall */ ) {
- fprintf( stderr ,
- "[dfn_busy] glommed, but not to cyclehead\n" );
- }
+ } else if ( childp -> cyclehead != cycleheadp /* firewall */ )
+ warnx("[dfn_busy] glommed, but not to cyclehead");
}
}
}
@@ -272,6 +270,7 @@ dfn_findcycle( childp )
* deal with self-cycles
* for lint: ARGSUSED
*/
+void
dfn_self_cycle( parentp )
nltype *parentp;
{
@@ -293,6 +292,7 @@ dfn_self_cycle( parentp )
* [MISSING: an explanation]
* and pop it off the stack
*/
+void
dfn_post_visit( parentp )
nltype *parentp;
{
diff --git a/usr.bin/gprof/gprof.c b/usr.bin/gprof/gprof.c
index 1829f9087af..afed1ac963f 100644
--- a/usr.bin/gprof/gprof.c
+++ b/usr.bin/gprof/gprof.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: gprof.c,v 1.6 2000/12/24 00:28:46 aaron Exp $ */
+/* $OpenBSD: gprof.c,v 1.7 2001/03/22 05:18:30 mickey Exp $ */
/* $NetBSD: gprof.c,v 1.8 1995/04/19 07:15:59 cgd Exp $ */
/*
@@ -44,14 +44,12 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)gprof.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: gprof.c,v 1.6 2000/12/24 00:28:46 aaron Exp $";
+static char rcsid[] = "$OpenBSD: gprof.c,v 1.7 2001/03/22 05:18:30 mickey Exp $";
#endif
#endif /* not lint */
#include "gprof.h"
-char *whoami = "gprof";
-
/*
* things which get -E excluded by default.
*/
@@ -59,6 +57,7 @@ char *defaultEs[] = { "mcount" , "__mcleanup" , 0 };
static struct gmonhdr gmonhdr;
+int
main(argc, argv)
int argc;
char **argv;
@@ -87,7 +86,7 @@ main(argc, argv)
#if defined(__i386__) || defined(__vax__) || defined(__tahoe__) || defined(__sparc__)
cflag = TRUE;
#else
- fprintf(stderr, "gprof: -c isn't supported on this architecture yet\n");
+ fprintf(stderr, "%s: -c isn't supported on this architecture yet\n", __progname);
exit(1);
#endif
break;
@@ -99,7 +98,7 @@ main(argc, argv)
# ifdef DEBUG
printf("[main] debug = %d\n", debug);
# else not DEBUG
- printf("%s: -d ignored\n", whoami);
+ warnx("-d ignored");
# endif DEBUG
break;
case 'E':
@@ -178,7 +177,7 @@ main(argc, argv)
*/
if (hz == 0) {
hz = 1;
- fprintf(stderr, "time is in ticks, not seconds\n");
+ warnx("time is in ticks, not seconds");
}
/*
* dump out a gmon.sum file if requested
@@ -206,7 +205,8 @@ main(argc, argv)
* print the index
*/
printindex();
- done();
+
+ return (0);
}
/*
@@ -214,21 +214,18 @@ main(argc, argv)
* and optionally the text space.
* On return symbol table is sorted by value.
*/
+void
getnfile()
{
FILE *nfile;
int valcmp();
nfile = fopen( a_outname ,"r");
- if (nfile == NULL) {
- perror( a_outname );
- done();
- }
+ if (nfile == NULL)
+ err(1, "fopen: %s", a_outname);
fread(&xbuf, 1, sizeof(xbuf), nfile);
- if (N_BADMAG(xbuf)) {
- fprintf(stderr, "%s: %s: bad format\n", whoami , a_outname );
- done();
- }
+ if (N_BADMAG(xbuf))
+ errx(1, "%s: bad format", a_outname );
getstrtab(nfile);
getsymtab(nfile);
gettextspace( nfile );
@@ -245,32 +242,25 @@ getnfile()
# endif DEBUG
}
+void
getstrtab(nfile)
FILE *nfile;
{
fseek(nfile, (long)(N_SYMOFF(xbuf) + xbuf.a_syms), 0);
- if (fread(&ssiz, sizeof (ssiz), 1, nfile) == 0) {
- fprintf(stderr, "%s: %s: no string table (old format?)\n" ,
- whoami , a_outname );
- done();
- }
+ if (fread(&ssiz, sizeof (ssiz), 1, nfile) == 0)
+ errx(1, "%s: no string table (old format?)" , a_outname);
strtab = calloc(ssiz, 1);
- if (strtab == NULL) {
- fprintf(stderr, "%s: %s: no room for %d bytes of string table\n",
- whoami , a_outname , ssiz);
- done();
- }
- if (fread(strtab+sizeof(ssiz), ssiz-sizeof(ssiz), 1, nfile) != 1) {
- fprintf(stderr, "%s: %s: error reading string table\n",
- whoami , a_outname );
- done();
- }
+ if (strtab == NULL)
+ errx(1, "%s: no room for %ld bytes of string table", a_outname , ssiz);
+ if (fread(strtab+sizeof(ssiz), ssiz-sizeof(ssiz), 1, nfile) != 1)
+ err(1, "%s: reading string table", a_outname);
}
/*
* Read in symbol table
*/
+void
getsymtab(nfile)
FILE *nfile;
{
@@ -288,17 +278,13 @@ getsymtab(nfile)
}
nname++;
}
- if (nname == 0) {
- fprintf(stderr, "%s: %s: no symbols\n", whoami , a_outname );
- done();
- }
+ if (nname == 0)
+ errx(1, "%s: no symbols", a_outname);
askfor = nname + 1;
nl = (nltype *) calloc( askfor , sizeof(nltype) );
- if (nl == 0) {
- fprintf(stderr, "%s: No room for %d bytes of symbol table\n",
- whoami, askfor * sizeof(nltype) );
- done();
- }
+ if (nl == 0)
+ errx(1, "No room for %d bytes of symbol table",
+ askfor * sizeof(nltype));
/* pass2 - read symbols */
fseek(nfile, (long)N_SYMOFF(xbuf), 0);
@@ -332,6 +318,7 @@ getsymtab(nfile)
/*
* read in the text space of an a.out file
*/
+void
gettextspace( nfile )
FILE *nfile;
{
@@ -341,17 +328,14 @@ gettextspace( nfile )
}
textspace = (u_char *) malloc( xbuf.a_text );
if ( textspace == 0 ) {
- fprintf( stderr , "%s: ran out room for %d bytes of text space: " ,
- whoami , xbuf.a_text );
- fprintf( stderr , "can't do -c\n" );
+ warnx("ran out room for %d bytes of text space: can't do -c", xbuf.a_text );
return;
}
(void) fseek( nfile , N_TXTOFF( xbuf ) , 0 );
if ( fread( textspace , 1 , xbuf.a_text , nfile ) != xbuf.a_text ) {
- fprintf( stderr , "%s: couldn't read text space: " , whoami );
- fprintf( stderr , "can't do -c\n" );
+ warnx("couldn't read text space: can't do -c");
free( textspace );
- textspace = 0;
+ textspace = NULL;
return;
}
}
@@ -360,6 +344,7 @@ gettextspace( nfile )
* an array of sampling hits within pc ranges,
* and the arcs.
*/
+void
getpfile(filename)
char *filename;
{
@@ -397,16 +382,12 @@ openpfile(filename)
int size;
int rate;
- if((pfile = fopen(filename, "r")) == NULL) {
- perror(filename);
- done();
- }
+ if((pfile = fopen(filename, "r")) == NULL)
+ err(1, "fopen: %s", filename);
fread(&tmp, sizeof(struct gmonhdr), 1, pfile);
if ( s_highpc != 0 && ( tmp.lpc != gmonhdr.lpc ||
- tmp.hpc != gmonhdr.hpc || tmp.ncnt != gmonhdr.ncnt ) ) {
- fprintf(stderr, "%s: incompatible with first gmon file\n", filename);
- done();
- }
+ tmp.hpc != gmonhdr.hpc || tmp.ncnt != gmonhdr.ncnt))
+ errx(1, "%s: incompatible with first gmon file", filename);
gmonhdr = tmp;
if ( gmonhdr.version == GMONVERSION ) {
rate = gmonhdr.profrate;
@@ -419,12 +400,9 @@ openpfile(filename)
}
if (hz == 0) {
hz = rate;
- } else if (hz != rate) {
- fprintf(stderr,
- "%s: profile clock rate (%d) %s (%d) in first gmon file\n",
- filename, rate, "incompatible with clock rate", hz);
- done();
- }
+ } else if (hz != rate)
+ errx(1, "%s: profile clock rate (%d) incompatible with clock rate "
+ "(%ld) in first gmon file", filename, rate, hz);
s_lowpc = (unsigned long) gmonhdr.lpc;
s_highpc = (unsigned long) gmonhdr.hpc;
lowpc = (unsigned long)gmonhdr.lpc / sizeof(UNIT);
@@ -447,6 +425,7 @@ openpfile(filename)
return(pfile);
}
+void
tally( rawp )
struct rawarc *rawp;
{
@@ -475,6 +454,7 @@ tally( rawp )
/*
* dump out the gmon.sum file
*/
+void
dumpsum( sumfile )
char *sumfile;
{
@@ -483,24 +463,18 @@ dumpsum( sumfile )
struct rawarc arc;
FILE *sfile;
- if ( ( sfile = fopen ( sumfile , "w" ) ) == NULL ) {
- perror( sumfile );
- done();
- }
+ if ( ( sfile = fopen ( sumfile , "w" ) ) == NULL )
+ err(1, "fopen: %s", sumfile);
/*
* dump the header; use the last header read in
*/
- if ( fwrite( &gmonhdr , sizeof gmonhdr , 1 , sfile ) != 1 ) {
- perror( sumfile );
- done();
- }
+ if ( fwrite( &gmonhdr , sizeof gmonhdr , 1 , sfile ) != 1 )
+ err(1, "fwrite: %s", sumfile);
/*
* dump the samples
*/
- if (fwrite(samples, sizeof (UNIT), nsamples, sfile) != nsamples) {
- perror( sumfile );
- done();
- }
+ if (fwrite(samples, sizeof (UNIT), nsamples, sfile) != nsamples)
+ err(1, "fwrite: %s", sumfile);
/*
* dump the normalized raw arc information
*/
@@ -509,10 +483,8 @@ dumpsum( sumfile )
arc.raw_frompc = arcp -> arc_parentp -> value;
arc.raw_selfpc = arcp -> arc_childp -> value;
arc.raw_count = arcp -> arc_count;
- if ( fwrite ( &arc , sizeof arc , 1 , sfile ) != 1 ) {
- perror( sumfile );
- done();
- }
+ if (fwrite ( &arc , sizeof arc , 1 , sfile ) != 1)
+ err(1, "fwrite: %s", sumfile);
# ifdef DEBUG
if ( debug & SAMPLEDEBUG ) {
printf( "[dumpsum] frompc 0x%x selfpc 0x%x count %d\n" ,
@@ -524,6 +496,7 @@ dumpsum( sumfile )
fclose( sfile );
}
+int
valcmp(p1, p2)
nltype *p1, *p2;
{
@@ -536,19 +509,17 @@ valcmp(p1, p2)
return EQUALTO;
}
+void
readsamples(pfile)
FILE *pfile;
{
- register i;
UNIT sample;
+ register int i;
if (samples == 0) {
samples = (UNIT *) calloc(sampbytes, sizeof (UNIT));
- if (samples == 0) {
- fprintf( stderr , "%s: No room for %d sample pc's\n",
- whoami , sampbytes / sizeof (UNIT));
- done();
- }
+ if (samples == 0)
+ errx(1, "No room for %d sample pc's", sampbytes / sizeof (UNIT));
}
for (i = 0; i < nsamples; i++) {
fread(&sample, sizeof (UNIT), 1, pfile);
@@ -556,12 +527,8 @@ readsamples(pfile)
break;
samples[i] += sample;
}
- if (i != nsamples) {
- fprintf(stderr,
- "%s: unexpected EOF after reading %d/%d samples\n",
- whoami , i , nsamples );
- done();
- }
+ if (i != nsamples)
+ errx(1, "unexpected EOF after reading %d/%d samples", i, nsamples );
}
/*
@@ -596,6 +563,7 @@ readsamples(pfile)
* only one sample for every four bytes of text space and never
* have any overlap (the two end cases, above).
*/
+void
asgnsamples()
{
register int j;
@@ -685,6 +653,7 @@ max(a, b)
* if it turns out that the entry point is in one bucket and the code
* for a routine is in the next bucket.
*/
+void
alignentries()
{
register struct nl *nlp;
@@ -742,16 +711,9 @@ funcsymbol( nlistp )
return TRUE;
}
#endif
- while ( c = *name++ ) {
- if ( c == '.' ) {
+ while ((c = *name++))
+ if (c == '.')
return FALSE;
- }
- }
- return TRUE;
-}
-done()
-{
-
- exit(0);
+ return TRUE;
}
diff --git a/usr.bin/gprof/gprof.h b/usr.bin/gprof/gprof.h
index 48c513e3141..6cd3c377e02 100644
--- a/usr.bin/gprof/gprof.h
+++ b/usr.bin/gprof/gprof.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: gprof.h,v 1.5 2001/03/21 22:27:36 miod Exp $ */
+/* $OpenBSD: gprof.h,v 1.6 2001/03/22 05:18:30 mickey Exp $ */
/* $NetBSD: gprof.h,v 1.13 1996/04/01 21:54:06 mark Exp $ */
/*
@@ -43,15 +43,11 @@
#include <a.out.h>
#include <stdio.h>
#include <stdlib.h>
+#include <err.h>
#include "machine.h"
/*
- * who am i, for error messages.
- */
-char *whoami;
-
- /*
* booleans
*/
typedef int bool;
@@ -239,76 +235,72 @@ struct stringlist *ktolist;
/*
* function declarations
*/
-/*
- addarc();
-*/
+void addarc();
+int addcycle __P((arctype **, arctype **));
+void addlist __P((struct stringlist *listp, char *funcname));
int arccmp();
arctype *arclookup();
-/*
- asgnsamples();
- printblurb();
- cyclelink();
- dfn();
-*/
+void asgnsamples();
+void alignentries();
+void printblurb();
+int cycleanalyze __P((void));
+void cyclelink __P((void));
+void cycletime __P((void));
+void compresslist __P((void));
+int descend __P((nltype *node, arctype **stkstart, arctype **stkp));
+void dfn();
bool dfn_busy();
-/*
- dfn_findcycle();
-*/
+void dfn_findcycle();
+void dfn_init();
bool dfn_numbered();
-/*
- dfn_post_visit();
- dfn_pre_visit();
- dfn_self_cycle();
-*/
+void dfn_post_visit();
+void dfn_pre_visit();
+void dfn_self_cycle();
nltype **doarcs();
-/*
- done();
- findcalls();
- flatprofheader();
- flatprofline();
-*/
+void doflags __P((void));
+void dotime __P((void));
+void dumpsum();
+void findcall __P((nltype *, u_long, u_long));
+void flatprofheader();
+void flatprofline();
bool funcsymbol();
-/*
- getnfile();
- getpfile();
- getstrtab();
- getsymtab();
- gettextspace();
- gprofheader();
- gprofline();
- main();
-*/
+void getnfile();
+void getpfile();
+void getstrtab();
+void getsymtab();
+void gettextspace();
+void gprofheader();
+void gprofline();
+int hertz();
+void inheritflags __P((nltype *childp));
unsigned long max();
int membercmp();
unsigned long min();
nltype *nllookup();
+bool onlist();
FILE *openpfile();
long operandlength();
operandenum operandmode();
char *operandname();
-/*
- printchildren();
- printcycle();
- printgprof();
- printmembers();
- printname();
- printparents();
- printprof();
- readsamples();
-*/
+void printchildren();
+void printcycle();
+void printgprof();
+void printindex();
+void printmembers();
+void printname();
+void printparents();
+void printprof();
+void readsamples(FILE *);
unsigned long reladdr();
-/*
- sortchildren();
- sortmembers();
- sortparents();
- tally();
- timecmp();
- topcmp();
-*/
+void sortchildren();
+void sortmembers();
+void sortparents();
+void tally();
+int timecmp();
+void timepropagate __P((nltype *));
+int topcmp();
int totalcmp();
-/*
- valcmp();
-*/
+int valcmp __P((nltype *p1, nltype *p2));
#define LESSTHAN -1
#define EQUALTO 0
diff --git a/usr.bin/gprof/hertz.c b/usr.bin/gprof/hertz.c
index 9121e697569..b185f05d792 100644
--- a/usr.bin/gprof/hertz.c
+++ b/usr.bin/gprof/hertz.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hertz.c,v 1.2 1996/06/26 05:33:52 deraadt Exp $ */
+/* $OpenBSD: hertz.c,v 1.3 2001/03/22 05:18:30 mickey Exp $ */
/* $NetBSD: hertz.c,v 1.5 1995/04/19 07:16:03 cgd Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)hertz.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: hertz.c,v 1.2 1996/06/26 05:33:52 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: hertz.c,v 1.3 2001/03/22 05:18:30 mickey Exp $";
#endif
#endif /* not lint */
@@ -50,6 +50,7 @@ static char rcsid[] = "$OpenBSD: hertz.c,v 1.2 1996/06/26 05:33:52 deraadt Exp $
*/
#define HZ_WRONG 0
+int
hertz()
{
struct itimerval tim;
diff --git a/usr.bin/gprof/hppa.c b/usr.bin/gprof/hppa.c
new file mode 100644
index 00000000000..d7df49cbec1
--- /dev/null
+++ b/usr.bin/gprof/hppa.c
@@ -0,0 +1,18 @@
+/* $OpenBSD: hppa.c,v 1.1 2001/03/22 05:18:30 mickey Exp $ */
+
+#ifndef lint
+static char rcsid[] = "$OpenBSD: hppa.c,v 1.1 2001/03/22 05:18:30 mickey Exp $";
+#endif /* not lint */
+
+#include "gprof.h"
+
+/*
+ * gprof -c isn't currently supported...
+ */
+void
+findcall( parentp , p_lowpc , p_highpc )
+ nltype *parentp;
+ unsigned long p_lowpc;
+ unsigned long p_highpc;
+{
+}
diff --git a/usr.bin/gprof/hppa.h b/usr.bin/gprof/hppa.h
new file mode 100644
index 00000000000..158bdddcb45
--- /dev/null
+++ b/usr.bin/gprof/hppa.h
@@ -0,0 +1,11 @@
+/* $OpenBSD: hppa.h,v 1.1 2001/03/22 05:18:30 mickey Exp $ */
+
+ /*
+ * offset (in bytes) of the code from the entry address of a routine.
+ * (see asgnsamples for use and explanation.)
+ */
+#define OFFSET_OF_CODE 0
+#define UNITS_TO_CODE (OFFSET_OF_CODE / sizeof(UNIT))
+
+enum opermodes { dummy };
+typedef enum opermodes operandenum;
diff --git a/usr.bin/gprof/i386.c b/usr.bin/gprof/i386.c
index 250852b167f..83957460685 100644
--- a/usr.bin/gprof/i386.c
+++ b/usr.bin/gprof/i386.c
@@ -1,8 +1,8 @@
-/* $OpenBSD: i386.c,v 1.3 1996/10/02 02:59:50 tholo Exp $ */
+/* $OpenBSD: i386.c,v 1.4 2001/03/22 05:18:30 mickey Exp $ */
/* $NetBSD: i386.c,v 1.5 1995/04/19 07:16:04 cgd Exp $ */
#ifndef lint
-static char rcsid[] = "$OpenBSD: i386.c,v 1.3 1996/10/02 02:59:50 tholo Exp $";
+static char rcsid[] = "$OpenBSD: i386.c,v 1.4 2001/03/22 05:18:30 mickey Exp $";
#endif /* not lint */
#include "gprof.h"
@@ -12,6 +12,7 @@ static char rcsid[] = "$OpenBSD: i386.c,v 1.3 1996/10/02 02:59:50 tholo Exp $";
/*
* gprof -c isn't currently supported...
*/
+void
findcall( parentp , p_lowpc , p_highpc )
nltype *parentp;
unsigned long p_lowpc;
diff --git a/usr.bin/gprof/lookup.c b/usr.bin/gprof/lookup.c
index e837075a127..682d4e372a6 100644
--- a/usr.bin/gprof/lookup.c
+++ b/usr.bin/gprof/lookup.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lookup.c,v 1.2 1996/06/26 05:33:53 deraadt Exp $ */
+/* $OpenBSD: lookup.c,v 1.3 2001/03/22 05:18:30 mickey Exp $ */
/* $NetBSD: lookup.c,v 1.5 1995/04/19 07:16:06 cgd Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)lookup.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: lookup.c,v 1.2 1996/06/26 05:33:53 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: lookup.c,v 1.3 2001/03/22 05:18:30 mickey Exp $";
#endif
#endif /* not lint */
@@ -81,10 +81,8 @@ nllookup( address )
}
}
# ifdef DEBUG
- if ( debug & LOOKUPDEBUG ) {
- fprintf( stderr , "[nllookup] (%d) binary search fails\n" ,
- nname-1 );
- }
+ if ( debug & LOOKUPDEBUG )
+ warnx("[nllookup] (%d) binary search fails", nname - 1);
# endif DEBUG
return 0;
}
@@ -97,7 +95,7 @@ arclookup( parentp , childp )
arctype *arcp;
if ( parentp == 0 || childp == 0 ) {
- fprintf( stderr, "[arclookup] parentp == 0 || childp == 0\n" );
+ warnx("[arclookup] parentp == 0 || childp == 0");
return 0;
}
# ifdef DEBUG
diff --git a/usr.bin/gprof/m68k.c b/usr.bin/gprof/m68k.c
index ccbb6c7dd91..a137c06740b 100644
--- a/usr.bin/gprof/m68k.c
+++ b/usr.bin/gprof/m68k.c
@@ -1,8 +1,8 @@
-/* $OpenBSD: m68k.c,v 1.2 1996/06/26 05:33:54 deraadt Exp $ */
+/* $OpenBSD: m68k.c,v 1.3 2001/03/22 05:18:30 mickey Exp $ */
/* $NetBSD: m68k.c,v 1.4 1995/04/19 07:16:07 cgd Exp $ */
#ifndef lint
-static char rcsid[] = "$OpenBSD: m68k.c,v 1.2 1996/06/26 05:33:54 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: m68k.c,v 1.3 2001/03/22 05:18:30 mickey Exp $";
#endif /* not lint */
#include "gprof.h"
@@ -10,6 +10,7 @@ static char rcsid[] = "$OpenBSD: m68k.c,v 1.2 1996/06/26 05:33:54 deraadt Exp $"
/*
* gprof -c isn't currently supported...
*/
+void
findcall( parentp , p_lowpc , p_highpc )
nltype *parentp;
unsigned long p_lowpc;
diff --git a/usr.bin/gprof/m88k.c b/usr.bin/gprof/m88k.c
index 41160231edc..5c3821454e6 100644
--- a/usr.bin/gprof/m88k.c
+++ b/usr.bin/gprof/m88k.c
@@ -1,8 +1,8 @@
-/* $OpenBSD: m88k.c,v 1.1 2000/12/28 23:44:37 smurph Exp $ */
+/* $OpenBSD: m88k.c,v 1.2 2001/03/22 05:18:30 mickey Exp $ */
/* $NetBSD: m88k.c,v 1.4 1995/04/19 07:16:07 cgd Exp $ */
#ifndef lint
-static char rcsid[] = "$OpenBSD: m88k.c,v 1.1 2000/12/28 23:44:37 smurph Exp $";
+static char rcsid[] = "$OpenBSD: m88k.c,v 1.2 2001/03/22 05:18:30 mickey Exp $";
#endif /* not lint */
#include "gprof.h"
@@ -10,6 +10,7 @@ static char rcsid[] = "$OpenBSD: m88k.c,v 1.1 2000/12/28 23:44:37 smurph Exp $";
/*
* gprof -c isn't currently supported...
*/
+void
findcall( parentp , p_lowpc , p_highpc )
nltype *parentp;
unsigned long p_lowpc;
diff --git a/usr.bin/gprof/mips.c b/usr.bin/gprof/mips.c
index e53f19363e7..ec3caf60000 100644
--- a/usr.bin/gprof/mips.c
+++ b/usr.bin/gprof/mips.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mips.c,v 1.2 1996/06/26 05:33:55 deraadt Exp $ */
+/* $OpenBSD: mips.c,v 1.3 2001/03/22 05:18:30 mickey Exp $ */
/* $NetBSD: mips.c,v 1.4 1995/04/19 07:16:11 cgd Exp $ */
/*
@@ -44,7 +44,7 @@
#if 0
static char sccsid[] = "@(#)mips.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: mips.c,v 1.2 1996/06/26 05:33:55 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: mips.c,v 1.3 2001/03/22 05:18:30 mickey Exp $";
#endif
#endif /* not lint */
@@ -77,6 +77,7 @@ nltype indirectchild = {
(arctype *) 0 /* list of callee arcs */
};
+void
findcall(parentp, p_lowpc, p_highpc)
nltype *parentp;
unsigned long p_lowpc;
diff --git a/usr.bin/gprof/ns32k.c b/usr.bin/gprof/ns32k.c
index 50a9614754b..213c5e126b8 100644
--- a/usr.bin/gprof/ns32k.c
+++ b/usr.bin/gprof/ns32k.c
@@ -1,8 +1,8 @@
-/* $OpenBSD: ns32k.c,v 1.2 1996/06/26 05:33:56 deraadt Exp $ */
+/* $OpenBSD: ns32k.c,v 1.3 2001/03/22 05:18:30 mickey Exp $ */
/* $NetBSD: ns32k.c,v 1.3 1995/04/19 07:16:13 cgd Exp $ */
#ifndef lint
-static char rcsid[] = "$OpenBSD: ns32k.c,v 1.2 1996/06/26 05:33:56 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: ns32k.c,v 1.3 2001/03/22 05:18:30 mickey Exp $";
#endif /* not lint */
#include "gprof.h"
@@ -10,6 +10,7 @@ static char rcsid[] = "$OpenBSD: ns32k.c,v 1.2 1996/06/26 05:33:56 deraadt Exp $
/*
* gprof -c isn't currently supported...
*/
+void
findcall( parentp , p_lowpc , p_highpc )
nltype *parentp;
unsigned long p_lowpc;
diff --git a/usr.bin/gprof/pmax.c b/usr.bin/gprof/pmax.c
index 1e81756bd8e..6f76533e58a 100644
--- a/usr.bin/gprof/pmax.c
+++ b/usr.bin/gprof/pmax.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pmax.c,v 1.2 1996/06/26 05:33:58 deraadt Exp $ */
+/* $OpenBSD: pmax.c,v 1.3 2001/03/22 05:18:30 mickey Exp $ */
/* $NetBSD: pmax.c,v 1.3 1995/04/19 07:16:18 cgd Exp $ */
/*
@@ -44,7 +44,7 @@
#if 0
static char sccsid[] = "@(#)mips.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: pmax.c,v 1.2 1996/06/26 05:33:58 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: pmax.c,v 1.3 2001/03/22 05:18:30 mickey Exp $";
#endif
#endif /* not lint */
@@ -77,6 +77,7 @@ nltype indirectchild = {
(arctype *) 0 /* list of callee arcs */
};
+void
findcall(parentp, p_lowpc, p_highpc)
nltype *parentp;
unsigned long p_lowpc;
diff --git a/usr.bin/gprof/powerpc.c b/usr.bin/gprof/powerpc.c
index 0b54229f3b8..09a971029de 100644
--- a/usr.bin/gprof/powerpc.c
+++ b/usr.bin/gprof/powerpc.c
@@ -1,8 +1,8 @@
-/* $OpenBSD: powerpc.c,v 1.1 1996/12/22 20:24:25 rahnds Exp $ */
+/* $OpenBSD: powerpc.c,v 1.2 2001/03/22 05:18:30 mickey Exp $ */
/* $NetBSD: m68k.c,v 1.4 1995/04/19 07:16:07 cgd Exp $ */
#ifndef lint
-static char rcsid[] = "$OpenBSD: powerpc.c,v 1.1 1996/12/22 20:24:25 rahnds Exp $";
+static char rcsid[] = "$OpenBSD: powerpc.c,v 1.2 2001/03/22 05:18:30 mickey Exp $";
#endif /* not lint */
#include "gprof.h"
@@ -10,6 +10,7 @@ static char rcsid[] = "$OpenBSD: powerpc.c,v 1.1 1996/12/22 20:24:25 rahnds Exp
/*
* gprof -c isn't currently supported...
*/
+void
findcall( parentp , p_lowpc , p_highpc )
nltype *parentp;
unsigned long p_lowpc;
diff --git a/usr.bin/gprof/printgprof.c b/usr.bin/gprof/printgprof.c
index 0ef4a307317..812bdbc9a6e 100644
--- a/usr.bin/gprof/printgprof.c
+++ b/usr.bin/gprof/printgprof.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: printgprof.c,v 1.2 1996/06/26 05:33:59 deraadt Exp $ */
+/* $OpenBSD: printgprof.c,v 1.3 2001/03/22 05:18:30 mickey Exp $ */
/* $NetBSD: printgprof.c,v 1.5 1995/04/19 07:16:21 cgd Exp $ */
/*
@@ -38,18 +38,19 @@
#if 0
static char sccsid[] = "@(#)printgprof.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: printgprof.c,v 1.2 1996/06/26 05:33:59 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: printgprof.c,v 1.3 2001/03/22 05:18:30 mickey Exp $";
#endif
#endif /* not lint */
#include "gprof.h"
#include "pathnames.h"
+void
printprof()
{
register nltype *np;
nltype **sortednlp;
- int index, timecmp();
+ int index;
actime = 0.0;
printf( "\f\n" );
@@ -58,9 +59,8 @@ printprof()
* Sort the symbol table in by time
*/
sortednlp = (nltype **) calloc( nname , sizeof(nltype *) );
- if ( sortednlp == (nltype **) 0 ) {
- fprintf( stderr , "[printprof] ran out of memory for time sorting\n" );
- }
+ if ( sortednlp == (nltype **) 0 )
+ warnx("[printprof] ran out of memory for time sorting");
for ( index = 0 ; index < nname ; index += 1 ) {
sortednlp[ index ] = &nl[ index ];
}
@@ -73,6 +73,7 @@ printprof()
free( sortednlp );
}
+int
timecmp( npp1 , npp2 )
nltype **npp1, **npp2;
{
@@ -95,31 +96,31 @@ timecmp( npp1 , npp2 )
/*
* header for flatprofline
*/
+void
flatprofheader()
{
- if ( bflag ) {
+ if (bflag)
printblurb( _PATH_FLAT_BLURB );
- }
- printf( "\ngranularity: each sample hit covers %d byte(s)" ,
- (long) scale * sizeof(UNIT) );
- if ( totime > 0.0 ) {
- printf( " for %.2f%% of %.2f seconds\n\n" ,
- 100.0/totime , totime / hz );
- } else {
+ printf("\ngranularity: each sample hit covers %ld byte(s)",
+ (long) scale * sizeof(UNIT));
+ if (totime > 0.0)
+ printf(" for %.2f%% of %.2f seconds\n\n" , 100.0/totime, totime / hz);
+ else {
printf( " no time accumulated\n\n" );
/*
* this doesn't hurt sinc eall the numerators will be zero.
*/
totime = 1.0;
}
- printf( "%5.5s %10.10s %8.8s %8.8s %8.8s %8.8s %-8.8s\n" ,
- "% " , "cumulative" , "self " , "" , "self " , "total " , "" );
- printf( "%5.5s %10.10s %8.8s %8.8s %8.8s %8.8s %-8.8s\n" ,
- "time" , "seconds " , "seconds" , "calls" ,
- "ms/call" , "ms/call" , "name" );
+ printf("%5.5s %10.10s %8.8s %8.8s %8.8s %8.8s %-8.8s\n" ,
+ "% " , "cumulative" , "self " , "" , "self " , "total " , "" );
+ printf("%5.5s %10.10s %8.8s %8.8s %8.8s %8.8s %-8.8s\n" ,
+ "time" , "seconds " , "seconds" , "calls" ,
+ "ms/call" , "ms/call" , "name" );
}
+void
flatprofline( np )
register nltype *np;
{
@@ -131,7 +132,7 @@ flatprofline( np )
printf( "%5.1f %10.2f %8.2f" ,
100 * np -> time / totime , actime / hz , np -> time / hz );
if ( np -> ncall != 0 ) {
- printf( " %8d %8.2f %8.2f " , np -> ncall ,
+ printf( " %8ld %8.2f %8.2f " , np -> ncall ,
1000 * np -> time / hz / np -> ncall ,
1000 * ( np -> time + np -> childtime ) / hz / np -> ncall );
} else {
@@ -141,13 +142,14 @@ flatprofline( np )
printf( "\n" );
}
+void
gprofheader()
{
if ( bflag ) {
printblurb( _PATH_CALLG_BLURB );
}
- printf( "\ngranularity: each sample hit covers %d byte(s)" ,
+ printf( "\ngranularity: each sample hit covers %ld byte(s)" ,
(long) scale * sizeof(UNIT) );
if ( printtime > 0.0 ) {
printf( " for %.2f%% of %.2f seconds\n\n" ,
@@ -169,21 +171,20 @@ gprofheader()
printf( "\n" );
}
+void
gprofline( np )
register nltype *np;
{
char kirkbuffer[ BUFSIZ ];
sprintf( kirkbuffer , "[%d]" , np -> index );
- printf( "%-6.6s %5.1f %7.2f %11.2f" ,
- kirkbuffer ,
+ printf( "%-6.6s %5.1f %7.2f %11.2f" , kirkbuffer ,
100 * ( np -> propself + np -> propchild ) / printtime ,
- np -> propself / hz ,
- np -> propchild / hz );
+ np -> propself / hz , np -> propchild / hz );
if ( ( np -> ncall + np -> selfcalls ) != 0 ) {
- printf( " %7d" , np -> npropcall );
+ printf( " %7ld" , np -> npropcall );
if ( np -> selfcalls != 0 ) {
- printf( "+%-7d " , np -> selfcalls );
+ printf( "+%-7ld " , np -> selfcalls );
} else {
printf( " %7.7s " , "" );
}
@@ -194,6 +195,7 @@ gprofline( np )
printf( "\n" );
}
+void
printgprof(timesortnlp)
nltype **timesortnlp;
{
@@ -276,6 +278,7 @@ totalcmp( npp1 , npp2 )
return strcmp( np1 -> name , np2 -> name );
}
+void
printparents( childp )
nltype *childp;
{
@@ -301,7 +304,7 @@ printparents( childp )
/*
* selfcall or call among siblings
*/
- printf( "%6.6s %5.5s %7.7s %11.11s %7d %7.7s " ,
+ printf( "%6.6s %5.5s %7.7s %11.11s %7ld %7.7s " ,
"" , "" , "" , "" ,
arcp -> arc_count , "" );
printname( parentp );
@@ -310,7 +313,7 @@ printparents( childp )
/*
* regular parent of child
*/
- printf( "%6.6s %5.5s %7.2f %11.2f %7d/%-7d " ,
+ printf( "%6.6s %5.5s %7.2f %11.2f %7ld/%-7ld " ,
"" , "" ,
arcp -> arc_time / hz , arcp -> arc_childtime / hz ,
arcp -> arc_count , cycleheadp -> npropcall );
@@ -320,6 +323,7 @@ printparents( childp )
}
}
+void
printchildren( parentp )
nltype *parentp;
{
@@ -335,7 +339,7 @@ printchildren( parentp )
/*
* self call or call to sibling
*/
- printf( "%6.6s %5.5s %7.7s %11.11s %7d %7.7s " ,
+ printf( "%6.6s %5.5s %7.7s %11.11s %7ld %7.7s " ,
"" , "" , "" , "" , arcp -> arc_count , "" );
printname( childp );
printf( "\n" );
@@ -343,7 +347,7 @@ printchildren( parentp )
/*
* regular child of parent
*/
- printf( "%6.6s %5.5s %7.2f %11.2f %7d/%-7d " ,
+ printf( "%6.6s %5.5s %7.2f %11.2f %7ld/%-7ld " ,
"" , "" ,
arcp -> arc_time / hz , arcp -> arc_childtime / hz ,
arcp -> arc_count , childp -> cyclehead -> npropcall );
@@ -353,6 +357,7 @@ printchildren( parentp )
}
}
+void
printname( selfp )
nltype *selfp;
{
@@ -380,6 +385,7 @@ printname( selfp )
}
}
+void
sortchildren( parentp )
nltype *parentp;
{
@@ -397,9 +403,9 @@ sortchildren( parentp )
* *prevp arc before the arc you are comparing.
*/
sorted.arc_childlist = 0;
- for ( (arcp = parentp -> children)&&(detachedp = arcp -> arc_childlist);
+ for ( arcp = parentp -> children, detachedp = arcp -> arc_childlist;
arcp ;
- (arcp = detachedp)&&(detachedp = detachedp -> arc_childlist)) {
+ arcp = detachedp, detachedp = detachedp -> arc_childlist) {
/*
* consider *arcp as disconnected
* insert it into sorted
@@ -420,6 +426,7 @@ sortchildren( parentp )
parentp -> children = sorted.arc_childlist;
}
+void
sortparents( childp )
nltype *childp;
{
@@ -437,22 +444,18 @@ sortparents( childp )
* *prevp arc before the arc you are comparing.
*/
sorted.arc_parentlist = 0;
- for ( (arcp = childp -> parents)&&(detachedp = arcp -> arc_parentlist);
- arcp ;
- (arcp = detachedp)&&(detachedp = detachedp -> arc_parentlist)) {
+ for (arcp = childp->parents, detachedp = arcp->arc_parentlist;
+ arcp; arcp = detachedp, detachedp = detachedp->arc_parentlist) {
/*
* consider *arcp as disconnected
* insert it into sorted
*/
- for ( prevp = &sorted ;
- prevp -> arc_parentlist ;
- prevp = prevp -> arc_parentlist ) {
- if ( arccmp( arcp , prevp -> arc_parentlist ) != GREATERTHAN ) {
+ for (prevp = &sorted; prevp->arc_parentlist;
+ prevp = prevp->arc_parentlist)
+ if (arccmp(arcp , prevp->arc_parentlist) != GREATERTHAN)
break;
- }
- }
- arcp -> arc_parentlist = prevp -> arc_parentlist;
- prevp -> arc_parentlist = arcp;
+ arcp->arc_parentlist = prevp->arc_parentlist;
+ prevp->arc_parentlist = arcp;
}
/*
* reattach sorted arcs to child
@@ -463,30 +466,28 @@ sortparents( childp )
/*
* print a cycle header
*/
+void
printcycle( cyclep )
nltype *cyclep;
{
char kirkbuffer[ BUFSIZ ];
- sprintf( kirkbuffer , "[%d]" , cyclep -> index );
- printf( "%-6.6s %5.1f %7.2f %11.2f %7d" ,
- kirkbuffer ,
- 100 * ( cyclep -> propself + cyclep -> propchild ) / printtime ,
- cyclep -> propself / hz ,
- cyclep -> propchild / hz ,
- cyclep -> npropcall );
- if ( cyclep -> selfcalls != 0 ) {
- printf( "+%-7d" , cyclep -> selfcalls );
- } else {
- printf( " %7.7s" , "" );
- }
- printf( " <cycle %d as a whole>\t[%d]\n" ,
- cyclep -> cycleno , cyclep -> index );
+ sprintf(kirkbuffer , "[%d]" , cyclep->index);
+ printf("%-6.6s %5.1f %7.2f %11.2f %7ld", kirkbuffer,
+ 100 * (cyclep->propself + cyclep->propchild) / printtime,
+ cyclep->propself / hz, cyclep->propchild / hz, cyclep->npropcall);
+ if (cyclep -> selfcalls != 0)
+ printf("+%-7ld" , cyclep->selfcalls);
+ else
+ printf(" %7.7s" , "");
+ printf(" <cycle %d as a whole>\t[%d]\n" ,
+ cyclep->cycleno , cyclep->index );
}
/*
* print the members of a cycle
*/
+void
printmembers( cyclep )
nltype *cyclep;
{
@@ -494,23 +495,22 @@ printmembers( cyclep )
sortmembers( cyclep );
for ( memberp = cyclep -> cnext ; memberp ; memberp = memberp -> cnext ) {
- printf( "%6.6s %5.5s %7.2f %11.2f %7d" ,
- "" , "" , memberp -> propself / hz , memberp -> propchild / hz ,
- memberp -> npropcall );
- if ( memberp -> selfcalls != 0 ) {
- printf( "+%-7d" , memberp -> selfcalls );
- } else {
- printf( " %7.7s" , "" );
- }
- printf( " " );
- printname( memberp );
- printf( "\n" );
+ printf( "%6.6s %5.5s %7.2f %11.2f %7ld" , "", "",
+ memberp->propself / hz, memberp->propchild / hz, memberp->npropcall );
+ if (memberp -> selfcalls != 0)
+ printf("+%-7ld" , memberp -> selfcalls);
+ else
+ printf(" %7.7s", "");
+ printf(" ");
+ printname(memberp);
+ printf("\n");
}
}
/*
* sort members of a cycle
*/
+void
sortmembers( cyclep )
nltype *cyclep;
{
@@ -524,14 +524,11 @@ sortmembers( cyclep )
*/
todo = cyclep -> cnext;
cyclep -> cnext = 0;
- for ( (doing = todo)&&(todo = doing -> cnext);
- doing ;
- (doing = todo )&&(todo = doing -> cnext )){
- for ( prev = cyclep ; prev -> cnext ; prev = prev -> cnext ) {
- if ( membercmp( doing , prev -> cnext ) == GREATERTHAN ) {
+ for (doing = todo, todo = doing -> cnext;
+ doing; doing = todo, todo = doing -> cnext) {
+ for (prev = cyclep; prev -> cnext; prev = prev -> cnext)
+ if (membercmp(doing, prev->cnext ) == GREATERTHAN)
break;
- }
- }
doing -> cnext = prev -> cnext;
prev -> cnext = doing;
}
@@ -653,6 +650,7 @@ arccmp( thisp , thatp )
}
}
+void
printblurb( blurbname )
char *blurbname;
{
@@ -661,12 +659,12 @@ printblurb( blurbname )
blurbfile = fopen( blurbname , "r" );
if ( blurbfile == NULL ) {
- perror( blurbname );
+ warn("fopen: %s", blurbname );
return;
}
- while ( ( input = getc( blurbfile ) ) != EOF ) {
+ while ( ( input = getc( blurbfile ) ) != EOF )
putchar( input );
- }
+
fclose( blurbfile );
}
@@ -677,6 +675,7 @@ namecmp( npp1 , npp2 )
return( strcmp( (*npp1) -> name , (*npp2) -> name ) );
}
+void
printindex()
{
nltype **namesortnlp;
@@ -689,9 +688,8 @@ printindex()
* to create an index.
*/
namesortnlp = (nltype **) calloc( nname + ncycle , sizeof(nltype *) );
- if ( namesortnlp == (nltype **) 0 ) {
- fprintf( stderr , "%s: ran out of memory for sorting\n" , whoami );
- }
+ if ( namesortnlp == (nltype **) 0 )
+ warnx("ran out of memory for sorting");
for ( index = 0 , nnames = 0 ; index < nname ; index++ ) {
if ( zflag == 0 && nl[index].ncall == 0 && nl[index].time == 0 )
continue;
diff --git a/usr.bin/gprof/printlist.c b/usr.bin/gprof/printlist.c
index 18ac1da0563..d2af9654a32 100644
--- a/usr.bin/gprof/printlist.c
+++ b/usr.bin/gprof/printlist.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: printlist.c,v 1.2 1996/06/26 05:33:59 deraadt Exp $ */
+/* $OpenBSD: printlist.c,v 1.3 2001/03/22 05:18:30 mickey Exp $ */
/* $NetBSD: printlist.c,v 1.5 1995/04/19 07:16:23 cgd Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)printlist.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: printlist.c,v 1.2 1996/06/26 05:33:59 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: printlist.c,v 1.3 2001/03/22 05:18:30 mickey Exp $";
#endif
#endif /* not lint */
@@ -63,6 +63,7 @@ struct stringlist *elist = &ehead;
struct stringlist Ehead = { 0 , 0 };
struct stringlist *Elist = &Ehead;
+void
addlist( listp , funcname )
struct stringlist *listp;
char *funcname;
@@ -70,10 +71,8 @@ addlist( listp , funcname )
struct stringlist *slp;
slp = (struct stringlist *) malloc( sizeof(struct stringlist));
- if ( slp == (struct stringlist *) 0 ) {
- fprintf( stderr, "gprof: ran out room for printlist\n" );
- done();
- }
+ if (slp == (struct stringlist *) 0)
+ errx(0, "ran out room for printlist");
slp -> next = listp -> next;
slp -> string = funcname;
listp -> next = slp;
diff --git a/usr.bin/gprof/sparc.c b/usr.bin/gprof/sparc.c
index 4959f3180e2..59087bfc3c7 100644
--- a/usr.bin/gprof/sparc.c
+++ b/usr.bin/gprof/sparc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sparc.c,v 1.2 1996/06/26 05:34:00 deraadt Exp $ */
+/* $OpenBSD: sparc.c,v 1.3 2001/03/22 05:18:30 mickey Exp $ */
/* $NetBSD: sparc.c,v 1.4 1995/04/19 07:16:24 cgd Exp $ */
/*
@@ -42,7 +42,7 @@
#if 0
static char sccsid[] = "@(#)sparc.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: sparc.c,v 1.2 1996/06/26 05:34:00 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: sparc.c,v 1.3 2001/03/22 05:18:30 mickey Exp $";
#endif
#endif /* not lint */
@@ -75,6 +75,7 @@ nltype indirectchild = {
(arctype *) 0 /* list of callee arcs */
};
+void
findcall(parentp, p_lowpc, p_highpc)
nltype *parentp;
unsigned long p_lowpc;
diff --git a/usr.bin/gprof/tahoe.c b/usr.bin/gprof/tahoe.c
index 505aa3eefd2..246e08976f5 100644
--- a/usr.bin/gprof/tahoe.c
+++ b/usr.bin/gprof/tahoe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tahoe.c,v 1.2 1996/06/26 05:34:01 deraadt Exp $ */
+/* $OpenBSD: tahoe.c,v 1.3 2001/03/22 05:18:30 mickey Exp $ */
/* $NetBSD: tahoe.c,v 1.5 1995/04/19 07:16:27 cgd Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)tahoe.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: tahoe.c,v 1.2 1996/06/26 05:34:01 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: tahoe.c,v 1.3 2001/03/22 05:18:30 mickey Exp $";
#endif
#endif /* not lint */
@@ -211,7 +211,7 @@ reladdr( modep )
cp += 1; /* skip over the mode */
switch ( mode ) {
default:
- fprintf( stderr , "[reladdr] not relative address\n" );
+ warnx("[reladdr] not relative address");
return (unsigned long) modep;
case byterel:
return (unsigned long) ( cp + sizeof *cp + *cp );
@@ -226,6 +226,7 @@ reladdr( modep )
}
}
+void
findcall( parentp , p_lowpc , p_highpc )
nltype *parentp;
unsigned long p_lowpc;
diff --git a/usr.bin/gprof/vax.c b/usr.bin/gprof/vax.c
index 5c1a6238791..4071a697d9c 100644
--- a/usr.bin/gprof/vax.c
+++ b/usr.bin/gprof/vax.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vax.c,v 1.3 1996/06/26 05:34:02 deraadt Exp $ */
+/* $OpenBSD: vax.c,v 1.4 2001/03/22 05:18:31 mickey Exp $ */
/* $NetBSD: vax.c,v 1.6 1996/04/20 14:56:37 ragge Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)vax.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: vax.c,v 1.3 1996/06/26 05:34:02 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: vax.c,v 1.4 2001/03/22 05:18:31 mickey Exp $";
#endif
#endif /* not lint */
@@ -212,7 +212,7 @@ reladdr( modep )
cp += 1; /* skip over the mode */
switch ( mode ) {
default:
- fprintf( stderr , "[reladdr] not relative address\n" );
+ warnx("[reladdr] not relative address");
return (unsigned long) modep;
case byterel:
return (unsigned long) ( cp + sizeof *cp + *cp );
@@ -225,6 +225,7 @@ reladdr( modep )
}
}
+void
findcall( parentp , p_lowpc , p_highpc )
nltype *parentp;
unsigned long p_lowpc;