37 | 37 |
if ($arg =~ /^\d+$/) {
|
38 | 38 |
%build_ids = get_build_ids_from_pid($arg);
|
39 | 39 |
} else {
|
40 | |
%build_ids = get_build_ids_from_core($arg);
|
|
40 |
%build_ids = get_build_ids_from_file($arg);
|
41 | 41 |
}
|
42 | 42 |
|
43 | 43 |
foreach my $id (keys %build_ids) {
|
|
73 | 73 |
my %ids;
|
74 | 74 |
|
75 | 75 |
foreach my $line (split(/\n/, $output)) {
|
76 | |
chomp $line;
|
77 | 76 |
# 0x7fa9b8017000+0x39e9a0 79450f6e36287865d093ea209b85a222209925ff@0x7fa9b8017280 /lib/x86_64-linux-gnu/libc.so.6 /usr/lib/debug/.build-id/79/450f6e36287865d093ea209b85a222209925ff.debug libc.so.6
|
78 | 77 |
# 0x7f7f7235e000+0x17000 - /usr/share/locale/de/LC_MESSAGES/bash.mo - /usr/share/locale/de/LC_MESSAGES/bash.mo
|
79 | 78 |
# 0x7ffd4098a000+0x2000 de7dac2df9f596f46fa94a387858ef25170603ec@0x7ffd4098a7d0 . - [vdso: 1740]
|
|
87 | 86 |
\s+
|
88 | 87 |
(\S+)
|
89 | 88 |
\s+
|
90 | |
(\S.*)
|
|
89 |
(\S+)?
|
91 | 90 |
$}ix) {
|
92 | 91 |
my $id = $1;
|
93 | 92 |
my $path = $2;
|
94 | 93 |
my $debug = $3;
|
95 | |
my $name = $4;
|
|
94 |
my $name = $4 // $path;
|
96 | 95 |
if ($debug ne '-') {
|
97 | 96 |
next;
|
98 | 97 |
}
|
|
117 | 116 |
}
|
118 | 117 |
}
|
119 | 118 |
return (%ids);
|
|
119 |
}
|
|
120 |
|
|
121 |
sub get_files_from_elf
|
|
122 |
{
|
|
123 |
my ($filename) = @_;
|
|
124 |
my @libs = ($filename);
|
|
125 |
my $output = capturex(qw(ldd --), $filename);
|
|
126 |
|
|
127 |
foreach my $line (split(/\n/, $output)) {
|
|
128 |
chomp $line;
|
|
129 |
my ($name, $path);
|
|
130 |
if ($line =~ /^\t.+ => (.+) \(0x[0-9a-f]+\)$/) {
|
|
131 |
push @libs, $1;
|
|
132 |
} elsif ($line =~ /^\t(.+) \(0x[0-9a-f]+\)$/) {
|
|
133 |
push @libs, $1;
|
|
134 |
} else {
|
|
135 |
warn "Cannot parse ldd output: '$line'\n";
|
|
136 |
}
|
|
137 |
}
|
|
138 |
|
|
139 |
return @libs;
|
|
140 |
}
|
|
141 |
|
|
142 |
sub get_build_ids_from_file
|
|
143 |
{
|
|
144 |
my ($filename) = @_;
|
|
145 |
if (is_core_file($filename)) {
|
|
146 |
return get_build_ids_from_core($filename);
|
|
147 |
} else {
|
|
148 |
my @filenames = get_files_from_elf($filename);
|
|
149 |
my %build_ids;
|
|
150 |
foreach my $filename (@filenames) {
|
|
151 |
next if $filename =~ /^linux-vdso\.so\./;
|
|
152 |
%build_ids = (%build_ids, get_build_ids_from_elf($filename));
|
|
153 |
}
|
|
154 |
return %build_ids;
|
|
155 |
}
|
|
156 |
}
|
|
157 |
|
|
158 |
sub get_build_ids_from_elf
|
|
159 |
{
|
|
160 |
my ($filename) = @_;
|
|
161 |
my $output = capturex(qw(eu-unstrip --list-only --executable), $filename);
|
|
162 |
|
|
163 |
return parse_eu_unstrip($output);
|
120 | 164 |
}
|
121 | 165 |
|
122 | 166 |
sub get_build_ids_from_core
|