File: oomtrace.pl

package info (click to toggle)
libvirt 5.0.0-4%2Bdeb10u1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 251,264 kB
  • sloc: ansic: 573,843; xml: 168,347; sh: 9,976; python: 4,883; perl: 3,953; makefile: 3,323; ml: 465
file content (41 lines) | stat: -rwxr-xr-x 713 bytes parent folder | download
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/env 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;
    }
}