|
From: <sv...@va...> - 2005-12-08 23:19:40
|
Author: njn
Date: 2005-12-08 23:19:35 +0000 (Thu, 08 Dec 2005)
New Revision: 5320
Log:
Fix minor Cachegrind bug that was occasionally causing misattributions of
counts when a function name was used in more than one module. This showe=
d
up for "???" functions when profiling Valgrind itself.
Modified:
branches/VALGRIND_3_1_BRANCH/cachegrind/cg_main.c
Modified: branches/VALGRIND_3_1_BRANCH/cachegrind/cg_main.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/VALGRIND_3_1_BRANCH/cachegrind/cg_main.c 2005-12-08 23:18:50=
UTC (rev 5319)
+++ branches/VALGRIND_3_1_BRANCH/cachegrind/cg_main.c 2005-12-08 23:19:35=
UTC (rev 5320)
@@ -1060,23 +1060,29 @@
// Traverse every lineCC
VG_(OSet_ResetIter)(CC_table);
while ( (lineCC =3D VG_(OSet_Next)(CC_table)) ) {
+ Bool just_hit_a_new_file =3D False;
// If we've hit a new file, print a "fl=3D" line. Note that becau=
se
// each string is stored exactly once in the string table, we can =
use
// pointer comparison rather than strcmp() to test for equality, w=
hich
// 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 !=3D currFile ) {
currFile =3D lineCC->loc.file;
VG_(sprintf)(buf, "fl=3D%s\n", currFile);
VG_(write)(fd, (void*)buf, VG_(strlen)(buf));
distinct_files++;
+ just_hit_a_new_file =3D True;
}
- // If we've hit a new function, print a "fn=3D" line.
- if ( lineCC->loc.fn !=3D currFn ) {
+ // If we've hit a new function, print a "fn=3D" 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 !=3D currFn ) {
currFn =3D lineCC->loc.fn;
VG_(sprintf)(buf, "fn=3D%s\n", currFn);
VG_(write)(fd, (void*)buf, VG_(strlen)(buf));
distinct_fns++;
+ just_hit_a_new_file =3D False;
}
=20
// Print the LineCC
|