New flag -u to suppress functions whose name does not begin with an

underscore.  Use it to avoid seeing badsw when profiling the kernel.

Print times more accurately (e.g. usec in %8.0f format instead of
msec in %8.2f format for averages) if hz >= 10000.  This should have
no effect now since profhz is only 1024.
This commit is contained in:
Bruce Evans 1994-09-05 16:14:54 +00:00
parent 350ce31055
commit ff18d3781d
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=2513
3 changed files with 32 additions and 10 deletions

View File

@ -91,8 +91,8 @@ Second, a flat profile is given,
similar to that provided by
.Xr prof 1 .
This listing gives the total execution times, the call counts,
the time in milleseconds the call spent in the routine itself, and
the time in milleseconds the call spent in the routine itself including
the time in msec or usec the call spent in the routine itself, and
the time in msec or usec the call spent in the routine itself including
its descendents.
.Pp
Finally, an index of the function names is provided.
@ -205,6 +205,13 @@ executions of gprof (probably also with a
to accumulate profile data across several runs of an
.Pa a.out
file.
.It Fl u
Suppresses the printing of functions whose name does not begin with
an underscore.
All relevant information about such functions belongs to the
(non-suppressed) function with the next lowest address.
This is useful for eliminating "functions" that are just labels
inside other functions.
.It Fl z
Displays routines that have zero usage (as shown by call counts
and accumulated time).

View File

@ -51,6 +51,7 @@ char *whoami = "gprof";
char *defaultEs[] = { "mcount" , "__mcleanup" , 0 };
static struct gmonhdr gmonhdr;
static bool uflag;
main(argc, argv)
int argc;
@ -125,6 +126,9 @@ main(argc, argv)
case 's':
sflag = TRUE;
break;
case 'u':
uflag = TRUE;
break;
case 'z':
zflag = TRUE;
break;
@ -704,8 +708,6 @@ bool
funcsymbol( nlistp )
struct nlist *nlistp;
{
extern char *strtab; /* string table from a.out */
extern int aflag; /* if static functions aren't desired */
char *name, c;
/*
@ -717,6 +719,7 @@ funcsymbol( nlistp )
return FALSE;
}
/*
* name must start with an underscore if uflag is set.
* can't have any `funny' characters in name,
* where `funny' includes `.', .o file names
* and `$', pascal labels.
@ -724,6 +727,8 @@ funcsymbol( nlistp )
* perhaps we should just drop this code entirely...
*/
name = strtab + nlistp -> n_un.n_strx;
if ( uflag && *name != '_' )
return FALSE;
#ifdef sparc
if ( *name == '.' ) {
char *p = name + 1;

View File

@ -110,7 +110,8 @@ flatprofheader()
"% " , "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" );
hz >= 10000 ? "us/call" : "ms/call" ,
hz >= 10000 ? "us/call" : "ms/call" , "name" );
}
flatprofline( np )
@ -121,12 +122,21 @@ flatprofline( np )
return;
}
actime += np -> time;
printf( "%5.1f %10.2f %8.2f" ,
100 * np -> time / totime , actime / hz , np -> time / hz );
if (hz >= 10000)
printf( "%5.1f %10.3f %8.3f" ,
100 * np -> time / totime , actime / hz , np -> time / hz );
else
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 ,
1000 * np -> time / hz / np -> ncall ,
1000 * ( np -> time + np -> childtime ) / hz / np -> ncall );
if (hz >= 10000)
printf( " %8d %8.0f %8.0f " , np -> ncall ,
1e6 * np -> time / hz / np -> ncall ,
1e6 * ( np -> time + np -> childtime ) / hz / np -> ncall );
else
printf( " %8d %8.2f %8.2f " , np -> ncall ,
1000 * np -> time / hz / np -> ncall ,
1000 * ( np -> time + np -> childtime ) / hz / np -> ncall );
} else {
printf( " %8.8s %8.8s %8.8s " , "" , "" , "" );
}