|
From: Philippe W. <phi...@so...> - 2019-11-03 17:02:42
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=7f63a884264f48baea87f8be480475eced857fd5 commit 7f63a884264f48baea87f8be480475eced857fd5 Author: Andreas Arnez <ar...@li...> Date: Wed Oct 23 20:35:50 2019 +0200 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 <phi...@sk...> Diff: --- cachegrind/cg_annotate.in | 7 +++---- callgrind/callgrind_annotate.in | 13 +++++-------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/cachegrind/cg_annotate.in b/cachegrind/cg_annotate.in index bcb9893..1daa15d 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 (<INPUTFILE>) { - 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 e18ed4e..8854aee 100644 --- a/callgrind/callgrind_annotate.in +++ b/callgrind/callgrind_annotate.in @@ -420,10 +420,8 @@ sub read_input_file() # Read header while(<INPUTFILE>) { - # 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 (<INPUTFILE>) { + # 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); |