FreeBSD/usr.bin/gprof/gprof.c
/*
 * dump out the gmon.sum file
 */
dump out the gmon.sum file
dump out the gmon . sum file
void
dumpsum(const char *sumfile)
{
    register nltype *nlp;
    register arctype *arcp;
    struct rawarc arc;
    FILE *sfile;
    if ( ( sfile = fopen ( sumfile , "w" ) ) == NULL )
	err( 1 , "%s" , sumfile );
    if ( fwrite( &gmonhdr , sizeof gmonhdr , 1 , sfile ) != 1 )
	err( 1 , "%s" , sumfile );
    if (fwrite(samples, histcounter_size, nsamples, sfile) != nsamples)
	err( 1 , "%s" , sumfile );
    for ( nlp = nl ; nlp < npe ; nlp++ ) {
	for ( arcp = nlp -> children ; arcp ; arcp = arcp -> arc_childlist ) {
	    arc.raw_frompc = arcp -> arc_parentp -> value;
	    arc.raw_selfpc = arcp -> arc_childp -> value;
	    arc.raw_count = arcp -> arc_count;
	    if ( fwrite ( &arc , sizeof arc , 1 , sfile ) != 1 )
		err( 1 , "%s" , sumfile );
#	    ifdef DEBUG
		if ( debug & SAMPLEDEBUG ) {
		    printf( "[dumpsum] frompc 0x%lx selfpc 0x%lx count %ld\n" ,
			    arc.raw_frompc , arc.raw_selfpc , arc.raw_count );
		}
#	    endif 
	}
    }
    fclose( sfile );
}
void dumpsum ( const char * sumfile ) { register nltype * nlp ; register arctype * arcp ; struct rawarc arc ; FILE * sfile ; if ( ( sfile = fopen ( sumfile , " " ) ) == NULL ) err ( 1 , " " , sumfile ) ; if ( fwrite ( & gmonhdr , sizeof gmonhdr , 1 , sfile ) != 1 ) err ( 1 , " " , sumfile ) ; if ( fwrite ( samples , histcounter_size , nsamples , sfile ) != nsamples ) err ( 1 , " " , sumfile ) ; for ( nlp = nl ; nlp < npe ; nlp ++ ) { for ( arcp = nlp -> children ; arcp ; arcp = arcp -> arc_childlist ) { arc . raw_frompc = arcp -> arc_parentp -> value ; arc . raw_selfpc = arcp -> arc_childp -> value ; arc . raw_count = arcp -> arc_count ; if ( fwrite ( & arc , sizeof arc , 1 , sfile ) != 1 ) err ( 1 , " " , sumfile ) ; #	    ifdef DEBUG if ( debug & SAMPLEDEBUG ) { printf ( " \n " , arc . raw_frompc , arc . raw_selfpc , arc . raw_count ) ; } #	    endif } } fclose ( sfile ) ; }
dump out the gmon.sum file
dump out the gmon . sum file
/*
     * dump the header; use the last header read in
     */ /*
     * dump the samples
     */ /*
     * dump the normalized raw arc information
     */ /* DEBUG */