Skip to content

proc/internal/ebpf: switch to header+param event ring buffer protocol - #4352

Merged
aarzilli merged 2 commits into
go-delve:masterfrom
derekparker:feature/ebpf-event-protocol
May 25, 2026
Merged

aarzilli merged 2 commits into
go-delve:masterfrom
derekparker:feature/ebpf-event-protocol

Conversation

@derekparker

Copy link
Copy Markdown
Member

Replace the single bpf_ringbuf_reserve/submit of the entire function_parameter_list_t struct with a multi-event protocol: one HEADER event per uprobe hit followed by one PARAM event per parameter. Each PARAM event carries the parameter's kind, val (0x30 bytes), and deref_val (0x30 bytes) inline via bpf_ringbuf_reserve/submit.

BPF changes:

  • Define packed event_header_t and param_event_t wire structs
  • Snapshot registers into a stack-local u64[16] array so helpers receive PTR_TO_STACK instead of PTR_TO_CTX, which the verifier accepts for indexed access
  • Remove goroutine_id from function_parameter_list_t; compute it at runtime and embed it in the HEADER event
  • Keep the existing val[0x30]/deref_val[0x30] data layout and the string/pointer/slice deref helpers unchanged

Go-side changes:

  • Deadline-based ring buffer polling: set a 10 ms deadline before each Read() call so the goroutine unblocks to check for context cancellation without a concurrent SetDeadline call
  • Pending-event reassembly: buffer HEADER events in a map keyed by (goroutine_id, fn_addr, is_ret) and attach incoming PARAM events; emit the completed RawUProbeParams once all params arrive
  • Store DWARF types and parameter names during UpdateArgMap and look them up by global index when parsing PARAM events, replacing the old argTypeInfo map
  • synthesizeTypeFromKind: create a godwarf.Type from reflect.Kind for parameters that lack a full DWARF type

Other changes:

  • CFA offset fix: use FirstPCAfterPrologue and the frame table to compute the CFA-from-RSP offset at the uprobe PC so DW_OP_fbreg expressions evaluate to correct RSP-relative offsets; input and return parameters are now evaluated at different PCs
  • Thread a LoadConfig through the RPC, debugger, and target layers so trace output verbosity is configurable
  • Upgrade the eBPF Docker build image to Ubuntu 26.04 / clang-22

This sets the stage for additional changes to be submitted later to allow for larger structs / arrays and dereferencing pointers.

Replace the monolithic function_parameter_list_t ring buffer write with a
structured two-event protocol: a HEADER event followed by per-parameter
PARAM events. Each param event carries the parameter's val and deref_val
data inline (0x30 bytes each), matching the original data model.

Key changes:
- BPF C: new event_header_t/param_event_t wire protocol with per-param
  bpf_ringbuf_reserve/submit, register snapshot via stack array
- Go helpers: deadline-based ring buffer polling (no more blocking
  Read()), pending event reassembly with goroutine+fn+is_ret keying,
  DWARF type and parameter name lookup by global index, type synthesis
  from reflect.Kind for backward compatibility
- LoadConfig plumbing: thread LoadConfig through RPC → debugger → target
  so trace output verbosity is configurable
- CFA offset fix: compute uprobe PC via FirstPCAfterPrologue and use
  frame table CFA offset for correct RSP-relative stack parameter
  locations (input vs return params now evaluated differently)
- Build: upgrade Docker image to Ubuntu 26.04 / clang-22
@derekparker
derekparker marked this pull request as ready for review May 20, 2026 21:17

@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.

TestGeneratedDoc fails.

@derekparker
derekparker force-pushed the feature/ebpf-event-protocol branch from 545e403 to 59abd8e Compare May 22, 2026 16:28

@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

@aarzilli
aarzilli merged commit 8fc4acb into go-delve:master May 25, 2026
4 checks passed
social4hyq pushed a commit to social4hyq/homebrew-core that referenced this pull request Sep 20, 2026
delve 1.27.0

Created-by: HarmonybrewBot
Commit-by: HarmonybrewBot
Merged-by: HarmonybrewBot
Description: Created by `brew bump`

---

Created with `brew bump-formula-pr`.<details>
  <summary>release notes</summary>
  <pre>## What's Changed
* service/dap: avoid Session.conn race in breakpoint-after-disconnect test by @alexsaezm in go-delve/delve#4317
* proc: implement frame pointer unwinding by @alexsaezm in go-delve/delve#4288
* proc: fix SP calculation for sigpanic frames on arm64 by @alexsaezm in go-delve/delve#4319
* native: propagate PtraceSetRegs error on linux/ppc64le by @cuiweixie in go-delve/delve#4321
* native: propagate PtraceGetRegs error on linux/ppc64le by @cuiweixie in go-delve/delve#4322
* proc: propagate AddrPiece ReadMemory errors in composite memory by @cuiweixie in go-delve/delve#4323
* proc/internal/ebpf: fix AddressToOffset off-by-one at section load by @cuiweixie in go-delve/delve#4324
* proc: fix OR handling in breakpointConditionSatisfiable by @cuiweixie in go-delve/delve#4325
* dwarf/reader: propagate errors during Reader entry iteration by @cuiweixie in go-delve/delve#4327
* proc: bail out of loadArrayValues after stride overflow by @cuiweixie in go-delve/delve#4328
* proc: compile hit-condition regexp once by @cuiweixie in go-delve/delve#4335
* service/dap: add newline to the build message by @sagg0t in go-delve/delve#4340
* proc: fix test for go1.27 regexp refactor by @aarzilli in go-delve/delve#4339
* proc: fix range over func stepping for go1.27 by @aarzilli in go-delve/delve#4343
* chore: fix some comments to improve readability by @box4wangjing in go-delve/delve#4344
* Teamcity: reenable riscv64 build by @aarzilli in go-delve/delve#4346
* proc: fix hasInlines in stacktrace, fix range step with inlining by @aarzilli in go-delve/delve#4345
* chore: fix comment to improve readability by @cuoguojida in go-delve/delve#4350
* service/dap: relax TestBadLaunchRequest by @aarzilli in go-delve/delve#4351
* TeamCity: adjust execution timeout by @vietage in go-delve/delve#4354
* proc/internal/ebpf: switch to header+param event ring buffer protocol by @derekparker in go-delve/delve#4352
* proc: add test for struct literals with embedded field selectors by @aarzilli in go-delve/delve#4362
* proc: disable some failing tests on riscv64 by @aarzilli in go-delve/delve#4361
* gobuild: increase wait length for deleting binaries on Windows by @aarzilli in go-delve/delve#4359
* proc: add test for accessing global C variables by @aarzilli in go-delve/delve#4358
* proc: support generic methods by @aarzilli in go-delve/delve#4356
* Revert "winarm64: remove experimental build tags (#4176)" by @aarzilli in go-delve/delve#4281
* proc/test: include GOEXPERIMENT in the fixture cache key  by @typesanitizer in go-delve/delve#4367
* proc: fix stepping test on go1.27 / arm64 by @aarzilli in go-delve/delve#4365
* service/dap: add dap write memory request handler by @DrSergei in go-delve/delve#4364
* proc: make PushPackageVarOrSelect check local variables first by @aarzilli in go-delve/delve#4181
* pkg/proc: add GOEXPERIMENT=mapsplitgroup support by @aarzilli in go-delve/delve#4370
* service/dap: send ExitedEvent before TerminatedEvent by @derekparker in go-delve/delve#4371
* service/dap: fix test failures from ExitedEvent change by @derekparker in go-delve/delve#4373
* service/dap,pkg/debugdetect: fix tests by @derekparker in go-delve/delve#4375
* v1.27.0 by @derekparker in go-delve/delve#4372

## New Contributors
* @sagg0t made their first contribution in go-delve/delve#4340
* @box4wangjing made their first contribution in go-delve/delve#4344
* @cuoguojida made their first contribution in go-delve/delve#4350

**Full Changelog**: go-delve/delve@v1.26.3...v1.27.0
**Curated Changelog**: https://github.com/go-delve/delve/blob/master/CHANGELOG.md#1270-2026-06-19</pre>
  <p>View the full release notes at <a href="https://github.com/go-delve/delve/releases/tag/v1.27.0">https://github.com/go-delve/delve/releases/tag/v1.27.0</a>.</p>
</details>
<hr>

See merge request: Harmonybrew/homebrew-core!12311
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