summaryrefslogtreecommitdiff
path: root/cachegrind
diff options
context:
space:
mode:
authornjn <njn@a5019735-40e9-0310-863c-91ae7b9d1cf9>2005-12-08 23:18:50 +0000
committernjn <njn@a5019735-40e9-0310-863c-91ae7b9d1cf9>2005-12-08 23:18:50 +0000
commit4311fe6d249cc8708e2004ea71e0cfe0c26cd52b (patch)
treee243d72031cdf8564a3db5e619d8a37e2c114c8a /cachegrind
parent52783ca9c51977276ef0a8367bad550f283b461a (diff)
Fix minor Cachegrind bug that was occasionally causing misattributions of
counts when a function name was used in more than one module. This showed up for "???" functions when profiling Valgrind itself. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5319 a5019735-40e9-0310-863c-91ae7b9d1cf9
Diffstat (limited to 'cachegrind')
-rw-r--r--cachegrind/cg_main.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/cachegrind/cg_main.c b/cachegrind/cg_main.c
index 99d70696..3c9627e1 100644
--- a/cachegrind/cg_main.c
+++ b/cachegrind/cg_main.c
@@ -1060,23 +1060,29 @@ static void fprint_CC_table_and_calc_totals(void)
// Traverse every lineCC
VG_(OSet_ResetIter)(CC_table);
while ( (lineCC = VG_(OSet_Next)(CC_table)) ) {
+ Bool just_hit_a_new_file = False;
// If we've hit a new file, print a "fl=" line. Note that because
// each string is stored exactly once in the string table, we can use
// pointer comparison rather than strcmp() to test for equality, which
// is good because most of the time the comparisons are equal and so
- // the whole strings would have to be traversed.
+ // the whole strings would have to be checked.
if ( lineCC->loc.file != currFile ) {
currFile = lineCC->loc.file;
VG_(sprintf)(buf, "fl=%s\n", currFile);
VG_(write)(fd, (void*)buf, VG_(strlen)(buf));
distinct_files++;
+ just_hit_a_new_file = True;
}
- // If we've hit a new function, print a "fn=" line.
- if ( lineCC->loc.fn != currFn ) {
+ // If we've hit a new function, print a "fn=" line. We know to do
+ // this when the function name changes, and also every time we hit a
+ // new file (in which case the new function name might be the same as
+ // in the old file, hence the just_hit_a_new_file test).
+ if ( just_hit_a_new_file || lineCC->loc.fn != currFn ) {
currFn = lineCC->loc.fn;
VG_(sprintf)(buf, "fn=%s\n", currFn);
VG_(write)(fd, (void*)buf, VG_(strlen)(buf));
distinct_fns++;
+ just_hit_a_new_file = False;
}
// Print the LineCC