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: evaluating an expression while target is running blocks delve and the debug session #762

Closed
polinasok opened this issue Oct 9, 2020 · 1 comment
Labels
Debug Issues related to the debugging functionality of the extension. FrozenDueToAge

Comments

@polinasok
Copy link
Contributor

Steps to reproduce:

  1. Program
func main() {
	for i := 0; true; i++ {
		fmt.Println("================== i", i)
		time.Sleep(2 * time.Second)
	}
}
  1. Launch debug session with "stopOnEntry":true
  2. Click "Continue" (F5)
  3. Evaluate any expression via Debug Console (e.g. 2+2)
  4. Try to pause - it will not work

Log shows:

From client: continue({"threadId":1})
ContinueRequest
To client: {"seq":0,"type":"response","request_seq":9,"command":"continue","success":true}
ContinueResponse
2020-10-09T08:27:52-07:00 debug layer=rpc (async 13) <- RPCServer.Command(api.DebuggerCommand{"name":"continue","ReturnInfoLoadConfig":null})
2020-10-09T08:27:52-07:00 debug layer=debugger continuing
================== i 0
================== i 1
================== i 2
2+2
From client: evaluate({"expression":"2+2","context":"repl"})
EvaluateRequest
2020-10-09T08:28:03-07:00 debug layer=rpc <- RPCServer.Eval(rpc2.EvalIn{"Scope":{"GoroutineID":-1,"Frame":0,"DeferredCall":0},"Expr":"2+2","Cfg":{"FollowPointers":true,"MaxVariableRecurse":1,"MaxStringLen":64,"MaxArrayValues":64,"MaxStructFields":-1}}) <===== BLOCKING
================== i 3
================== i 4
From client: pause({"threadId":1})
PauseRequest
To client: {"seq":0,"type":"response","request_seq":11,"command":"pause","success":true}
PauseResponse <=============== NOT WORKING
================== i 5
================== i 6
From client: pause({"threadId":1})
PauseRequest
To client: {"seq":0,"type":"response","request_seq":12,"command":"pause","success":true}
PauseResponse  <=============== NOT WORKING
From client: disconnect({"restart":false})
DisconnectRequest
HaltRequest  <=============== BLOCKED
================== i 7
Killing debug process manually as we could not halt delve in time
killing debugee (pid: 32107)...
DisconnectRequest to parent
To client: {"seq":0,"type":"response","request_seq":13,"command":"disconnect","success":true}
DisconnectResponse

A call to getDebugState can be used before a call to delve is made to determine if it is running. In that case we can return an error that evaluation of expression is only supported when stopped.

@polinasok polinasok added Debug Issues related to the debugging functionality of the extension. DelveDAP labels Oct 9, 2020
@gopherbot gopherbot added this to the Untriaged milestone Apr 8, 2021
@hyangah hyangah modified the milestones: Untriaged, Backlog Apr 14, 2021
@polinasok
Copy link
Contributor Author

This has been addressed in the new dlv-dap adapter. The pause PR is still pending, but testing this with just disconnect, it is clear that delve is not blocked after getting an expression when running.

================== i 0
================== i 1
2+2
Unable to process `evaluate`: debuggee is running
================== i 2
Detaching and terminating target process
dlv dap (45444) exited with code: 0

With logging on:

8:39:22-07:00 debug layer=debugger continuing
================== i 0
================== i 1
================== i 2
2+2
2021-05-13T18:39:26-07:00 debug layer=dap [<- from client]{"seq":11,"type":"request","command":"evaluate","arguments":{"expression":"2+2","context":"repl","format":{}}}
2021-05-13T18:39:26-07:00 debug layer=dap Unable to process `evaluate`: debuggee is running
2021-05-13T18:39:26-07:00 debug layer=dap [-> to client]{"seq":0,"type":"response","request_seq":11,"success":false,"command":"evaluate","message":"Unable to process `evaluate`","body":{"error":{"id":4000,"format":"Unable to process `evaluate`: debuggee is running"}}}
Unable to process `evaluate`: debuggee is running
2021-05-13T18:39:28-07:00 debug layer=dap [<- from client]{"seq":12,"type":"request","command":"disconnect","arguments":{"terminateDebuggee":true}}
2021-05-13T18:39:28-07:00 debug layer=debugger halting
2021-05-13T18:39:28-07:00 debug layer=dap "continue" command stopped - reason "manual"
2021-05-13T18:39:28-07:00 debug layer=dap [-> to client]{"seq":0,"type":"event","event":"stopped","body":{"reason":"pause","allThreadsStopped":true}}
Detaching and terminating target process
2021-05-13T18:39:28-07:00 debug layer=dap [-> to client]{"seq":0,"type":"event","event":"output","body":{"category":"console","output":"Detaching and terminating target process\n","source":{}}}
2021-05-13T18:39:28-07:00 debug layer=debugger detaching
2021-05-13T18:39:28-07:00 debug layer=dap [-> to client]{"seq":0,"type":"response","request_seq":12,"success":true,"command":"disconnect"}
2021-05-13T18:39:28-07:00 debug layer=dap DAP server stopping...
2021-05-13T18:39:28-07:00 debug layer=dap DAP server stopped
dlv dap (42672) exited with code: 0

@golang golang locked and limited conversation to collaborators May 14, 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

3 participants