Skip to main content
Redhat Developers  Logo
  • AI

    Get started with AI

    • Red Hat AI
      Accelerate the development and deployment of enterprise AI solutions.
    • AI learning hub
      Explore learning materials and tools, organized by task.
    • AI interactive demos
      Click through scenarios with Red Hat AI, including training LLMs and more.
    • AI/ML learning paths
      Expand your OpenShift AI knowledge using these learning resources.
    • AI quickstarts
      Focused AI use cases designed for fast deployment on Red Hat AI platforms.
    • No-cost AI training
      Foundational Red Hat AI training.

    Featured resources

    • OpenShift AI learning
    • Open source AI for developers
    • AI product application development
    • Open source-powered AI/ML for hybrid cloud
    • AI and Node.js cheat sheet

    Red Hat AI Factory with NVIDIA

    • Red Hat AI Factory with NVIDIA is a co-engineered, enterprise-grade AI solution for building, deploying, and managing AI at scale across hybrid cloud environments.
    • Explore the solution
  • Learn

    Self-guided

    • Documentation
      Find answers, get step-by-step guidance, and learn how to use Red Hat products.
    • Learning paths
      Explore curated walkthroughs for common development tasks.
    • Guided learning
      Receive custom learning paths powered by our AI assistant.
    • See all learning

    Hands-on

    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.
    • Interactive labs
      Learn by doing in these hands-on, browser-based experiences.
    • Interactive demos
      Click through product features in these guided tours.

    Browse by topic

    • AI/ML
    • Automation
    • Java
    • Kubernetes
    • Linux
    • See all topics

    Training & certifications

    • Courses and exams
    • Certifications
    • Skills assessments
    • Red Hat Academy
    • Learning subscription
    • Explore training
  • Build

    Get started

    • Red Hat build of Podman Desktop
      A downloadable, local development hub to experiment with our products and builds.
    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.

    Download products

    • Access product downloads to start building and testing right away.
    • Red Hat Enterprise Linux
    • Red Hat AI
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat Developer Toolset

    References

    • E-books
    • Documentation
    • Cheat sheets
    • Architecture center
  • Community

    Get involved

    • Events
    • Live AI events
    • Red Hat Summit
    • Red Hat Accelerators
    • Community discussions

    Follow along

    • Articles & blogs
    • Developer newsletter
    • Videos
    • Github

    Get help

    • Customer service
    • Customer support
    • Regional contacts
    • Find a partner

    Join the Red Hat Developer program

    • Download Red Hat products and project builds, access support documentation, learning content, and more.
    • Explore the benefits

How lazy debuginfo loading improves GDB and Valgrind

January 2, 2024
Aaron Merey
Related topics:
CompilersLinux
Related products:
Red Hat Enterprise Linux

    Debugging information, a.k.a debuginfo, relates the machine instructions in an executable or shared library with human-readable information from the binary's source files. This information includes the names of functions and variables as well as the source file and line numbers where these symbols are declared and referenced. Debuggers such as GDB, the GNU debugger, and profilers such as Valgrind use debuginfo to provide developers with richly detailed views into the occurrence of memory errors in a running process or the exact cause of a crash recorded in a core file. To learn more about debuginfo, check out the following articles: Debuginfo is not just for debugging programs and The GDB developer’s GNU Debugger tutorial Part 2.

    Debuginfod

    Debuginfo is very useful for developers but it can come with a few downsides. One problem is that it can be quite large. For example, libwebkitgtk debuginfo is well over 3 GB. Acquiring the precise version of a binary's debuginfo and having the necessary permissions to install it and make it available to your debugger can be inconvenient or even impossible, depending on your particular debugging environment.

    We developed the debuginfod tool for developer tools to automatically download the exact debuginfo files they require for maximally detailed debugging and profiling. Debuginfod is an HTTP file server and client library that enables tools to easily download debugging resources, including debuginfo and source files. Debugging tools, including GDB and Valgrind, can use Fedora's public debuginfod server to download the precise set of debuginfo and source files needed to debug or profile any executable packaged for Fedora since Fedora 32. Other Linux distributions also provide public debuginfod servers. Refer to the documentation for a complete list of supported distros. Debuginfod is part of the elfutils project. For more information, read my 2019 article introducing debuginfod.

    The problem with eagerly loading debuginfo

    A straightforward implementation of a debuginfod client for GDB and Valgrind simply downloads shared library debuginfo as soon as  each shared library is linked to the running process being debugged or referenced in a core file. However just because a shared library is linked doesn't mean that it's relevant to every debugging or profiling session. This eager downloading of debuginfo for every library associated with a process or core file can result in longer download times as well as wasted space taken up by the unnecessary debuginfo. This problem is also relevant even when the tool is not using debuginfod but is instead accessing debuginfo that has been installed locally. Decoding and reading all of the symbols, strings, addresses, etc. in every library's debuginfo can be time consuming. If this information is never used during the debugging or profiling session, then time was wasted. The extent and significance of this waste of time depends on factors such as the state of the debugged process, the size of all relevant debuginfo, the speed of your network, and the amount of available storage space, etc.

    Improving GDB and Valgrind with lazy debuginfo loading

    To improve the efficiency of debuginfo reading and downloading in GDB and Valgrind, we have been implementing lazy loading of debuginfo. In contrast to eager loading, lazy loading defers downloading or parsing debuginfo until the tool has a specific need to do so. GDB leverages debuginfod's ELF/DWARF section downloading to implement lazy loading. Instead of downloading a shared library's entire debuginfo file, GDB can instead download only the gdb-index section of the debuginfo. These indices contain information regarding the shared library's symbols that GDB can use until full debuginfo is actually needed. The size of these indices is around 7% of the size of the entire debuginfo file, so this can significantly reduce the total amount of debuginfo downloaded in a given debugging session.

    Here are a few comparisons of lazy loading download sizes to eager loading download sizes. Disclaimer: the following numbers can change depending on the exact versions of the executables and shared libraries involved, as well as debuginfo that you have already installed.

    • $ gdb -ex ‘break do_main’ -ex ‘run’ /usr/lib64/firefox/firefox
      • 94% reduction (235 MB vs 3.8 GB)
    • $ gdb -ex ‘backtrace’ --pid [/usr/bin/virt-manager process]
      • 82% reduction (57 MB vs 323 MB)
    • $ gdb --core libreoffice-writer.core
      • 87% reduction (204 MB vs 1.6 GB)
    • $ gdb -ex ‘run’ /usr/local/bin/gdb
      • 86% reduction (11 MB vs 80 MB)

    Valgrind's lazy loading implementation differs from GDB's by not requiring any indices. Valgrind simply postpones downloading and reading of shared library debuginfo until it needs specific address or symbol information from a shared library. There are cases where Valgrind ends up requiring debuginfo for most shared libraries linked to some process. In that case, the performance of eager and lazy loading will be similar. In these cases, we can at least be sure that Valgrind is actually making use of every debuginfo it downloads. In other cases, we see significant reductions in the amount of debuginfo downloaded with lazy loading.

    • $ valgrind /usr/bin/gnome-calendar
      • 94% reduction (279 MB vs 4.8 GB)
    • $ valgrind /usr/local/bin/gdb
      • 41% reduction (47 MB vs 80 MB)
    • $ valgrind /usr/bin/virt-manager
      • 15% reduction (273 MB vs 323 MB)

    Lazy loading is now supported in Valgrind since Fedora 37. GDB's lazy loading is currently in development and will be coming to Fedora once complete.

    Last updated: April 1, 2024

    Related Posts

    • Remote debugging with GDB

    • How to debug memory errors with Valgrind and GDB

    • The GDB developer's GNU Debugger tutorial, Part 1: Getting started with the debugger

    • Debuginfo is not just for debugging programs

    • Using Delve to debug Go programs on Red Hat Enterprise Linux

    • Exploring x86-64-v3 for Red Hat Enterprise Linux 10

    Recent Posts

    • Every layer counts: Defense in depth for AI agents with Red Hat AI

    • Fun in the RUN instruction: Why container builds with distroless images can surprise you

    • Trusted software factory: Building trust in the agentic AI era

    • Build a zero trust AI pipeline with OpenShift and RHEL CVMs

    • Red Hat Hardened Images: Top 5 benefits for software developers

    What’s up next?

    This cheat sheet presents a collection of Linux commands and executables for developers who are using the Linux operating system in advanced programming scenarios. 

    Get the cheat sheet
    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Build

    • Developer Sandbox
    • Developer tools
    • Interactive tutorials
    • API catalog

    Quicklinks

    • Learning resources
    • E-books
    • Cheat sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site status dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2026 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Chat Support

    Please log in with your Red Hat account to access chat support.