Commit Graph

1100 Commits

Author SHA1 Message Date
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
Archana Ravindar
89123a0000
pkg/terminal,service/debugger: Support to add a new suboption --follow-calls to trace subcommand (#3594)
* rebasing on master to implement --followcalls

* in progress changes to enable --followcalls

* rebase to master: modified function to add children to funcs array

* modify main traversal loop

* added tests to check different scenarios

* added tests to check different scenarios

* added tests to check different scenarios

* add test to check for overlapping regular expression

* modified type of strings array as a return only

* changed depth to a simple integer instead of a global map

* avoid calling traverse on recursive calls

* Added tests for various call graphs to test trace followfuncs

* Added tests for various call graphs to test trace followfuncs

* Added tests for various call graphs to test trace followfuncs

* made auxillary changes for build to go through for new option follow-calls

* Add support to print depth of the function calls as well

* Added two sample output files for checking

* Bypass morestack_noctxt in output for verification testing

* Corrected newline error by adding newlines only if the line does not match morestack_noctxt

* Added more tests

* Cleanup

* Updated documentation

* fixed error message in fmt.Errorf

* Fixed result of Errorf not used error

* Addressing review comments to fix depth reporting and other issues

* dont invoke stacktrace if tracefollowcalls is enabled, compute depth from main regex root symbol than main.main

* Addressing a part of review comments

* Added changes to allow deferred functions to be picked up for tracing

* Fix issue to avoid printing stack for a simple trace option

* Moving most tests to integration2_test.go and keeping only one in dlv_test.go

* Moving most tests to integration2_test.go and keeping only one in dlv_test.go

* Adding panic-defer test case

* Moved rest of the tests to integration2_test.go

* addressing review comments: folding Functions and FunctionsDeep, reducing branches by using depth prefix, wrap using %w and other comments

* Optimize traversal and parts of printing trace point function and modify trace output layout
and adjust tests accordingly

* Resolved error occurring due to staticcheck

* Implemented traversal algorithm using breadth first search

* Addressing review comments on the breadth first search implementation and
other comments

* Inline filterRuntimeFuncs and remove duplicate initialization
2024-06-12 12:35:48 -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
Alessandro Arzilli
40670aadc2
proc/gdbserial: add environment variables to configure rr invocation (#3726)
Adds two environment variables to configure rr invocations.

Fixes #3670
2024-05-24 11:33:23 -07:00
Oleksandr Redko
8347f97c00
*: remove redundant lines at the start/end of block (#3730) 2024-05-20 14:16:22 -07:00
Oleksandr Redko
468727c34d
pkg/terminal: remove deprecated starlark global options (#3722) 2024-05-20 08:35:30 -07:00
Alessandro Arzilli
7c7265f4e6
gdbserial: fixes for rr 5.7.0 (#3718)
The following fixes have been applied to make delve work with rr 5.7.0

- added a new launch prefix to exclude from stderr output
- allow the thread selection packet to be sent for 'c' commands even
  when the stub supports thread suffixes, because the specification is
  unclear over what should be done with bc and bs packets with thread
  suffixes.
- changed the way qRRCmd are escaped and added a thread selector to
  them to match changes to rr codebase
2024-05-16 16:07:20 -07:00
Alessandro Arzilli
2331fa8f8a
gdbserial: update path of lldb protocol extension documentation (#3727) 2024-05-15 11:45:53 -07:00
Derek Parker
4f28742da6
pkg/proc/gdbserial: optimize gdbwire backend (#3715)
This change optimizes the gdbwire backend by reducing the number of
round trips we have to make to debugserver. It does this by using the
jstopinfo packet to only query threads which we know to have a stop
reason, and it also uses the registers returned by the 'T' packet
to avoid issuing a bunch of 'p' packets to get the register values.
2024-05-15 09:48:38 +02: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
Archana Ravindar
8c07c984e8
pkg/terminal: Add function name to return tracepoints (#3712) 2024-04-23 14:22:17 -07:00
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