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

New Delve features in RHEL 9.2

Plus a deep dive into function call injections

July 20, 2023
Derek Parker
Related topics:
GoLinux
Related products:
Red Hat Enterprise Linux

    Delve, the Go debugger, ships with the go-toolset package in Red Hat Enterprise Linux (RHEL). The go-toolset package in RHEL 9.2 contains Delve version 1.9.1, which contains many improvements and features.

    Delve 1.9.1 is also the last release to contain the old versioning scheme; new releases of Delve will mirror the corresponding Go release <major>.<minor> versioning, only diverging for point releases. So, for example, the latest release of Delve is 1.20.x which corresponds to the 1.20.x release of Go. Delve releases a new minor version when the Go project releases a new version's first RC (Release Candidate). Once that version of Go is released in RHEL, the corresponding version of Delve is also released.

    New features

    Each new release of Delve boasts many new features, fixes, and improvements. Let's take a moment to highlight some of the new features in the 1.9.x cycle.

    In cycle 1.9.x, several additions, fixes, and changes were made to Delve, such as:

    • support for empty strings and exact matches in the substitute path config;
    • support for gnu_debuglink section to improve support for external debug information;
    • the ability to show disassembly instead of source code when single-stepping CPU instructions; and
    • the option to use -per-g-hitcount for breakpoint conditions.

    One other major feature is the implementation of function call injection on the ARM64 architecture. This enables developers to call a function in the program being debugged during a debugging session, a feature already available to users on the AMD64 architecture.

    This feature is very powerful, but it can be tricky to implement. The next section will dig into the feature in more detail.

    Function call injection

    This feature requires support from the Go runtime to ensure that Delve can safely inject function calls into the Go program being debugged. Injecting a function call into a Go program is very difficult to do safely to ensure the program is not disrupted or put into a bad state. If not for coordination with the Go runtime, we would run into potential deadlocks from the garbage collector, issues with stack space in the Go routine you'd like to use to call the function, and more.

    However, as mentioned above, thanks to coordination with the Go runtime, function call injection can be done safely and provide enhanced insight and interactivity during your debug session.

    The coordination between Delve and the Go runtime for injecting function calls happens at a very low level. Delve and the Go runtime communicate via setting specific values in specific CPU registers and reading and writing memory in the address space of the program being debugged. The Go runtime provides this via a private function called `debugCallV2` (in current Go releases). As shown in the name, this function is versioned to allow for changing the function injection protocol in ways that may not be backward compatible.

    The basic flow for function call injection on AMD64 is as follows (taken from the Go runtime documentation):

    1. Check that the goroutine is in state _Grunning and that at least 256 bytes are free on the stack.
    2. Push the current PC on the stack (updating SP).
    3. Write the desired argument frame size at SP-16 (using the SP after step 2).
    4. Save all machine registers (including flags and XMM registers) so the debugger can restore them later.
    5. Set the PC to debugCallV2 and resume execution.

    Once Delve invokes debugCallV2, the runtime takes over and checks that the program is at a safe location to initiate a function call, and ensures there is enough space on the stack for the function being called to execute. Once the Go runtime has completed its checks and allocated stack space for the function call, it sets the appropriate register state to communicate with Delve. Then it notifies Delve by executing a breakpoint instruction, transferring control back to Delve. The debugger then reads the program memory and register values and continues with the function call injection protocol.

    If the Go runtime reports no issues or errors, Delve will continue with the function call, running to completion and obtaining the return values to display to the user. If there are errors, Delve will either remedy them if they are recoverable from the debuggers perspective or abandon the function call notifying the user as to the reason why.

    Summary

    Delve, the Go debugger, has introduced new features and improvements in its 1.9.x cycle. Notable features include support for empty strings and exact matches in the substitute path configuration, support for the gnu_debuglink section to enhance external debug information support, the ability to display disassembly instead of source code during CPU instruction single-stepping, and the option to use -per-g-hitcount for breakpoint conditions. The ARM64 architecture also received a significant addition with implementing function call injection. This feature allows developers to call functions within the program being debugged, enhancing interactivity and insight during debugging sessions.

    The coordination between Delve and the Go runtime ensures the safe injection of function calls by leveraging low-level communication and utilizing the runtime's private function, debugCallV2. The Go runtime performs necessary checks and stack allocations before transferring control back to Delve for further processing. Function call injection in Delve provides developers with advanced debugging capabilities while maintaining the stability of the program being debugged.

    A solid, reliable debugger is an invaluable tool for developers. We ship Delve alongside Go with the go-toolset package, so you have everything you need to be a productive Go developer. Be on the lookout for new features and improvements as we continue to develop and improve both the Go toolchain and Delve debugger.

    Last updated: August 14, 2023

    Related Posts

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

    • How debugging Go programs with Delve and eBPF is faster

    • Some notes on porting Delve to PPC64LE

    • Improve your code: Tales from confinement without a debugger

    • Deploying debuginfod servers for your developers

    Recent Posts

    • Protect data offloaded to GPU-accelerated environments with OpenShift sandboxed containers

    • Case study: Measuring energy efficiency on the x64 platform

    • How to prevent AI inference stack silent failures

    • Preventing GPU waste: A guide to JIT checkpointing with Kubeflow Trainer on OpenShift AI

    • How to manage TLS certificates used by OpenShift GitOps operator

    What’s up next?

    Convert2RHEL is a command-line utility that can streamline your migration path from CentOS Linux 7 to a fully supported Red Hat Enterprise Linux (RHEL) operating system. This cheat sheet outlines how to convert your CentOS Linux instance to RHEL in just 7 steps.

    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.