Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [lsp4e-dev] How to cleanly terminate a session?

Hi Jonah,

Thanks for the response. I've seen that Overview diagram before, and I'm essentially following what it does, though since I have a REPL loop evaluating multiple expressions the adapter has no reason to send back a "terminated" event after (say) the first evaluation. If I tweak it to add that event, the socket to the DA Launcher is closed and subsequent REPL commands give an error, but the Eclipse "Debug Adapter Target" is still showing an active thread after the terminate - it's "stuck" :(

17:35:57.021: <<< DAP { "type" : "response", "seq" : 16, "request_seq" : 6, "command" : "evaluate", "success" : true, "body" : { "result" : "= 12178", "variablesReference" : 0 } }
17:35:57.021: <<< DAP { "type" : "event", "seq" : 17, "event" : "output", "body" : { "output" : "Executed in 2.891 secs.\n" } }
17:35:57.022: <<< DAP { "type" : "event", "seq" : 18, "event" : "output", "body" : { "output" : "A> " } }
17:35:57.023: <<< DAP { "type" : "event", "seq" : 19, "event" : "terminated" }
17:35:57.023: >>> DAP {"type":"request","seq":11,"command":"threads"}
17:35:57.024: <<< DAP { "type" : "response", "seq" : 20, "request_seq" : 11, "command" : "threads", "success" : true, "body" : { "threads" : [  ] } }
17:35:57.056: >>> DAP {"type":"request","seq":12,"command":"stackTrace","arguments":{"threadId":14,"startFrame":0,"levels":20}}
17:35:57.057: <<< DAP { "type" : "response", "seq" : 21, "request_seq" : 12, "command" : "stackTrace", "success" : true, "message" : "", "body" : { "stackFrames" : [  ], "totalFrames" : 0 } }

And in the console:

A> f()
Executed in 2.891 secs.
= 12178
A> 1+1
org.eclipse.lsp4j.jsonrpc.JsonRpcException: java.net.SocketException: Socket closed

Without the "terminated", the REPL loop continues and I can evaluate multiple expressions, which is what I need... but I can't stop the thing cleanly in that case!
I suppose I could interpret the "evaluate" _expression_, look for "/quit" and then send a terminated event, but it looks like the DA Target would still not terminate gracefully.
If I'm missing something, please let me know :)

Cheers,
-nick


On Fri, 27 Mar 2020 at 17:07, Jonah Graham <jonah@xxxxxxxxxxxxxxxx> wrote:
Hi Nick,

There is some documentation as part of the spec as far as shutdown/termination -  https://microsoft.github.io/debug-adapter-protocol/overview "Debug session end" section  - please let me know if that is helpful and if LSP4E.debug is not handling something in that area properly.

Once you kill it by force, the whole thing usually locks up on subsequent launches.

This sounds like a bug.

Is there a clean way to close a session?

There should be - but I can't look it up at the moment. However I admit that a lot of the time the terminating of the debug session is overlooked a little, hence bugs in that area.  


Thanks,
Jonah
 
~~~
Jonah Graham
Kichwa Coders
www.kichwacoders.com


On Fri, 27 Mar 2020 at 12:56, Nick Battle <nick.battle@xxxxxxxxx> wrote:
Hi Mickael,

Thanks for the suggestions.

To illustrate the point that often problems are not bugs but my own misunderstandings, I've just made a considerable improvement by adding Thread started/exited events to my adapter. Now lsp4e seems a *lot* happier and will evaluate multiple sequential debug executions without locking up or getting confused about which threads are which.

I still can't get the adapter to terminate gracefully, so perhaps I'm missing something *else*... and some valid DAP traces would be very useful. I'll check the examples you suggest. Thanks again.

Cheers,
-nick

_______________________________________________
lsp4e-dev mailing list
lsp4e-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/lsp4e-dev
_______________________________________________
lsp4e-dev mailing list
lsp4e-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/lsp4e-dev

Back to the top