Commit Graph

2139 Commits

Author SHA1 Message Date
polinasok
11cf6e689f
service/dap: support setting breakpoints while running (#2472)
* service/dap: support setting breakpoints while running

* Review comments, faster test

* Fix comments

* Address review comments

* Do not continue automatically

* Add TODO to resume exeuction

* Handle async test messages in either order

Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
2021-05-17 09:17:00 -07:00
Suzy Mueller
32021981a7
service/dap: move build error to output event (#2482) 2021-05-17 09:13:25 -07:00
Suzy Mueller
252bcc4ebc
service/dap: fix continueOnEntryTest (#2489)
Accept the empty response in case the threads request arrived after the program
terminated
2021-05-17 09:07:55 +02:00
Suzy Mueller
5fa4a3527c
service/dap: fix flaky TestPreSetBreakpoint test (#2483) 2021-05-15 07:34:59 +02:00
Hyang-Ah Hana Kim
66782f9b27
daptest/gen: use %#v instead of %q (#2478)
Messages don't look good with %q.
2021-05-12 19:58:38 -07:00
polinasok
8057f5c96b
proc: fix typo 'unkown' => 'unknown' (#2473)
Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
2021-05-10 11:36:03 -07:00
Suzy Mueller
1b8428eb6c
service/dap: add type information to dap variables (#2465)
* service/dap: add type information to dap variables

* add comment explaining map type choice

* rename to setClientCapabilities

* respond to review

* update TypeString definition
2021-05-10 11:34:42 -07:00
Alessandro Arzilli
58762685e3
proc/native: low level support for watchpoints in linux/amd64 (#2301)
Adds the low-level support for watchpoints (aka data breakpoints) to
the native linux/amd64 backend.

Does not add user interface or functioning support for watchpoints
on stack variables.

Updates #279
2021-05-06 10:33:56 -07:00
Alessandro Arzilli
1962c3a627
TeamCity: fix Windows builds (#2467)
Bintray is shutting down and the URL we used to install mingw is no
longer available. Use chocolatey instead.
2021-05-06 10:05:17 -07:00
Hyang-Ah Hana Kim
4b4f7a589a
daptest/gen: autogenerate some assertion functions (#2441)
daptest has type assertion functions that panic
if the read response/event message is not
the expected type. This is not only against the
recommended style guideline (Don't Panic, Useful
Test Failures, ...), but also it prevents from
quickly diagnosing test failures occurred in remote
CIs.

This PR changes the type assertion to the two
return value type assertion, and t.Fatal with details
if the type is not expected.
service/dap/daptest/main.go is a program that auto
generates those assertion functions in resp.go.

Run `go generate` from the service/dap directory
to update resp.go.
2021-05-06 11:11:45 +02:00
Suzy Mueller
49555a9e8a
service/dap: validate the client configurations in initialize request (#2435)
The client can specify certain configurations in the initialize request.
For example, pathFormat determines the pathFormat. We do not currently
support configuring pathFormat, linesStartAt1, or columnsStartAt1, so
we report an error if the client attempts to set these to an
unsupported value.
2021-05-06 09:56:29 +02:00
Alessandro Arzilli
c5d58f494a
proc: add way to use CPU registers in expressions (#2446)
Changes the expression evaluation code so that register names, when not
shadowed by local or global variables, will evaluate to the current
value of the corresponding CPU register.

This allows a greater flexibility with displaying CPU registers than is
possible with using the ListRegisters API call. Also it allows
debuggers users to view register values even if the frontend they are
using does not implement a register view.
2021-05-04 12:56:17 -07:00
polinasok
32f646e3e8
service/dap: auto-loading for fully missing children of nested vars (#2455)
* service/dap: auto-loading for fully missing pointers, structs, maps, slices and arrays

* Add call test

* Add TODO

Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
2021-05-04 12:53:42 -07:00
polinasok
03f1ec1dfc
service/dap: support running requests asynchronously (#2423)
* service/dap: refine teardown logic

* Address review comments + add missing lock/unlock

* Narrow lock scope

* Update comments only

* Remove redundan temp var from stopNoDebugProcess

* Clarify comment

* service/dap: support running requests asynchronously

* Respond to review comments

* Remove debugging printf

* Refine locking. Add call TODO. Use -1 for running thread id.

* Fix TestAttachStopOnEntry: it can terminate on halt

* Respond to review comments

* Recover panics in async requests handling

* defer releasing asyncSetupDone, so it happens on panic

Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
2021-05-04 12:49:52 -07:00
Alessandro Arzilli
0da1c9a9d7
Documentation: document passing arguments to the test program (#2459)
Add documentation on how to pass arguments to the program generated by
`dlv test`.

Fixes #2458
2021-05-04 12:37:09 -07:00
Alessandro Arzilli
c6e52ecf5c
dwarf: make debug_line header parser more resilient (#2456)
Check for errors, log them and return early, do not try to allocate
large chunks of memory that we can never possibly read from the file.

Fixes #2449
2021-05-04 12:36:22 -07:00
polinasok
6a25ee09f5
go.mod: update google/go-dap to 0.5.0 (#2460)
* go.mod: update google/go-dap to 0.5.0

* Go mod tidy

Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
2021-05-04 12:33:50 -07:00
Christian Banse
4bd16ad756
Slightly better version check for gdb server on newer macOS (arm64) (#2461)
* proc: Slightly better version check for gdb server on newer macOS

* Adjusted version to be >= 1200 and <= 1205
2021-05-04 12:33:10 -07:00
Hyang-Ah Hana Kim
9ed4ba0c49
Documentation: correct the flag name used to configure log destination (#2464)
The documentation mentions flags that do not exist. Replace them with
the existing, --log-dest flag.
2021-05-04 08:39:01 +02:00
polinasok
ef337d3022
service/dap: log stacktrace when panic is recovered (#2457) 2021-04-29 11:15:32 +02:00
Alessandro Arzilli
35d4f05c4e
proc: remove duplicate Registers.Get implementations (#2415)
Moves the implementation of Registers.Get out of the backends and into
proc where it can be implemented only once per architecture.
2021-04-28 10:00:26 -07:00
Felix Geisendörfer
7bf5482b32
examinememory: evaluate addr as expression (#2385)
* examinememory: evaluate addr as expression

This makes it easy to read memory locations at an offset of a known
address, e.g.:

x 0xc000046800 + 32

* use feedback from @aarzilli

- expression mode is now enabled via -x flag
- support "-x var", "-x &var" in addition to "-x <addr expr>"
- some refactoring

* add test cases

* deal with double spaces

* update docs

* add new failing test

* fix docs

* simplify implementation, update test & docs

* Fix docs
2021-04-26 10:36:24 -07:00
Suzy Mueller
bbae9a9d12
service/dap: add go build stderr to error response (#2448)
* service/dap: add go build stderr to error response

* service/dap: add go build stderr to error response

* Skip message check for build errors

* test for flag provided message
2021-04-26 10:31:59 -07:00
Suzy Mueller
ee5729e107
service/dap: log working directory of launch program (#2447) 2021-04-23 15:17:38 +02:00
Alessandro Arzilli
6a85f34966
debugger: report error when switching goroutine is impossible (#2424)
Due to variable shadowing the SwitchGoroutine command never failed.
2021-04-21 13:39:19 -07:00
Alessandro Arzilli
ea9541b860
proc: disable part of TestAttachDetach test on macOS (#2429)
There seems to be a problem where debugserver will leave a zombie
process instead of detaching correctly, we are sending the right
commands, it doesn't seem to be a problem with Delve.
2021-04-21 13:37:53 -07:00
polinasok
e141c47eb8
service/dap: refine teardown logic (#2414)
* service/dap: refine teardown logic

* Address review comments + add missing lock/unlock

* Narrow lock scope

* Update comments only

* Remove redundan temp var from stopNoDebugProcess

* Clarify comment

* Set debugger to nil after detach to prevent dup teardown in Stop()

Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
2021-04-21 13:28:15 -07:00
Suzy Mueller
af1796d171
service/dap: rename launch configuration 'wd' to 'cwd' (#2433)
Rename the launch configuration for specifying the working directory.
2021-04-20 09:40:34 +02:00
Suzy Mueller
2408ed87bf
service/dap: annotate shadowed variable names in variables request (#2428)
* service/dap: annotate shadowed variable names in variables request

In order to distinguish variables that are shadowed, this change
updates the names from 'name' to '(name)'. This is the same syntax
used in the terminal package.

* remove unnecessary comment

* Add todo for evaluate name

* Check the evaluateName result is the unshadowed var
2021-04-19 11:14:50 -07:00
Alessandro Arzilli
e3d438876e
service/rpccommon: fix shutdown related bugs (#2439)
* service/rpcommon: resolve race between Detach and shutdown

Detach will close DisconnectChan causing the server to initiate
shutdown, there is a race between Detach writing its response to the
client and the shutdown terminating the server process.
If Detach loses the race the response to the Detach request is never
sent to the client and the client will report an EOF error instead.

This change delays the start of the shutdown process until after Detach
has written its response.

Fixes an occasional failure of TestContinue.

* service/rpccommon: ignore listener error when shutting down

Ignore the closed listener error when the server is being shut down in
response to a SIGINT signal.

Fixes #1633
2021-04-19 11:12:51 -07:00
Koichi Shiraishi
7d343b6b7b
_scripts: support macOS Big Sur (#2437) 2021-04-17 12:33:33 +02:00
Suzy Mueller
4eb54b01e7
service/dap: add substitutePath configuration (#2379)
* service/dap: add substitutePath configuration

Similar to substitute-path configuration in the dlv cli, substitutePath
in dap allows users to specify path mappings that are applied to the
source files in stacktrace and breakpoint requests.

Updates #2203

* service/dap: refactor the startup of the fixture for attach

Add a helper function for starting up a process to attach to.

* service/dap: update substitute path tests for windows

* service/dap: remove lines that should have been removed in merge

* respond to comments on pr

* move logging to helper functions

* make test comments more clear

* Add comments about absolute paths

* fix log messages

* clarify test comments

* remove comment about absolute paths
2021-04-15 16:35:37 -07:00
polinasok
747f037883
service/dap: fix temp binary deletion race (#2413)
Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
2021-04-14 09:22:40 +02:00
Alessandro Arzilli
3c69f7435e
*: Never use pointer to proc.ErrProcessExited (#2431)
We have some places where we use proc.ErrProcessExited and some places
that use &proc.ErrProcessExited, resulting in checks for process exited
errors occasionally failing on some architectures.
Uniform use of ErrProcessExited to the non-pointer version.

Fixes intermittent failure of TestStepOutPreservesGoroutine.
2021-04-13 08:52:29 +02:00
polinasok
fe616c27ff
service/dap: fallback to CurrentThread if SelectedGouroutine is not available (#2422)
Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
2021-04-12 15:00:26 -07:00
Alessandro Arzilli
781ad72d62
service: fix breakpoint IDs after Restart with disabled breakpoints (#2425)
When restarting we must take care of setting breakpoint IDs correctly
so that enabled breakpoints do not end up having the same ID as a
disabled breakpoint, also we must make sure that breakpoints created
after restart will not get an ID already used by a disabled breakpoint.
2021-04-12 14:59:43 -07:00
Alessandro Arzilli
f3d7b25fdf
*: remove unused code, variables and constants (#2426) 2021-04-12 14:57:39 -07:00
Alessandro Arzilli
623667b0f4
*: Skipped tests review (#2430)
Delete tests for old versions of Go that are no longer run, remove skip
from tests that seemingly work.
2021-04-12 14:56:12 -07:00
Ernie Hershey
1ffe2413c2
Typo and comma for readability (#2434) 2021-04-12 14:54:13 -07:00
polinasok
aa426a2e50
service/dap: delay disconnect response and log teardown progress (#2427)
Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
2021-04-12 14:50:15 -07:00
Hyang-Ah Hana Kim
8b20609227
dap: suppress error popup for failed evaluation request in repl mode (#2420)
It's expected that users enter invalid expressions through DEBUG
CONSOLE. Pop up for every error is not pleasant.
2021-04-09 10:03:59 +02:00
polinasok
79e6f7fa90
service/dap: minor test refactoring (#2421) 2021-04-08 11:09:41 +02:00
polinasok
c4b9c85843
service/dap: handle terminated events in TestStepOutPreservesGoroutine (#2417)
Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
2021-04-07 10:00:14 +02:00
Alessandro Arzilli
618f366998
proc: be more lenient when parsing debug_info (#2394)
- allow a concrete subprogram to be treated as the abstract origin for an inlined call
- allow nameless concrete and abstract subprograms

Fixes #2393
2021-04-05 11:50:59 -07:00
Hyang-Ah Hana Kim
da27e34217
dap: change how noDebug launch request is served (#2407)
* dap: change how noDebug launch request is served

PR #2400 added support for noDebug launch requests - that was done
by directly starting the target program using os/exec.Cmd and blocking
the launch request indefinitely until the program terminates or
is stopped with a disconnect request (when dlv dap can support it).
Even though the approach seemed to work for user, that adds an extra
control flow and complexity to the codebase.

This change takes a different approach to implement the noDebug
launch feature. Instead of using os/exec.Cmd, this uses the existing
debug launch path, but avoids setting breakpoints. Finally, the program
will start upon receiving onConfigurationDoneRequest and blocks there
until the program terminates. This simplifies the code.

The DAP spec does not explicitly specify what to do about other
requests. It seems like VSCode can issue evaluate requests or other
requests after the configuration done request. Currently they are
blocked because the program is in running state. We can consider checking
s.noDebug and responding with an error in the future if we want/need to.

See the log below for a typical DAP request/response sequence:

2021-03-29T01:42:53-04:00 debug layer=dap building binary at /Users/hakim/projects/s/__debug_bin
2021-03-29T01:42:55-04:00 info layer=debugger launching process with args: [/Users/hakim/projects/s/__debug_bin]
2021-03-29T01:42:55-04:00 debug layer=dap [-> to client]{"seq":0,"type":"event","event":"initialized"}
2021-03-29T01:42:55-04:00 debug layer=dap [-> to client]{"seq":0,"type":"response","request_seq":2,"success":true,"command":"launch"}
2021-03-29T01:42:55-04:00 debug layer=dap [<- from client]{"seq":3,"type":"request","command":"setBreakpoints","arguments":{"source":{"name":"main.go","path":"/Users/hakim/projects/s/main.go"},"breakpoints":[{"line":9}],"lines":[9]}}
2021-03-29T01:42:55-04:00 error layer=dap Unable to set or clear breakpoints: running in noDebug mode
2021-03-29T01:42:55-04:00 debug layer=dap [-> to client]{"seq":0,"type":"response","request_seq":3,"success":false,"command":"setBreakpoints","message":"Unable to set or clear breakpoints","body":{"error":{"id":2002,"format":"Unable to set or clear breakpoints: running in noDebug mode"}}}
2021-03-29T01:42:55-04:00 debug layer=dap [<- from client]{"seq":4,"type":"request","command":"configurationDone","arguments":{}}
2021-03-29T01:42:55-04:00 debug layer=dap [-> to client]{"seq":0,"type":"response","request_seq":4,"success":true,"command":"configurationDone"}
2021-03-29T01:42:55-04:00 debug layer=debugger continuing
Hello
2021-03-29T01:43:00-04:00 debug layer=dap [-> to client]{"seq":0,"type":"event","event":"terminated","body":{}}
2021-03-29T01:43:00-04:00 debug layer=dap [<- from client]{"seq":5,"type":"request","command":"threads"}
2021-03-29T01:43:00-04:00 debug layer=dap [-> to client]{"seq":0,"type":"response","request_seq":5,"success":true,"command":"threads","body":{"threads":null}}
2021-03-29T01:43:00-04:00 debug layer=dap [<- from client]{"seq":6,"type":"request","command":"disconnect","arguments":{}}
2021-03-29T01:43:00-04:00 debug layer=dap [-> to client]{"seq":0,"type":"response","request_seq":6,"success":true,"command":"disconnect"}
2021-03-29T01:43:00-04:00 debug layer=debugger halting
2021-03-29T01:43:00-04:00 error layer=dap Process 27219 has exited with status 0
2021-03-29T01:43:00-04:00 debug layer=debugger detaching

Updates https://github.com/golang/vscode-go/issues/1111

* service/dap: address polina's comments for noDebug logic

Reworked so the noDebug launch request again blocks launch request
handler after responding with the launch response. By skipping
the initialized event, it should prevent well-behaving clients from
sending any further requests. Currently, doesn't matter because
the handler goroutine will be blocked until the program termination
anyway.

Placed mutex back, since I noticed that's the only way to prevent
racing between Stop and the handler goroutine. The synchronization
lotic (in particular, during teardown) should be revisited after
asynchronous request support work is done.

* dap: address more comments
2021-04-05 11:44:02 -07:00
Alessandro Arzilli
7ace7a8e76
proc/gdbserial: remove unnecessary conditional compilation (#2389)
Remove unnecessary conditionally compiled files introduced with the
darwin/arm64 port.
2021-04-05 11:23:32 -07:00
Alessandro Arzilli
c223ef656d
Documentation: mention developer group in macOS install instructions (#2409)
Some users seem to need to do this in order to use a debugger.
2021-04-02 09:34:44 -07:00
Suzy Mueller
370ec4e6e4
service/dap: switch goroutines when stepping (#2403)
* service/dap: switch goroutine before stepping

The correct goroutine needs to be selected when stepping in order
for the step to execute to the correct location.

* handle next in progress while stepping

* Add tests for steps when switching goroutine

* remove nextInProgress handling

* add new step out test and review debug state check

* update text of stopped event and set goroutine id
2021-04-02 09:19:16 -07:00
Hyang-Ah Hana Kim
743f243841
service/dap: change dap error response logging to debug level (#2412)
Error level logging shows up in the users' consoles/terminals
so be more conservative when logging. Move the followings to
Debug logging.

- DAP error reponses caused by invalid requests.
They are application level errors and DAP clients should handle them.
- Errors reported when debugee already exited.

Fixes golang/vscode-go#1392
2021-04-02 09:17:43 -07:00
Alessandro Arzilli
b120b11cc3
terminal: add optional format argument to print, display (#2398)
Changes print so a format argument can be specified by using '%' as
prefix. For example:

    print %x d

will print variable 'd' in hexadecimal. The interpretarion of the
format argument is the same as that of fmt's package.

Fixes #1038
Fixes #1800
Fixes #2159
2021-03-25 09:45:30 -07:00