]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
callgrind_annotate, cg_annotate: don't truncate function names at '#'
authorAndreas Arnez <arnez@linux.ibm.com>
Wed, 23 Oct 2019 18:35:50 +0000 (20:35 +0200)
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Sun, 3 Nov 2019 16:39:36 +0000 (17:39 +0100)
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 <philippe.waroquiers@skynet.be>
cachegrind/cg_annotate.in
callgrind/callgrind_annotate.in

index bcb98935b5fb5de15bb876bf677da81dbefcc3ae..1daa15da23169264512237b6e6211d9b1eb6bb5d 100644 (file)
@@ -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) 
index e18ed4ed968eb046aa0cbdb40611ce167dd0cd1f..8854aee137365826836844c4b2f879d33e4212e0 100644 (file)
@@ -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);