Debug symbol download in gdb

Since I had OpenSuse tumbleweed running on my laptop, I noticed an issue with gdb downloading quite a lot of debugging symbols. I did not know why it happens, nor where it loads the symbols from, nor how to stop it from doing so.

Due to the nature of a rolling linux distribution, base packages get updated quite often. So the debug symbols for many base libraries need to be downloaded again and again for every update which is really annoying.

I can see that there are use cases where it helps to have access to debug symbols from build servers, but I don't know why it is enabled by default. It is very hard for users to see what is happening, why gdb accesses some server the user did not configured, storing data on some unknown location, and how to stop.

I personally don't need that functionality at all and it gets in my way more often than not. When debugging a locally built binary, I do have the symbols in place, and for all third-party libraries I don't need the symbols most of the time. On slow network connections, it can take a long time (several minutes) to get all symbols, and the user does not even get at least some basic progress feedback. Sometimes it is possible to abort the download with Ctrl-C but in my experience it does not work reliable and also only for a single library, so even it works, you have to press it quite often.

I expect to have debugging symbols as part of the devel package, or some separate debug packages. In OpenSuse, those packages are named *debuginfo*.

This feature can also be a security issue, especially if the user does not know why it download stuff and from which server.

So here is what is happening and how to avoid/configure it at least.

1. What is happening?

Since version 10.1 gdb supports Debuginfod, a server infrastructure for getting debug symbols for a given build ID.

OpenSuse installs a package named libdebuginfod which sets up the stuff so GDB contacts https://debuginfod.opensuse.org/ for symbols. The environment variable DEBUGINFOD_URLS describes the server to use. It is defined in the file /etc/profile.d/debuginfod.*

2. How to disable it

There are two ways to disabled the use of online servers.

You can undefine the environment DEBUGINFOD_URLS to temporarily disable it.

To permanently disable it, uninstall the package libdebuginfod1. It will install a dummy package instead.

3. Final thoughts

This feature can be quite useful in certain environments, but in my opinion, it should not be enabled by default. There are quite some downsides:
tags: gdb1
older (2021-03-16): Code completion for emacs with LSP