24 Commits

Author SHA1 Message Date
cui
3e7fcd4e06
proc/internal/ebpf: fix AddressToOffset off-by-one at section load (#4324)
AddressToOffset compared virtual addresses with strict inequality against
each executable ELF section load address. PCs landing exactly on Section
.Addr were never matched while still within [Addr, Addr+Size).

Use inclusive lower bounds so the scan matches the usual VMA half-open
interval.
2026-05-04 13:09:14 -07:00
Archana Ravindar
29aa227c5c
pkg/proc: extend feature to print procedure parameters in trace on eBPF backend (#4305)
* Extend feature to print procedure parameters in trace on eBPF backend
Fixes #4266

* address review comments

* ran go fmt
2026-04-23 11:52:31 -07:00
Derek Parker
0b686c36d0
proc/internal/ebpf,build: extend eBPF tracing type support (#4285)
* proc/internal/ebpf,build: extend eBPF tracing type support and update Docker build

Add support for additional Go types in the eBPF tracing backend:

- Bool: use BoolType with ByteSize 1 instead of IntType with ByteSize 8
- Int/Uint: use actual DWARF size instead of hardcoded ByteSize 8
- Float32/Float64: synthesize FloatType, detect XMM registers as unreadable
- Complex64/Complex128: synthesize ComplexType with XMM detection
- Pointer: capture pointer address and dereference pointed-to value via
  bpf_probe_read_user in eBPF C code
- Slice: capture slice header (ptr+len+cap) and dereference element data
- Graceful degradation: map, chan, interface, func, struct, and array
  types now produce specific "not yet supported" errors instead of
  generic "type not supported by ebpf"

Add Unreadable field to RawUProbeParam so the Go-side parser can
propagate specific error messages through to Variable display.

Update eBPF build infrastructure:
- Replace EOL Ubuntu 21.04 base image with Ubuntu 22.04
- Use clang-12 (required: newer clang generates BPF code that fails
  the kernel verifier with "dereference of modified ctx ptr disallowed")
- Update Go from 1.17 to 1.24
- Remove sudo requirement from build-ebpf-builder-img.sh
- Add -u flag to Docker run to avoid root-owned output files

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* dwarf/godwarf,proc: fix slice ReflectKind and address PR review feedback

Fix a bug in the DWARF type parser where SliceType.ReflectKind was not
set (stayed 0/reflect.Invalid). When parsing struct types, the code
creates a new StructType, sets ReflectKind on it, then for slices
creates a new SliceType and reassigns the pointer — losing the
ReflectKind. The String case already had an explicit fix for this
(str.ReflectKind = reflect.String), but the Slice case was missing it.

This caused the eBPF tracing backend (which uses dt.Common().ReflectKind
to determine type kind) to see kind=0 for slice parameters, making them
appear as unsupported types. The ptrace backend was unaffected because it
uses Go type assertions (case *godwarf.SliceType) instead of ReflectKind.

Also addresses PR review feedback:
- Add t.Parallel() to TestTraceEBPFTypes subtests
- Use regexp matching for pointer/slice address verification
- Add content verification for slice test output
- Add comment explaining -u flag in build-ebpf-objects.sh
- Add comment explaining amd64-only XMM register threshold
- Handle CreateCompositeMemory errors in target.go
- Remove debug prints from target.go

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* docs: document eBPF type support pipeline and TestTraceEBPFTypes

Add documentation for the eBPF type support pipeline, currently
supported types, the canonical test (TestTraceEBPFTypes) for adding
new type support, and the clang-12 build constraint.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* proc/internal/ebpf: clarify pointer/slice comments per review

Clarify that the eBPF probe does capture dereferenced data, but
loadValue runs Go-side after the probe returns and cannot follow
pointer chains through fake memory addresses. Also remove unicode
arrow from XMM register comment.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* proc/internal/ebpf: clarify pointer/slice deref_val limitations

Explain why we display raw addresses instead of dereferenced values:
element type info isn't propagated through the eBPF pipeline, and
deref_val is limited to 48 bytes which is insufficient for nested
or variable-length types.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* address review feedback

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-26 09:27:35 +01:00
Derek Parker
e7c6842466
cmd/dlv: Add trace backend parity test and fix eBPF formatting (#4250)
Adds a comprehensive parity test ensuring ptrace and eBPF trace backends
produce identical output, preventing formatting divergence as new types
are added.

The test revealed and fixes several eBPF formatting issues:
1. Goroutine format: Now uses "goroutine(N):" to match ptrace
2. Return value format: Now uses ">> goroutine(N): func => (val)"
3. String capture bug: Strings were showing as empty - fixed by adding
   StringType to eBPF helpers so string values are properly loaded

Test coverage:
- Fixture tests all currently supported types: int64, uint64, bool,
string
- Runs dlv trace with both backends on same function
- Compares outputs byte-for-byte (filtering process exit messages)
- Updated all existing eBPF test expectations to match new format

All eBPF trace tests now pass with consistent formatting between
backends.

Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-29 15:24:15 +01:00
Derek Parker
0288b22328
proc/internal/ebpf: fix goroutine leak and shutdown sequence for ebpf (#4231) 2026-01-15 09:59:35 +01:00
Derek Parker
61573cffb3
*: modernize codebase with newer syntax / helpers (#4110)
Changes came from running
https://pkg.go.dev/golang.org/x/tools/gopls/internal/analysis/modernize
on the codebase.
2025-08-29 15:50:08 +02:00
3u13r
1dc394cfbb
pkg/proc/internal/ebpf: Fix uprobe address (#3894)
The update of gilium/ebpf introduced a beaking change in it's API: The `offset` in the UprobeOptions is now relative to the added option `address`. Since `address` was only default initalized, the library did not use `address` and `offset` as address for the uprobe, but tried to calculate the offset itself based on the given symbol. Since we set the path of the executable as symbol, the library errored when trying to resolve it.

Fixes https://github.com/go-delve/delve/pull/3491
2025-01-03 10:41:52 -08:00
Oleksandr Redko
13d6cd4e0d
*: Correct spelling mistakes (#3555) 2023-11-06 07:55:44 -06:00
Oleksandr Redko
255afbfdb7
all: remove obsolete build tags "// +build" (#3513) 2023-10-03 08:50:11 -07:00
Eng Zer Jun
382bb0fde6
pkg/proc/internal/ebpf: remove redundant nil check (#3502)
From the Go specification:

  "1. For a nil slice, the number of iterations is 0." [1]

Therefore, an additional nil check for before the loop is unnecessary.

[1]: https://go.dev/ref/spec#For_range

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2023-09-18 08:01:52 -07:00
Derek Parker
f0b534ddcc
pkg/proc: add support for more types in ebpf tracing backend (#3474) 2023-08-18 19:56:44 +02:00
Derek Parker
1d28ceccdc
pkg/proc: fix ebpf probe tracing backen uprobe handling (#3417)
Uprobes get automatically cleaned and removed when the reference to
the Link object is lost. Hold a reference to any active Uprobe Link
for duration of Delve execution and ensure they are cleaned up
at exit.

Fixes ebpf probes don't work after time.Sleep() #3227
2023-06-15 12:07:32 +02:00
Derek Parker
f3bfa7c177
pkg/proc: remove memlock limit for ebpf trace backend (#3353)
Fixes #3283
2023-05-03 09:41:32 +02:00
Hengqi Chen
64d5ce26d6
proc: Simplify eBPF backend implementation (#3325)
* Remove standard C headers since we have vmlinux.h already
* Simplify get_goroutine_id() implementation, this reduces a map
  and thus reduces runtime memory comsumption.

While at it, unify all indention using 4 spaces.

Signed-off-by: Hengqi Chen <hengqi.chen@gmail.com>
2023-04-24 13:37:58 -07:00
Derek Parker
5c5fca4849
pkg/proc/internal/ebpf: Fix handling of entry / return (#3081)
This patch removes the old error-prone way of tracking
whether the tracepoint is for a function entry or
return. Instead of trying to guess, let the data structure
simply tell us directly.
2022-07-29 12:00:32 +02:00
Derek Parker
36b35aad00
pkg/proc/internal/ebpf: Fix size of ebpf type for fn_addr (#3080)
Must have been an issue overlooked in the initial implementation but
we should be using a 64-bit wide type to store the function address.
2022-07-28 11:30:08 +02:00
Alessandro Arzilli
5452c30fac
proc/internal/ebpf: drop dependency on cgo (#3072)
The ebpf implementations uses cgo, but only to access some C struct
definitions. Instead of using cgo simply duplicate the defintion of
those two structs in Go and add a test to check that the duplicate
definitions remain synchronized.

Fixes #2827
2022-07-22 19:39:18 +02:00
Derek Parker
661cb33699
pkg/proc: switch to Dual MIT/GPL license for ebpf (#2849) 2021-12-30 20:14:37 +01:00
Derek Parker
a88c9bde4a
pkg/proc: add build scripts & docker image for ebpf (#2847)
Adds a few build scripts and a container image for reproducible builds
of the ebpf programs.
2021-12-30 09:04:59 +01:00
Alessandro Arzilli
2cd9d268d3
proc: add dummy files to fix vendoring of Delve (#2807)
Add some dummy go files so that 'go mod vendor' works for modules that
require Delve, becuase directories that do not contain any go code will
not be vendored.
2021-12-07 09:20:10 -08:00
Derek Parker
cd9e6c02a6
*: Replace libbpfgo with cilium/ebpf (#2771) 2021-11-03 16:58:04 +01:00
Derek Parker
689e08260b
eBPF tracing backend return value parsing (#2704)
Add return value parsing for eBPF tracing backend.
2021-10-25 12:37:36 -07:00
Derek Parker
1b2f7f0051
pkg/proc: Parse Goroutine ID in eBPF tracer (#2654)
This patch enables the eBPF tracer backend to parse the ID of the
Goroutine which hit the uprobe. This implementation is specific to AMD64
and will have to be generalized further in order to be used on other
architectures.
2021-08-24 14:53:27 +02:00
Derek Parker
10406f96d5
*: Initial eBPF tracing support (#2625) 2021-07-31 17:16:26 +02:00