Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically download user space debug symbols using a debuginfod service #1774

Closed
ema opened this issue Apr 6, 2021 · 2 comments · Fixed by iovisor/bcc#3393
Closed

Automatically download user space debug symbols using a debuginfod service #1774

ema opened this issue Apr 6, 2021 · 2 comments · Fixed by iovisor/bcc#3393
Labels
enhancement New feature or request, changes on existing features

Comments

@ema
Copy link
Contributor

ema commented Apr 6, 2021

Debugging symbols need to be installed in order to probe user space programs with bpftrace:

$ sudo bpftrace -e 'uprobe:/bin/ls:format_user_or_group { print(pid); exit() }'
No probes to attach

After installing the right package - in this case with apt install coreutils-dbgsym given that I am on a Debian system:

$ sudo bpftrace -e 'uprobe:/bin/ls:format_user_or_group { print(pid); exit() }'
Attaching 1 probe...
377901

GDB and SystemTap support using a debuginfod service in order to automatically fetch the appropriate debuginfo symbols from the network without any user intervention. It would be great if this feature could be added to bpftrace as well.

@ema ema added the enhancement New feature or request, changes on existing features label Apr 6, 2021
rupran added a commit to rupran/bcc that referenced this issue Apr 30, 2021
This change adds debuginfod as a new source for debug
information. By using libdebuginfod we can query a server
for a file containing debug information for a given ELF
binary. The environment variable DEBUGINFOD_URLS has to
be defined to an URL for a debuginfod server providing
debug information files for your distribution or the
federating server provided by the elfutils project:

For example, to use the Fedora server, you would need:
$ export DEBUGINFOD_URLS="https://debuginfod.fedoraproject.org/"

Or for the elfutils server which federates to servers for
openSUSE, Void Linux, Debian and Fedora, among others:
$ export DEBUGINFOD_URLS="https://debuginfod.elfutils.org/"

Calls to the debuginfod_find_debuginfo function from
libdebuginfod will fail if the environment variable is not
set, otherwise the library will attempt to download debug
information for a build ID extracted from the binary in
question and store it in a local cache directory.

Fixes bpftrace/bpftrace#1774

Signed-off-by: Andreas Ziegler <[email protected]>
rupran added a commit to rupran/bcc that referenced this issue Apr 30, 2021
This change adds debuginfod as a new source for debug
information. By using libdebuginfod we can query a server
for a file containing debug information for a given ELF
binary. The environment variable DEBUGINFOD_URLS has to
be defined to an URL for a debuginfod server providing
debug information files for your distribution or the
federating server provided by the elfutils project:

For example, to use the Fedora server, you would need:
$ export DEBUGINFOD_URLS="https://debuginfod.fedoraproject.org/"

Or for the elfutils server which federates to servers for
openSUSE, Void Linux, Debian and Fedora, among others:
$ export DEBUGINFOD_URLS="https://debuginfod.elfutils.org/"

Calls to the debuginfod_find_debuginfo function from
libdebuginfod will fail if the environment variable is not
set, otherwise the library will attempt to download debug
information for a build ID extracted from the binary in
question and store it in a local cache directory.

Fixes bpftrace/bpftrace#1774

Signed-off-by: Andreas Ziegler <[email protected]>
@rupran
Copy link

rupran commented Apr 30, 2021

As the code dealing with debug information resides in iovisor/bcc, I implemented the debuginfod integration there, happy to take comments and suggestions!

rupran added a commit to rupran/bcc that referenced this issue May 6, 2021
This change adds debuginfod as a new source for debug
information. By using libdebuginfod we can query a server
for a file containing debug information for a given ELF
binary. The environment variable DEBUGINFOD_URLS has to
be defined to an URL for a debuginfod server providing
debug information files for your distribution or the
federating server provided by the elfutils project:

For example, to use the Fedora server, you would need:
$ export DEBUGINFOD_URLS="https://debuginfod.fedoraproject.org/"

Or for the elfutils server which federates to servers for
openSUSE, Void Linux, Debian and Fedora, among others:
$ export DEBUGINFOD_URLS="https://debuginfod.elfutils.org/"

Calls to the debuginfod_find_debuginfo function from
libdebuginfod will fail if the environment variable is not
set, otherwise the library will attempt to download debug
information for a build ID extracted from the binary in
question and store it in a local cache directory.

Fixes bpftrace/bpftrace#1774

Signed-off-by: Andreas Ziegler <[email protected]>
yonghong-song pushed a commit to iovisor/bcc that referenced this issue May 9, 2021
This change adds debuginfod as a new source for debug
information. By using libdebuginfod we can query a server
for a file containing debug information for a given ELF
binary. The environment variable DEBUGINFOD_URLS has to
be defined to an URL for a debuginfod server providing
debug information files for your distribution or the
federating server provided by the elfutils project:

For example, to use the Fedora server, you would need:
$ export DEBUGINFOD_URLS="https://debuginfod.fedoraproject.org/"

Or for the elfutils server which federates to servers for
openSUSE, Void Linux, Debian and Fedora, among others:
$ export DEBUGINFOD_URLS="https://debuginfod.elfutils.org/"

Calls to the debuginfod_find_debuginfo function from
libdebuginfod will fail if the environment variable is not
set, otherwise the library will attempt to download debug
information for a build ID extracted from the binary in
question and store it in a local cache directory.

Fixes bpftrace/bpftrace#1774

Signed-off-by: Andreas Ziegler <[email protected]>
@yump
Copy link

yump commented Oct 14, 2023

Any ideas on how to make this work on Fedora 38?

> sudo bpftrace -e 'uprobe:/bin/ls:format_user_or_group { print(pid); exit() }'
No probes to attach
> sudo debuginfo-install /usr/bin/ls
*SNIP*
> sudo bpftrace -e 'uprobe:/bin/ls:format_user_or_group { print(pid); exit() }'
Attaching 1 probe...
574429
> sudo dnf history undo last
*SNIP*
> ldd /usr/bin/bpftrace | grep debug
        libdebuginfod.so.1 => /lib64/libdebuginfod.so.1 (0x00007f6613626000)
> env | grep -i debug
DEBUGINFOD_URLS=https://debuginfod.fedoraproject.org/
> gdb ls
GNU gdb (GDB) Fedora Linux 13.2-5.fc38
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http:https://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http:https://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ls...

This GDB supports auto-downloading debuginfo from the following URLs:
  <https://debuginfod.fedoraproject.org/>
Enable debuginfod for this session? (y or [n]) y
Debuginfod has been enabled.
To make this setting permanent, add 'set debuginfod enabled on' to .gdbinit.
Reading symbols from /home/rhaley/.cache/debuginfod_client/a146002a40b622e4d8420c5b96513f0784c8eb7b/debuginfo...

What am I missing?

Edit: Aha! DEBUGINFOD_URLS is an env variable, but bpftrace requires sudo, and sudo drops env variables.

Solution:

sudo --preserve-env=DEBUGINFOD_URLS bpftrace -e 'uprobe:/bin/ls:format_user_or_group { print(pid); exit() }'

CrackerCat pushed a commit to CrackerCat/bcc that referenced this issue Jul 31, 2024
This change adds debuginfod as a new source for debug
information. By using libdebuginfod we can query a server
for a file containing debug information for a given ELF
binary. The environment variable DEBUGINFOD_URLS has to
be defined to an URL for a debuginfod server providing
debug information files for your distribution or the
federating server provided by the elfutils project:

For example, to use the Fedora server, you would need:
$ export DEBUGINFOD_URLS="https://debuginfod.fedoraproject.org/"

Or for the elfutils server which federates to servers for
openSUSE, Void Linux, Debian and Fedora, among others:
$ export DEBUGINFOD_URLS="https://debuginfod.elfutils.org/"

Calls to the debuginfod_find_debuginfo function from
libdebuginfod will fail if the environment variable is not
set, otherwise the library will attempt to download debug
information for a build ID extracted from the binary in
question and store it in a local cache directory.

Fixes bpftrace/bpftrace#1774

Signed-off-by: Andreas Ziegler <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request, changes on existing features
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants