Commit Graph

1087 Commits

Author SHA1 Message Date
John Howard
baf68e0e79
rr: fix gdb parsing (#3705)
* rr: fix gdb parsing

Attempt to fix https://github.com/go-delve/delve/issues/3704

* Fold into one branch
2024-04-19 10:38:01 -07:00
Alessandro Arzilli
64a46abd81
proc: generalize escapeCheck and allocString (#3687)
* proc: generalize escapeCheck and allocString

Generalizes the function for checking for escaping pointers so that it
can be used to iterate on all pointers of a variable.
Also generalizes the string allocation opcodes so that in the future we
can use it to call other special runtime functions (for example: map
access, channel send/receive, etc).

* review changes
2024-04-19 08:44:47 -07:00
Oleksandr Redko
95e2a57b92
pkg/terminal: remove duplicated word (#3707) 2024-04-18 08:56:52 -07:00
Derek Parker
6d3556784d
pkg/terminal: clear erroneous name setting on postfix if (#3702)
When a breakpoint was set on the current line via `break if i ==3` style
condition setting, we would erroneously set the breakpoint name to be
'if'.
2024-04-15 10:07:36 +02:00
Alessandro Arzilli
2e88b7ead3
tests: fix tests on Go 1.23 (#3697)
* Adjust rtype.go script to handle constants moved to internal/abi from
  runtime
* Remove tests in service/dap/server_test that relied on knowledge of
  the internal layout of channels.
2024-04-11 09:40:57 -07: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
Derek Parker
689c86355b
pkg/terminal: allow postfix if for breakpoint conds (#3693)
Allows for a user to specify the breakpoint condition directly
when creating the breakpoint. The new syntax looks like the
following:

```
break <name> <locspec> [if <expression>]
```

Also updates docs to include more examples and locspec description
instead of directing users to the online / source documentation.
2024-04-09 15:15:38 +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
Alessandro Arzilli
bae4dfbc4c
proc,go.mod: update x/sys remove KeepAlive calls (#3680)
* Cirrus-CI: update to FreeBSD 13.3

* proc,go.mod: update x/sys remove KeepAlive calls

Update version of golang.org/x/sys to the latest version and remove
calls to runtime.KeepAlive calls that were added to the FreeBSD backend
to work around an issue in the version of x/sys that we were using.
2024-03-04 11:36:46 -08:00
Alessandro Arzilli
40b58f9643
proc: catch panics when reading debug info for stripped executables (#3678)
Adds a recover to the functions reading debug info from the go runtime
data structures for stripped executables.

This function is best-effort and can sometimes fail in weird ways,
instead of crashing recover any panic and turn them into errors.

Fixes #3650
2024-03-04 09:17:12 -08:00
Oleksandr Redko
fdb732b54e
dwarf/loclist: remove impossible condition (#3677) 2024-03-04 09:15:54 -08:00
Oleksandr Redko
649e61e415
proc/evalop: remove no longer needed old Go files (#3676) 2024-03-04 09:15:00 -08:00
Derek Parker
d688d4c83b
pkg/terminal: print breakpoint number on stop (#3675) 2024-02-28 15:49:33 +01: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
Alessandro Arzilli
490869e75f
elfwriter: add WriteSectionHeaders (#3666)
Add ability to write out section headers to elfwriter.
2024-02-23 14:14:28 -08:00
Alessandro Arzilli
5bd835a801
*: misc fixes for go1.23 (#3663)
- skip staticcheck on go1.23 for now
- fix reading interface values in go1.23
- sync list of waitreasons from go1.23
2024-02-22 11:35:15 -08:00
Alessandro Arzilli
ff2f69343e
dwarfbuilder: fix makeAbbrevTable (#3665)
It did not terminate the section with the required 0 byte.
2024-02-22 11:33:44 -08:00
Alessandro Arzilli
26799555e5
*: release version 1.22.1 (#3662)
Thank you @ardnew, @muggle-nil, @michaelmerg
2024-02-21 12:29:06 -08:00
Derek Parker
4a72c523be
pkg/proc: remove usage of gore dependency (#3664) 2024-02-21 12:10:41 +01:00
Alessandro Arzilli
8df2b6bedb
terminal: add prompt color option (#3648)
Add option to configure prompt color.

Fixes #3603
2024-02-07 11:07:11 -08:00
Alessandro Arzilli
9405996b5d
terminal: add color highlighting to stacktraces (#3649)
Adds configurable highlighting for function names and filenames in stack traces.

Fixes #720
2024-02-07 11:06:30 -08:00
Alessandro Arzilli
6cd0b70b30
proc: if a reslice operator is used load the whole slice (#3623)
When the users uses a reslice operation load the whole resliced
variable, ignoring the MaxArrayValues setting.
Only apply this when the 'high' part is specified and a literal and the
'low' part is either unspecified or a literal.

Fixes #3600
2024-01-24 09:21:59 -08:00
Alessandro Arzilli
ef20fbbf12
proc/gdbserver: clean up rr directory on detach (#3570)
We used to autoremove the trace recorded by rr but as a result of
various refactorings done to implement follow exec mode this broke.
Restore the functionality.

Also remove the _fixtures/testfnpos.go file which is autogenerated
during testing.
2024-01-24 09:21:20 -08: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
fb4a8fb171
evalop: fix name of executeOp function in test (#3643) 2024-01-24 09:18:18 -08:00
Alessandro Arzilli
664bd95d24
proc/native: add support sentinel for FreeBSD with cgo disabled (#3636)
Adds a support sentinel file for building on FreeBSD with cgo disabled.
Makes the build error for FreeBSD easier to understand.

Fixes #3630
2024-01-19 12:05:53 -08:00
Alessandro Arzilli
1b201c3184
proc/native: remove dead code in nonative_darwin.go (#3637)
Removes unnecessary code from nonative_darwin.go
2024-01-17 16:31:27 -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
88380654fe
proc: fix dynamic library loading with musl loader (#3621)
With the glibc loader the link map entry for the static executable has
an empty name field and address equal to 0x0. This case was already
handled by the check in bininfo.go AddImage for names to be valid
paths.
With the musl loader however the first entry, corresponding to the
static executable, has a valid path with address equal to 0x0, since we
record a real address for the image corresponding to the static
executable this results in having two entries for the executable when
musl is used to link go programs.

Change the code scanning the debug link map so that the first entry is
skipped if it has address equal to zero.

Fixes #3617
2024-01-10 07:33:35 -08:00
Alessandro Arzilli
bf627d0f7d
proc: fix TestCondBreakpointWithFrame flakes on 1.22rc1 (#3624)
The flake manifests as an error where the variable i can not be found in
frame 1 and happens in go1.22rc1 between 0.1% and 0.5% of the time (it is highly dependent on CPU contention)
This problem is caused by the new code in evalop.PushLocal referencing the
stale value of SelectedGoroutine. This happens because:

-  evalop.PushLocal calls ConvertEvalScope
- ConvertEvalScope calls FindGoroutine
- FindGoroutine checks the value of selectedGoroutine

When breakpoint conditions are evaluated both the value of selectedGoroutine
and currentThread are stale because we can only set their definitive value
*after* all breakpoint conditions have been evaluated.

The fact that it only happens in 1.22rc1 is coincidental, it's probably
caused by the fact that 1.22rc1 migrates goroutines between threads more in
this particular circumstance.

This commit fixes the problem in two ways:

1. selectedGoroutine and currentThread are given temprorary non-stale values
   before breakpoint conditions are evaluated
2. evalop.PushLocal is changed so it takes a stack trace of the current
   thread rather than resolving it through the selected goroutine.

Either one would suffice however I think we should do both, (2) ensures that
the runtime.frame(n).var will work even if the current thread is not running
any goroutine and (1) ensures that we don't accidentally reference a stale
selectedGoroutine in the future.
2024-01-10 06:53:16 -08:00
Alessandro Arzilli
f8de498d77
terminal: add paging to print, vars, args and locals (#3620)
Add automatic paging to the output of print, vars, args and locals.

Fixes #3615
2024-01-09 14:13:37 -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
Alessandro Arzilli
31a3c0de97
*: release version 1.22.0 (#3606)
Thank you @alexandear, @stefanhaller, @testwill
2023-12-29 14:48:07 -08:00
Derek Parker
050a108c3c
*: Update gore dep for 1.22 (#3611) 2023-12-27 18:28:56 +01:00
Alessandro Arzilli
ba403e365d
proc: fix TestPackageRenames on go1.22 on linux/386 (#3610) 2023-12-26 10:17:25 -08:00
Alessandro Arzilli
a9c67f1548
goversion: include pre-releases in VersionAfterOrEqual check (#3607)
Change VersionAfterOrEqual(x, A, B) to return true for pre-releases of
version A.B. This is what it did before, it was broken when goversion
was changed to support the new version format.
2023-12-26 10:15:43 -08:00
Alessandro Arzilli
5b52958909
proc: fix ppc64 arch name check (#3608)
The name of the ppc64 architecture is ppc64le not ppc64.
2023-12-26 10:14:27 -08:00
Alessandro Arzilli
66fbe30586
teamcity,version: add 1.22 to supported versions and CI matrix (#3601) 2023-12-20 15:31:30 -08:00
Alessandro Arzilli
57dad9342a
proc: make some type casts less counterintuitive
* proc: make some type casts less counterintuitive

The interaction of type casts with load configuration is sometimes
counterintuitive. This commit changes the way it is performed so that
when converting slices to strings and vice versa the maximum size
corresponding to the target type is used (i.e. MaxStringLen when
converting slices to strings and MaxArrayValues when converting slices
to strings).

This doesn't fully solve the problem (conversions to []rune are
problematic and multiple chained type casts will still be confusing)
but removes the problem for the majority of practical uses.

Fixes #3595, #3539
2023-12-12 11:43:41 -08:00
Derek Parker
dda8f693e6
*: Use forked goretk/gore module (#3597)
This allows us to update this dependency on our schedule which is important because the module relies on manually updating the known list of Go versions to function correctly. Forking allows us to keep this up to date ourselves and possibly create a new system to prevent having to perform this manual step in the future.
2023-12-12 10:13:32 +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
37db3e8e68
proc: skip trapthread for harcoded breakpoints after manual stop (#3582)
When using debugserver as a backend a manual stop request can end up
looking like an hardcoded breakpoint if the thread that receives the
stop request happens to be stopped right after a hardcoded breakpoint
(and the space between functions is filled with hardcoded breakpoints).
When creating hardcoded breakpoints we should ignore the trapthread if
a manual stop has been requested.

This problem made TestSetBreakpointWhileRunning and
TestSetFunctionBreakpointWhileRunning fail on macOS between 1.7% and 6%
of the time.

TestIssue1376 in rr_test.go used to pass accidentally, the stop when
the start of the recording was reached was mistaken for a hardcoded
breakpoint.
2023-11-27 09:17:58 -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
Oleksandr Redko
f1daaeb1b0
pkg,service/dap: use switch instead of ifs (#3576) 2023-11-22 09:07:08 -08:00
Alessandro Arzilli
721a0d7c9c
proc/gdbserial: refactor parsing of key-value pairs from gdb protocol (#3574)
The gdb remote serial protocol returns in several places a list of key
value pair in the form key1:value1;key2:value2;...;keyN:valueN.
We had ad-hoc parsers for this in three places, this commit
consolidates the parser in a single utility object.
2023-11-20 10:50:37 -08:00
Alessandro Arzilli
a5b03f0623
proc: simplify and generalize runtime.mallocgc workaround (#3571)
Instead of having a different version for each architecture have a
single version that uses an architecture specific list of registers.
Also generalize it so that, if we want, we can extend the workaround to
other runtime functions we might want to call (for example the channel
send/receive functions).
2023-11-20 10:43:15 -08:00
Alessandro Arzilli
650f2d5e23
terminal: clear substitute path rules cache when config is used (#3567)
Fixes #3565
2023-11-16 10:43:23 -08: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