summaryrefslogtreecommitdiffstats
path: root/usr.bin/gprof
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>1994-09-05 16:14:54 +0000
committerbde <bde@FreeBSD.org>1994-09-05 16:14:54 +0000
commit63eff9d9b845dca66ab4dc6bde9960b5edfc249a (patch)
treecda563e13e0df6f2d4199f44712b1a165f696055 /usr.bin/gprof
parent889bf31f37aef15112814b058e35c5d89e8ad6db (diff)
downloadFreeBSD-src-63eff9d9b845dca66ab4dc6bde9960b5edfc249a.zip
FreeBSD-src-63eff9d9b845dca66ab4dc6bde9960b5edfc249a.tar.gz
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.
Diffstat (limited to 'usr.bin/gprof')
-rw-r--r--usr.bin/gprof/gprof.111
-rw-r--r--usr.bin/gprof/gprof.c9
-rw-r--r--usr.bin/gprof/printgprof.c22
3 files changed, 32 insertions, 10 deletions
diff --git a/usr.bin/gprof/gprof.1 b/usr.bin/gprof/gprof.1
index dfb0f21..63ea872 100644
--- a/usr.bin/gprof/gprof.1
+++ b/usr.bin/gprof/gprof.1
@@ -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).
diff --git a/usr.bin/gprof/gprof.c b/usr.bin/gprof/gprof.c
index 5057e32..c1d45b7 100644
--- a/usr.bin/gprof/gprof.c
+++ b/usr.bin/gprof/gprof.c
@@ -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;
diff --git a/usr.bin/gprof/printgprof.c b/usr.bin/gprof/printgprof.c
index 5ede772..884c368 100644
--- a/usr.bin/gprof/printgprof.c
+++ b/usr.bin/gprof/printgprof.c
@@ -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 " , "" , "" , "" );
}
OpenPOWER on IntegriCloud