add the -b option to print a blurb about the listings.
authorPeter B. Kessler <peter@ucbvax.Berkeley.EDU>
Wed, 11 Nov 1981 13:05:31 +0000 (05:05 -0800)
committerPeter B. Kessler <peter@ucbvax.Berkeley.EDU>
Wed, 11 Nov 1981 13:05:31 +0000 (05:05 -0800)
SCCS-vsn: usr.bin/gprof/gprof.h 1.7
SCCS-vsn: usr.bin/gprof/gprof.c 1.8
SCCS-vsn: usr.bin/gprof/printgprof.c 1.5

usr/src/usr.bin/gprof/gprof.c
usr/src/usr.bin/gprof/gprof.h
usr/src/usr.bin/gprof/printgprof.c

index 5369747..d131dca 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-    static     char *sccsid = "@(#)gprof.c     1.7 (Berkeley) %G%";
+    static     char *sccsid = "@(#)gprof.c     1.8 (Berkeley) %G%";
 #endif lint
 
 #include "gprof.h"
 #endif lint
 
 #include "gprof.h"
@@ -23,10 +23,12 @@ main(argc, argv)
 #          endif DEBUG
        } else if ( **argv == 'a' ) {
            aflag++;
 #          endif DEBUG
        } else if ( **argv == 'a' ) {
            aflag++;
+       } else if ( **argv == 'b' ) {
+           bflag++;
        } else if ( **argv == 'c' ) {
            cflag++;
        } else if ( **argv == 'z' ) {
        } else if ( **argv == 'c' ) {
            cflag++;
        } else if ( **argv == 'z' ) {
-           zflg++;
+           zflag++;
        }
        argv++;
     }
        }
        argv++;
     }
index 10340a1..a362468 100644 (file)
@@ -1,4 +1,4 @@
-    /* sccsid:  @(#)gprof.h    1.6 (Berkeley) %G% */
+    /* sccsid:  @(#)gprof.h    1.7 (Berkeley) %G% */
 
 #include <stdio.h>
 #include <sys/types.h>
 
 #include <stdio.h>
 #include <sys/types.h>
index 98c0ffb..1f4b83f 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-    static     char *sccsid = "@(#)printgprof.c        1.4 (Berkeley) %G%";
+    static     char *sccsid = "@(#)printgprof.c        1.5 (Berkeley) %G%";
 #endif lint
 
 #include "gprof.h"
 #endif lint
 
 #include "gprof.h"
@@ -10,6 +10,8 @@ printprof()
     nltype             **sortednlp;
     int                        index;
 
     nltype             **sortednlp;
     int                        index;
 
+    printf( "\ngranularity: each sample hit covers %d byte(s)" , (long) scale );
+    printf( " for %.2f%% of %.2f seconds\n\n" , 100.0/totime , totime / HZ );
     actime = 0.0;
     flatprofheader();
        /*
     actime = 0.0;
     flatprofheader();
        /*
@@ -28,8 +30,6 @@ printprof()
        flatprofline( np );
     }
     actime = 0.0;
        flatprofline( np );
     }
     actime = 0.0;
-    printf( "\ngranularity: each sample hit covers %.1f bytes" , scale );
-    printf( " for %.2f%% of %.2f seconds\n" , 100.0/totime , totime / HZ );
 }
 
 timecmp( npp1 , npp2 )
 }
 
 timecmp( npp1 , npp2 )
@@ -51,6 +51,9 @@ timecmp( npp1 , npp2 )
 flatprofheader()
 {
     
 flatprofheader()
 {
     
+    if ( bflag ) {
+       printblurb( "flat.blurb" );
+    }
     printf( "%5.5s %7.7s %7.7s %7.7s %-8.8s\n" ,
            "%time" , "cumsecs" , "seconds" , "calls" , "name" );
 }
     printf( "%5.5s %7.7s %7.7s %7.7s %-8.8s\n" ,
            "%time" , "cumsecs" , "seconds" , "calls" , "name" );
 }
@@ -59,7 +62,7 @@ flatprofline( np )
     register nltype    *np;
 {
 
     register nltype    *np;
 {
 
-    if ( zflg == 0 && np -> ncall == 0 && np -> time == 0 ) {
+    if ( zflag == 0 && np -> ncall == 0 && np -> time == 0 ) {
        return;
     }
     actime += np -> time;
        return;
     }
     actime += np -> time;
@@ -75,6 +78,10 @@ flatprofline( np )
 
 gprofheader()
 {
 
 gprofheader()
 {
+
+    if ( bflag ) {
+       printblurb( "callg.blurb" );
+    }
     printf( "%6.6s %5.5s %7.7s %11.11s %7.7s/%-7.7s     %-8.8s\n" ,
        "" , "" , "" , "" , "called" , "total" , "parents" , "" );
     printf( "%-6.6s %5.5s %7.7s %11.11s %7.7s+%-7.7s %-8.8s\t%5.5s\n" ,
     printf( "%6.6s %5.5s %7.7s %11.11s %7.7s/%-7.7s     %-8.8s\n" ,
        "" , "" , "" , "" , "called" , "total" , "parents" , "" );
     printf( "%-6.6s %5.5s %7.7s %11.11s %7.7s+%-7.7s %-8.8s\t%5.5s\n" ,
@@ -142,7 +149,7 @@ printgprof()
     gprofheader();
     for ( index = 0 ; index < nname + cyclemax ; index ++ ) {
        parentp = timesortnlp[ index ];
     gprofheader();
     for ( index = 0 ; index < nname + cyclemax ; index ++ ) {
        parentp = timesortnlp[ index ];
-       if ( zflg == 0 &&
+       if ( zflag == 0 &&
             parentp -> ncall == 0 &&
             parentp -> selfcalls == 0 &&
             parentp -> time == 0 &&
             parentp -> ncall == 0 &&
             parentp -> selfcalls == 0 &&
             parentp -> time == 0 &&
@@ -535,3 +542,25 @@ arccmp( thisp , thatp )
        }
     }
 }
        }
     }
 }
+
+printblurb( blurbname )
+    char       *blurbname;
+{
+    char       pathname[ BUFSIZ ];
+    FILE       *blurbfile;
+    int                input;
+
+#   ifndef BLURBLIB
+#      define BLURBLIB "./"
+#   endif not BLURBLIB
+    sprintf( pathname , "%s%s" , BLURBLIB , blurbname );
+    blurbfile = fopen( pathname , "r" );
+    if ( blurbfile == NULL ) {
+       perror( pathname );
+       return;
+    }
+    while ( ( input = getc( blurbfile ) ) != EOF ) {
+       putchar( input );
+    }
+    fclose( blurbfile );
+}