Package: pylibdebuginfod
pylibdebuginfodPython bindings forlibdebuginfod.This library provides a Python interface for the functions in thelibdebuginfod.solibrary fromelfutils. Thedebuginfodclient/server infrastructure allows automatic distribution of debugging information (ELF symbol tables, DWARF and even source code) for binaries installed on the current system.The debuginfod server is queried using a SHA-1 hash (the build ID) which is contained in a section.note.gnu.build-idin the stripped binary file.PrerequisitesThe minimum Python version required is 3.5.The bindings require an installation oflibdebuginfod.soand thepyelftoolslibrary.libdebuginfod.sois shipped in the major distributions in the following packages:Debian (buster-backports,bullseye,sid):libdebuginfod1Fedora/CentOS:elfutils-debuginfod-clientopenSUSE Tumbleweed:elfutilsUbuntu (20.10 and later):libdebuginfod1Alternatively, you can get and compile the source code from the officialelfutils Git repository.UsageThe following examples were run under Debian Buster with thelibdebuginfod1,libelf1andlibdw1packages frombuster-backports.In order to makelibdebuginfod.soaware of the servers to query, you can set theDEBUGINFOD_URLSenvironment variable. For example, to query the Debian server, you can run:$exportDEBUGINFOD_URLS="https://debuginfod.debian.net"If theDEBUGINFOD_URLSenvironment variable is not set, it is temporarily set to theelfutilsserver (https://debuginfod.elfutils.org/) which federates to all trusted servers (listed on theelfutilswebsite).The other environment variables listed in themanual pageare also respected as they are handled bylibdebuginfod.soitself.You can extract the build ID information using thereadelftool like this:$readelf-n/lib/x86_64-linux-gnu/libc-2.28.so

Displayingnotesfoundin:.note.gnu.build-idOwnerDatasizeDescriptionGNU0x00000014NT_GNU_BUILD_ID(uniquebuildIDbitstring)BuildID:18b9a9a8c523e5cfe5b5d946d605d09242f09798With the prerequisites in place, you can use theDebugInfoDclass as follows:>>>fromlibdebuginfodimportDebugInfoD>>>session=DebugInfoD()>>>session.begin()# optional, is also called from __init__ at the moment.>>>fd,path=session.find_debuginfo('18b9a9a8c523e5cfe5b5d946d605d09242f09798')>>>print((fd,path))(3,b'/home/user/.cache/debuginfod_client/18b9a9a8c523e5cfe5b5d946d605d09242f09798/debuginfo')>>>session.end()In a more pythonic way,DebugInfoDcan also be used as a context manager wherebegin()andend()are called automatically.>>>fromlibdebuginfodimportDebugInfoD>>>withDebugInfoD()asd:...fd,path=d.find_debuginfo('18b9a9a8c523e5cfe5b5d946d605d09242f09798')...print((fd,path))...(3,b'/home/user/.cache/debuginfod_client/18b9a9a8c523e5cfe5b5d946d605d09242f09798/debuginfo')Thescripts/debuginfod-find.pyscript supports three commands (debuginfo,executableandsource) and accepts either a build ID or a path to a target file. If the filename matches the pattern[0-9a-f]+, please provide the path (e.g.,./e3) to avoid misinterpretation of the input as a build ID. If the command issource, you need to provide the path or build ID as the first input parameter and an absolute path to the target source file (as present in the DWARF information) as the second input parameter.Example usage:$./scripts/debuginfod-find.pydebuginfo/lib/x86_64-linux-gnu/libc-2.28.so
/home/user/.cache/debuginfod_client/18b9a9a8c523e5cfe5b5d946d605d09242f09798/debuginfoLicense(s)The bindings themselves are released under theMITlicense. As the script atscripts/debuginfod-find.pyis a reimplementation of thedebuginfod-findapplication fromelfutils(which is licensed under the GPLv3+ license), the script is also released under theGPLv3+license and not included in the packaged release of the bindings.