221 Commits

Author SHA1 Message Date
8a7650b013 service/dap: do not try to access value of unreadable string variables (#4055)
Fixes #4053
2025-07-14 09:12:48 -07:00
2ac3573b74 dap: Exclude internal breakpoints from response (#4027) 2025-06-12 09:10:51 -07:00
3c4e58b0d3 service/dap: fix race condition between disconnect and continue (#4028)
If a disconnect requests comes in while the runUntilStopAndNotify
goroutine is hitting a breakpoint a nil debugger dereference can happen
at various points.

This change resolves the problem by never resetting the debugger field
to nil, instead a separate flag is set (which mostly just exist to
avoid duplicate logging and to keep tests happy).

Fixes #4006, #4007, #4020
2025-06-11 11:28:10 -07:00
7c9b7d8dca service/dap: do not attempt further loading on unreadable string vars (#4016)
Do not attempt further loading of unreadable string vars because their
Value field will be nil, causing a panic, and also it can't possibly
work.

Fixes #4010
2025-06-05 16:38:03 -07:00
2e8df9d9b6 service/debugger,rpc2,dap: target locking review (#3997)
We had a few problems with missing targetMutex acquisitions in
service/debugger, this commit takes care of a few other methods (although I
don't think any of these are problems in practice).

- DwarfRegisterToString is removed, there is no need to call this method
  outside of the context of ScopeRegisters/ThreadRegisters which can
  directly return the function that DwarfRegisterToString would call
- add lock acquisition to BuildID
- remove Target, TargetGroup, TargetLock and TargetUnlock. Replace them with
  a single LockTargetGroup method that acquires the lock and returns the
  target group and the unlock function. Callers can still misuse
  LockTargetGroup by calling unlock immediately and continuing to use the
  target group but this is harder to do accidentally compared to the others.
2025-05-21 12:46:59 -07:00
84aae7f972 service/dap: fix race condition when launching with backend=rr (#3971)
fixes #3970
2025-04-07 11:52:02 -07:00
0b821e4516 telemetry: add stack counter for internal errors (#3930)
Add stack counter for the various places where we catch internal
errors.
2025-03-05 08:25:00 -08:00
38af36e942 service/dap: provide process events after launch (#3902)
This change adds support to emit the process DAP event after handling launch
requests
2025-01-17 09:38:25 -08:00
091e5535ab all: remove redundant err declarations (#3855) 2024-11-12 08:04:22 -08:00
822014b8e8 service,terminal,cmd/dlv: automatically guessing substitute-path config (#3781)
Add command, API calls and launch.json option to automatically guess
substitute-path configuration.
2024-10-31 10:19:08 -07:00
7857f233ad service/dap: make handlesMap generic (#3798)
The oldest version of Go we compile with is 1.20 at this point, we can
thus make use of generic type parameters and the handlesMap support
type in service/dap is improved by them.
2024-09-03 10:40:34 -07:00
0d0d2e1b16 *: replace fmt.Errorf with errors.New (#3752) 2024-06-20 21:50:18 +02:00
15a9f9d353 cmd/dlv: print out message with stack trace when breakpoint is hit but has no waiting client (#3632)
* Print out message and dump stack on pause

* Fix test

* Move the logic to debugger layer

* Remove unused fields

* Do not use defer to get state

* move channel to connection

* remove lock on isClosed

* Use mutex

* Remove unwanted changes
2024-06-12 12:31:46 -07:00
8347f97c00 *: remove redundant lines at the start/end of block (#3730) 2024-05-20 14:16:22 -07:00
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
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
f2b3b18ca7 service/dap: support waitfor option for 'dap attach' only (#3656)
Add a waitfor option for 'dap attach' that waits for a process with a
given name to appear before attaching to it.

This recovers PR #3584, originally by @muggle-nil, which was fine
except for a broken test.
2024-02-07 11:03:36 -08:00
4b2612a6b3 service/dap: make TestEvaluateCallFunction independent of line numbers (#3644)
_fixtures/fncall.go was made to support TestCallFunction in pkg/proc
and new things must be added to fncall.go to test new features. Having
a test depend on precise line numbers makes the process tedious.
2024-01-24 09:17:56 -08:00
e80e401c7e service/dap: fix close on closed channel (#3609)
This fixes an infrequent close on closed channel panic in service/dap
caused by a race condition with closing a channel.
2023-12-26 10:16:52 -08:00
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
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
f1daaeb1b0 pkg,service/dap: use switch instead of ifs (#3576) 2023-11-22 09:07:08 -08:00
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
c727ec52c5 service: fix a bunch of linter warnings from GoLand (#3551) 2023-11-05 17:36:37 +01:00
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
b041bd8e98 service/dap: add the concrete type to interface type (#3510) 2023-10-03 08:51:46 -07:00
30b70bc606 service/dap: accept a string list as launch request's buildFlags (#3496)
This change accepts both string type and []string. dap.BuildFlags
is a union of string and []string.

Fixes #2718
For golang/vscode-go#1831, golang/vscode-go#1027
2023-09-19 09:32:15 -07:00
c7097b8e1d service/dap: strip package paths from symbols in callstack (#3500)
This solves the problem that function names with long package paths are hard to
read when the callstack window is narrow, because all you see is the beginning
of the package path.

For example, instead of

  github.com/some/long/package/path/pkg.(*SomeType).SomeMethod

we now display

  pkg.(*SomeType).SomeMethod
2023-09-16 06:06:28 +02:00
7fb9ddae4d api,dap: fix hexadecimal printing of vars with symbolic const values (#3487)
Fix hexadecimal printing of variables that can be represented using
symbolic const values in DAP as well as the command line interface.

Fixes #3485
2023-08-29 09:24:10 -07:00
17d1f4c829 service/dap: use == to test io.EOF (#3464)
The documentation of io.EOF: Read must return EOF itself, not an error
wrapping EOF, because callers will test for EOF using ==.

This is a trivial change; people may think it's normal use of "errors.Is",
even it's OK, it could be replaced with "errors.Is(err, io.EOF)" in idiomatic way.
2023-08-12 09:41:30 +02:00
2b785f293b logflags: simplify Logger interface (#3274)
Remove methods we never used or used only very sparingly (Print) and we
probably shouldn't be using at all (Fatal).
2023-08-07 13:55:45 -07:00
0e3cae9dc9 service/dap: fix typos in comments (#3438) 2023-07-11 16:10:41 +02:00
db0bc26949 terminal,service: better printing of suspended breakpoints (#3415)
Show the location expression that will be used to set a suspended
breakpoint in the breakpoints list.

Also change 'target' called without arguments to print a better error
message and 'target follow-exec' without the last argument to print the
state of follow-exec.
2023-07-07 10:33:40 -07:00
53998cbb18 pkg/proc,service/*: Supports sending output to clients when running programs remotely (#3253)
* wip: Support sending output when remote debug

* wip: Support local output and remote output

* wip: fix stderr and stdout assignment error

* wip: optimize code

* wip: Only if outputMode is "remote" is the redirected console output

* wip: Redirected debugMode output(Not tested on windows)

* wip: support remote debugging output redirection of windows

* wip: real-time write back output

* wip: support for windows

* wip: fix windows remote debug not output

* wip: fix truncated output redirection

* wip: delete printfln

* wip: use debugger.Config to pass redirect(macOS)

* wip: use debugger.Config to pass redirect(linux)

* wip: Change redirect to a concrete type

* wip: s.wg.wait before sending "terminated"

* wip: add proc/redirect test(darwin and linux)

* Merge branch 'master' of github.com:tttoad/delve into feat-console

* wip: Fix test failure on windows

* fix: undefined: proc.Redirects

* fix: compile failure

* wip: Remove useless code

* fix: filename error

* fix: os.file not close

* test: add server_test.redirect

* fix: Remove 'eol' from end of file

* fix: gdbserial: File not closed in file mode.
(in reality, gdbserial will never use file mode)

* feat: Remove "only-remote". Fix spelling mistakes.

* fix: spelling mistakes

* refactor: redirect

* fix: stdout and stderr are not set to default values

* fix: Restore code logic for rr.openRedirects()

* fix: Optimization Code

* fix: utiltest

* fix: execpt out

* fix: Resource release for redirects

* fix: build failure

* fix: clean->clear

* fix: build failure

* fix: test failure

* fix: Optimization Code

* style: remove useless code

* refactor: namedpipe

* refactor: namedpipe, launch ...

* fix: freebsd compile failure

* fix: proc_darwin compile failure

* style:  remove useless code

* feat: add d.config.Stdxx check on debug.Restart

* style: formatting and adding comments

* style: formatting and adding comments

* feat: add d.config.Stdxx check on debug.Restart

* style: namedpipe->redirector

* style: namedPipe->redirector

---------

Co-authored-by: 李翔 <qian.fu2@amh-group.com>
2023-07-05 08:39:01 -07:00
322a138cf2 service/dap: fix typos in comments (#3426) 2023-06-20 14:53:18 +02:00
e549a02f0e service/dap: update go-dap to latest (#3414)
* service/dap: update go-dap to latest

* update remaining possible nil checks

* move helper functions to the end of the file
2023-06-12 14:29:44 -07:00
e33806a3f7 service: fix typos in comments, logs, tests, and vars (#3378) 2023-05-23 18:21:36 +02:00
84b757ad57 cmd/dlv,service/dap: use randomized name as default output binary (#3366)
Using a fixed path as the default output binary means that executing
Delve twice in the same directory will cause the second invocation to
overwrite the output binary of the first instance of Delve, making the
restart command not work correctly.

Fixes #3345
2023-05-16 09:36:15 -07:00
a57c60e43a service/dap: refactor funcs always returning nil error (#3357) 2023-05-08 10:41:14 -07:00
9873e0ef63 service/dap: use reloaded value
The only part of the reloaded value that was used was the
Children. This caused a bug where the Time format string was
reloaded, but it was not being displayed.

Fixes go-delve/delve#3342
2023-04-29 09:55:45 +02:00
cc71863594 service: fix typos in comments (#3344) 2023-04-27 13:39:33 -07:00
260229b979 terminal/logflags: Added SetLoggerFactory(LoggerFactory) (#3257)
* terminal/logflags: Added `SetLoggerFactory(LoggerFactory)`

This change will enable people who want to embed Delve into their applications to adjust the logging better to their needs.

* terminal/logflags: Added `SetLoggerFactory(LoggerFactory)`

Added changes from code review.

* terminal/logflags: Added `SetLoggerFactory(LoggerFactory)`

Reworked requested changes.

* terminal/logflags: Added `SetLoggerFactory(LoggerFactory)`

Reworked requested changes.
2023-02-14 09:46:35 -08:00
4303ae45a8 service/dap: correct typos in comments (#3264) 2023-02-02 13:46:19 +01:00
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
95a151379b Add type to call evaluation and expression evaluation (#3172) 2022-10-24 17:44:47 -07:00
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
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
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
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
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