is00hcw / gperftools

Automatically exported from code.google.com/p/gperftools
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Callgrind output doesn't work with DWARF v4 #646

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a binary with a recent gcc, using DWARF v4 debugging information.
2. Run the profiling tool.
3. Attempt to output a callgrind file.

What is the expected output? What do you see instead?
I expect a callgrind-compatible file, what I actually get is a set of warnings 
from Perl. e.g.
Use of uninitialized value in string comparison (cmp) at pprof line 1286.

The problem appears to be due to a couple of things.
1) Recent addr2line tools output (discriminator n) suffixes where there are 
multiple paths through the code on a single line.
2) Recent addr2line tools use ? for an unknown line number rather than 0.

What version of the product are you using? On what operating system?
Git revision 3c326d9 (19 August 2014)
Ubuntu 14.04.1

Please provide any additional information below.

This is a patch that fixes the problem (though I admit this is more of a 
workaround).

From 1ea034b90454f3d4e8856b6b2139561510f662dc Mon Sep 17 00:00:00 2001
From: Adam McNeeney <adam@meliorist.co.uk>
Date: Fri, 22 Aug 2014 10:01:24 +0100
Subject: [PATCH] Cope with new addr2line outputs for DWARF4

Copes with ? for line number (converts to 0).
Copes with (discriminator <num>) suffixes to file/linenum (removes).

Change-Id: I96207165e4852c71d3512157864f12d101cdf44a

---
 src/pprof |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/src/pprof b/src/pprof
index 4f04094..be214fe 100755
--- a/src/pprof
+++ b/src/pprof
@@ -4762,6 +4762,12 @@ sub MapToSymbols {

     $filelinenum =~ s|\\|/|g; # turn windows-style paths into unix-style paths

+    # Remove discriminator markers as this comes after the line number and
+    # confuses the rest of this script.
+    $filelinenum =~ s/ \(discriminator \d+\)$//;
+    # Convert unknown line numbers into line 0.
+    $filelinenum =~ s/:\?$/:0/;
+
     my $pcstr = $pclist->[$count];
     my $function = ShortFunctionName($fullfunction);
     my $nms = $nm_symbols->{$pcstr};
--
1.7.3.2

Original issue reported on code.google.com by a...@meliorist.co.uk on 22 Aug 2014 at 9:27

GoogleCodeExporter commented 9 years ago
applied. Thanks.

Original comment by alkondratenko on 23 Aug 2014 at 10:37