aboutsummaryrefslogtreecommitdiff
path: root/gprof/gprof.c
diff options
context:
space:
mode:
authorSean Eric Fagan <sef@cygnus>1993-08-13 21:38:41 +0000
committerSean Eric Fagan <sef@cygnus>1993-08-13 21:38:41 +0000
commit2ea5f3252a4267a0fb46c107cb6619257e6c814b (patch)
treeebbaa6caeb392c7190022431092a5c84adcf4f6c /gprof/gprof.c
parent1095e08dba8738d5311bb972aa980944476b19c2 (diff)
downloadgdb-2ea5f3252a4267a0fb46c107cb6619257e6c814b.zip
gdb-2ea5f3252a4267a0fb46c107cb6619257e6c814b.tar.gz
gdb-2ea5f3252a4267a0fb46c107cb6619257e6c814b.tar.bz2
Use BFD to determine what a symbol prefix is, be better about determining
which symbols to study, and divide by the correct amount.
Diffstat (limited to 'gprof/gprof.c')
-rw-r--r--gprof/gprof.c46
1 files changed, 39 insertions, 7 deletions
diff --git a/gprof/gprof.c b/gprof/gprof.c
index af54a9d..063fc80 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()