cycle headers have their own namelist.
authorPeter B. Kessler <peter@ucbvax.Berkeley.EDU>
Wed, 9 Jun 1982 02:29:15 +0000 (18:29 -0800)
committerPeter B. Kessler <peter@ucbvax.Berkeley.EDU>
Wed, 9 Jun 1982 02:29:15 +0000 (18:29 -0800)
SCCS-vsn: usr.bin/gprof/arcs.c 1.6
SCCS-vsn: usr.bin/gprof/gprof.c 1.11
SCCS-vsn: usr.bin/gprof/gprof.h 1.11
SCCS-vsn: usr.bin/gprof/printgprof.c 1.8

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

index e787373..f63b513 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-    static     char *sccsid = "@(#)arcs.c      1.5 (Berkeley) %G%";
+    static     char *sccsid = "@(#)arcs.c      1.6 (Berkeley) %G%";
 #endif lint
 
 #include "gprof.h"
 #endif lint
 
 #include "gprof.h"
@@ -65,8 +65,6 @@ doarcs()
     arctype    *arcp;
     nltype     **topsortnlp;
     long       index;
     arctype    *arcp;
     nltype     **topsortnlp;
     long       index;
-    nltype     *childp;
-    double     share;
 
        /*
         *      initialize various things:
 
        /*
         *      initialize various things:
@@ -131,87 +129,99 @@ doarcs()
         *      propogate children times
         */
     for ( index = 0 ; index < nname ; index += 1 ) {
         *      propogate children times
         */
     for ( index = 0 ; index < nname ; index += 1 ) {
-       parentp = topsortnlp[ index ];
-       for ( arcp = parentp->children ; arcp ; arcp = arcp->arc_childlist ) {
-           childp = arcp -> arc_childp;
+       propagate( topsortnlp[ index ] );
+    }
+    printgprof();
+}
+
+propagate( parentp )
+    nltype     *parentp;
+{
+    arctype    *arcp;
+    nltype     *childp;
+    double     share;
+
+       /*
+        *      gather time from children of this parent.
+        */
+    for ( arcp = parentp->children ; arcp ; arcp = arcp->arc_childlist ) {
+       childp = arcp -> arc_childp;
+#      ifdef DEBUG
+           if ( debug & ARCDEBUG ) {
+               printf( "[propagate] " );
+               printname( parentp );
+               printf( " calls " );
+               printname( childp );
+               printf( " %d (%d) times\n" ,
+                       arcp -> arc_count , childp -> ncall );
+           }
+#      endif DEBUG
+       if ( arcp -> arc_count == 0 ) {
+           continue;
+       }
+       if ( childp -> ncall == 0 ) {
+           continue;
+       }
+       if ( childp == parentp ) {
+           continue;
+       }
+       if ( childp -> cyclehead != childp ) {
+           if ( parentp -> cycleno == childp -> cycleno ) {
+               continue;
+           }
 #          ifdef DEBUG
                if ( debug & ARCDEBUG ) {
 #          ifdef DEBUG
                if ( debug & ARCDEBUG ) {
-                       printf( "[doarcs] " );
-                       printname( parentp );
-                       printf( " calls " );
-                       printname( childp );
-                       printf( " %d (%d) times\n" ,
-                               arcp -> arc_count , childp -> ncall );
+                   printf( "[propagate]\t it's a call into cycle %d\n" ,
+                           childp -> cycleno );
                }
 #          endif DEBUG
                }
 #          endif DEBUG
-           if ( arcp -> arc_count == 0 ) {
-               continue;
+           if ( parentp -> toporder <= childp -> toporder ) {
+               fprintf( stderr , "[propagate] toporder botches\n" );
            }
            }
-           if ( childp -> ncall == 0 ) {
-               continue;
-           }
-           if ( childp == parentp ) {
+           childp = childp -> cyclehead;
+       } else {
+           if ( parentp -> toporder <= childp -> toporder ) {
+               fprintf( stderr , "[propagate] toporder botches\n" );
                continue;
            }
                continue;
            }
-           if ( childp -> cyclehead != childp ) {
-               if ( parentp -> cycleno == childp -> cycleno ) {
-                   continue;
-               }
-#              ifdef DEBUG
-                   if ( debug & ARCDEBUG ) {
-                       printf( "[doarcs]\t it's a call into cycle %d\n" ,
-                               childp -> cycleno );
-                   }
-#              endif DEBUG
-               if ( parentp -> toporder <= childp -> toporder ) {
-                   fprintf( stderr , "[doarcs] toporder botches\n" );
-               }
-               childp = childp -> cyclehead;
-           } else {
-               if ( parentp -> toporder <= childp -> toporder ) {
-                   fprintf( stderr , "[doarcs] toporder botches\n" );
-                   continue;
-               }
+       }
+           /*
+            *  distribute time for this arc
+            */
+       arcp -> arc_time = childp -> time *
+                           ( ( (double) arcp -> arc_count ) /
+                           ( (double) childp -> ncall ) );
+       arcp -> arc_childtime = childp -> childtime *
+                           ( ( (double) arcp -> arc_count ) /
+                           ( (double) childp -> ncall ) );
+       share = arcp -> arc_time + arcp -> arc_childtime;
+#      ifdef DEBUG
+           if ( debug & ARCDEBUG ) {
+               printf( "[propagate]\t " );
+               printname( childp );
+               printf( " time %8.2f + childtime %8.2f\n" ,
+                   childp -> time , childp -> childtime );
+               printf( "[propagate]\t this is %d arcs of the %d calls\n",
+                   arcp -> arc_count , childp -> ncall );
+               printf( "[propagate]\t so this gives %8.2f+%8.2f to %s\n" ,
+                   arcp -> arc_time , arcp -> arc_childtime ,
+                   parentp -> name );
            }
            }
-               /*
-                *      distribute time for this arc
-                */
-           arcp -> arc_time = childp -> time *
-                               ( ( (double) arcp -> arc_count ) /
-                               ( (double) childp -> ncall ) );
-           arcp -> arc_childtime = childp -> childtime *
-                               ( ( (double) arcp -> arc_count ) /
-                               ( (double) childp -> ncall ) );
-           share = arcp -> arc_time + arcp -> arc_childtime;
+#      endif DEBUG
+       parentp -> childtime += share;
+           /*
+            *  add this share to the cycle header, if any
+            */
+       if ( parentp -> cyclehead != parentp ) {
 #          ifdef DEBUG
                if ( debug & ARCDEBUG ) {
 #          ifdef DEBUG
                if ( debug & ARCDEBUG ) {
-                   printf( "[doarcs]\t " );
-                   printname( childp );
-                   printf( " time %8.2f + childtime %8.2f\n" ,
-                       childp -> time , childp -> childtime );
-                   printf( "[doarcs]\t this is %d arcs of the %d calls\n",
-                       arcp -> arc_count , childp -> ncall );
-                   printf( "[doarcs]\t so this gives %8.2f+%8.2f to %s\n" ,
-                       arcp -> arc_time , arcp -> arc_childtime ,
-                       parentp -> name );
+                   printf( "[propagate]\t and to cycle %d\n" ,
+                           parentp -> cycleno );
                }
 #          endif DEBUG
                }
 #          endif DEBUG
-           parentp -> childtime += share;
-               /*
-                *      add this share to the cycle header, if any
-                */
-           if ( parentp -> cyclehead != parentp ) {
-#              ifdef DEBUG
-                   if ( debug & ARCDEBUG ) {
-                       printf( "[doarcs]\t and to cycle %d\n" ,
-                               parentp -> cycleno );
-                   }
-#              endif DEBUG
-               parentp -> cyclehead -> childtime += share;
-           }
+           parentp -> cyclehead -> childtime += share;
        }
     }
        }
     }
-    printgprof();
 }
 
 cyclelink()
 }
 
 cyclelink()
@@ -229,19 +239,24 @@ cyclelink()
        /*
         *      Count the number of cycles, and initialze the cycle lists
         */
        /*
         *      Count the number of cycles, and initialze the cycle lists
         */
-    cyclemax = 0;
+    ncycle = 0;
     for ( nlp = nl ; nlp < npe ; nlp++ ) {
            /*
             *  this is how you find unattached cycles
             */
        if ( nlp -> cyclehead == nlp && nlp -> cnext != 0 ) {
     for ( nlp = nl ; nlp < npe ; nlp++ ) {
            /*
             *  this is how you find unattached cycles
             */
        if ( nlp -> cyclehead == nlp && nlp -> cnext != 0 ) {
-           cyclemax += 1;
+           ncycle += 1;
        }
     }
        }
     }
-    if ( cyclemax > ncycles ) {
-       fprintf( stderr , "prof: %d cycles in %d names exceeds %f%%\n" ,
-               cyclemax , nname , CYCLEFRACTION * 100.0 );
-       exit( 1 );
+       /*
+        *      cyclenl is indexed by cycle number:
+        *      i.e. it is origin 1, not origin 0.
+        */
+    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 ) );
+       done();
     }
        /*
         *      now link cycles to true cycleheads,
     }
        /*
         *      now link cycles to true cycleheads,
@@ -253,7 +268,7 @@ cyclelink()
            continue;
        }
        cycle += 1;
            continue;
        }
        cycle += 1;
-       cyclenlp = &nl[nname+cycle];
+       cyclenlp = &cyclenl[cycle];
        cyclenlp -> cycleno = cycle;
        cyclenlp -> cyclehead = cyclenlp;
        cyclenlp -> cnext = nlp;
        cyclenlp -> cycleno = cycle;
        cyclenlp -> cyclehead = cyclenlp;
        cyclenlp -> cnext = nlp;
index 670b2bc..18a1326 100644 (file)
@@ -1,9 +1,11 @@
 #ifndef lint
 #ifndef lint
-    static     char *sccsid = "@(#)gprof.c     1.10 (Berkeley) %G%";
+    static     char *sccsid = "@(#)gprof.c     1.11 (Berkeley) %G%";
 #endif lint
 
 #include "gprof.h"
 
 #endif lint
 
 #include "gprof.h"
 
+char   *whoami = "gprof";
+
 main(argc, argv)
        int argc;
        char **argv;
 main(argc, argv)
        int argc;
        char **argv;
@@ -65,13 +67,13 @@ main(argc, argv)
        if ( *argv != 0 ) {
            gmonname = *argv;
        }
        if ( *argv != 0 ) {
            gmonname = *argv;
        }
-    } while ( sflag && *argv++ != 0 );
+    } while ( *argv++ != 0 );
        /*
         *      dump out a gmon.sum file if requested
         */
        /*
         *      dump out a gmon.sum file if requested
         */
-       if ( sflag ) {
-           dumpsum( GMONSUM );
-       }
+    if ( sflag ) {
+       dumpsum( GMONSUM );
+    }
        /*
         *      assign samples to procedures
         */
        /*
         *      assign samples to procedures
         */
@@ -87,11 +89,11 @@ main(argc, argv)
     done();
 }
 
     done();
 }
 
-/*
- * Set up string and symbol tables from a.out.
*     and optionally the text space.
- * On return symbol table is sorted by value.
- */
+    /*
    * Set up string and symbol tables from a.out.
    * and optionally the text space.
    * On return symbol table is sorted by value.
    */
 getnfile()
 {
     FILE       *nfile;
 getnfile()
 {
     FILE       *nfile;
@@ -103,7 +105,7 @@ getnfile()
     }
     fread(&xbuf, 1, sizeof(xbuf), nfile);
     if (N_BADMAG(xbuf)) {
     }
     fread(&xbuf, 1, sizeof(xbuf), nfile);
     if (N_BADMAG(xbuf)) {
-       fprintf(stderr, "%s: bad format\n", a_outname );
+       fprintf(stderr, "%s: %s: bad format\n", whoami , a_outname );
        done();
     }
     getstrtab(nfile);
        done();
     }
     getstrtab(nfile);
@@ -128,17 +130,19 @@ getstrtab(nfile)
 
     fseek(nfile, (long)(N_SYMOFF(xbuf) + xbuf.a_syms), 0);
     if (fread(&ssiz, sizeof (ssiz), 1, nfile) == 0) {
 
     fseek(nfile, (long)(N_SYMOFF(xbuf) + xbuf.a_syms), 0);
     if (fread(&ssiz, sizeof (ssiz), 1, nfile) == 0) {
-       fprintf(stderr, "%s: no string table (old format?)\n", a_outname );
+       fprintf(stderr, "%s: %s: no string table (old format?)\n" ,
+               whoami , a_outname );
        done();
     }
     strtab = (char *)calloc(ssiz, 1);
     if (strtab == NULL) {
        done();
     }
     strtab = (char *)calloc(ssiz, 1);
     if (strtab == NULL) {
-       fprintf(stderr, "%s: no room for %d bytes of string table",
-               a_outname , ssiz);
+       fprintf(stderr, "%s: %s: no room for %d bytes of string table",
+               whoami , a_outname , ssiz);
        done();
     }
     if (fread(strtab+sizeof(ssiz), ssiz-sizeof(ssiz), 1, nfile) != 1) {
        done();
     }
     if (fread(strtab+sizeof(ssiz), ssiz-sizeof(ssiz), 1, nfile) != 1) {
-       fprintf(stderr, "%s: error reading string table\n", a_outname );
+       fprintf(stderr, "%s: %s: error reading string table\n",
+               whoami , a_outname );
        done();
     }
 }
        done();
     }
 }
@@ -164,21 +168,14 @@ getsymtab(nfile)
        nname++;
     }
     if (nname == 0) {
        nname++;
     }
     if (nname == 0) {
-       fprintf(stderr, "%s: no symbols\n", a_outname );
+       fprintf(stderr, "%s: %s: no symbols\n", whoami , a_outname );
        done();
     }
        done();
     }
-       /*
-        *      ask also for CYCLEFRACTION extra namelist entries for 
-        *      cycle entries.  these hide out at the end of the namelist
-        *      and aren't accessed unless the whole namelist (nname+ncycles)
-        *      is sorted and searched.
-        */
-    ncycles = nname * CYCLEFRACTION;
-    askfor = nname + 1 + ncycles;
+    askfor = nname + 1;
     nl = (nltype *) calloc( askfor , sizeof(nltype) );
     if (nl == 0) {
     nl = (nltype *) calloc( askfor , sizeof(nltype) );
     if (nl == 0) {
-       fprintf(stderr, "prof: No room for %d bytes of symbol table\n",
-               askfor * sizeof(nltype) );
+       fprintf(stderr, "%s: No room for %d bytes of symbol table\n",
+               whoami, askfor * sizeof(nltype) );
        done();
     }
 
        done();
     }
 
@@ -225,14 +222,15 @@ gettextspace( nfile )
     }
     textspace = malloc( xbuf.a_text );
     if ( textspace == 0 ) {
     }
     textspace = malloc( xbuf.a_text );
     if ( textspace == 0 ) {
-       fprintf( stderr , "gprof: ran out room for %d bytes of text space:  " );
-       fprintf( stderr , "can't do -c\n" , xbuf.a_text );
+       fprintf( stderr , "%s: ran out room for %d bytes of text space:  " ,
+                       whoami , xbuf.a_text );
+       fprintf( stderr , "can't do -c\n" );
        return;
     }
     (void) fseek( nfile , N_TXTOFF( xbuf ) , 0 );
     if ( fread( textspace , 1 , xbuf.a_text , nfile ) != xbuf.a_text ) {
        return;
     }
     (void) fseek( nfile , N_TXTOFF( xbuf ) , 0 );
     if ( fread( textspace , 1 , xbuf.a_text , nfile ) != xbuf.a_text ) {
-       fprintf( stderr , "couldn't read text space:  " );
-       fprintf( stderr , "can't do -c\n" , xbuf.a_text );
+       fprintf( stderr , "%s: couldn't read text space:  " , whoami );
+       fprintf( stderr , "can't do -c\n" );
        free( textspace );
        textspace = 0;
        return;
        free( textspace );
        textspace = 0;
        return;
@@ -389,8 +387,8 @@ readsamples(pfile)
     if (samples == 0) {
        samples = (unsigned UNIT *) calloc(sampbytes, sizeof (unsigned UNIT));
        if (samples == 0) {
     if (samples == 0) {
        samples = (unsigned UNIT *) calloc(sampbytes, sizeof (unsigned UNIT));
        if (samples == 0) {
-           fprintf( stderr , "prof: No room for %d sample pc's\n", 
-               sampbytes / sizeof (unsigned UNIT));
+           fprintf( stderr , "%s: No room for %d sample pc's\n", 
+               whoami , sampbytes / sizeof (unsigned UNIT));
            done();
        }
     }
            done();
        }
     }
@@ -402,8 +400,8 @@ readsamples(pfile)
     }
     if (i != nsamples) {
        fprintf(stderr,
     }
     if (i != nsamples) {
        fprintf(stderr,
-           "prof: unexpected EOF after reading %d/%d samples\n",
-               --i, nsamples);
+           "%s: unexpected EOF after reading %d/%d samples\n",
+               whoami , --i , nsamples );
        done();
     }
 }
        done();
     }
 }
@@ -505,7 +503,7 @@ funcsymbol( nlistp )
        return FALSE;
     }
        /*
        return FALSE;
     }
        /*
-        *      can't have any `funny characters in name,
+        *      can't have any `funny' characters in name,
         *      where `funny' includes  `.', .o file names
         *                      and     `$', pascal labels.
         */
         *      where `funny' includes  `.', .o file names
         *                      and     `$', pascal labels.
         */
index 4737381..75bcd5a 100644 (file)
@@ -1,4 +1,4 @@
-    /* sccsid:  @(#)gprof.h    1.10 (Berkeley) %G% */
+    /* sccsid:  @(#)gprof.h    1.11 (Berkeley) %G% */
 
 #include <stdio.h>
 #include <sys/types.h>
 
 #include <stdio.h>
 #include <sys/types.h>
@@ -7,6 +7,11 @@
 #include <pagsiz.h>
 #include "gcrt0.h"
 
 #include <pagsiz.h>
 #include "gcrt0.h"
 
+    /*
+     * who am i, for error messages.
+     */
+char   *whoami;
+
     /*
      * ticks per second
      */
     /*
      * ticks per second
      */
@@ -44,31 +49,31 @@ struct arcstruct {
 };
 typedef struct arcstruct       arctype;
 
 };
 typedef struct arcstruct       arctype;
 
-/*
- * The symbol table;
- * for each external in the specified file we gather
- * its address, the number of calls and compute its share of cpu time.
- */
+    /*
    * The symbol table;
    * for each external in the specified file we gather
    * its address, the number of calls and compute its share of cpu time.
    */
 struct nl {
 struct nl {
-       char            *name;          /* the name */
-       unsigned long   value;          /* the pc entry point */
-       double          time;           /* ticks in this routine */
-       double          childtime;      /* cumulative ticks in children */
-       long            ncall;          /* how many times called */
-       long            selfcalls;      /* how many calls to self */
-       int             index;          /* index in the graph list */
-       int             toporder;       /* graph call chain top-sort order */
-       int             cycleno;        /* internal number of cycle on */
-       struct nl       *cyclehead;     /* pointer to head of cycle */
-       struct nl       *cnext;         /* pointer to next member of cycle */
-       arctype         *parents;       /* list of caller arcs */
-       arctype         *children;      /* list of callee arcs */
+    char               *name;          /* the name */
+    unsigned long      value;          /* the pc entry point */
+    double             time;           /* ticks in this routine */
+    double             childtime;      /* cumulative ticks in children */
+    long               ncall;          /* how many times called */
+    long               selfcalls;      /* how many calls to self */
+    int                        index;          /* index in the graph list */
+    int                        toporder;       /* graph call chain top-sort order */
+    int                        cycleno;        /* internal number of cycle on */
+    struct nl          *cyclehead;     /* pointer to head of cycle */
+    struct nl          *cnext;         /* pointer to next member of cycle */
+    arctype            *parents;       /* list of caller arcs */
+    arctype            *children;      /* list of callee arcs */
 };
 typedef struct nl      nltype;
 
 nltype *nl;                    /* the whole namelist */
 nltype *npe;                   /* the virtual end of the namelist */
 };
 typedef struct nl      nltype;
 
 nltype *nl;                    /* the whole namelist */
 nltype *npe;                   /* the virtual end of the namelist */
-int            nname;                  /* the number of function names */
+int    nname;                  /* the number of function names */
 
     /*
      * flag which marks a nl entry as topologically ``busy''
 
     /*
      * flag which marks a nl entry as topologically ``busy''
@@ -76,36 +81,34 @@ int         nname;                  /* the number of function names */
 #define        DFN_BUSY        -1
 
     /* 
 #define        DFN_BUSY        -1
 
     /* 
-     * the number of cycles is estimated as this fraction of nnames
-     * ncycles, the number of allocated cycle namelist entries,
-     * not to be confused with cyclemax, the number of discovered cycles.
+     * namelist entries for cycle headers.
+     * the number of discovered cycles.
+     */
+nltype *cyclenl;               /* cycle header namelist */
+int    ncycle;                 /* number of cycles discovered */
+
+    /*
+     * The header on the gmon.out file.
+     * gmon.out consists of one of these headers,
+     * and then an array of ncnt samples
+     * representing the discretized program counter values.
+     * this should be a struct phdr, but since everything is done
+     * as UNITs, this is in UNITs too.
      */
      */
-#define        CYCLEFRACTION   ( 0.10 )
-int    ncycles;                /* maximum allocated cycle headers */
-int    cyclemax;               /* number of cycles discovered */
-
-/*
- * The header on the gmon.out file.
- * gmon.out consists of one of these headers,
- * and then an array of ncnt samples
- * representing the discretized program counter values.
- *     this should be a struct phdr, but since everything is done
- *     as UNITs, this is in UNITs too.
- */
 struct hdr {
 struct hdr {
-       UNIT    *lowpc;
-       UNIT    *highpc;
-       int     ncnt;
+    UNIT       *lowpc;
+    UNIT       *highpc;
+    int        ncnt;
 };
 
 struct hdr     h;
 
 int    debug;
 
 };
 
 struct hdr     h;
 
 int    debug;
 
-/*
- * Each discretized pc sample has
- * a count of the number of samples in its range
- */
+    /*
    * Each discretized pc sample has
    * a count of the number of samples in its range
    */
 unsigned UNIT  *samples;
 
 unsigned long  s_lowpc;        /* lowpc from the profile file */
 unsigned UNIT  *samples;
 
 unsigned long  s_lowpc;        /* lowpc from the profile file */
index bb5e60e..b510ed3 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-    static     char *sccsid = "@(#)printgprof.c        1.7 (Berkeley) %G%";
+    static     char *sccsid = "@(#)printgprof.c        1.8 (Berkeley) %G%";
 #endif lint
 
 #include "gprof.h"
 #endif lint
 
 #include "gprof.h"
@@ -131,21 +131,21 @@ printgprof()
 
        /*
         *      Now, sort by time + childtime.
 
        /*
         *      Now, sort by time + childtime.
-        *      include the cycle headers hiding out past nl[nname].
-        *      don't include the dummy hiding at nl[nname].
+        *      sorting both the regular function names
+        *      and cycle headers.
         */
         */
-    timesortnlp = (nltype **) calloc( nname + cyclemax , sizeof(nltype *) );
+    timesortnlp = (nltype **) calloc( nname + ncycle , sizeof(nltype *) );
     if ( timesortnlp == (nltype **) 0 ) {
     if ( timesortnlp == (nltype **) 0 ) {
-       fprintf( stderr , "[doarcs] ran out of memory for sorting\n" );
+       fprintf( stderr , "%s: ran out of memory for sorting\n" , whoami );
     }
     for ( index = 0 ; index < nname ; index++ ) {
        timesortnlp[index] = &nl[index];
     }
     }
     for ( index = 0 ; index < nname ; index++ ) {
        timesortnlp[index] = &nl[index];
     }
-    for ( index = 1 ; index <= cyclemax ; index++ ) {
-       timesortnlp[(nname-1)+index] = &nl[nname+index];
+    for ( index = 1 ; index <= ncycle ; index++ ) {
+       timesortnlp[nname+index-1] = &cyclenl[index];
     }
     }
-    qsort( timesortnlp , nname + cyclemax , sizeof(nltype *) , totalcmp );
-    for ( index = 0 ; index < nname + cyclemax ; index++ ) {
+    qsort( timesortnlp , nname + ncycle , sizeof(nltype *) , totalcmp );
+    for ( index = 0 ; index < nname + ncycle ; index++ ) {
        timesortnlp[ index ] -> index = index + 1;
     }
        /*
        timesortnlp[ index ] -> index = index + 1;
     }
        /*
@@ -153,7 +153,7 @@ printgprof()
         */
     printf( "\f\n" );
     gprofheader();
         */
     printf( "\f\n" );
     gprofheader();
-    for ( index = 0 ; index < nname + cyclemax ; index ++ ) {
+    for ( index = 0 ; index < nname + ncycle ; index ++ ) {
        parentp = timesortnlp[ index ];
        if ( zflag == 0 &&
             parentp -> ncall == 0 &&
        parentp = timesortnlp[ index ];
        if ( zflag == 0 &&
             parentp -> ncall == 0 &&