2017-09-18 20:35:50 +08:00
|
|
|
#!/usr/bin/env perl
|
2008-05-29 23:21:45 +08:00
|
|
|
|
|
|
|
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*$/ ) {
|
2012-07-27 20:51:28 +08:00
|
|
|
$trace{$2} = $1;
|
2008-05-29 23:21:45 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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*$/ ) {
|
2012-07-27 20:51:28 +08:00
|
|
|
print $lines{$2};
|
2008-05-29 23:21:45 +08:00
|
|
|
} else {
|
2012-07-27 20:51:28 +08:00
|
|
|
print;
|
2008-05-29 23:21:45 +08:00
|
|
|
}
|
|
|
|
}
|