parseHitCondition rebuilt the same regexp from a MustCompile literal on
every call. Move hitConditionRegex to package scope so the pattern is
compiled once at initialization while keeping parseHitCondition behavior
unchanged.
Detecting uint overflow when computing Base+stride*count already sets
v.Unreadable, but execution continued into memory prefetch and element
loading with inconsistent state. Return immediately like other guard
clauses in this function.
The token.OR branch required both operands to pass satisf recursively,
matching AND semantics incorrectly. Use logical disjunction so hit-count
fast paths treat disjunctive breakpoint conditions accurately.
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.
newCompositeMemory ignored errors from MemoryReadWriter.ReadMemory when
building address-based DWARF fragments, so failed reads silently produced
zero-filled data. Return a wrapped error with size and address context,
consistent with RegPiece failures.
ptraceGetGRegs ignored the return value from sys.PtraceGetRegs, so
registers() never reported syscall failures when reading general purpose
registers. Assign the error and normalize syscall.Errno(0) to nil like
other ptrace helpers.
ptraceSetGRegs ignored the return value from sys.PtraceSetRegs, so
setPC and SetReg never reported syscall failures when writing general
purpose registers. Assign the error and normalize errno(0) to nil like
the rest of the ptrace helpers.
* proc: fix SP calculation for sigpanic frames on arm64
Without this fix, stack traces from linux/arm64 core dumps showed SP
values that differed from the runtime's panic output.
Fixes#3591
* Update withCoreFile
TestWaitFor could have the following sequence of events:
1. cmd.Start() is called.
2. The process is started in the kernel.
3. CreateToolhelp32Snapshot (inside waitForSearchProcess) sees
the process and returns from native.WaitFor.
4. The test immediately deferences cmd.Process, but cmd.Process
has not been assigned yet in cmd.Start() -> nil panic.
This patch fixes the issue by introducing a channel that is
written to from testWaitForSetup() _after_ cmd.Start() returns.
Unlike the mutex + boolean, this channel can be waited upon
without spinning, and only then cmd.Process is read inside
the test code.
* 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>
TestWaitFor was flaky on Windows. This seems to be linked to
prefix-based matching, where the fixture process spawned by
one test could be waited upon by another test. Adding a
unique no-op argument to different invocations of the
same fixture binary appears to fix the flakiness issue.
* proc: fix stack watch breaklet index for recorded replay
When adding the extra WatchOutOfScope breakpoint at the CALL before the
return PC, the code used len(retbp.Breaklets) to index into retbp2.Breaklets.
If the return address already had other breaklets (e.g. a user breakpoint),
that index could be out of range.
Add TestWatchpointStackRecordedOutOfScopeBreakletIndex (runs with -backend=rr)
to cover this path.
* fix: review
Adds caching to stacktraces so that stacktrace requests are not
quadratic. Also add a Skip parameter to the Stacktrace RPC request so
that clients can only request the frames they need.
Fixes#3809Fixes#989
* service/dap,proc: tolerate debuginfod events in tests
When debuginfod is available on the system (e.g. Fedora), asynchronous
"Download debug info" output events can arrive during DAP sessions and
EventBinaryInfoDownload events can appear in the proc event stream.
Tests were not expecting these and would fail.
Fix the DAP test client to skip debuginfod download output events in
ExpectMessage, and fix TestBreakpointMaterializedEvent to search for the
materialized event rather than assuming it is the first event.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* proc: fix test failures with Go 1.27 (gotip)
TestClassicMap: replace panic with t.Skip since the noswissmap
GOEXPERIMENT was removed in Go 1.27.
TestRangeOverFuncNextInlined: extend skip to all Go >= 1.24. The
inlined range-over-func symbol name issue (#3882) still requires a
compiler fix that has not landed in 1.27.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* cmd/dlv: skip TestStaticcheck on development versions of Go
Staticcheck output depends on the Go version used to build it. When
running against a development version (e.g. gotip), the output will
not match the checked-in baseline, causing spurious failures.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
go.mod specifies 1.24, so it's not possible to compile the
tests with Go toolchains <= 1.23 anyway. It doesn't make
sense to skip certain tests for older toolchains, because
attempting to use old toolchains will fail at build time.
* proc: support debugging non-Go binaries that dlopen Go shared libraries
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.
* proc: address PR review feedback for non-Go binary debugging
- 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 <noreply@anthropic.com>
Replace SinglelineStringFormatted, SinglelineStringWithShortTypes and
MultilineString with a single configurable StringWithOptions.
The Variable type was starting to have too many formatting helper methods.
Keep SinglelineString since it's used everywhere.
Co-authored-by: Shang Jian Ding <rifflegrass@gmail.com>
The fix adds validation at every point where pointers are dereferenced
or struct fields are accessed:
- loadTypes: check dirPtr after maybeDereference for both small map
(dirLen <= 0) and large map (dirLen > 0) paths.
- loadCurrentTable: check tab after maybeDereference; check all
toField() returns for the index, groups, groups.data, and
groups.lengthMask fields; extend existing groups nil check to also
check Unreadable.
- loadCurrentGroup: check toField() returns for slots and ctrl fields.
In all cases, the map is marked as Unreadable with a descriptive error
message rather than panicking.
Fixes#4005
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>
The riscv64 builder has been broken since it was enabled. While we wait
for a stable builder and assurances that riscv64 is passing, disable the
CI target and require the `exp.linuxrisc
Run go run
golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@latest
-fix -test ./... on the codebase now that the module version has updated
to 1.24.
To mach the behaviour of the native backend, do not set detached to
true if when we kill the process. This fixes a test failure of
TestRestartRequestRebuildFail on macOS.
* TeamCity: fix download url in test_mac.sh
The direct link to storage.googleapis.com no longer works, use the one
that's on the website.
* proc: fix loading goroutine labels
The format used to store goroutine labels changed again. Adapt to the change.
* Cirrus-CI: upgrade FreeBSD image used
14.2 no longer exists
* replace github.com/hashicorp/golang-lru with a custom lru cache
* fix caplocks
* use a mutex instead of rwmutex
* add lrucache tests
* move lru to its own package
Add a fake delve.catch function that can be used to wrap the expression
of breakpoint conditions so that they do not stop if the expression can
not be evaluated correctly.
The main use case for this is that it's hard to set breakpoint
conditions on interface variables that assume different types but it
can also be useful in other cases (for example checking the value of a
pointer-to-struct that sometimes is nil).
Fix some failing tests for go1.26. The arm64 failures are due to
different optimizations. The test failures on windows are due to there
being an extra goroutine with a starting location for which we do not
have line number informations.
This invariant does not hold for optimized binaries. For the example
program included in this patch, the disassembly of the function for an
optimized build looks like the following:
``` TEXT main.ManyArgsWithNamedReturns(SB)
/home/deparker/Code/delve/_fixtures/multinamedreturns.go
multinamedreturns.go:24 0x4a9f40 4c894c2470 mov qword ptr [rsp+0x70], r9
multinamedreturns.go:24 0x4a9f45 4c899c2480000000 mov qword ptr
[rsp+0x80], r11 => multinamedreturns.go:7 0x4a9f4d 488d1403 lea rdx, ptr
[rbx+rax*1] multinamedreturns.go:7 0x4a9f51 4801ca add rdx, rcx
multinamedreturns.go:7 0x4a9f54 4801fa add rdx, rdi
multinamedreturns.go:7 0x4a9f57 4801f2 add rdx, rsi
multinamedreturns.go:7 0x4a9f5a 4c01c2 add rdx, r8
multinamedreturns.go:7 0x4a9f5d 4c01ca add rdx, r9
multinamedreturns.go:7 0x4a9f60 4c01d2 add rdx, r10 ... ```
As you can see the entry is marked as line 24, whereas the first line we
really want to stop at is line 7 in this build. Enforcing that we want
to find a statement with the same line as the entry, this makes Delve
stop at the end at the `ret` instruction:
``` multinamedreturns.go:22 0x4aa01b 488d1c11 lea rbx, ptr [rcx+rdx*1]
multinamedreturns.go:22 0x4aa01f 48d1fb sar rbx, 0x1
multinamedreturns.go:24 0x4aa022 c3 ret ```
Add a test to read the runtime type of an interface variable that is
not used in any other ways except through interfaces.
This is a regression check for issue #4080 which is a compiler problem.
Fixes#4080
With the recent changes in 1e3ccee (#4118) structMember became largely
reduntant with the new findStructMemberOrMethod. This commit simplifies
the code of structMember so that it does not handle embedded structs
and interfaces and changes its name to structField so that it can be
kept as an internal lightweight version of findStructMemberOrMethod.
* CI: add windows arm64 workflow
* add win-arm64 capslock
* add capslock build tag
* add servive test build tag
* skip proc_test.go
* unskip more tests
* skip TestHardcodedBreakpointCounts as flaky
* add gotip
* add version log to ps1
* switch logic to use stable json endpoint for getting latest go
* add continue-on-error for gotip
Use DAP's exception breakpoints to represent the predefined breakpoints
we set for unrecovered panics and fatal throws, so that DAP users can
disable those breakpoints.
Fixes#4038