Commit Graph

170 Commits

Author SHA1 Message Date
Alessandro Arzilli
00df758d57
proc/native: fix FreeBSD backend (#3224)
- use PT_SUSPEND/PT_RESUME to control running threads in
  resume/stop/singleStep
- change manual stop signal from SIGTRAP to SIGSTOP to make manual stop
  handling simpler
- change (*nativeProcess).trapWaitInternal to suspend newly created
  threads when we are stepping a thread
- change (*nativeProcess).trapWaitInternal to handle some unhandled
  stop events
- remove misleading (*nativeProcess).waitFast which does not do
  anything different from the normal wait variant
- rewrite (*nativeProcess).stop to only set breakpoints for threads of
  which we have received SIGTRAP
- rewrite (*nativeThread).singleStep to actually execute a single
  instruction and to properly route signals
2022-12-20 09:54:16 -08:00
Quim Muntal
e5006c105c
Test windows/arm64 pipeline (#3200)
* Test windows/arm64 pipeline

* update build script to support windows/arm64

* skip TestLaunchRequestWithRelativeExecPath is symblink can't be created

* partially fix and skip TestCgoStacktrace

* update backend health docs

* update

* log test output

* skip starbind test on windows arm64

* skip starbind test on windows arm64

* skip rtype test on windows arm64

* skip pie backend tests on windows/arm64

* fix tests

* skip function calls test on windows/arm64

* fix tests

* revert hardware breakpoint test relax

* add pie test clarification

* skip symlink test only on windows

* skip TestStepConcurrentDirect

* readd exp.winarm64

* fix param

* add exp.winarm64 tags

* skip TestGeneratedDoc on winarm64
2022-12-05 15:21:52 -08:00
Alessandro Arzilli
6bda7085c7
proc: allow type casts between compatible types (#3149)
Go allows some type casts when the underlying types are the same.
Conform to that behavior.

Fixes #3130
2022-09-29 10:08:19 -07:00
Suzy Mueller
8a230b7f59
service/dap: show full value when evaluating log messages (#3141)
When evaluating variables in a log message, do not truncate the
string representation.

Updates golang/vscode-go#2447
2022-09-26 10:11:15 -07:00
Suzy Mueller
5170a6e0ff
service/dap: fix indexing bug for maps (#3068)
service/dap: fix indexing bug for maps

There was a bug that cut off the second half of a map, because the
number of variables was not accurately reported to the client.

Fixes golang/vscode-go#2351
2022-07-29 11:58:46 +02:00
Alessandro Arzilli
059406e74f
service/dap: limit disassembly range (#3045)
Due to dyanmically loaded libraries there could be aribitrarily large
gaps in the address space, between functions. Limit the memory size we
are willing to disassemble.

Fixes #3040
2022-07-15 13:29:44 +02:00
Alessandro Arzilli
c412dcdc4f
*: run go1.19 'go fmt' on everything and fix problems (#3031)
Go 1.19 also formats doc comments according to the new godoc syntax.
Some of our comments, especially unexported symbols did not conform to
the godoc syntax and therefore are mangled by 'go fmt'.

This PR runs 'go fmt' from go1.19 on everything and manually fixes the
problems.

See also:
	https://github.com/golang/proposal/blob/master/design/51082-godocfmt.md
2022-06-17 10:08:11 -07:00
polinasok
5bc8460328
dap: add MultiClientCloseServerMock and fix test shutdown leak (#3011)
Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
2022-05-18 10:33:06 -07:00
polinasok
705ab206cd
dap: remote attach must not use terminateDebuggee in single-client launch mode (#2995) 2022-05-18 12:23:47 +02:00
Alessandro Arzilli
2b97231e30
proc,service: pretty print time.Time variables (#2865)
Fixes #999
2022-03-25 13:59:57 -07:00
polinasok
b5f60db954
service/dap: support terminateDebuggee option for attach only (#2940)
* service/dap: support terminateDebuggee option for attach only

* Update dlv_test

Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
2022-03-22 07:19:56 -07:00
Alessandro Arzilli
b3e528e4fb
service/dap: deflake DAP tests (#2872)
1. change ExpectOutputEventProcessExited to accept -1 exit status, this
   is a real problem on linux but we don't know how to fix it and we
   already have a test in proc for it.
2. change TestNoDebug_AcceptNoRequestButDisconnect to be less picky
   about message ordering, all message orderings seem to be fine, there
   is no reason to insist on a particular one, since the DAP server is
   unable to actually produce it deterministically.

Fixes #2860
2022-01-19 10:40:54 -08:00
Suzy Mueller
a2927f6117
service/dap: set min/max addresses for invalid instructions (#2832) 2022-01-06 09:02:19 -08:00
Suzy Mueller
66478f21e3
pkg/proc: set stop reason for step instruction (#2828)
* service/dap: move presentationHint to frame from source

* pkg/proc: set stop reason for step instruction
2022-01-06 09:01:47 -08:00
Hyang-Ah Hana Kim
21bdb466f1
dap: support 'Env' attribute for launch requests (#2846)
* dap: support 'Env' attribute for launch requests

Env is applied in addition to the delve process environment
variables. The env setting is done by calling os.Setenv
as early as possible when a Launch request is received.

Prior discussion is in https://github.com/go-delve/delve/pull/2582

In Visual Studio Code, setting null for an environment variable
in launch.json or tasks.json indicates users want to unset
the environment variable. Support the behavior by accepting
nil value.

* dap: Env field itself can be omitempty

* edit comment
2022-01-06 09:01:09 -08:00
Alessandro Arzilli
4a94b3eff2
Updates for go1.18beta1 (#2831)
* go.mod: update golang.org/x/tools to v0.1.8

Fixes TestGeneratedDoc on go1.18

* TeamCity: bump test matrix

Add 1.18 to test matrix. Remove 1.15 from test matrix and from support range.

* proc,tests: update for regabi on arm64 and 386

Make sure that stacktrace registers always contain the PC register of
the current frame, even though the debug_frame rules might not specify
it on architectures that use a link register.
The PC register is needed to look up loclist entries for variable
evaluation.

* goversion: bump maximum supported Go version to 1.18

* proc: disable asyncpreempt on linux/arm64

Asyncpreempt on linux/arm64 can sometimes restart a sequence of
instructions which will make breakpoint appear to be hit twice in some
cases.
2021-12-22 10:26:21 -08:00
Suzy Mueller
a4ac69e87d
service/dap: support goroutine filters in dap (#2759)
* service/dap: filter goroutines

* adjust defaults

* add tests

* remove label change

* fix typos

* send invalidated areas

* respond to review, and allow to clear goroutineFilters
2021-12-07 09:23:55 -08:00
polinasok
d0898e4de1
service/dap: misc remote attach improvements (#2778)
Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
2021-12-07 09:23:26 -08:00
Suzy Mueller
3833c3d029
service/dap: move presentationHint to frame from source (#2810) 2021-12-01 10:57:03 +01:00
polinasok
88dca53e5c
service/dap: fix TestNextParked (#2784)
Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
2021-11-24 13:46:14 -08:00
Suzy Mueller
935161f8bf
service/dap: expose sources command in evaluate request (#2797)
* service/dap: expose sources command in evaluate request
2021-11-24 13:38:37 -08:00
Suzy Mueller
19ce116bb2
service/dap: allow expression evaluation in log messages (#2747)
From the DAP spec:

If this attribute exists and is non-empty, the backend must not 'break' (stop) but log the message instead.
Expressions within {} are interpolated.
This change parses the log messages and stores the parsed values as a format string and list of expressions to evaluate and get the string value of.

Updates golang/vscode-go#123
2021-10-29 19:41:30 -07:00
Suzy Mueller
f8deab8522
service/dap: fix goroutine id selection for hardcoded breakpoints (#2748)
* service/dap: fix goroutine id selection for hardcoded breakpoints

Determining the stopped goroutine id on a breakpoint required
checking for breakpoints since some may be tracepoints. However,
there may be goroutines stopped on hardcoded breakpoints with
no breakpoint. We fix this by checking for runtime.breakpoint or
StopReason=proc.StopHardcodedBreakpoint.
2021-10-29 19:40:16 -07:00
Suzy Mueller
922c4cebd4
service/dap: add config expressions to evaluate requests (#2750)
We want to provide more flexibility for users to make changes to their configurations while the debug session is running. This could be accomplished by creating a custom request, but that were require a new UI as well, and every client of dlv dap to provide its own UI for this. By using the evaluate context, users can use the already existing debug console to change their configurations.

This change includes a refactor of the terminal code in order to share the code with the dap package.

This change provides a very similar to UI as the terminal package, but there are different configuration options that are DAP specific. We plan to use this same mechanism to expose a few other commands including "sources" to help users debug an ineffective substitutePath configuration.
2021-10-29 19:35:13 -07:00
polinasok
b48ceec161
service/dap: improve shutdown logic and test coverage (#2749)
This high-level goal is to push more shutdown logic into Session and not rely Server.Stop() because dap's version of Stop() is different from rpccommon. That means triggering the same shutdown steps in multiple places, so additional safeguards are added to make some of the duplicate steps no-ops to avoid errors, extra logging, etc.

This includes the following changes:

close client conn when request loop in serveDAPCodec exits (to match rpccommon)
exit request loop after processing a disconnect request (instead of relying on next read to fail because conn got closed by triggered Stop(), which is skipped in case of accept-multiclient and is not closed in Stop() in rpccommon)
reset debugger to nil to avoid shutting it down more than once and causing duplicate logging (in case stopDebugSession is called from onDisconnectRequest and Server.Stop or Session.Close as things shut down)
reset binaryToRemove to "" upon removal to avoid duplicate error (in case Close() is called more than once outside of Stop(), which technically is not the case right now)
expand testing for all possible server shutdown triggers
testing for Session-only shutdown as it will be integrated into rpccommon without dap.Server wrapper
updates golang/vscode-go#1830
updates #2328

Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
2021-10-26 10:11:55 -07:00
polinasok
b31565d8aa
service/dap: support JSON-RPC and DAP on the same port from "dlv debug/exec/test/attach" (#2755)
* Support JSON-RPC and DAP on the same port

* Fix test

Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
2021-10-25 12:39:28 -07:00
Alessandro Arzilli
8ebd2d83ae
Misc fixes for test problems (#2751)
* service/dap: remove deadlock in TestLaunchDebugRequest

Fixes #2746

* terminal: fix TestScopePrefix flakiness

When there are more than 10 frames api.PrintStack will prefix the
output with spaces to right justify the frame number, which confuses
TestScopePrefix.

* _scripts: pass -buildvcs for Go 1.18 and later on TeamCity

Go 1.18 will try to stamp builds with the VCS version, this doesn't
work on TeamCity because the checkout isn't a valid repository (but
looks like it).
Pass -buildvcs=false to disable this feature.

* proc: switch to goroutine stack if first frame's func can not be found

If the first frame on the system stack can not be resolved to a
function switch directly to the goroutine stack.
2021-10-18 13:17:47 -07:00
Suzy Mueller
b99d5f5971
service/dap: add option to hide system goroutines (#2743) 2021-10-18 13:13:12 -07:00
Suzy Mueller
99f03597c3
service/dap: add registers configuration for variables response (#2742) 2021-10-15 13:57:50 +02:00
polinasok
c8f6c3a685
service/dap: support remote-attaching to running debugger (#2737)
Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
2021-10-14 10:58:53 -07:00
Suzy Mueller
ce5238944d
service/dap: support disassemble request (#2728)
This adds support for disassembling a region of code using the instructionPointerReference value returned in the stack trace request.
2021-10-14 10:44:36 -07:00
polinasok
64f2200202
service/dap: fix data race for noDebugProcess.ProcessState (#2735)
Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
2021-10-13 18:38:22 -07:00
Suzy Mueller
6c4029c765
service/dap: auto resume execution when setting breakpoints (#2726)
A set breakpoints request could come in while the program is running. For a seamless user experience, the server should set the breakpoint and then continue program execution.

Updates golang/vscode-go#1676
2021-10-13 08:52:06 -07:00
Suzy Mueller
d1c888f22a
service/dap: set instruction breakpoints (#2716)
Support setting instruction breakpoints, this is newly supported in VS Code for the disassembly view.
2021-10-13 08:34:09 -07:00
polinasok
d613f8ec45
service/dap: use constants for testing error codes (#2741)
Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
2021-10-10 15:57:06 +02:00
polinasok
3515be1db1
service/dap: support accept-multiclient shutdown in remote attach mode (#2731)
Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
2021-10-10 15:52:52 +02:00
Suzy Mueller
69634d5d60
service/dap: allow "instruction" stepping granularity (#2713) 2021-10-08 08:58:19 +02:00
polinasok
0baf3b7cf1
service/dap: fix nil dereference when byte array cannot be converted to string (#2733)
Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
2021-10-08 08:57:51 +02:00
polinasok
b3b177dc40
service/dap: rename delveCwd to dlvCwd and clarify comments (#2734)
Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
2021-10-07 11:28:15 +02:00
polinasok
b2a2b32336
service/dap: Dap => DAP (#2739)
Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
2021-10-07 11:27:04 +02:00
Suzy Mueller
b48dd09251
service/dap: log goroutine id and include source info (#2730) 2021-10-05 18:29:46 -07:00
Suzy Mueller
70df230e72
service/dap: merge arguments and local scopes (#2717) 2021-10-05 10:35:14 -07:00
Hyang-Ah Hana Kim
fa10cec9fa
dap: support delveCwd and use a temporary file as default debug binary (#2660) 2021-10-05 13:40:17 +02:00
polinasok
dc2f615c9a
service/dap: refactor the server into two layers (#2729)
* service/dap: refactor the server into two layers

* Add delay before setting debugger in remote tests

Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
2021-10-04 09:13:17 -07:00
aarzilli
cf58ba4380 tests: miscellaneus test fixes for Go 1.18 2021-10-02 15:44:30 +02:00
Suzy Mueller
4b30ba4228
service/dap: add basic log points (#2634)
Log points are special kinds of breakpoints that do not 'break' but instead log a message and then continue. This change implements basic log points that simply log the provided message, without any interpolation.

In order to resume execution after hitting a breakpoint, I added a new lock resumeMu and tracked the running state within the DAP server. resumeMu must be held in order to issue a debugger request that would start execution. This means it can be used to make sure that another goroutine does not resume execution while you are holding the lock.

Most of the synchronization logic is taken from PR #2530

Updates golang/vscode-go#123
2021-09-24 15:22:32 -07:00
Suzy Mueller
e00670b901
service/debugger: return correct exit status on manual halt (#2674)
* service/dap: add test for nonzero exit status
2021-09-24 15:18:28 -07:00
polinasok
2b306e32a6
service/dap: initial remote attach (handler support only) (#2709) 2021-09-24 13:43:46 +02:00
Suzy Mueller
c7e2a9b6fb
service/dap: remove unused test helper arg (#2714) 2021-09-22 21:29:05 -07:00
polinasok
a3897eafa7
service/dap: client must treat non-build launch/attach errors as visible (#2671)
Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
2021-09-22 21:12:48 -07:00