Skip to content

Gdb core file support#17

Merged
derekparker merged 2 commits into
go-delve:masterfrom
T-J-Teru:gdb-core-file-support
Apr 29, 2026
Merged

Gdb core file support#17
derekparker merged 2 commits into
go-delve:masterfrom
T-J-Teru:gdb-core-file-support

Conversation

@T-J-Teru

Copy link
Copy Markdown
Contributor

Two changes to improve core file debugging using GDB.

  1. The first fixes actually starting core file debugging, which is currently broken. However, this makes use of some features that have only just been merged to upstream GDB. We could possibly avoid this by doing more work in the mcp server itself, e.g. sending raw GDB commands to load the core file. But I've not done this for now, preferring to use the latest upstream features to make the mcp server simpler.
  2. GDB is pretty good these days at finding the executable that matches a core file, especially if the core file has build-ids within it. The second commit allows a user to skip specifying the executable path, instead allowing GDB to auto-detect it. I don't know if the delve debugger supports this, so for now I've left path as required when using delve for core file debug. I've also updated the docs in this commit, which in a few places meant adding text describing core file debug as it was otherwise missing.

Comment thread tools_test.go Outdated
T-J-Teru and others added 2 commits April 29, 2026 19:42
GDB's DAP implementation does not support core files via the launch
request. When the MCP server sent a launch request with a coreFile
argument, GDB ignored coreFile and ran the program from scratch,
resulting in a hang followed by session termination.

Upstream GDB handles core files via the attach request with a coreFile
argument, this has been added with GDB commit:

  commit 0a481bb9a6d49591a7f21b132ff63a96704bce97
  Date:   Mon Mar 23 22:25:17 2026 +0000

      gdb/dap: add support for opening core files

which is merged to GDB's master branch, and should be in the GDB 18
release later this year (2026).  The approach taken by GDB is
consistent with how lldb-dap also handles core files.  This commit
updates the server to make use of this new GDB functionality, after
which basic core file debugging now works as expected.

Delve continues to use launch requests with debug mode "core", and
should see no change after this commit.

A new CoreRequestType() method on the DebuggerBackend interface lets
each backend declare which DAP request type to use for core dump
debugging.  The "core" debug mode uses this to create an appropriate
request type.

The only problem with this approach is that it requires building top
of tree GDB in order to test it.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
GDB can auto-detect the executable from a core file, so the path
parameter is no longer required when using GDB in core mode. Delve
still requires the path as it cannot perform this auto-detection.

The gdbBackend.CoreArgs() method now omits the "program" field from
the DAP attach request when no path is specified, letting GDB resolve
it from the core file metadata.

Adds TestGDBCoreDumpWithoutPath to verify path-less core debugging
works alongside the existing TestGDBCoreDump with-path test.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@T-J-Teru T-J-Teru force-pushed the gdb-core-file-support branch from 813ad4e to ab44fdf Compare April 29, 2026 18:58

@derekparker derekparker left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@derekparker derekparker merged commit 56963c2 into go-delve:master Apr 29, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants