Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

debug: communicate clearly when setting breakpoint fails #1840

Closed
hyangah opened this issue Oct 14, 2021 · 13 comments
Closed

debug: communicate clearly when setting breakpoint fails #1840

hyangah opened this issue Oct 14, 2021 · 13 comments
Labels
Debug Issues related to the debugging functionality of the extension. FrozenDueToAge

Comments

@hyangah
Copy link
Contributor

hyangah commented Oct 14, 2021

$ dlv-dap version -v ``` Delve Debugger Version: 1.7.2 Build: $Id: 5b6f24e7fbcad3fe3bc574d3763b2f20afa1d6a1 $ Build Details: devel go1.18-577bb7dba1 Mon Oct 11 17:02:03 2021 +0000 mod github.com/go-delve/delve v1.7.3-0.20211014014620-6cf7a7149d35 h1:fbOXXhwHdkZrhkZlAZdS+7vLqZm+d890dE3IuN9hQaw= dep github.com/cosiner/argv v0.1.0 h1:BVDiEL32lwHukgJKP87btEPenzrrHUjajs/8yzaqcXg= dep github.com/cpuguy83/go-md2man/v2 v2.0.0 h1:EoUDS0afbrsXAZ9YQ9jdu/mZ2sXgT1/2yyNng4PGlyM= dep github.com/derekparker/trie v0.0.0-20200317170641-1fdf38b7b0e9 h1:G765iDCq7bP5opdrPkXk+4V3yfkgV9iGFuheWZ/X/zY= dep github.com/google/go-dap v0.6.0 h1:Y1RHGUtv3R8y6sXq2dtGRMYrFB2hSqyFVws7jucrzX4= dep github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc= dep github.com/mattn/go-isatty v0.0.3 h1:ns/ykhmWi7G9O+8a448SecJU3nSMBXJfqQkl0upE1jI= dep github.com/mattn/go-runewidth v0.0.3 h1:a+kO+98RDGEfo6asOGMmpodZq4FNtnGP54yps8BzLR4= dep github.com/peterh/liner v1.2.1 h1:O4BlKaq/LWu6VRWmol4ByWfzx6MfXc5Op5HETyIy5yg= dep github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q= dep github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo= dep github.com/sirupsen/logrus v1.6.0 h1:UBcNElsrwanuuMsnGSlYmtmgbb23qDR5dG+6X6Oo89I= dep github.com/spf13/cobra v1.1.3 h1:xghbfqPkxzxP3C/f3n5DdpAbdKLj4ZE4BWQI362l53M= dep github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= dep go.starlark.net v0.0.0-20200821142938-949cc6f4b097 h1:YiRMXXgG+Pg26t1fjq+iAjaauKWMC9cmGFrtOEuwDDg= dep golang.org/x/arch v0.0.0-20190927153633-4e8777c89be4 h1:QlVATYS7JBoZMVaf+cNjb90WD/beKVHnIxFKT4QaHVI= dep golang.org/x/sys v0.0.0-20210514084401-e8d321eab015 h1:hZR0X1kPW+nwyJ9xRxqZk1vx5RUObAPBdKVvXPDUH/E= dep gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= ```

What did I do

  1. Set breakpoints that fail to match. (e.g. function breakpoints with println or init.
  2. Run program.

What did I expect

Either program stops in functions where the names match one of the function breakpoints I set, or if they can't be set, see output message.

What did I see instead

Program runs without being stopped.

In fact, dlv returned information about the failed breakpoint setting as a response of setBreakpointRequests.

2021-10-14T09:10:43-04:00 debug layer=dap [<- from client]{"seq":4,"type":"request","command":"setFunctionBreakpoints","arguments":{"breakpoints":[{"name":"println"},{"name":"init"}]}}
2021-10-14T09:10:43-04:00 debug layer=dap [-> to client]{"seq":0,"type":"response","request_seq":4,"success":true,"command":"setFunctionBreakpoints","body":{"breakpoints":[{"verified":false,"message":"location \"println\" not found","source":{}},{"verified":false,"message":"Location \"init\" ambiguous: runtime.(*itab).init, runtime.(*mcentral).init, runtime.(*fixalloc).init, runtime.(*gcControllerState).init, runtime.(*gcWork).init…","source":{}}]}}

These are meant to be used to populate the BREAKPOINTS viewlet and hover message. However, unfortunately, since the program continued and eventually the debug session ended, users wouldn't know that unless the program is stopped at other (successfully configured) breakpoints or paused for other reasons.

@suzmue @polinasok What do you think about generating Output events (console) to make it more visible?

Full log ``` Starting: /Users/hakim/go/bin/dlv-dap dap --check-go-version=false --listen=127.0.0.1:58566 --log=true --log-output=dap,debugger --log-dest=3 from /Users/hakim/report/b DAP server listening at: 127.0.0.1:58566 2021-10-14T09:10:41-04:00 debug layer=dap DAP server pid = 7778 2021-10-14T09:10:41-04:00 debug layer=dap DAP connection started 2021-10-14T09:10:41-04:00 debug layer=dap [<- from client]{"seq":1,"type":"request","command":"initialize","arguments":{"clientID":"vscode","clientName":"Visual Studio Code","adapterID":"go","locale":"en-us","linesStartAt1":true,"columnsStartAt1":true,"pathFormat":"path","supportsVariableType":true,"supportsVariablePaging":true,"supportsRunInTerminalRequest":true,"supportsMemoryReferences":true,"supportsProgressReporting":true,"supportsInvalidatedEvent":true}} 2021-10-14T09:10:41-04:00 debug layer=dap [-> to client]{"seq":0,"type":"response","request_seq":1,"success":true,"command":"initialize","body":{"supportsConfigurationDoneRequest":true,"supportsFunctionBreakpoints":true,"supportsConditionalBreakpoints":true,"supportsEvaluateForHovers":true,"supportsSetVariable":true,"supportsExceptionInfoRequest":true,"supportTerminateDebuggee":true,"supportsDelayedStackTraceLoading":true,"supportsLogPoints":true,"supportsClipboardContext":true,"supportsSteppingGranularity":true,"supportsInstructionBreakpoints":true}} 2021-10-14T09:10:41-04:00 debug layer=dap [<- from client]{"seq":2,"type":"request","command":"launch","arguments":{"name":"Launch Package","type":"go","request":"launch","mode":"debug","program":".","stopOnEntry":false,"logOutput":"dap,debugger","showLog":true,"__configurationTarget":5,"packagePathToGoModPathMap":{"/Users/hakim/report/b":"/Users/hakim/report/b","/Users/hakim/report/a":"/Users/hakim/report/a","/Users/hakim/sdk/gotip/src/runtime":"/Users/hakim/sdk/gotip/src"},"debugAdapter":"dlv-dap","apiVersion":2,"dlvLoadConfig":{"followPointers":true,"maxVariableRecurse":1,"maxStringLen":64,"maxArrayValues":64,"maxStructFields":-1},"showGlobalVariables":false,"substitutePath":[],"dlvToolPath":"/Users/hakim/go/bin/dlv-dap","env":{},"__buildDir":"/Users/hakim/report/b","__sessionId":"cf62686b-8a6d-4693-a0da-30bf2fed7d03"}} 2021-10-14T09:10:41-04:00 debug layer=dap parsed launch config: { "mode": "debug", "program": ".", "backend": "default", "stackTraceDepth": 50 } 2021-10-14T09:10:42-04:00 debug layer=dap building from "/Users/hakim/report/b": [go build -o /var/folders/bw/6r6k9d113sv1_vvzk_1kfxbm001py5/T/__debug_bin2601615257 -gcflags all=-N -l .] 2021-10-14T09:10:42-04:00 debug layer=dap launching binary '/var/folders/bw/6r6k9d113sv1_vvzk_1kfxbm001py5/T/__debug_bin2601615257' with config: { "mode": "debug", "program": "/Users/hakim/report/b", "cwd": "/Users/hakim/report/b", "output": "/var/folders/bw/6r6k9d113sv1_vvzk_1kfxbm001py5/T/__debug_bin2601615257", "dlvCwd": "/Users/hakim/report/b", "backend": "default", "stackTraceDepth": 50 } 2021-10-14T09:10:42-04:00 info layer=debugger launching process with args: [/var/folders/bw/6r6k9d113sv1_vvzk_1kfxbm001py5/T/__debug_bin2601615257] 2021-10-14T09:10:43-04:00 debug layer=dap [-> to client]{"seq":0,"type":"event","event":"initialized"} 2021-10-14T09:10:43-04:00 debug layer=dap [-> to client]{"seq":0,"type":"response","request_seq":2,"success":true,"command":"launch"} 2021-10-14T09:10:43-04:00 debug layer=dap [<- from client]{"seq":3,"type":"request","command":"setBreakpoints","arguments":{"source":{"name":"main.go","path":"/Users/hakim/report/a/main.go"},"breakpoints":[{"line":24}],"lines":[24]}} 2021-10-14T09:10:43-04:00 debug layer=dap [-> to client]{"seq":0,"type":"response","request_seq":3,"success":true,"command":"setBreakpoints","body":{"breakpoints":[{"verified":false,"message":"could not find file /Users/hakim/report/a/main.go","source":{}}]}} 2021-10-14T09:10:43-04:00 debug layer=dap [<- from client]{"seq":4,"type":"request","command":"setFunctionBreakpoints","arguments":{"breakpoints":[{"name":"println"},{"name":"init"}]}} 2021-10-14T09:10:43-04:00 debug layer=dap [-> to client]{"seq":0,"type":"response","request_seq":4,"success":true,"command":"setFunctionBreakpoints","body":{"breakpoints":[{"verified":false,"message":"location \"println\" not found","source":{}},{"verified":false,"message":"Location \"init\" ambiguous: runtime.(*itab).init, runtime.(*mcentral).init, runtime.(*fixalloc).init, runtime.(*gcControllerState).init, runtime.(*gcWork).init…","source":{}}]}} 2021-10-14T09:10:43-04:00 debug layer=dap [<- from client]{"seq":5,"type":"request","command":"setInstructionBreakpoints","arguments":{"breakpoints":[]}} 2021-10-14T09:10:43-04:00 debug layer=dap [-> to client]{"seq":0,"type":"response","request_seq":5,"success":true,"command":"setInstructionBreakpoints","body":{"breakpoints":[]}} 2021-10-14T09:10:43-04:00 debug layer=dap [<- from client]{"seq":6,"type":"request","command":"configurationDone","arguments":{}} 2021-10-14T09:10:43-04:00 debug layer=dap [-> to client]{"seq":0,"type":"response","request_seq":6,"success":true,"command":"configurationDone"} 2021-10-14T09:10:43-04:00 debug layer=debugger continuing foo bar main 2021-10-14T09:10:43-04:00 debug layer=dap [-> to client]{"seq":0,"type":"event","event":"terminated","body":{}} 2021-10-14T09:10:43-04:00 debug layer=dap [<- from client]{"seq":7,"type":"request","command":"threads"} 2021-10-14T09:10:43-04:00 debug layer=dap Process 7794 has exited with status 0 2021-10-14T09:10:43-04:00 debug layer=dap [-> to client]{"seq":0,"type":"response","request_seq":7,"success":true,"command":"threads","body":{"threads":[{"id":1,"name":"Dummy"}]}} 2021-10-14T09:10:43-04:00 debug layer=dap [<- from client]{"seq":8,"type":"request","command":"disconnect","arguments":{}} 2021-10-14T09:10:43-04:00 debug layer=dap [-> to client]{"seq":0,"type":"event","event":"output","body":{"category":"console","output":"Process 7794 has exited with status 0\n","source":{}}} 2021-10-14T09:10:43-04:00 debug layer=dap [-> to client]{"seq":0,"type":"event","event":"output","body":{"category":"console","output":"Detaching\n","source":{}}} 2021-10-14T09:10:43-04:00 debug layer=debugger detaching 2021-10-14T09:10:43-04:00 debug layer=dap [-> to client]{"seq":0,"type":"response","request_seq":8,"success":true,"command":"disconnect"} 2021-10-14T09:10:43-04:00 debug layer=dap [-> to client]{"seq":0,"type":"event","event":"terminated","body":{}} 2021-10-14T09:10:43-04:00 debug layer=dap DAP server stopping...
</details>

@gopherbot gopherbot added this to the Untriaged milestone Oct 14, 2021
@hyangah hyangah added the Debug Issues related to the debugging functionality of the extension. label Oct 14, 2021
@suzmue
Copy link
Contributor

suzmue commented Oct 14, 2021

One issue with making the breakpoint failures more obvious is that users with dual debugging there may be many breakpoints that will fail since VS Code sends breakpoints to all active debug sessions (see #1648 (comment)).

Since function breakpoints are user provided text, I agree that for these it might be useful to provide some notification that it was not set.

@polinasok
Copy link
Contributor

vscode UI has a clear marking system for breakpoints. Red if it was successfully set. Grey if it failed. And you can mouse over for the reason. These markers show up both in the side bar and in the code. That's why StopOnEntry is useful. It gives you a chance to validate your breakpoints.

@polinasok
Copy link
Contributor

Also, since we already communicate this with an ErrorResponse, we could turn on showUser to have it generate a visible pop-up.

@hyangah
Copy link
Contributor Author

hyangah commented Oct 14, 2021

@polinasok VS Code UI doesn't show the reasons once the session ends and there is no session. In addition, as @suzmue pointed out, error is not the right action in this case when there are multiple sessions.

@polinasok
Copy link
Contributor

polinasok commented Oct 14, 2021

Sorry, never mind, we don't send error responses. We send a success response with the error messages in it. And in all other cases, where we were not happy with standard UI features, we went for OutputEvents.

@polinasok
Copy link
Contributor

polinasok commented Oct 14, 2021

I do worry that output events get buried amidst everything else (program's output, stderr, logging, etc). Should we intercept the ones sent to stderr as well as ErrorResponses in the thin adapter and also dump all problems to a separate Output tab? Those will survive after the session.

@hyangah
Copy link
Contributor Author

hyangah commented Oct 14, 2021

Most users don't enable logging. Separate Output tab - we already know Go Debug output tab is already hard to discover (and I hope to minimize use of it if possible). :-) Nice thing about Debug Console is there is a dedicated separate console for each debug session.

@polinasok
Copy link
Contributor

I was thinking that problems could be logged to an Output tab always. No logging controls needed. Unless there is a way to put this in the PROBLEMS tab.

Even though there is a dedicated Debug Console per session, the breakpoints from all files will be sent everywhere, so errors will go to all instances :(

@hyangah
Copy link
Contributor Author

hyangah commented Oct 14, 2021

the breakpoints from all files will be sent everywhere, so errors will go to all instances

I'd say showing what breakpoints are effective or not for each session is a good thing. Once the console mode is enabled, I hope output from the target program would go to other terminal.

@hyangah
Copy link
Contributor Author

hyangah commented Oct 14, 2021

We can start with function breakpoints at least - which is easy to misconfigure and needs feedback.

@polinasok
Copy link
Contributor

Yes, we can.

@suzmue suzmue modified the milestones: Untriaged, On Deck Nov 1, 2021
@suzmue suzmue self-assigned this Nov 5, 2021
@gopherbot
Copy link
Collaborator

Change https://golang.org/cl/366915 mentions this issue: docs/debugging: include logpoints, remove stop conditions, revise faqs

gopherbot pushed a commit that referenced this issue Dec 7, 2021
They are all fixed in the latest dlv version.

Updates #1676
Updates #123
Updates #855
Updates #1840

Change-Id: I6014a1382396865a1921eb6c92e1ccccdea556de
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/366915
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Polina Sokolova <polina@google.com>
@hyangah
Copy link
Contributor Author

hyangah commented Dec 7, 2021

Thinking it again, the current breakpoint UI that highlights only effective breakpoints is sufficient. Additional popup or console message will interfere the workflows of already established users more. I hope people find the hint and the verification procedure from the FAQ entry. Closing.

@hyangah hyangah closed this as completed Dec 7, 2021
@golang golang locked and limited conversation to collaborators Dec 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Debug Issues related to the debugging functionality of the extension. FrozenDueToAge
Projects
None yet
Development

No branches or pull requests

4 participants