[patch] gprof corefile.c incorrectly handles .NNN functions
James Blackburn
james.blackburn@broadcom.com
Thu Jul 15 13:31:00 GMT 2010
Hi,
We just pulled a patch to corefile.c for supporting 'nested subprograms'. It looks like a bug was introduced in corefile.c 1.28. There is no 'break;' after the nested for loop used to check for .NNN. This means if a function name matches <foo>.NNN, name is incremented pass the null-character and the loop iterates over other contents of the sym struct.
I've also added a check for *.clone.NNN which is present using link time optimisation with recent GCCs.
Cheers,
James
### Eclipse Workspace Patch 1.0
#P gprof
Index: corefile.c
===================================================================
RCS file: /cvs/src/src/gprof/corefile.c,v
retrieving revision 1.39
diff -u -r1.39 corefile.c
--- corefile.c 27 Apr 2010 14:46:09 -0000 1.39
+++ corefile.c 15 Jul 2010 13:29:20 -0000
@@ -385,12 +385,19 @@
if (*name == '$')
return 0;
- /* Do not discard nested subprograms (those
- which end with .NNN, where N are digits). */
if (*name == '.')
- for (name++; *name; name++)
- if (! ISDIGIT (*name))
- return 0;
+ {
+ /* allow GCC cloned functions */
+ if (strlen(name) > 7 && strncmp(name, ".clone.", 7) == 0)
+ name += 6;
+
+ /* Do not discard nested subprograms (those
+ which end with .NNN, where N are digits). */
+ for (name++; *name; name++)
+ if (! ISDIGIT (*name))
+ return 0;
+ break;
+ }
}
/* On systems where the C compiler adds an underscore to all
More information about the Binutils
mailing list