summaryrefslogtreecommitdiffstats
path: root/debian/vendor-h2o/share/h2o/annotate-backtrace-symbols
blob: 6d7c8a2d6db392da0968d66ef9955677eb7929a6 (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
#! /bin/sh
exec ${H2O_PERL:-perl} -x $0 "$@"
#! perl

use strict;
use warnings;

while (my $line = <STDIN>) {
    chomp $line;
    if ($line =~ m{^([^\(\[]+)(.*?)\[(0x[0-9A-Fa-f]+)\]}) {
        my ($exe, $info, $addr) = ($1, $2, $3);
        my $resolved = addr2line($exe, $addr);
        $line = "$exe${info}[$addr] $resolved"
            if $resolved;
    }
    print "$line\n";
}

sub addr2line {
    my ($exe, $addr) = @_;
    open my $fh, "-|", qw(addr2line -pif -e), $exe, $addr
        or return;
    my $resolved = <$fh>;
    chomp $resolved;
    $resolved;
}