Service - Debuginfod

Debuginfod

This section describes what debuginfod is and how users can benefit from Ubuntu’s debuginfod service.

What is debuginfod?

From the project’s official page:

debuginfod is a client/server […] that automatically distributes ELF/DWARF/source-code from servers to clients such as debuggers across HTTP.

This means that users will be able to debug programs shipped with Ubuntu without the need to manually install the distribution’s debuginfo packages.

Ubuntu maintains its own debuginfod service, which regularly indexes the debug symbols present in ddebs and other packages and serve this information over HTTPS.

Currently, the service only provides DWARF information. There are plans to make it also index and serve source-code in the future.

Using the service

From Kinetic onwards, when you install GDB your system will be automatically configured to use Ubuntu’s debuginfod service. For previous Ubuntu releases, you can manually enable the service by setting the DEBUGINFOD_URLS environment variable in your shell. If you use Bash, you can do that by adding the following snippet to your ~/.bashrc:

export DEBUGINFOD_URLS="https://debuginfod.ubuntu.com"

When you run GDB, and if you have the DEBUGINFOD_URLS variable in your environment, you will be asked whether you would like to use the service. If you want to make sure that GDB always uses debuginfod, you can put the following snippet inside your ~/.gdbinit file:

set debuginfod enabled on

The debug symbol files will be downloaded on-the-fly during the debugging session, and will be saved locally inside the ~/.cache/debuginfod_client/ directory. You can safely remove this directory or any files inside it; they will be downloaded again only if and when needed.

Example session with GDB

Assuming that you have enabled the use of debuginfod in your system, here is what happens when you invoke GDB to debug a binary from an Ubuntu package:

$ gdb -q program
Reading symbols from program...

This GDB supports auto-downloading debuginfo from the following URLs:
https://debuginfod.ubuntu.com 
Enable debuginfod for this session? (y or [n]) 

When you answer y to the question above, GDB will download the debug symbols for program:

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.
Downloading 0.20 MB separate debug info for /home/ubuntu/program
Reading symbols from /home/ubuntu/.cache/debuginfod_client/c0fbda15a807f880e9d0b2dcc635eeeb1f0f728e/debuginfo...                                                                           
(gdb) 

Opting out of the service

If, for some reason, you prefer not to use the service, you can opt-out of it by unsetting the DEBUGINFOD_URLS environment variable. This can be done by putting the following snippet inside your shell’s configuration file:

unset DEBUGINFOD_URLS

You can also disable GDB’s willingness to use debuginfod by putting the following snippet inside your ~/.gdbinit:

set debuginfod enabled off

FAQ

If you have more questions about the service, please refer to the FAQ page.

3 Likes

Maybe link “manually install” to https://wiki.ubuntu.com/Debug%20Symbol%20Packages, if that page is still up-to-date.

Can you show an example of debuginfod in action, on the client side?

Also, does each invocation of gdb trigger a download, or are those symbols installed in some cache directory? Or are the actual ddebs installed, as if I followed https://wiki.ubuntu.com/Debug%20Symbol%20Packages and installed them manually?

Good idea, thanks. Link done.

I have expanded the article to better explain these points. Please take a look and let me know what you think. Thanks.

I don’t think you need to repeat that.

I didn’t like repeating it, but I also thought it’d be worth mentioning again. Anyway, I’ve removed the paragraph.

Nice!
Other questions that come to mind now, which you can decide if are worth expanding in the docs or not (after all, this is not a tutorial):

  • if the binary is updated (assuming it came from a deb), gdb will me smart enough to download a new set of symbols?
  • will that local cache just keep growing? Any tips on pruning it? Can it be pruned per-package? (i.e., "please remove debuginfod info for package libreoffice only). I’m making a comparison with ddebs, which I can remove individually.
  • can ddebs coexist with the data downloaded by debuginfod? Or should I remove the ddeb lines from sources.list? Is there a fallback ordering of some sort?
  • how tightly is this coupled with deb packaging? Can I use gdb against something I coded and built locally (i.e., hello_world.c), which uses some system libraries, and have gdb download debuginfod data for those system libraries?
1 Like

Thanks for the careful review!

I would like to keep this page simple because it will be the landing page for https://debuginfod.ubuntu.com, but I also understand that there might be other details about the service that would be good to cover.

I think it may be worth having a separate FAQ page that’s not directly part of the Server Guide but is linked from this page, WDYT? Then I can not only go over more details about the service, but also allow the users to ask their questions in a single place.

A FAQ is fine, elsewhere here on Discourse, or even in the Server Guide as another page/section, I wouldn’t mind.

1 Like