summaryrefslogtreecommitdiff
blob: 6d423e796a84a5db0346ca991e96b0e43a2d82c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/perl

use strict;
use warnings;

(my $ME = $0) =~ s|.*/||;
# use File::Coda; # http://meyering.net/code/Coda/
END {
  defined fileno STDOUT or return;
  close STDOUT and return;
  warn "$ME: failed to close standard output: $!\n";
  $? ||= 1;
}


my @data = <>;


my %trace;
my %lines;

foreach (@data) {
    if (/^\s*TRACE:\s+(\S+?)(?:\(.*\))?\s+\[0x(.*)\]\s*$/ ) {
        $trace{$2} = $1;
    }
}

foreach my $key (keys %trace) {
    my $val = $trace{$key};
    my $info = $val =~ /\?\?/ ? $val : `addr2line -e $val $key`;
    $lines{$key} = $info;
}


foreach (@data) {
    if (/^\s*TRACE:\s+(\S+?)(?:\(.*\))?\s+\[0x(.*)\]\s*$/ ) {
        print $lines{$2};
    } else {
        print;
    }
}