From: Josef Weidendorfer Date: Thu, 31 Aug 2006 22:54:36 +0000 (+0000) Subject: Callgrind: Fix annotate script for data produced with --dump-instr=yes X-Git-Tag: svn/VALGRIND_3_3_0~687 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=012d22a22ea9c26f627a2aba4d3c5ad8604154f3;p=thirdparty%2Fvalgrind.git Callgrind: Fix annotate script for data produced with --dump-instr=yes 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 --- diff --git a/callgrind/callgrind_annotate.in b/callgrind/callgrind_annotate.in index 617354d194..859d51a96b 100644 --- a/callgrind/callgrind_annotate.in +++ b/callgrind/callgrind_annotate.in @@ -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 () { + $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; } }