Use err(3).
This commit is contained in:
parent
710d46eadc
commit
b34f7debd8
@ -32,9 +32,14 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)arcs.c 8.1 (Berkeley) 6/6/93";
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)arcs.c 8.1 (Berkeley) 6/6/93";Q
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$Id$";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <err.h>
|
||||
#include "gprof.h"
|
||||
|
||||
#ifdef DEBUG
|
||||
@ -235,7 +240,7 @@ doarcs()
|
||||
*/
|
||||
timesortnlp = (nltype **) calloc( nname + ncycle , sizeof(nltype *) );
|
||||
if ( timesortnlp == (nltype **) 0 ) {
|
||||
fprintf( stderr , "%s: ran out of memory for sorting\n" , whoami );
|
||||
warnx("ran out of memory for sorting");
|
||||
}
|
||||
for ( index = 0 ; index < nname ; index++ ) {
|
||||
timesortnlp[index] = &nl[index];
|
||||
@ -374,8 +379,7 @@ cyclelink()
|
||||
*/
|
||||
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 ) );
|
||||
warnx("no room for %d bytes of cycle headers", (ncycle+1)*sizeof(nltype) );
|
||||
done();
|
||||
}
|
||||
/*
|
||||
@ -478,8 +482,7 @@ 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 * ) );
|
||||
warnx("no room for %d bytes of cycle stack", (size+1)*sizeof(arctype *) );
|
||||
return;
|
||||
}
|
||||
# ifdef DEBUG
|
||||
@ -595,8 +598,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;
|
||||
@ -641,7 +644,6 @@ compresslist()
|
||||
int maxexitcnt;
|
||||
int maxwithparentcnt;
|
||||
int maxnoparentcnt;
|
||||
char *type;
|
||||
|
||||
maxexitcnt = 0;
|
||||
maxwithparentcnt = 0;
|
||||
|
@ -32,19 +32,22 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char copyright[] =
|
||||
static const char copyright[] =
|
||||
"@(#) Copyright (c) 1983, 1993\n\
|
||||
The Regents of the University of California. All rights reserved.\n";
|
||||
#endif /* not lint */
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)gprof.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$Id$";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <err.h>
|
||||
#include "gprof.h"
|
||||
|
||||
char *whoami = "gprof";
|
||||
|
||||
/*
|
||||
* things which get -E excluded by default.
|
||||
*/
|
||||
@ -83,8 +86,7 @@ main(argc, argv)
|
||||
#if defined(vax) || defined(tahoe)
|
||||
cflag = TRUE;
|
||||
#else
|
||||
fprintf(stderr, "gprof: -c isn't supported on this architecture yet\n");
|
||||
exit(1);
|
||||
errx(1, "-c isn't supported on this architecture yet");
|
||||
#endif
|
||||
break;
|
||||
case 'd':
|
||||
@ -95,7 +97,7 @@ main(argc, argv)
|
||||
# ifdef DEBUG
|
||||
printf("[main] debug = %d\n", debug);
|
||||
# else not DEBUG
|
||||
printf("%s: -d ignored\n", whoami);
|
||||
printf("gprof: -d ignored\n");
|
||||
# endif DEBUG
|
||||
break;
|
||||
case 'E':
|
||||
@ -237,7 +239,7 @@ getnfile()
|
||||
}
|
||||
fread(&xbuf, 1, sizeof(xbuf), nfile);
|
||||
if (N_BADMAG(xbuf)) {
|
||||
fprintf(stderr, "%s: %s: bad format\n", whoami , a_outname );
|
||||
warnx("%s: bad format", a_outname );
|
||||
done();
|
||||
}
|
||||
getstrtab(nfile);
|
||||
@ -262,19 +264,16 @@ getstrtab(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 );
|
||||
warnx("%s: no string table (old format?)" , a_outname );
|
||||
done();
|
||||
}
|
||||
strtab = calloc(ssiz, 1);
|
||||
if (strtab == NULL) {
|
||||
fprintf(stderr, "%s: %s: no room for %d bytes of string table\n",
|
||||
whoami , a_outname , ssiz);
|
||||
warnx("%s: no room for %d bytes of string table", 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 );
|
||||
warnx("%s: error reading string table", a_outname );
|
||||
done();
|
||||
}
|
||||
}
|
||||
@ -300,14 +299,13 @@ getsymtab(nfile)
|
||||
nname++;
|
||||
}
|
||||
if (nname == 0) {
|
||||
fprintf(stderr, "%s: %s: no symbols\n", whoami , a_outname );
|
||||
warnx("%s: no symbols", a_outname );
|
||||
done();
|
||||
}
|
||||
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) );
|
||||
warnx("no room for %d bytes of symbol table", askfor * sizeof(nltype) );
|
||||
done();
|
||||
}
|
||||
|
||||
@ -352,15 +350,12 @@ 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;
|
||||
return;
|
||||
@ -415,7 +410,7 @@ openpfile(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);
|
||||
warnx("%s: incompatible with first gmon file", filename);
|
||||
done();
|
||||
}
|
||||
gmonhdr = tmp;
|
||||
@ -556,8 +551,7 @@ readsamples(pfile)
|
||||
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));
|
||||
warnx("no room for %d sample pc's", sampbytes / sizeof (UNIT));
|
||||
done();
|
||||
}
|
||||
}
|
||||
@ -568,9 +562,7 @@ readsamples(pfile)
|
||||
samples[i] += sample;
|
||||
}
|
||||
if (i != nsamples) {
|
||||
fprintf(stderr,
|
||||
"%s: unexpected EOF after reading %d/%d samples\n",
|
||||
whoami , --i , nsamples );
|
||||
warnx("unexpected EOF after reading %d/%d samples", --i , nsamples );
|
||||
done();
|
||||
}
|
||||
}
|
||||
|
@ -64,11 +64,6 @@
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* who am i, for error messages.
|
||||
*/
|
||||
char *whoami;
|
||||
|
||||
/*
|
||||
* booleans
|
||||
*/
|
||||
|
@ -32,9 +32,14 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)printgprof.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$Id$";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <err.h>
|
||||
#include "gprof.h"
|
||||
#include "pathnames.h"
|
||||
|
||||
@ -698,7 +703,7 @@ printindex()
|
||||
*/
|
||||
namesortnlp = (nltype **) calloc( nname + ncycle , sizeof(nltype *) );
|
||||
if ( namesortnlp == (nltype **) 0 ) {
|
||||
fprintf( stderr , "%s: ran out of memory for sorting\n" , whoami );
|
||||
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 )
|
||||
|
@ -32,9 +32,14 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)printlist.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$Id$";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <err.h>
|
||||
#include "gprof.h"
|
||||
|
||||
/*
|
||||
@ -64,7 +69,7 @@ addlist( listp , funcname )
|
||||
|
||||
slp = (struct stringlist *) malloc( sizeof(struct stringlist));
|
||||
if ( slp == (struct stringlist *) 0 ) {
|
||||
fprintf( stderr, "gprof: ran out room for printlist\n" );
|
||||
warnx("ran out room for printlist");
|
||||
done();
|
||||
}
|
||||
slp -> next = listp -> next;
|
||||
|
Loading…
x
Reference in New Issue
Block a user