FreeBSD/usr.sbin/pmcannotate/pmcannotate.c
/*
 * Analyze the "objdump -S" output, locate functions and start
 * printing out the C functions content.
 * We do not use newfunction() because we actually need the
 * function name in available form, but the heurstic used is
 * the same.
 * In order to maintain the printout sorted, on the first pass it
 * simply stores the file offsets in order to fastly moved later
 * (when the file is hot-cached also) when the real printout will
 * happen.
 */
Analyze the "objdump -S" output, locate functions and start
printing out the C functions content.
We do not use newfunction() because we actually need the
function name in available form, but the heurstic used is
the same.
In order to maintain the printout sorted, on the first pass it
simply stores the file offsets in order to fastly moved later
(when the file is hot-cached also) when the real printout will
happen.
Analyze the " objdump - S " output locate functions and start printing out the C functions content . We do not use newfunction () because we actually need the function name in available form but the heurstic used is the same . In order to maintain the printout sorted on the first pass it simply stores the file offsets in order to fastly moved later ( when the file is hot - cached also ) when the real printout will happen .
static int
cparse(FILE *fp)
{
	char buffer[LNBUFF], fname[FNBUFF];
	struct aggent *agg;
	void *ptr;
	while (fgets(buffer, LNBUFF, fp) != NULL) {
		if (isspace(buffer[0]))
			continue;
		if (sscanf(buffer, "%p <%[^>:]>:", &ptr, fname) != 2)
			continue;
		agg = fqueue_findent_by_name(fname);
		if (agg == NULL)
			continue;
		agg->ag_offset = ftell(fp);
	}
	TAILQ_FOREACH(agg, &fqueue, ag_fiter) {
		if (fseek(fp, agg->ag_offset, SEEK_SET) == -1)
			return (-1);
		printf("Profile trace for function: %s() [%.2f%%]\n",
		    agg->ag_name, PERCSAMP(agg->ag_nsamples));
		if (general_printc(fp, agg) == -1)
			return (-1);
		printf("\n");
	}
	return (0);
}
static int cparse ( FILE * fp ) { char buffer [ LNBUFF ] , fname [ FNBUFF ] ; struct aggent * agg ; void * ptr ; while ( fgets ( buffer , LNBUFF , fp ) != NULL ) { if ( isspace ( buffer [ 0 ] ) ) continue ; if ( sscanf ( buffer , " " , & ptr , fname ) != 2 ) continue ; agg = fqueue_findent_by_name ( fname ) ; if ( agg == NULL ) continue ; agg -> ag_offset = ftell ( fp ) ; } TAILQ_FOREACH ( agg , & fqueue , ag_fiter ) { if ( fseek ( fp , agg -> ag_offset , SEEK_SET ) == -1 ) return ( -1 ) ; printf ( " \n " , agg -> ag_name , PERCSAMP ( agg -> ag_nsamples ) ) ; if ( general_printc ( fp , agg ) == -1 ) return ( -1 ) ; printf ( " \n " ) ; } return ( 0 ) ; }
Analyze the "objdump -S" output, locate functions and start
 printing out the C functions content.
Analyze the " objdump - S " output locate functions and start printing out the C functions content .