No longer trap fatal signals
[notion/jeffpc.git] / utils / profiling / addr2line.pl
blobe33b80b85581f56c974b8069b2e721c8f27b6264
1 #!/usr/bin/perl
3 use strict;
4 use warnings;
6 my $executable = $ARGV[0];
8 my %lines = ();
9 my %functionNames = ();
11 sub getline {
12 my $addr = shift;
14 if ($addr eq "") {
15 return "?? ??:0";
17 if ($addr !~ /^0x/) {
18 return $addr;
21 my $line = $lines{$addr};
22 if (!defined($line)) {
23 $line = `addr2line -f -e $executable $addr`;
24 chomp($line);
25 $line =~ s/\n/ /g;
26 $lines{$addr} = $line;
28 return $line;
31 while (<STDIN> =~ /(\w)\t([^\t]+)\t([^t]*)\t(\S+)/) {
32 my ($action, $calledaddr, $calleraddr, $time) = ($1, $2, $3, $4);
34 my $called = getline($calledaddr);
35 my $caller = getline($calleraddr);
37 if ($called =~ /^\(null\) (.*)/) {
38 if (defined $functionNames{$1}) {
39 $called = "$functionNames{$1} $1";
40 } else {
41 $called = "$1 $1";
44 elsif ($called =~ /^(\S+) (.*)/) {
45 $functionNames{$2} = $1;
48 print "$action\t$called\t$caller\t$time\n";