-
Notifications
You must be signed in to change notification settings - Fork 354
/
check-debug-info
executable file
·63 lines (48 loc) · 1.11 KB
/
check-debug-info
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env perl
use strict;
use warnings;
use Getopt::Std qw( getopts );
my %opts;
getopts("hp:", \%opts)
or die usage();
my $pid = $opts{p}
or die "No -p <pid> option specified.\n";
my $exec_file = "/proc/$pid/exe";
if (!-f $exec_file) {
die "User process $pid is not running or ",
"you do not have enough permissions.\n";
}
my $path = readlink $exec_file;
my %files = ($path => 1);
{
my $maps_file = "/proc/$pid/maps";
open my $in, $maps_file
or die "Cannot open $maps_file for reading: $!\n";
while (<$in>) {
if (/\s+(\/\S+\.so)$/) {
if (!exists $files{$1}) {
$files{$1} = 1;
#warn $1, "\n";
}
}
}
close $in;
}
for my $file (sort keys %files) {
my $lines = `objdump --dwarf=str $file|wc -l`;
if ($? != 0) {
warn "Failed to check file $file: $?\n";
next;
}
if ($lines <= 3) {
warn "File $file has no debug info embedded.\n";
} else {
#warn "File $file checked.\n";
}
}
sub usage {
print <<_EOC_
Usage:
check-debug-info -p <pid>
_EOC_
}