]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Callgrind: Fix annotate script for data produced with --dump-instr=yes
authorJosef Weidendorfer <Josef.Weidendorfer@gmx.de>
Thu, 31 Aug 2006 22:54:36 +0000 (22:54 +0000)
committerJosef Weidendorfer <Josef.Weidendorfer@gmx.de>
Thu, 31 Aug 2006 22:54:36 +0000 (22:54 +0000)
I just noticed that this is still a little wrong, as counts for e.g.
"strcmp" from libc and "strcmp" from ld.so will make up only one entry,
with the object name randomly choosen... but otherwise, it matches
with the data shown by KCachegrind.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6044

callgrind/callgrind_annotate.in

index 617354d194582860e0192dd924d19a55423c4d8e..859d51a96b10a07638d6bca8e760f76bf34b8041 100644 (file)
@@ -483,6 +483,7 @@ sub read_input_file()
     my $curr_fn;
     my $curr_name;
     my $curr_line_num = 0;
+    my $prev_line_num = 0;
 
     my $curr_cobj = "";
     my $curr_cfile = "";
@@ -496,17 +497,19 @@ sub read_input_file()
 
     # Read body of input file.
     while (<INPUTFILE>) {
+       $prev_line_num = $curr_line_num;
+
         s/#.*$//;   # remove comments
-       s/^\+(\d+)/$curr_line_num+$1/e;
-        s/^\-(\d+)/$curr_line_num-$1/e;
-        s/^\*/$curr_line_num/e;
-        if (s/^(\d+|0x\w+)\s+//) {
+        s/^\+(\d+)/$prev_line_num+$1/e;
+        s/^\-(\d+)/$prev_line_num-$1/e;
+        s/^\*/$prev_line_num/e;
+        if (s/^(-?\d+|0x\w+)\s+//) {
             $curr_line_num = $1;
            if ($has_addr) {
              if ($has_line) {
-                s/^\+(\d+)/$curr_line_num+$1/e;
-               s/^\-(\d+)/$curr_line_num-$1/e;
-                s/^\*/$curr_line_num/e;
+                s/^\+(\d+)/$prev_line_num+$1/e;
+               s/^\-(\d+)/$prev_line_num-$1/e;
+                s/^\*/$prev_line_num/e;
 
                if (s/^(\d+)\s+//) { $curr_line_num = $1; }
              }