From: Andreas Arnez Date: Wed, 23 Oct 2019 18:35:50 +0000 (+0200) Subject: callgrind_annotate, cg_annotate: don't truncate function names at '#' X-Git-Tag: VALGRIND_3_16_0~207 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7f63a884264f48baea87f8be480475eced857fd5;p=thirdparty%2Fvalgrind.git callgrind_annotate, cg_annotate: don't truncate function names at '#' C++ function names can contain substrings like "{lambda()#1}". But callgrind_annotate and cg_annotate interpret the '#'-character as a comment marker anywhere on each input line, and thus truncate such names there. On the other hand, the documentation in docs/cl-format.xml, states: Everywhere, comments on own lines starting with '#' are allowed. This seems to imply that a comment line must start with '#' in the first column. Thus skip exactly such lines in the input file and don't handle '#' as a comment marker anywhere else. Signed-off-by: Philippe Waroquiers --- diff --git a/cachegrind/cg_annotate.in b/cachegrind/cg_annotate.in index bcb98935b5..1daa15da23 100644 --- a/cachegrind/cg_annotate.in +++ b/cachegrind/cg_annotate.in @@ -398,7 +398,9 @@ sub read_input_file() # Read body of input file. while () { - s/#.*$//; # remove comments + # Skip comments and empty lines. + next if /^\s*$/ || /^\#/; + if (s/^(-?\d+)\s+//) { my $lineNum = $1; my $CC = line_to_CC($_); @@ -436,9 +438,6 @@ sub read_input_file() # Assume that a "fn=" line is followed by a "fl=" line. $currFileFuncName = undef; - } elsif (s/^\s*$//) { - # blank, do nothing - } elsif (s/^summary:\s+//) { $summary_CC = line_to_CC($_); (scalar(@$summary_CC) == @events) diff --git a/callgrind/callgrind_annotate.in b/callgrind/callgrind_annotate.in index e18ed4ed96..8854aee137 100644 --- a/callgrind/callgrind_annotate.in +++ b/callgrind/callgrind_annotate.in @@ -420,10 +420,8 @@ sub read_input_file() # Read header while() { - # remove comments - s/#.*$//; - - if (/^$/) { ; } + # Skip comments and empty lines. + if (/^\s*$/ || /^\#/) { ; } elsif (/^version:\s*(\d+)/) { # Can't read format with major version > 1 @@ -540,9 +538,11 @@ sub read_input_file() # Read body of input file. while () { + # Skip comments and empty lines. + next if /^\s*$/ || /^\#/; + $prev_line_num = $curr_line_num; - s/#.*$//; # remove comments s/^\+(\d+)/$prev_line_num+$1/e; s/^\-(\d+)/$prev_line_num-$1/e; s/^\*/$prev_line_num/e; @@ -646,9 +646,6 @@ sub read_input_file() $curr_fn_CC = $fn_totals{$curr_name}; $curr_fn_CC = [] unless (defined $curr_fn_CC); - } elsif (s/^\s*$//) { - # blank, do nothing - } elsif (s/^cob=(.*)$//) { $curr_cobj = uncompressed_name("ob",$1);