Commit Graph

333 Commits

Author SHA1 Message Date
Ethan Reesor
987e99b29d service/dap: Implement suspended breakpoints (#4075)
* service/dap: Implement suspended breakpoints

This enables support for 'suspended' breakpoints, for example for a
plugin that hasn't been loaded yet.

Fixes #4074

* Address comments

* Cleanup
2025-09-02 17:23:40 -04: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
Derek Parker
6346593568 pkg/proc: return better error attempting to call nonexistent function (#4062)
Fixes #4051
2025-08-24 21:27:14 +02:00
yelvens
fbcae21681 pkg/proc: add support for additional stack-switching functions on loong64 (#4100)
Extend loong64SwitchStack to handle:
- cgo-related functions (Fixes #4099)
- runtime.mstart, runtime.newstack, runtime.systemstack

Co-authored-by: Huang Qiqi <huangqiqi@loongson.cn>
2025-08-21 09:42:44 -07:00
Alessandro Arzilli
44123aeea6 *: fix some failing tests on go1.25 (#4089)
* Skip TestIssue256 on linux/386, it fails because the line it relies
on
  (a return) does not have code generated for it.
* Skip running gen-usage-docs in TestGeneratedDocs on linux/ppc64le, I
  don't know why this fails, likely just a problem with the build
agent,
  but it doesn't matter: the test doesn't need to run on every
  architecture.
* Change TestRestartRequestWithNewArgs so that it doesn't depend on the
  cap value of a slice (it changed in go1.25/windows/amd64)
2025-08-20 10:41:46 -07:00
Oleksandr Redko
946e4885b6 pkg,service: simplify tests with slices.Contains (#4040) 2025-06-25 13:40:34 -07:00
Alessandro Arzilli
193f21e49b proc: replace Thread.Location method with a function (#3972)
Replaces the Thread.Location method with a ThreadLocation function. All
backends implemented the Location method exactly the same way, this
change deduplicates it.
2025-04-07 11:45:17 -07:00
Alessandro Arzilli
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
Alessandro Arzilli
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
Alessandro Arzilli
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
Derek Parker
1df310a2e3 pkg/proc: support watchpoint on nil interface (#3924) 2025-02-28 11:02:35 +01:00
Derek Parker
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
Alessandro Arzilli
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
yelvens
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
Alessandro Arzilli
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
Alessandro Arzilli
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
Oleksandr Redko
b4cfc8f6c7 tests: calling os.Exit in TestMain is not required (#3856) 2024-11-12 08:03:50 -08:00
Alessandro Arzilli
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
lrzlin
75c41f2b64 delve: add linux-riscv64 support (#3785) 2024-10-11 12:34:25 -07:00
Oleksandr Redko
8c645a32d7 pkg/proc: simplify tests by using errors.As (#3818) 2024-10-01 08:54:11 -07:00
Alessandro Arzilli
64f3d34663 proc: move stepping test to their own file (#3784)
Move all tests of the functionality of proc.next,
proc.(*TargetGroup).Next, proc.(*TargetGroup).Step,
proc.(*TargetGroup).StepOut to their own test file.
2024-07-19 21:29:56 -07:00
Alessandro Arzilli
c1366e90cc proc: fix bug with range-over-func stepping (#3778)
Set a breakpoint on the return address of the current function, if it's
a range-over-func body, and clear the stepping breakpoints for the
current function (except the entry one) when its hit.

Without this what can happen is the following:

1. the range-over-func body finishes and returns to the iterator
2. the iterator calls back into the range-over-func body
3. a stepping breakpoint that's inside the prologue gets hit

Updates #3733
2024-07-14 21:27:47 -07:00
Alessandro Arzilli
abad6bb97e proc: use .closureptr for stepping through range-over-func statements (#3763)
* proc: use .closureptr for stepping through range-over-func statements

Uses special variables .closureptr and #yieldN to correctly identify
the parent frame of a range-over-func body closure call.

Updates #3733

* fix
2024-07-11 10:26:38 -07:00
Oleksandr Redko
b791f91c0e pkg/dwarf/line: use t.Logf instead of fmt.Printf in tests (#3772) 2024-07-11 10:19:09 -07:00
Oleksandr Redko
7a801c440b *: remove redundant lines at the start/end of block (#3773) 2024-07-11 13:54:55 +02:00
Alessandro Arzilli
608eaa3d7c proc: support stepping through range-over-func statements with inlining (#3755)
Extends support for stepping through range-over-func statement to
programs compiled with inlining enabled.

Updates #3733
2024-07-01 11:22:59 -07:00
Alessandro Arzilli
ed2960b01c proc: initial support for expressions with range-over-func (#3750)
Supports viewing local variables and evaluating expressions correctly
when range-over-func is used.
The same limitations that the previous commit on this line had still
apply (no inlining, wrong way to identify the range parent in some
cases).

Updates #3733
2024-06-24 13:04:06 -07:00
Oleksandr Redko
0d0d2e1b16 *: replace fmt.Errorf with errors.New (#3752) 2024-06-20 21:50:18 +02:00
Alessandro Arzilli
4b628b81cb proc: refactor identifier evaluation for range-over-func support (#3738)
Because of how range-over-func is implemented it is difficult to
determine the set of visible local variables during expression
compilation (i.e. it is difficulto to keep the HasLocal function
correct).
This commit moves that logic from expression compilation to expression
evaluation.

Updates #3733
2024-06-14 14:36:11 -07:00
Alessandro Arzilli
cce54c0992 proc: fix TestRangeOverFuncNext (#3740)
Fix TestRangeOverFuncNext on non-linux operating systems, on arm64 and
when the build mode is PIE.
2024-06-14 14:32:34 -07:00
Alessandro Arzilli
06053a7e4b proc: fix bug with stack watchpoints going out of scope (#3742)
When stack watchpoints go out of scope simultaneously they can hide (or
duplicate the effect) of other breakpoints (including other watchpoints
going out of scope) that are placed on the same physical memory
location.

This happens because we delete the watchpoint-out-of-scope breakpoint
while we are evaluating hit breakpoints, mangling the breaklets list.

This commit moves breakpoint deletion out of the
watchpoint-out-of-scope condition, delaying it until all hit
breakpoints have been evaluated.

Also fix bug where on amd64 if all four watchpoints are in use the last
one is not checked.

Fixes #3739
2024-06-12 12:37:04 -07:00
Alessandro Arzilli
2ec2e831d6 proc: initial stepping with range-over-func support (#3736)
Initial support for stepping in functions that use the new
range-over-func statement in go1.23.
Does not support:

- inlining
- viewing variables of the enclosing function from a range-over-func
  body closure
- the correct way to find the enclosing function from a range-over-func
  body closure (but it should work most of the time).

Updates #3733
2024-06-04 12:52:30 -07:00
Oleksandr Redko
8347f97c00 *: remove redundant lines at the start/end of block (#3730) 2024-05-20 14:16:22 -07:00
Derek Parker
bba7547156 pkg/proc: fix watchpoints on macos (#3703)
It seems newer MacOS kernels are sending mach exceptions for watchpoints
which contain the hardware register number as opposed to the address
which triggered the exception. Also, ARM64 seems to have switched to
sending _EXC_I386_SGL as medata[0] for this exception type.
2024-04-29 14:06:32 +02:00
Alessandro Arzilli
fb430eac5e proc: change 'step' command so that it steps through go statements (#3686)
Change 'step' command so that when stepping into a 'go statement' the
debugger will stop on the newly created goroutine, instead of just
stepping over the go statement.
2024-04-09 15:53:23 +02:00
Alessandro Arzilli
bbcea6b9f4 proc: support reading captured variables of closures (#3682)
Supports showing captured variables for function closures on versions
of Go that export informations about the closure struct (Go >= 1.23)

Fixes #3612
2024-04-07 21:36:50 -07:00
Derek Parker
6f1f549c71 pkg/proc: defend better against missing DWARF (#3695)
The `scope.Locals` function did not have any guard checks against missing DWARF information.
This patch adds a check, which likely will need to be added to other functions as well.
2024-04-05 11:46:39 +02:00
Derek Parker
29aa2ea8c9 pkg/terminal,pkg/proc: Implement next-instruction (#3671)
The next-instruction (nexti) command behaves like
step-instruction (stepi) however, similar to the
`next` command it will step over function calls.
2024-02-28 09:28:33 +01:00
Derek Parker
4a72c523be pkg/proc: remove usage of gore dependency (#3664) 2024-02-21 12:10:41 +01:00
Alessandro Arzilli
0d35295491 proc: skip TestDebugStripped on development versions of Go (#3642)
The test can never work on development versions of Go.
2024-01-24 09:18:51 -08:00
Alessandro Arzilli
4ed69d0280 proc: fix stacktrace frame after runtime.sigpanic (#3638)
The first frame after sigpanic didn't execute a call so we shouldn't
decrement the PC address to look up its location.

Fixes #3634
2024-01-17 16:31:04 -08:00
Alessandro Arzilli
1a1e215fac TeamCity: speed up ppc64le CI (#3622)
The builder is currently spending 15 to 20 minutes installing gcc and
upgrading packages every time we run the tests.
Because of this the build fails sometimes by running out of time.
This change reduces that to 5 minutes by:

* switching from curl to wget (which seems to have fewer dependencies)
* not installing gcc on ppc64le
* skipping tests that depend on gcc or other binutils
2024-01-09 14:13:00 -08:00
Derek Parker
050a108c3c *: Update gore dep for 1.22 (#3611) 2023-12-27 18:28:56 +01:00
Alessandro Arzilli
c4a10ecb16 tests: fix tests in go1.22 (#3583)
Go1.22 has changed some line number assignments. The new line number
assignments are still valid however some tests in dap relied on them
being different and broke as a result. This commit fixes those tests
and makes them less brittle.
Also disables TestDebugStripped and TestDebugStripped2 temporarily on
1.22.
2023-11-27 14:59:55 -08:00
Alessandro Arzilli
4ed41e9060 proc: fix TestIssue1101 flake (#3585)
If the target process exits and receives a signal at the same time and
we receive the signal first we should call waitpid again to read the
target's exit status.

This also fixes a nil pointer dereference when trapWaitInternal returns
an error, this fix is probably incomplete but I wasn't able to
reproduce its circumstances after 30000 runs of TestIssue1101 to
properly address it.
2023-11-27 08:58:27 -08:00
Derek Parker
6e8e1cee9b pkg/proc: use gore to obtain info from stripped binaries (#3577)
This patch switches from using a forked version of one of the libraries
of goretk/gore to using the module directly. This is possible now that
certain functionality has been exposed / fixed within that module making
it usable for Delve.
2023-11-23 09:12:10 +01:00
Alessandro Arzilli
a8ee87e473 *: remove checks for TRAVIS env variable (#3568)
We had a few checks left over for the TRAVIS variable that detected if
we were running under the TravisCI build system.
This variable hasn't been set since 2020.
2023-11-16 10:42:41 -08:00
Derek Parker
0466226b1d pkg/proc: unskip passing tests and reorganize (#3561) 2023-11-12 12:01:21 +01:00
Derek Parker
d186e14fd9 pkg/proc: improve support unwinding from sigpanic (#3559)
See: https://github.com/golang/go/issues/63862

Fixes #3545
2023-11-10 15:32:20 +01:00
Alessandro Arzilli
438d036fed TeamCity: reupgrade linux/386 builder to Go 1.21 (#3560)
The bug that prevented updating to linux/386 has been fixed upstream,
update linux/386 to 1.21 in the test matrix and fix some broken bugs.
2023-11-09 17:38:37 -06:00