Add support for finding dbgsym packages for executables and libraries

parent 12af3bee
......@@ -7,6 +7,7 @@ debian-goodies (0.80) UNRELEASED; urgency=medium
[ Paul Wise ]
* find-dbgsym-packages:
+ Add support for finding dbgsyms for executables and libraries
+ Ignore debug symbols that are in already installed packages
+ Detect debug symbols packages with no or bad meta-data
* Use 'set -e' in shell scripts instead of 'sh -e' in shebangs
......
......@@ -38,7 +38,7 @@ foreach my $arg (@ARGV) {
if ($arg =~ /^\d+$/) {
%build_ids = get_build_ids_from_pid($arg);
} else {
%build_ids = get_build_ids_from_core($arg);
%build_ids = get_build_ids_from_file($arg);
}
foreach my $id (keys %build_ids) {
......@@ -74,7 +74,6 @@ sub parse_eu_unstrip
my %ids;
foreach my $line (split(/\n/, $output)) {
chomp $line;
# 0x7fa9b8017000+0x39e9a0 79450f6e36287865d093ea209b85a222209925ff@0x7fa9b8017280 /lib/x86_64-linux-gnu/libc.so.6 /usr/lib/debug/.build-id/79/450f6e36287865d093ea209b85a222209925ff.debug libc.so.6
# 0x7f7f7235e000+0x17000 - /usr/share/locale/de/LC_MESSAGES/bash.mo - /usr/share/locale/de/LC_MESSAGES/bash.mo
# 0x7ffd4098a000+0x2000 de7dac2df9f596f46fa94a387858ef25170603ec@0x7ffd4098a7d0 . - [vdso: 1740]
......@@ -88,12 +87,12 @@ sub parse_eu_unstrip
\s+
(\S+)
\s+
(\S.*)
(\S+)?
$}ix) {
my $id = $1;
my $path = $2;
my $debug = $3;
my $name = $4;
my $name = $4 // $path;
if ($debug ne '-') {
next;
}
......@@ -120,6 +119,51 @@ sub parse_eu_unstrip
return (%ids);
}
sub get_files_from_elf
{
my ($filename) = @_;
my @libs = ($filename);
my $output = capturex(qw(ldd --), $filename);
foreach my $line (split(/\n/, $output)) {
chomp $line;
my ($name, $path);
if ($line =~ /^\t.+ => (.+) \(0x[0-9a-f]+\)$/) {
push @libs, $1;
} elsif ($line =~ /^\t(.+) \(0x[0-9a-f]+\)$/) {
push @libs, $1;
} else {
warn "Cannot parse ldd output: '$line'\n";
}
}
return @libs;
}
sub get_build_ids_from_file
{
my ($filename) = @_;
if (is_core_file($filename)) {
return get_build_ids_from_core($filename);
} else {
my @filenames = get_files_from_elf($filename);
my %build_ids;
foreach my $filename (@filenames) {
next if $filename =~ /^linux-vdso\.so\./;
%build_ids = (%build_ids, get_build_ids_from_elf($filename));
}
return %build_ids;
}
}
sub get_build_ids_from_elf
{
my ($filename) = @_;
my $output = capturex(qw(eu-unstrip --list-only --executable), $filename);
return parse_eu_unstrip($output);
}
sub get_build_ids_from_core
{
my ($filename) = @_;
......
......@@ -2,16 +2,16 @@
=head1 NAME
find-dbgsym-packages - gets list of dbgsym packages from core dump or PID
find-dbgsym-packages - gets list of dbgsym packages from executable, library, core dump or process
=head1 SYNOPSIS
B<find-dbgsym-packages> I<core file or PID> [I<core file or PID> …]
B<find-dbgsym-packages> I<executable, core file or PID> [I<executable, library, core file or PID> …]
=head1 DESCRIPTION
B<find-dbgsym-packages> lists all I<*-dbgsym> packages required to
properly debug processes given by a list of core dump or PID numbers.
properly debug processes given by a list of executables, libraries, core dumps or PID numbers.
=head1 PREREQUISITES
......@@ -32,6 +32,10 @@ I<dctrl-tools> packages to be installed.
libcap2-dbgsym libtinfo5-dbg zsh-dbgsym
$ find-dbgsym-packages /var/crash/1000/15865-1000-1000-11-1511059476-c6--bin-zsh.core
libcap2-dbgsym libtinfo5-dbg zsh-dbgsym
$ find-dbgsym-packages /bin/ls
coreutils-dbgsym libpcre3-dbg libselinux1-dbgsym
$ find-dbgsym-packages /lib/x86_64-linux-gnu/libselinux.so.1
libpcre3-dbg libselinux1-dbgsym
=head1 AUTHOR
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment