mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-11-29 20:54:13 +01:00
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:
parent
889bf31f37
commit
63eff9d9b8
@ -91,8 +91,8 @@ Second, a flat profile is given,
|
|||||||
similar to that provided by
|
similar to that provided by
|
||||||
.Xr prof 1 .
|
.Xr prof 1 .
|
||||||
This listing gives the total execution times, the call counts,
|
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 msec or usec 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 including
|
||||||
its descendents.
|
its descendents.
|
||||||
.Pp
|
.Pp
|
||||||
Finally, an index of the function names is provided.
|
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
|
to accumulate profile data across several runs of an
|
||||||
.Pa a.out
|
.Pa a.out
|
||||||
file.
|
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
|
.It Fl z
|
||||||
Displays routines that have zero usage (as shown by call counts
|
Displays routines that have zero usage (as shown by call counts
|
||||||
and accumulated time).
|
and accumulated time).
|
||||||
|
@ -51,6 +51,7 @@ char *whoami = "gprof";
|
|||||||
char *defaultEs[] = { "mcount" , "__mcleanup" , 0 };
|
char *defaultEs[] = { "mcount" , "__mcleanup" , 0 };
|
||||||
|
|
||||||
static struct gmonhdr gmonhdr;
|
static struct gmonhdr gmonhdr;
|
||||||
|
static bool uflag;
|
||||||
|
|
||||||
main(argc, argv)
|
main(argc, argv)
|
||||||
int argc;
|
int argc;
|
||||||
@ -125,6 +126,9 @@ main(argc, argv)
|
|||||||
case 's':
|
case 's':
|
||||||
sflag = TRUE;
|
sflag = TRUE;
|
||||||
break;
|
break;
|
||||||
|
case 'u':
|
||||||
|
uflag = TRUE;
|
||||||
|
break;
|
||||||
case 'z':
|
case 'z':
|
||||||
zflag = TRUE;
|
zflag = TRUE;
|
||||||
break;
|
break;
|
||||||
@ -704,8 +708,6 @@ bool
|
|||||||
funcsymbol( nlistp )
|
funcsymbol( nlistp )
|
||||||
struct nlist *nlistp;
|
struct nlist *nlistp;
|
||||||
{
|
{
|
||||||
extern char *strtab; /* string table from a.out */
|
|
||||||
extern int aflag; /* if static functions aren't desired */
|
|
||||||
char *name, c;
|
char *name, c;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -717,6 +719,7 @@ funcsymbol( nlistp )
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
* name must start with an underscore if uflag is set.
|
||||||
* can't have any `funny' characters in name,
|
* can't have any `funny' characters in name,
|
||||||
* where `funny' includes `.', .o file names
|
* where `funny' includes `.', .o file names
|
||||||
* and `$', pascal labels.
|
* and `$', pascal labels.
|
||||||
@ -724,6 +727,8 @@ funcsymbol( nlistp )
|
|||||||
* perhaps we should just drop this code entirely...
|
* perhaps we should just drop this code entirely...
|
||||||
*/
|
*/
|
||||||
name = strtab + nlistp -> n_un.n_strx;
|
name = strtab + nlistp -> n_un.n_strx;
|
||||||
|
if ( uflag && *name != '_' )
|
||||||
|
return FALSE;
|
||||||
#ifdef sparc
|
#ifdef sparc
|
||||||
if ( *name == '.' ) {
|
if ( *name == '.' ) {
|
||||||
char *p = name + 1;
|
char *p = name + 1;
|
||||||
|
@ -110,7 +110,8 @@ flatprofheader()
|
|||||||
"% " , "cumulative" , "self " , "" , "self " , "total " , "" );
|
"% " , "cumulative" , "self " , "" , "self " , "total " , "" );
|
||||||
printf( "%5.5s %10.10s %8.8s %8.8s %8.8s %8.8s %-8.8s\n" ,
|
printf( "%5.5s %10.10s %8.8s %8.8s %8.8s %8.8s %-8.8s\n" ,
|
||||||
"time" , "seconds " , "seconds" , "calls" ,
|
"time" , "seconds " , "seconds" , "calls" ,
|
||||||
"ms/call" , "ms/call" , "name" );
|
hz >= 10000 ? "us/call" : "ms/call" ,
|
||||||
|
hz >= 10000 ? "us/call" : "ms/call" , "name" );
|
||||||
}
|
}
|
||||||
|
|
||||||
flatprofline( np )
|
flatprofline( np )
|
||||||
@ -121,12 +122,21 @@ flatprofline( np )
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
actime += np -> time;
|
actime += np -> time;
|
||||||
printf( "%5.1f %10.2f %8.2f" ,
|
if (hz >= 10000)
|
||||||
100 * np -> time / totime , actime / hz , np -> time / hz );
|
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 ) {
|
if ( np -> ncall != 0 ) {
|
||||||
printf( " %8d %8.2f %8.2f " , np -> ncall ,
|
if (hz >= 10000)
|
||||||
1000 * np -> time / hz / np -> ncall ,
|
printf( " %8d %8.0f %8.0f " , np -> ncall ,
|
||||||
1000 * ( np -> time + np -> childtime ) / hz / 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 {
|
} else {
|
||||||
printf( " %8.8s %8.8s %8.8s " , "" , "" , "" );
|
printf( " %8.8s %8.8s %8.8s " , "" , "" , "" );
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user