From 2ea5f3252a4267a0fb46c107cb6619257e6c814b Mon Sep 17 00:00:00 2001 From: Sean Eric Fagan Date: Fri, 13 Aug 1993 21:38:41 +0000 Subject: [PATCH] Use BFD to determine what a symbol prefix is, be better about determining which symbols to study, and divide by the correct amount. --- gprof/gprof.c | 46 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/gprof/gprof.c b/gprof/gprof.c index af54a9ded16..063fc80a598 100644 --- a/gprof/gprof.c +++ b/gprof/gprof.c @@ -576,7 +576,7 @@ asgnsamples() /* read samples and assign to namelist symbols */ scale = highpc - lowpc; - scale /= nsamples; + scale /= nsamples - 1; alignentries(); for (i = 0, j = 1; i < nsamples; i++) { ccnt = samples[i]; @@ -683,6 +683,7 @@ funcsymbol( symp ) extern int aflag; /* if static functions aren't desired */ CONST char *name; int i; + char symprefix; /* * must be a text symbol, @@ -699,6 +700,31 @@ funcsymbol( symp ) #endif return FALSE; } + + symprefix = bfd_get_symbol_leading_char (abfd); + i = bfd_decode_symclass (symp); +#if defined(DEBUG) && 0 + if (i != 'T' && i != 't') + fprintf (stderr, "%s(%d): %s is of class %c\n", __FILE__, __LINE__, symp->name, i); +#endif + + /* + * Any external text symbol should be okay. (Only problem would be + * variables in the text section.) + */ + + if (i == 'T') + return TRUE; + + /* + * 't' is static text; -a says to ignore it. So if it's not + * a static text symbol, *or* it is and the user gave -a, we + * ignore it. + */ + + if (i != 't' || aflag) + return FALSE; + /* * can't have any `funny' characters in name, * where `funny' includes `.', .o file names @@ -713,13 +739,19 @@ funcsymbol( symp ) } } - i = bfd_decode_symclass (symp); -#if defined(DEBUG) && 0 - if (i != 'T' && i != 't') - fprintf (stderr, "%s(%d): %s is of class %c\n", __FILE__, __LINE__, symp->name, i); -#endif + /* On systems where the C compiler adds an underscore to all names, + * static names without underscores seem usually to be labels in + * hand written assembler in the library. We don't want these + * names. This is certainly necessary on a Sparc running SunOS 4.1 + * (try profiling a program that does a lot of division). I don't + * know whether it has harmful side effects on other systems. + * Perhaps it should be made configurable. + */ + + if (symprefix && symprefix != *symp->name) + return FALSE; - return (i == 'T' || i == 't'); + return TRUE; } done() -- 2.30.2