Package list debian-goodies / 9a82dbc
Add support for finding dbgsym packages for executables and libraries Paul Wise 3 years ago
3 changed file(s) with 56 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
66
77 [ Paul Wise ]
88 * find-dbgsym-packages:
9 + Add support for finding dbgsyms for executables and libraries
910 + Ignore debug symbols that are in already installed packages
1011 + Detect debug symbols packages with no or bad meta-data
1112 * Use 'set -e' in shell scripts instead of 'sh -e' in shebangs
3737 if ($arg =~ /^\d+$/) {
3838 %build_ids = get_build_ids_from_pid($arg);
3939 } else {
40 %build_ids = get_build_ids_from_core($arg);
40 %build_ids = get_build_ids_from_file($arg);
4141 }
4242
4343 foreach my $id (keys %build_ids) {
7373 my %ids;
7474
7575 foreach my $line (split(/\n/, $output)) {
76 chomp $line;
7776 # 0x7fa9b8017000+0x39e9a0 79450f6e36287865d093ea209b85a222209925ff@0x7fa9b8017280 /lib/x86_64-linux-gnu/libc.so.6 /usr/lib/debug/.build-id/79/450f6e36287865d093ea209b85a222209925ff.debug libc.so.6
7877 # 0x7f7f7235e000+0x17000 - /usr/share/locale/de/LC_MESSAGES/bash.mo - /usr/share/locale/de/LC_MESSAGES/bash.mo
7978 # 0x7ffd4098a000+0x2000 de7dac2df9f596f46fa94a387858ef25170603ec@0x7ffd4098a7d0 . - [vdso: 1740]
8786 \s+
8887 (\S+)
8988 \s+
90 (\S.*)
89 (\S+)?
9190 $}ix) {
9291 my $id = $1;
9392 my $path = $2;
9493 my $debug = $3;
95 my $name = $4;
94 my $name = $4 // $path;
9695 if ($debug ne '-') {
9796 next;
9897 }
117116 }
118117 }
119118 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);
120164 }
121165
122166 sub get_build_ids_from_core
11
22 =head1 NAME
33
4 find-dbgsym-packages - gets list of dbgsym packages from core dump or PID
4 find-dbgsym-packages - gets list of dbgsym packages from executable, library, core dump or process
55
66 =head1 SYNOPSIS
77
8 B<find-dbgsym-packages> I<core file or PID> [I<core file or PID> …]
8 B<find-dbgsym-packages> I<executable, core file or PID> [I<executable, library, core file or PID> …]
99
1010 =head1 DESCRIPTION
1111
1212 B<find-dbgsym-packages> lists all I<*-dbgsym> packages required to
13 properly debug processes given by a list of core dump or PID numbers.
13 properly debug processes given by a list of executables, libraries, core dumps or PID numbers.
1414
1515 =head1 PREREQUISITES
1616
3131 libcap2-dbgsym libtinfo5-dbg zsh-dbgsym
3232 $ find-dbgsym-packages /var/crash/1000/15865-1000-1000-11-1511059476-c6--bin-zsh.core
3333 libcap2-dbgsym libtinfo5-dbg zsh-dbgsym
34 $ find-dbgsym-packages /bin/ls
35 coreutils-dbgsym libpcre3-dbg libselinux1-dbgsym
36 $ find-dbgsym-packages /lib/x86_64-linux-gnu/libselinux.so.1
37 libpcre3-dbg libselinux1-dbgsym
3438
3539 =head1 AUTHOR
3640