Commit Graph

178 Commits

Author SHA1 Message Date
Hyang-Ah Hana Kim
9f731debb1
go.mod: update github.com/google/go-dap to v0.7.0 (#3237)
* go.mod: update github.com/google/go-dap to v0.7.0

Updates https://github.com/google/go-dap/issues/66

* Run go mod tidy
2023-01-03 08:40:51 -08:00
gfszr
95a151379b
Add type to call evaluation and expression evaluation (#3172) 2022-10-24 17:44:47 -07:00
Alessandro Arzilli
6440b3ba92
service/dap: fix nil ptr deref when current addr is not in a func (#3157)
Fixes nil pointer dereference when current PC address does not belong
to any known func.

Fixes #3156
2022-10-05 07:09:44 -07:00
Alessandro Arzilli
6e7e1d8830
proc,terminal: allow setting suspended breakpoints (#3154)
Allows setting suspended breakpoints and try to enable them
automatically after every time a plugin is loaded.

Fixes #1653
Updates #2551
2022-10-04 08:07:05 -07:00
Alessandro Arzilli
ec5fcc07fe
proc,service/debugger: track how breakpoints were originally set (#3148)
Adds field to breakpoint struct to track how a breakpoint was
originally set, moves the logic for disabling and enabling a breakpoint
to proc.
This will allow creating suspended breakpoints that are automatically
enabled when a plugin is loaded. When follow exec mode is implemented
it will also be possible to automatically enable breakpoints (whether
or not they were suspended) on new child processes, as they are
spawned.

It also improves breakpoint restore after a restart, before this after
a restart breakpoints would be re-enabled using their file:line
position, for breakpoints set using a function name or a location
expression this could be the wrong location after a recompile.

Updates #1653
Updates #2551
2022-09-28 11:35:07 -07:00
Alessandro Arzilli
a73eaeffd2
proc,service: change FindLocation to work with multiple targets (#3103)
Changes FindLocation to support multiple targets and adds an AddrPid
member to api.Breakpoint so that clients can set breakpoints by address
when multiple targets are connected (but at them moment this field is
ignored).

Updates #1653
Updates #2551
2022-09-26 10:12:34 -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
Alessandro Arzilli
5b9f65dac2
*: switch to int64 for goroutine IDs (#3110)
Go 1.20 switched to uint64 to represent goroutine IDs, we can't
actually follow suit because we have allowed clients to use -1 to refer
to the currently selected goroutine, however we should at least switch
to int64 and also update the rtype check to accept the 1.20 type.
2022-08-16 09:31:11 -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
roketyyang
ec1d1efb7f
terminal/command: 'goroutines' command add new flags '-exec command' (#3044)
* terminal/command: 'goroutines' command add new flags '-exec command'

Support run command on every goroutine.

Fixes #3043

* terminal/command: 'goroutines' command add new flags '-exec command'

Support run command on every goroutine.

Fixes #3043

* terminal/command: add -per-g-hitcount option to condition command

Support use per goroutine hitcount as hintcond operand.

Fixes #3050

Co-authored-by: roketyyang <roketyyang@tencent.com>
2022-07-25 10:14:43 -07:00
André Eriksson
e72d9b3372
pkg/locspec: support exact match in SubstitutePath (#3075)
In order to support substituting a single file within
a larger package, and not substituting a directory wholesale,
this commit introduces the ability for SubstitutePath
to replace individual file paths if there is an exact match.

This behavior is backwards-compatible with the previous
configuration.

Fixes #3074
2022-07-25 09:57:31 -07: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
6f34add5db
proc,service/debugger: introduce TargetGroup abstraction (#3030)
Introduces a new TargetGroup abstraction that can be used to manage
multiple related targets.
No actual management of child processes is implemented here, this is
just a refactoring to make it possible to do that in the future.

Updates #2551
2022-07-14 14:14:45 -07: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
Alessandro Arzilli
78471b3a5a
proc,service: represent logical breakpoints explicitly (#2946)
Adds a LogicalBreakpoint type to represent logical breakpoints
explicitly. Until now logical breakpoints were constructed implicitly
by grouping physical breakpoints together by their LogicalID.

Having logical breakpoints represented explicitly allows for a simpler
implementation of disabled breakpoints, as well as allowing a simple
implementation of delayed breakpoints (#1653, #2551) and in general of
breakpoints spanning multiple processes if we implement debugging
process trees (#2551).

Updates #1653
Updates #2551
2022-05-25 13:58:26 -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
cui fliter
9a9c1a9f33
*: fix some typos
Signed-off-by: cuishuang <imcusg@gmail.com>
2022-03-23 16:10:00 +01: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
Hyang-Ah Hana Kim
0005eb9f58
dap: create temporary binary in the current working directory (#2868)
This is a partial revert of PR #2660.

Some users develop in environments where execution of binaries
in temp directory is prohibited or undesirable. Moreover, the
current implementation creates binaries with random names
and that made it more difficult to set up firewall exclusion
rules. Revert it and always use the default debug output name.
(The debug binary will be created in the delve's working directory
and an editor does not have any promise on working directory
unless user specifies it through dlvCwd. So users still need to
chase them unless they set the exclusion rule purely based on
the file base name).

Fixes golang/vscode-go#1955
2022-01-19 11:02:49 -08:00
Suzy Mueller
a2927f6117
service/dap: set min/max addresses for invalid instructions (#2832) 2022-01-06 09:02:19 -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
Fabio Falzoi
79d5db24a5
Automatically disable breakpoints with hitcount conditions that will never be satisfied again (#2833)
* service/debugger: disable breakpoints with hitcond not satisfiable

To avoid slowing down the debugged process unnecessarily, we disable
breakpoints with a hit condition that can no longer be hit again.

* test: add integration tests for hit conditions no more satisfiable

* proc/test: fix typo in breakpoints related tests

* test: use the new API for hitcond integration tests
2022-01-06 09:00:46 -08:00
Suzy Mueller
5842c1fe9e
service/dap: fix race in no debug test (#2766)
Check for a possible output event when disconnecting from a
process that has already exited.

Fixes #2763
2022-01-04 12:03:20 +01:00
polinasok
fcc9561cbe
service/dap: update request inventory comments and labels in Server.handleRequest (#2854)
Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
2022-01-03 10:58:13 +01:00
polinasok
2f13672765
service/dap: fix compile error from merge conflict (#2818)
Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
2021-12-08 11:37:35 +01: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
9013a121d8
server/dap: stop running command if conn closed - fixes nil dereference bug (#2781)
Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
2021-11-09 09:24:26 +01: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
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
polinasok
8a9f141d51
service/dap: log parsed and applied launch configs (#2732)
* service/dap: log parsed and applied launch configs

Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
2021-10-13 12:05:47 -07:00
Hyang-Ah Hana Kim
98a0bcf772
cmd/dlv: add --client-addr flag to run dap with a predefined client (#2568)
This adds a new `--client-addr=host:port` flag to `dlv dap`.
If it is supplied, the dap process will dial into the tcp port where
a DAP client is waiting, and work with only the DAP client.
The DAP client is supposed to start the normal DAP message
exchange starting with the 'initialize' request after the dlv dap
process dials in and the connection is set up. 

VS Code Go extension plans to use this mode for

* reliably detecting `dlv dap` readiness. Currently it depends on
watching the log stream. After this PR, it can listen on a network port.
* running `dlv dap` from any terminal (part of RunInTerminal workflow
implementation).
2021-10-13 11:43:47 -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
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
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