diff --git a/debian/changelog b/debian/changelog index b8ef8ec..83e6a3e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -7,6 +7,7 @@ [ 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 diff --git a/find-dbgsym-packages b/find-dbgsym-packages index 37b7f73..b319ca8 100755 --- a/find-dbgsym-packages +++ b/find-dbgsym-packages @@ -38,7 +38,7 @@ 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 @@ 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 @@ \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; } @@ -118,6 +117,51 @@ } } 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 diff --git a/find-dbgsym-packages.pod b/find-dbgsym-packages.pod index 50bbb99..b954ae5 100644 --- a/find-dbgsym-packages.pod +++ b/find-dbgsym-packages.pod @@ -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 I [I …] +B I [I …] =head1 DESCRIPTION B 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 @@ 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