Skip to content

proc: support debugging stripped non-Go binaries - #4263

Merged
aarzilli merged 4 commits into
go-delve:masterfrom
derekparker:feature/non-go-binary-debugging
Feb 26, 2026
Merged

aarzilli merged 4 commits into
go-delve:masterfrom
derekparker:feature/non-go-binary-debugging

Conversation

@derekparker

Copy link
Copy Markdown
Member

Add support for debugging non-Go stub binaries that dynamically load Go shared libraries via dlopen or other dynamic linkage modes. When the initial binary has no Go runtime symbols or DWARF info, Delve now marks it as non-Go and defers Go-specific initialization instead of exiting. A breakpoint on the dynamic linker's _dl_debug_state function detects shared library loads, allowing Delve to pick up Go debug info when a Go .so is loaded at runtime.

Should allow for use cases such as golang/go#77484.

Add support for debugging non-Go stub binaries that dynamically load Go
shared libraries via dlopen or other dynamic linkage modes. When the
initial binary has no Go runtime symbols or DWARF info, Delve now marks
it as non-Go and defers Go-specific initialization. A breakpoint on the
dynamic linker's _dl_debug_state function detects shared library loads,
allowing Delve to pick up Go debug info when a Go .so is loaded at
runtime.
@derekparker

Copy link
Copy Markdown
Member Author

@Pawloland are you able to confirm if this enables your use case?

@aarzilli

Copy link
Copy Markdown
Member

The test failures look real.

Comment thread pkg/proc/linutil/auxv.go Resolved
Comment thread pkg/proc/bininfo.go Resolved
Comment thread pkg/proc/bininfo.go Resolved
Comment thread pkg/proc/bininfo.go Resolved
Comment thread pkg/terminal/command.go Resolved
derekparker and others added 2 commits February 20, 2026 10:07
- Deduplicate auxv parsing by extracting searchAuxv helper
- Rename IsNonGo to IsGo (positive flag is easier to reason about)
- Move Go image detection into loadDebugInfoMaps to avoid reparsing
  debug_info; uses DW_AT_language == DW_LANG_Go which is already
  checked there for cu.isgo
- Remove hasGoProducer function (no longer needed)
- Remove pkg/proc import from pkg/terminal/command.go; use string
  literal for stop reason comparison instead
- Update CLAUDE.md with DWARF parsing and layer boundary guidance

Co-Authored-By: Claude Opus 4.6 <[email protected]>
With non-Go binary debugging support, attaching to PID 1 can succeed
in privileged environments (e.g. CI Docker containers running as root)
since the binary is now treated as a non-Go process that may load a
Go shared library later. Remove this OS-dependent sub-case; the
remaining sub-tests cover DAP attach config validation.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@derekparker

Copy link
Copy Markdown
Member Author

Ended up removing the failing DAP test as I don't think it's relevant. In the container we can attach to PID 1 and with this change it won't fail if it's non-Go. Locally it passes because when not in container the user typically won't have privileges to attach to PID 1.

Used claude code for review feedback, so updated the CLAUDE.md as well with a hint.

@Pawloland

Pawloland commented Feb 20, 2026 •

Copy link
Copy Markdown

@Pawloland are you able to confirm if this enables your use case?

I am positive, that the behavior changed from the previous one as the dlv in server mode now waits for the dlv in client mode for connections instead of closing immediately. As for debugging, it is still not working. I will explain more in golang/go#77484 (comment).

Comment thread pkg/proc/target.go Resolved

@aarzilli aarzilli 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, don't know if you want to merge it like this or also address further problems from the upstream issue.

@derekparker

Copy link
Copy Markdown
Member Author

LGTM, don't know if you want to merge it like this or also address further problems from the upstream issue.

The other issues upstream seem to be related to path issues, so maybe lacking proper substitute-path settings?

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.

3 participants