Fixed printf format errors. In printgprof.c, also convert the scale

without possibly losing lots of precision, and print the scale using
%g instead of %d in case it is non-integral.  %g might not be the best
format for this.
This commit is contained in:
Bruce Evans 2002-02-21 12:07:21 +00:00
parent 312a529b81
commit 8d57b8d3d2
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=91018
4 changed files with 39 additions and 39 deletions

View File

@ -89,7 +89,7 @@ aout_getnfile(const char *filename, char ***defaultEs)
register int j;
for (j = 0; j < nname; j++){
printf("[getnfile] 0X%08x\t%s\n", nl[j].value, nl[j].name);
printf("[getnfile] 0X%08lx\t%s\n", nl[j].value, nl[j].name);
}
}
# endif DEBUG
@ -167,7 +167,7 @@ getsymtab(FILE *nfile, const char *filename)
npe->name = strtab+nbuf.n_un.n_strx;
# ifdef DEBUG
if ( debug & AOUTDEBUG ) {
printf( "[getsymtab] %d %s 0x%08x\n" ,
printf( "[getsymtab] %d %s 0x%08lx\n" ,
nname , npe -> name , npe -> value );
}
# endif DEBUG

View File

@ -61,7 +61,7 @@ addarc( parentp , childp , count )
# ifdef DEBUG
if ( debug & TALLYDEBUG ) {
printf( "[addarc] %d arcs from %s to %s\n" ,
printf( "[addarc] %ld arcs from %s to %s\n" ,
count , parentp -> name , childp -> name );
}
# endif DEBUG
@ -72,7 +72,7 @@ addarc( parentp , childp , count )
*/
# ifdef DEBUG
if ( debug & TALLYDEBUG ) {
printf( "[tally] hit %d += %d\n" ,
printf( "[tally] hit %ld += %ld\n" ,
arcp -> arc_count , count );
}
# endif DEBUG
@ -173,7 +173,7 @@ doarcs()
*/
# ifdef DEBUG
if ( debug & BREAKCYCLE ) {
printf("[doarcs] pass %d, cycle(s) %d\n" , pass , ncycle );
printf("[doarcs] pass %ld, cycle(s) %d\n" , pass , ncycle );
}
# endif DEBUG
if ( pass == 1 ) {
@ -342,7 +342,7 @@ timepropagate( parentp )
if ( debug & PROPDEBUG ) {
printf( "[dotime] child \t" );
printname( childp );
printf( " with %f %f %d/%d\n" ,
printf( " with %f %f %ld/%ld\n" ,
childp -> time , childp -> childtime ,
arcp -> arc_count , childp -> npropcall );
printf( "[dotime] parent\t" );
@ -718,13 +718,13 @@ compresslist()
maxarcp -> arc_childp -> npropcall -= maxarcp -> arc_count;
# ifdef DEBUG
if ( debug & BREAKCYCLE ) {
printf( "%s delete %s arc: %s (%d) -> %s from %d cycle(s)\n" ,
printf( "%s delete %s arc: %s (%ld) -> %s from %u cycle(s)\n" ,
"[compresslist]" , type , maxarcp -> arc_parentp -> name ,
maxarcp -> arc_count , maxarcp -> arc_childp -> name ,
maxarcp -> arc_cyclecnt );
}
# endif DEBUG
printf( "\t%s to %s with %d calls\n" , maxarcp -> arc_parentp -> name ,
printf( "\t%s to %s with %ld calls\n" , maxarcp -> arc_parentp -> name ,
maxarcp -> arc_childp -> name , maxarcp -> arc_count );
prev = &cyclehead;
for ( clp = cyclehead ; clp ; ) {
@ -757,7 +757,7 @@ printsubcycle( clp )
printf( "%s <cycle %d>\n" , (*arcpp) -> arc_parentp -> name ,
(*arcpp) -> arc_parentp -> cycleno ) ;
for ( endlist = &clp -> list[ clp -> size ]; arcpp < endlist ; arcpp++ )
printf( "\t(%d) -> %s\n" , (*arcpp) -> arc_count ,
printf( "\t(%ld) -> %s\n" , (*arcpp) -> arc_count ,
(*arcpp) -> arc_childp -> name ) ;
}
#endif DEBUG

View File

@ -255,7 +255,7 @@ getpfile(filename)
while ( fread( &arc , sizeof arc , 1 , pfile ) == 1 ) {
# ifdef DEBUG
if ( debug & SAMPLEDEBUG ) {
printf( "[getpfile] frompc 0x%x selfpc 0x%x count %d\n" ,
printf( "[getpfile] frompc 0x%lx selfpc 0x%lx count %ld\n" ,
arc.raw_frompc , arc.raw_selfpc , arc.raw_count );
}
# endif DEBUG
@ -300,7 +300,7 @@ openpfile(filename)
hz = rate;
} else if (hz != rate) {
fprintf(stderr,
"%s: profile clock rate (%d) %s (%d) in first gmon file\n",
"%s: profile clock rate (%d) %s (%ld) in first gmon file\n",
filename, rate, "incompatible with clock rate", hz);
done();
}
@ -312,15 +312,15 @@ openpfile(filename)
nsamples = sampbytes / sizeof (UNIT);
# ifdef DEBUG
if ( debug & SAMPLEDEBUG ) {
printf( "[openpfile] hdr.lpc 0x%x hdr.hpc 0x%x hdr.ncnt %d\n",
printf( "[openpfile] hdr.lpc 0x%lx hdr.hpc 0x%lx hdr.ncnt %d\n",
gmonhdr.lpc , gmonhdr.hpc , gmonhdr.ncnt );
printf( "[openpfile] s_lowpc 0x%x s_highpc 0x%x\n" ,
printf( "[openpfile] s_lowpc 0x%lx s_highpc 0x%lx\n" ,
s_lowpc , s_highpc );
printf( "[openpfile] lowpc 0x%x highpc 0x%x\n" ,
printf( "[openpfile] lowpc 0x%lx highpc 0x%lx\n" ,
lowpc , highpc );
printf( "[openpfile] sampbytes %d nsamples %d\n" ,
sampbytes , nsamples );
printf( "[openpfile] sample rate %d\n" , hz );
printf( "[openpfile] sample rate %ld\n" , hz );
}
# endif DEBUG
return(pfile);
@ -344,7 +344,7 @@ tally( rawp )
childp -> ncall += rawp -> raw_count;
# ifdef DEBUG
if ( debug & TALLYDEBUG ) {
printf( "[tally] arc from %s to %s traversed %d times\n" ,
printf( "[tally] arc from %s to %s traversed %ld times\n" ,
parentp -> name , childp -> name , rawp -> raw_count );
}
# endif DEBUG
@ -394,7 +394,7 @@ dumpsum( sumfile )
}
# ifdef DEBUG
if ( debug & SAMPLEDEBUG ) {
printf( "[dumpsum] frompc 0x%x selfpc 0x%x count %d\n" ,
printf( "[dumpsum] frompc 0x%lx selfpc 0x%lx count %ld\n" ,
arc.raw_frompc , arc.raw_selfpc , arc.raw_count );
}
# endif DEBUG
@ -500,7 +500,7 @@ asgnsamples()
time = ccnt;
# ifdef DEBUG
if ( debug & SAMPLEDEBUG ) {
printf( "[asgnsamples] pcl 0x%x pch 0x%x ccnt %d\n" ,
printf( "[asgnsamples] pcl 0x%lx pch 0x%lx ccnt %d\n" ,
pcl , pch , ccnt );
}
# endif DEBUG
@ -524,7 +524,7 @@ asgnsamples()
if (overlap > 0) {
# ifdef DEBUG
if (debug & SAMPLEDEBUG) {
printf("[asgnsamples] (0x%x->0x%x-0x%x) %s gets %f ticks %d overlap\n",
printf("[asgnsamples] (0x%lx->0x%lx-0x%lx) %s gets %f ticks %lu overlap\n",
nl[j].value/sizeof(UNIT), svalue0, svalue1,
nl[j].name,
overlap * time / scale, overlap);
@ -579,7 +579,7 @@ alignentries()
if (bucket_of_entry < bucket_of_code) {
# ifdef DEBUG
if (debug & SAMPLEDEBUG) {
printf("[alignentries] pushing svalue 0x%x to 0x%x\n",
printf("[alignentries] pushing svalue 0x%lx to 0x%lx\n",
nlp->svalue, nlp->svalue + UNITS_TO_CODE);
}
# endif DEBUG

View File

@ -99,8 +99,8 @@ flatprofheader()
if ( bflag ) {
printblurb( _PATH_FLAT_BLURB );
}
printf( "\ngranularity: each sample hit covers %d byte(s)" ,
(long) scale * sizeof(UNIT) );
printf( "\ngranularity: each sample hit covers %g byte(s)" ,
scale * sizeof(UNIT) );
if ( totime > 0.0 ) {
printf( " for %.2f%% of %.2f seconds\n\n" ,
100.0/totime , totime / hz );
@ -136,15 +136,15 @@ flatprofline( np )
100 * np -> time / totime , actime / hz , np -> time / hz );
if ( np -> ncall != 0 ) {
if (hz >= 10000000)
printf( " %8d %8.0f %8.0f " , np -> ncall ,
printf( " %8ld %8.0f %8.0f " , np -> ncall ,
1e9 * np -> time / hz / np -> ncall ,
1e9 * ( np -> time + np -> childtime ) / hz / np -> ncall );
else if (hz >= 10000)
printf( " %8d %8.0f %8.0f " , np -> ncall ,
printf( " %8ld %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 ,
printf( " %8ld %8.2f %8.2f " , np -> ncall ,
1000 * np -> time / hz / np -> ncall ,
1000 * ( np -> time + np -> childtime ) / hz / np -> ncall );
} else {
@ -160,8 +160,8 @@ gprofheader()
if ( bflag ) {
printblurb( _PATH_CALLG_BLURB );
}
printf( "\ngranularity: each sample hit covers %d byte(s)" ,
(long) scale * sizeof(UNIT) );
printf( "\ngranularity: each sample hit covers %g byte(s)" ,
scale * sizeof(UNIT) );
if ( printtime > 0.0 ) {
printf( " for %.2f%% of %.2f seconds\n\n" ,
100.0/printtime , printtime / hz );
@ -194,9 +194,9 @@ gprofline( np )
np -> propself / hz ,
np -> propchild / hz );
if ( ( np -> ncall + np -> selfcalls ) != 0 ) {
printf( " %7d" , np -> npropcall );
printf( " %7ld" , np -> npropcall );
if ( np -> selfcalls != 0 ) {
printf( "+%-7d " , np -> selfcalls );
printf( "+%-7ld " , np -> selfcalls );
} else {
printf( " %7.7s " , "" );
}
@ -314,7 +314,7 @@ printparents( childp )
/*
* selfcall or call among siblings
*/
printf( "%6.6s %5.5s %7.7s %11.11s %7d %7.7s " ,
printf( "%6.6s %5.5s %7.7s %11.11s %7ld %7.7s " ,
"" , "" , "" , "" ,
arcp -> arc_count , "" );
printname( parentp );
@ -323,7 +323,7 @@ printparents( childp )
/*
* regular parent of child
*/
printf( "%6.6s %5.5s %7.2f %11.2f %7d/%-7d " ,
printf( "%6.6s %5.5s %7.2f %11.2f %7ld/%-7ld " ,
"" , "" ,
arcp -> arc_time / hz , arcp -> arc_childtime / hz ,
arcp -> arc_count , cycleheadp -> npropcall );
@ -348,7 +348,7 @@ printchildren( parentp )
/*
* self call or call to sibling
*/
printf( "%6.6s %5.5s %7.7s %11.11s %7d %7.7s " ,
printf( "%6.6s %5.5s %7.7s %11.11s %7ld %7.7s " ,
"" , "" , "" , "" , arcp -> arc_count , "" );
printname( childp );
printf( "\n" );
@ -356,7 +356,7 @@ printchildren( parentp )
/*
* regular child of parent
*/
printf( "%6.6s %5.5s %7.2f %11.2f %7d/%-7d " ,
printf( "%6.6s %5.5s %7.2f %11.2f %7ld/%-7ld " ,
"" , "" ,
arcp -> arc_time / hz , arcp -> arc_childtime / hz ,
arcp -> arc_count , childp -> cyclehead -> npropcall );
@ -482,14 +482,14 @@ printcycle( cyclep )
char kirkbuffer[ BUFSIZ ];
sprintf( kirkbuffer , "[%d]" , cyclep -> index );
printf( "%-6.6s %5.1f %7.2f %11.2f %7d" ,
printf( "%-6.6s %5.1f %7.2f %11.2f %7ld" ,
kirkbuffer ,
100 * ( cyclep -> propself + cyclep -> propchild ) / printtime ,
cyclep -> propself / hz ,
cyclep -> propchild / hz ,
cyclep -> npropcall );
if ( cyclep -> selfcalls != 0 ) {
printf( "+%-7d" , cyclep -> selfcalls );
printf( "+%-7ld" , cyclep -> selfcalls );
} else {
printf( " %7.7s" , "" );
}
@ -507,11 +507,11 @@ printmembers( cyclep )
sortmembers( cyclep );
for ( memberp = cyclep -> cnext ; memberp ; memberp = memberp -> cnext ) {
printf( "%6.6s %5.5s %7.2f %11.2f %7d" ,
printf( "%6.6s %5.5s %7.2f %11.2f %7ld" ,
"" , "" , memberp -> propself / hz , memberp -> propchild / hz ,
memberp -> npropcall );
if ( memberp -> selfcalls != 0 ) {
printf( "+%-7d" , memberp -> selfcalls );
printf( "+%-7ld" , memberp -> selfcalls );
} else {
printf( " %7.7s" , "" );
}
@ -605,14 +605,14 @@ arccmp( thisp , thatp )
printname( thisparentp );
printf( " calls " );
printname ( thischildp );
printf( " %f + %f %d/%d\n" ,
printf( " %f + %f %ld/%ld\n" ,
thisp -> arc_time , thisp -> arc_childtime ,
thisp -> arc_count , thischildp -> ncall );
printf( "[arccmp] " );
printname( thatparentp );
printf( " calls " );
printname( thatchildp );
printf( " %f + %f %d/%d\n" ,
printf( " %f + %f %ld/%ld\n" ,
thatp -> arc_time , thatp -> arc_childtime ,
thatp -> arc_count , thatchildp -> ncall );
printf( "\n" );