Commit Graph

2731 Commits

Author SHA1 Message Date
Stefan Haller
f8c8b33da3
Show pprof labels in thread names (#3501)
* Add pprofLabelForThreadNames config

The config is a string value that indicates the key of a pprof label whose value
should be shown as a goroutine name in the threads view.
2023-12-04 15:44:10 +01:00
Alessandro Arzilli
f558ca4f32
service/dap: fix close on closed channel panic (#3573)
Fixes close on closed channel panic that happens sporadically on many
of the dap tests (for example 1 ~ 3% of the times on
TestStepInstruction).
2023-12-04 15:40:59 +01:00
Artem Khvastunov
15142ac3d6
add all branches but PRs to filter (#3590) 2023-11-29 12:23:34 +01:00
Michael Pratt
d8ed28ff35
all: run go mod tidy (#3589)
Fixes #3588.
2023-11-28 17:01:56 -08: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
Artem Khvastunov
4e2d63fa26
update TeamCity DSL version to 2023.05 and remove tip configurations from Aggregator (#3581) 2023-11-23 16:04:46 +01:00
Artem Khvastunov
e96c50e99f
add missing import in TeamCity DSL (#3580) 2023-11-23 12:27:50 +01: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
Derek Parker
08eced2f1f
CI: update teamcity settings (#3579)
Fix a build config error and add a scheduled trigger
to perform nightly builds.
2023-11-23 09:07:41 +01:00
Oleksandr Redko
f1daaeb1b0
pkg,service/dap: use switch instead of ifs (#3576) 2023-11-22 09:07:08 -08:00
Artem Khvastunov
60a9014dcf
CI: Extract tip builds into a separate sub-project (#3578)
* extract tip into a separate project

* exclude pull request from tip builds
2023-11-22 09:05:56 -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
03e8dd77bf
TeamCity: remove windows/arm64 builders from chain (#3572)
We haven't had a builder for 2 months so it can be declared legally
dead.
2023-11-19 18:10:43 -08:00
Oleksandr Redko
c17e258895
service: fix typo in variable name (#3575) 2023-11-19 07:32:03 +01: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
Oleksandr Redko
938cb6e9d8
pkg,service: remove unnecessary convertions (#3564) 2023-11-14 16:36:55 +01:00
guangwu
e6fdc1052a
chore: use strings.Contains instead (#3562) 2023-11-14 10:16:39 +01: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
Stefan Haller
aec354cd0b
Shorten variable types (#3535)
* Add ShortenType function

Taken from

  https://github.com/aarzilli/gdlv/blob/master/internal/prettyprint/short.go

with kind permission by @aarzilli.

* Shorten type names in variable values

The variables view in VS Code is a lot easier to read if long type names are
shortened in much the same way as we shorten them for functions in the call
stack view.

We only shorten them in the value strings; the Type field of dap.Variable is
kept as is. Since this only appears in a tooltip, it isn't a problem to have the
full type visible there.
2023-11-09 10:15:25 +01:00
Oleksandr Redko
d6f215b27b
pkg,service: Remove redundant build constraints (#3556) 2023-11-06 16:22:50 +01:00
Oleksandr Redko
13d6cd4e0d
*: Correct spelling mistakes (#3555) 2023-11-06 07:55:44 -06:00
Derek Parker
c727ec52c5
service: fix a bunch of linter warnings from GoLand (#3551) 2023-11-05 17:36:37 +01:00
Derek Parker
4d1c1f3a36
*: update dependencies (#3552) 2023-11-04 17:07:55 +01:00
Alessandro Arzilli
e06a1163d0
proc: add regression test for issue #3548 (#3553)
Issue #3548 describes a bug in the compiler which was fixed by commit
505e50b. But this case wasn't covered by our current tests (obviously)
and the fix in the compiler looks accidental so it's worth adding a
test for it.

Fixes #3548
2023-11-04 10:31:03 -05:00
Derek Parker
ff7a9f9f9a
cmd: fix a bunch of linter warnings from GoLand (#3550) 2023-11-03 17:22:02 +01:00
Derek Parker
6c77c35586
pkg/proc: add inline function support for stripped binaries (#3549)
This patch adds support for listing and setting breakpoints on inlined functions within stripped binaries. It uses a forked version of `debug/gosym` copied from golang.org/x/vuln/internal/vulncheck/internal/gosym which adds support for parsing the inline tree of the pclntab section. Parsing this section requires knowing the offset of the "go:func.*" symbol, which is not present in stripped binaries via the ``.symtab` section so instead, we search the `.noptrdata` section which contains `runtime.moduledatap` which contains the value of that missing symbol, which we then can use to find the inline tree for a given function.

Given all this we parse the inline tree for each function we find, and then add that information the the appropriate `Function` contained in `bi.Functions`, using a relatively empty `Function` struct as what would be the abstract origin.
2023-11-03 10:00:49 +01:00
Alessandro Arzilli
0631684f99
proc/native: wherever we check for exited we should also check detached (#3547)
Only Linux and Windows are affected but it's better to do this for all
platforms for consistency.
2023-10-31 10:18:46 -07:00
Alessandro Arzilli
96a6db9d36
*: release 1.21.2 (#3546)
Thank you @suzmue, @hyangah, @4a6f656c and @alexandear.
2023-10-31 10:15:52 -07:00
Alessandro Arzilli
2187c75fb5
proc,service/dap,proc/gdbserial: fixes for debugserver --unmask-signals (#3541)
- fix TestRefreshCurThreadSelGAfterContinueOnceError and TestBadAccess
  to work when debugserver has --unmask-signals
- when a fatal signal is received while singlestepping delay its
  delivery until the subsequent continue, otherwise debugserver will get
  stuck completely (fixes TestNilPtrDerefInBreakInstr)
2023-10-30 09:19:23 -07:00
Derek Parker
cde14a46f1
*: Add explicit code of conduct (#3540)
Adds a callout to the standard Go code of conduct in the CONTRIBUTING.md doc.
2023-10-27 15:07:39 +02:00
Derek Parker
1e2338d233
proc: allow evaluator to reference previous frames (#3534)
Fixes #3515
2023-10-24 18:57:39 +02:00
Alessandro Arzilli
b9b553bccd
service/api: use bitfield for prettyprint flags (#3536)
Use a bitfield for the internal flags used by the prettyprinting code.
2023-10-24 09:35:37 -07:00
Alessandro Arzilli
d4104a6bcc
proc: remove expr evaluation goroutine from EvalExpressionWithCalls (#3532)
We have used a goroutine to keep track of some of the expression
evaluation status across target resumes during call injections.
Now that the expression interpreter has been rewritten to use a stack
machine we can move what little state is left into the stack machine
and get rid of the goroutine-and-channel mechanism.
2023-10-23 12:29:04 -07:00
Alessandro Arzilli
90a1571f88
CI: update staticcheck version (#3533)
Update staticcheck version and re-enable TestStaticcheck on Go 1.22.
2023-10-20 10:05:58 -07:00
Alessandro Arzilli
909add7894
proc: add min and max builtins (#3530)
Go 1.21 added two new builtins: min and max. Add them to the expression
evaluator.
2023-10-19 11:05:36 -07:00
Oleksandr Redko
0761d37c53
proc: fix comment typos (#3531) 2023-10-19 11:04:31 -07:00
Alessandro Arzilli
2c700230de
proc: use stack machine to evaluate expressions (#3508)
* proc: use stack machine to evaluate expressions

This commit splits expression evaluation into two parts. The first part (in
pkg/proc/evalop/evalcompile.go) "compiles" as ast.Expr into a list of
instructions (defined in pkg/proc/evalop/ops.go) for a stack machine
(defined by `proc.(*evalStack)`).
The second part is a stack machine (implemented by `proc.(*EvalScope).eval`
and `proc.(*EvalScope).evalOne`) that has two modes of operation: in the
main mode it executes inteructions from the list (by calling `evalOne`), in
the second mode it executes the call injection protocol by calling
`funcCallStep` repeatedly until it either the protocol finishes, needs more
input from the stack machine (to set call arguments) or fails.

This approach has several benefits:

- it is now possible to remove the goroutine we use to evaluate expression
  and the channel used to communicate with the Continue loop.
- every time we resume the target to execute the call injection protocol we
  need to update several local variables to match the changed state of the
  target, this is now done at the top level of the evaluation loop instead of
  being hidden inside a recurisive evaluator
- using runtime.Pin to pin addresses returned by an injected call would
  allow us to use a more natural evaluation order for function calls, which
  would solve some bugs #3310, allow users to inspect values returned by a
  call injection #1599 and allow implementing some other features #1465. Doing
  this with the recursive evaluator, while keeping backwards compatibility
  with versions of Go that do not have runtime.Pin is very hard. However after
  this change we can simply conditionally change how compileFunctionCall works
  and add some opcodes.

* review round 1

* review round 2
2023-10-17 11:21:59 -07:00
Alessandro Arzilli
788df884e6
proc: use DW_AT_trampoline to detect auto-generated code (#3528)
Use the trampoline attribute to detect auto-generated code. This fixes
a bug where stepping into a method of a generic type called through an
interface will take the debugger into an auto-generated wrapper that
does not have a dictionary and using next will step out of the wrapper.

Fixes a bug reported on the #delve channel of the gophers slack server.
2023-10-16 08:57:33 -07:00
Joel Sing
04bb7fda33
proc/native: use cgo instead of C for freebsd (#3529)
There is no benefit to having a small part of the freebsd backend
implemented in C, rather than using cgo. While here, add a missing
call to procstat_close and check the return value of
procstat_getpathname.
2023-10-16 08:56:17 -07:00
Alessandro Arzilli
9986a9845f
service/test: disable TestClientServer_chanGoroutines with rr backend (#3492)
It doesn't work with rr because it uses runtime.Breakpoint to stop.
2023-10-13 10:55:24 -07:00
Alessandro Arzilli
20350611ce
proc: implement follow exec mode on Windows (#3507) 2023-10-13 16:51:11 +02:00
Upils
70f21c9f86
Use a valid timezone in tested binary (#3527)
With recent changes to debian/ubuntu tzdata package, the Mexico/BajaSur is not valid anymore (not present by default). It is now present in the tzdata-legacy package, which is not a essential package. Without this timezone, the call to time.LoadLocation() will send a nil location, which will provoke a panic in time.ParseInLocation(). This change uses the underlying associated timezone America/Mazatlan.
2023-10-12 12:24:49 +02:00
Derek Parker
6185e673c2
pkg/terminal: support vscode in edit command (#3524) 2023-10-09 17:58:21 +02:00
Hyang-Ah Hana Kim
f90ede4653
service/dap: fix bugs in stdout/stderr handling (#3522)
Fixes bugs introduced in v1.21.1

* Avoid dropping the last bytes from stderr/stdout when Read returns an
  error. (Read returns n>0). And skip sending Output event if Read
  returns n==0.

* Fix the bug that drops all stdout in the existing noDebug mode.

For #3253
2023-10-09 08:27:32 -07:00