896 Commits

Author SHA1 Message Date
a80904ca1f proc: do not always allocate struct literals (#3953)
Do not always allocate new struct literals to the target's memroy. Wait
until they actually need to have an address.

Fixes #1465
2025-03-24 10:24:49 -07:00
d5fb3bee42 proc/core: skip tests on ppc64le (#3954)
These tests have been somewhat silently failing on our CI because the
test ends up being skipped [due to the lack of coredumpctl](https://delve.teamcity.com/buildConfiguration/Delve_linux_ppc64le_1_24/66766?buildTab=tests&focusLine=NaN&name=testcore&suite=github.com%2Fgo-delve%2Fdelve%2Fpkg%2Fproc%2Fcore%3A+&expandedTest=build%3A%28id%3A66766%29%2Cid%3A2000000704&showLog=66766_20670_112.20612.20670&logFilter=debug&logView=flowAware).

When `coredumpctl` is present, the test [fails
anyways](https://issues.redhat.com/browse/RHEL-83939), so let's just
skip it on ppc64le for now.
2025-03-20 09:15:19 +01:00
55486fbab4 service/test: skip substitutepath test when modules disabled (#3955)
See: https://issues.redhat.com/browse/RHEL-83958
2025-03-20 09:14:20 +01:00
18ce5d6baa proc: add support for struct literals (#3935)
* service/test: fix compile error in tests

Due to a merge conflict the tests in service/test are not compiling.

* proc: add support for struct literals

Adds support for evaluating struct literals, and allocating them into
the target's memory.

Updates #1465
2025-03-18 10:11:05 -07:00
b329489c6c goversion: add check for DWARFv5 compatibility (#3943)
Due to #3861 which was fixed in:

https://go-review.googlesource.com/c/go/+/656675
https://go-review.googlesource.com/c/go/+/655976

debugging DWARFv5 executables only works if Delve itself is built with
1.25 or later. Add this check to the version compatibility checks.

Fixes #3861
2025-03-13 10:59:21 -07:00
b7eb6c8f26 proc: add RegnumToString to PPC64LE architecture (#3944)
This field was not initialized.
2025-03-13 10:57:42 -07:00
486574cb65 *: fix various test problems with go1.25 (#3946)
- disable dwz test if it fails because of dwarf5
- fix TestExamineMemoryCmd, which made unwarranted assumptions about memory
2025-03-13 10:57:11 -07:00
6ef45f534c proc: expose breakpoint hitcounts in expressions (#3874)
Expose breakpoint hitcounts in the expression language through the
special variable runtime.bphitcount:
  delve.bphitcount[1]
  delve.bphitcount["bpname"]
will evaluate respectively to the hitcount of breakpoint with id == 1
and to the hitcount of the breakpoint named "bpname".

This is intended to be used in breakpoint conditions and allows
breakpoints to be chained such that one breakpoint is only hit after a
different is hit first.

A few optimizations are implemented so that chained breakpoints are
evaluated efficiently.
2025-03-05 12:39:47 -08:00
2685a42bc0 proc: do not pin function call returns for toplevel call (#3925)
For the toplevel function call do not perform pinning since the
function results are unpinned immediately.
2025-03-05 08:58:01 -08:00
0b821e4516 telemetry: add stack counter for internal errors (#3930)
Add stack counter for the various places where we catch internal
errors.
2025-03-05 08:25:00 -08:00
e6e7aeb667 dwarf,proc: various fixes to support DWARFv5 (#3893)
Miscellaneous fixes to our DWARFv5 implementation, several contributed by @thanm.
2025-03-03 08:42:44 -08:00
1df310a2e3 pkg/proc: support watchpoint on nil interface (#3924) 2025-02-28 11:02:35 +01:00
2880422885 pkg/proc: add support for interface watchpoints (#3922)
Adds support for setting a watchpoint on an interface by setting
the watchpoint on the data pointer in the eface/iface runtime
structs representing the interface.
2025-02-27 16:15:09 +01:00
6badfa1792 proc/gdbserial: use rr version to determine style of qRRCmd (#3921)
Previously we relied on availability of the thread suffix protocol
extension to determine whether we should use the old or new encoding
for the qRRCmd extension of rr. Newly released version 5.9.0 of rr
removes this ability by not reporting the thread suffix extension as
available unless it gets to start lldb itself.
Use the value of rr's version instead.

Fixes #3920
2025-02-20 11:06:46 -08:00
62cd2d423c proc: some refactorings for supporting struct literals (#3909)
* deduplicates exprToString, defined in multiple packages, and moves it
  to astutil
* moves resolveTypedef into pkg/dwarf/godwarf, this is currently only
  used by pkg/proc but we will need to call it from pkg/proc/evalop
* creates a new FakePointerType function in pkg/dwarf/godwarf, this is
  also a function that is only used by pkg/proc but pkg/proc/evalop will
  also need.

Updates #1465
2025-02-07 07:36:23 -08:00
6a362a2b2a proc: better error message for breakpoints on stripped binaries (#3914)
Produce a better error when trying to set a breakpoint, by line, on
stripped binaries.

Fixes #3913
2025-02-07 07:35:46 -08:00
06b95cdd34 proc: allow access to thread registers after a function call (#3908)
After a call injection sequence terminates allow the evaluator to
access thread registers again so that variables stored in registers can
be used as arguments.

Fixes #3310
2025-01-24 08:58:48 -08:00
d2f748f1bd *: add support for linux/loong64 to native backend (#3892)
* delve: support linux-loong64 native debug

LoongArch is a new RISC ISA, which is independently designed by Loongson Technology.

LoongArch includes a reduced 32-bit version (LA32R), a standard 32-bit version (LA32S)
and a 64-bit version (LA64), and loong64 is the 64-bit version of LoongArch.

LoongArch documentation: https://github.com/loongson/LoongArch-Documentation.git

* *: mark loong64 port as experimental

---------

Co-authored-by: Huang Qiqi <huangqiqi@loongson.cn>
2025-01-17 09:41:37 -08:00
c4ab92e331 proc: switch to goroutine stack if we make no progress on thread stack (#3898)
When creating a stack trace, if we make no progress with the normal
thread stack switch to the goroutine stack before giving up. This
improves stacktraces on the main thread of minidumps created on Windows
by WER.

Fixes #3824
2025-01-09 08:57:19 -08:00
5d9a7dff9e proc: remove irrelevant TODO comment (#3891)
The arm64 disassembler is in fact already compiled in unconditionally.
2025-01-03 10:44:55 -08:00
75c20c328c pkg: refactor sort.Sort to slices.SortFunc (#3880) 2025-01-03 10:44:28 -08:00
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
5a2fe18739 proc: remove leftover fmt.Printf (#3885) 2024-12-19 10:13:48 -08:00
1a55e8e30e fix check it.Err() != nil but return a nil value error err (#3886) 2024-12-19 10:13:07 -08:00
59aece9c0a goversion,proc_test: add go1.24 compatiblity, disable broken test (#3882)
Add go1.24 to compatibility set and test matrix.
Remove go1.21 from test matrix.

TestRangeOverFuncNextInlined is disabled because the improved inlining
of go1.24 produces symbol names that are too complicated for us to
correlate, a fix for this will require a change to the compiler that
will probably be too complex to make it into 1.24.
2024-12-17 15:59:38 -08:00
530afae62e proc: fix loading goroutine labels on Go 1.24 (#3879)
Go 1.24 changed the way goroutine labels are stored.
2024-12-16 12:31:24 -08:00
477e46ebbd pkg/proc: support swiss table map implementation (#3838)
Adds support for the swiss table implementation for Go's maps.
2024-12-04 19:14:47 -08:00
d97b471292 pkg/proc,service/debugger: do not disable unsatisfiable breakpoints (#3868)
Previously breakpoints with hitcount conditions that became
unsatisfiable
would become disabled, this was done as an optimization so that the
continue loop would no longer need to stop on them and evaluate their
conditions.
As a side effect this meant that on restart these breakpoints would
remain disabled, even though their hit condition returned satisfiable.

This commit changes Delve behavior so that breakpoints with
unsatisifiable hitcount conditions are no longer disabled but the
associated physical breakpoints are removed anyway, preserving the
optimization.

Some refactoring is done to the way conditions are represented and the
enable status is managed so that in the future it will be possible to
use hitcount conditions to implement "chained" breakpoints (also known
as dependet breakpoints), i.e. breakpoints that become active only
after a second breakpoint has been hit.
2024-12-04 19:07:56 -08:00
7b9a379e59 proc: allow accessing captured variable as if they were struct fields (#3866)
If 'a' is a captured variable in a function pointer called 'f' let
'f.a' evaluate to its value.
2024-12-02 11:20:51 -08:00
5d82dc10dc proc: fix issue on Windows when launching process while detached (#3867)
When the Delve instance is running in a detached state and it launches
a process an additional child conhost.exe process will be created, we
should detach from it.

Fixes #3864
2024-11-26 11:45:46 -08:00
5c12831340 proc/core/minidump: remove newlines from minidump logs (#3869)
They are redundant.
2024-11-26 11:44:46 -08:00
e0c80c8612 pkg/proc/native,pkg/proc/amd64util: xsave decoding cleanup (#3840)
- move the cpuid querying code to pkg/proc/native/cpuid since
  pkg/proc/native is the only package entitled to calling it
- add a type to describe the xstate_bv bitmap instead of using
  hardcoded constants everywhere
- use xcr0 instead of xstate_bv for the offset heuristic like gdb does
2024-11-21 13:06:51 +01:00
091e5535ab all: remove redundant err declarations (#3855) 2024-11-12 08:04:22 -08:00
b4cfc8f6c7 tests: calling os.Exit in TestMain is not required (#3856) 2024-11-12 08:03:50 -08:00
b16e12fde7 proc: do not ignore error return of funcCallEvalFuncExpr (#3850)
This is probably the cause of the panic such as in issue #3848 and
other similar issues, it is hard to be sure because we never get a
proper reproducer but judging from the stack traces it should be this.
Also it doesn't affect versions of Go that have the debug pinner.

Fixes #3848
2024-11-06 10:27:44 -08:00
6b2ed0d684 proc: fix typos in errors and comments (#3852) 2024-11-06 15:15:48 +01:00
844712a30b proc: run gofmt (#3851) 2024-11-06 15:15:14 +01:00
e9616a7f98 proc: fix rangeFuncStackTrace with inlined functions (#3849)
If an inlined function is encountered we should keep searching for its
rangeParent even if we don't have a closurePtr because it could be that
the function has been inlined into its rangeParent.

This does not need a new test, the existing tests already fail on
go1.24.
2024-11-04 08:21:40 -08:00
822014b8e8 service,terminal,cmd/dlv: automatically guessing substitute-path config (#3781)
Add command, API calls and launch.json option to automatically guess
substitute-path configuration.
2024-10-31 10:19:08 -07:00
bef326c6a5 proc: use CPUID to determine ZMM_Hi256 region offset (#3831)
The offset of state component i can be found via
CPUID.(EAX=0DH,ECX=i):EBX. The ZMM_Hi256 is state component 6, so we use
CPUID to enumerate the offset instead of hardcoding.

For core dumps, we guess the ZMM_Hi256 offset based on xcr0 and the
length of xsave region. The logic comes from binutils-gdb.

Fixes #3827.
2024-10-21 09:16:57 -07:00
1a9bd03d7a goversion: parse version for development builds (#3837)
Once upon a time Go version strings for development builds did not
reference the major/minor version they belonged to, therefore the best
we could do was to always assume that a development build belonged to
the most recently released version of Go.

This commit changes pkg/goversion so that the new style of development
version string is fully parsed.
2024-10-21 09:15:02 -07:00
064ef226ca pkg/proc/core: Clean up some repetitive code (#3834)
Cleans up repetitive code in pkg/proc/core and also adds coredumpctl
support to our test suite.
2024-10-21 09:12:34 -07:00
05dc760877 *: mark riscv64 port as experimental (#3835)
Delete non-working prologue detection code and mark port as experimental.

Updates #3832
2024-10-14 11:04:03 -07:00
75c41f2b64 delve: add linux-riscv64 support (#3785) 2024-10-11 12:34:25 -07:00
025d47c6e9 proc: adds pointer pinning to call injection (#3787)
This commit adds a new mode to call injection. If the runtime.debugPinner
function is available in the target executable it obtains a pinner by
calling it and then uses it to pin the pointers in the results of call
injection.

This allows the code for call injection to be refactored to execute the
calls in the normal order, since it doesn't need to be concerned with having
space on the target's memory to store intermediate values.

Updates #3310
2024-10-04 10:44:57 -07:00
a3d7712752 *: replace uses of uniq with slices.Compact (#3821) 2024-10-01 10:16:49 -07:00
8c645a32d7 pkg/proc: simplify tests by using errors.As (#3818) 2024-10-01 08:54:11 -07:00
def0688e7a proc: step into coroutine (#3791)
The step command is changed such that when the function being currently
called is a coroutine switch function it will move to the associated
coroutine.
Functions that switch coroutines are currently the next, stop and yield
closures produced by the iter.Pull function.
2024-09-24 10:22:04 -07:00
059f149433 proc: cache module data (#3800)
Cache module data so that we don't reload it every time we look up a
variable with a generic type.
2024-09-18 14:17:07 -07:00
582305a813 proc: for optimized functions allow .closureptr to not exist (#3808)
* proc: flag variables correctly when range-over-func stmts are used

Argument variables of a range-over-func body closure should be returned
flagged as normal local variables, not as function arguments.

Updates #3806

* proc: for optimized functions allow .closureptr to not exist

For optimized functions .closureptr is sometimes omitted from DWARF,
allow it to be 0 and try to recover the range-over-func stack by best
effort.

Fixes #3806
2024-09-18 14:16:34 -07:00