libc-database
libc-database copied to clipboard
Add debug symbols to ./download
This is a tentative attempt at automating the process of grabbing debug .so
s and libc sources, which are useful for providing source-level libc debugging in gdb.
The scope of this PR is limited to ubuntu only; non-apt-based libc packages are really outside of my knowledge and I'd rather not attempt that. I tried checking debian packages but a lot of their libc6-dbg
packages only contain .debug
files that I don't really know what to do with.
The added code has also not been extensively tested. It might work on my machine, but bash is notoriously easy to mess up. Here's an example of what a correct run might look like:
~/libc-database$ ./download libc6_2.27-3ubuntu1_amd64
Getting libc6_2.27-3ubuntu1_amd64
-> Location: http://security.ubuntu.com/ubuntu/pool/main/g/glibc//libc6_2.27-3ubuntu1_amd64.deb
-> Downloading package
-> Extracting package
-> Package saved to libs/libc6_2.27-3ubuntu1_amd64
Getting debug materials for libc6_2.27-3ubuntu1_amd64
-> Location: http://security.ubuntu.com/ubuntu/pool/universe/g/glibc//glibc-source_2.27-3ubuntu1_all.deb
-> Downloading package
-> Extracting package
-> Location: http://security.ubuntu.com/ubuntu/pool/main/g/glibc//libc6-dbg_2.27-3ubuntu1_amd64.deb
-> Downloading package
-> Extracting package
~/libc-database$ ls libs/libc6_2.27-3ubuntu1_amd64
debug libBrokenLocale-2.27.so libcrypt-2.27.so libm-2.27.so libnsl-2.27.so libnss_dns.so.2 libnss_nis-2.27.so libpthread-2.27.so librt.so.1 libutil.so.1
ld-2.27.so libBrokenLocale.so.1 libcrypt.so.1 libmemusage.so libnsl.so.1 libnss_files-2.27.so libnss_nisplus-2.27.so libpthread.so.0 libSegFault.so source
ld-linux-x86-64.so.2 libc-2.27.so libc.so.6 libm.so.6 libnss_compat-2.27.so libnss_files.so.2 libnss_nisplus.so.2 libresolv-2.27.so libthread_db-1.0.so
libanl-2.27.so libcidn-2.27.so libdl-2.27.so libmvec-2.27.so libnss_compat.so.2 libnss_hesiod-2.27.so libnss_nis.so.2 libresolv.so.2 libthread_db.so.1
libanl.so.1 libcidn.so.1 libdl.so.2 libmvec.so.1 libnss_dns-2.27.so libnss_hesiod.so.2 libpcprofile.so librt-2.27.so libutil-2.27.so
~/libc-database$ ls libs/libc6_2.27-3ubuntu1_amd64/debug/
ld-2.27.so libc-2.27.so libdl-2.27.so libmvec-2.27.so libnss_dns-2.27.so libnss_nis-2.27.so libresolv-2.27.so libthread_db-1.0.so
libanl-2.27.so libcidn-2.27.so libm-2.27.so libnsl-2.27.so libnss_files-2.27.so libnss_nisplus-2.27.so librt-2.27.so libutil-2.27.so
libBrokenLocale-2.27.so libcrypt-2.27.so libmemusage.so libnss_compat-2.27.so libnss_hesiod-2.27.so libpcprofile.so libSegFault.so
~/libc-database$ ls libs/libc6_2.27-3ubuntu1_amd64/source/
glibc-2.27
~/libc-database$ ls libs/libc6_2.27-3ubuntu1_amd64/source/glibc-2.27/
abi-tags ChangeLog COPYING dlfcn gnulib include libio mach manual nptl_db README shadow streams test-skeleton.c
aclocal.m4 ChangeLog.old COPYING.LIB elf grp inet libof-iterator.mk MAINTAINERS math nscd resolv shlib-versions string time
argp config.h.in crypt extra-lib.mk gshadow INSTALL libpthread Makeconfig mathvec nss resource signal sunrpc timezone
assert config.make.in csu fbtl hesiod intl LICENSES Makefile misc o-iterator.mk rt socket support version.h
benchtests configure ctype fbtl_db hurd io locale Makefile.in NEWS po Rules soft-fp sysdeps wcsmbs
bits configure.ac debug gen-locales.mk iconv libc-abis localedata Makerules nis posix scripts stdio-common sysvipc wctype
catgets conform dirent gmon iconvdata libidn login malloc nptl pwd setjmp stdlib termios
Any feedback is welcome.
Just to set expectations right, I won't have time to look at this in detail within the coming weeks or months. If somebody else like @peace-maker or @ajabep wants to review this, I'll be happy to consider merging it if their feedback is positive
BTW this fails for some libcs, e.g. libc6_2.31-0ubuntu9.7_amd64
on https://github.com/niklasb/libc-database/blob/c7b6d38b7f6178d6ecf9c1b472b0af2ea48c5c09/download#L91
The reason is some weird directory layout in this version, where $tmp/lib/*/*
also matches some directory. Maybe this should be $tmp/lib/*/*.so
instead (or cp -r
if we want to copy that directory as well)
Also, maybe this should unpack to .debug
instead of debug
, because then gdb will pick them up automatically (unless I'm doing something wrong)
But this might be confusing as dotfiles are hidden