Repository navigation
Debugee exit code not correctly reported during event_exited #475
Description
Activity
testforstephen commented
on Mar 7, 2023 ContributorMore actionsThe exited event is an internal DAP event, and not supposed to be used by end user. I'm wondering how this affects the user experience?
Hmm, that is strange, what do you mean by internal ? My use case is very much dependent on the exit code, for example i would like to keep the console / terminal stdout/stderr open when the exit code is 1 and simply close it if it is 0 since i don't want / care for the output in that case (for example). Note that i am already using this approach with other adapters - such as codelldb and lldb for example which pickup the exit code correctly.
testforstephen commented
on Mar 14, 2023 ContributorMore actionswhat do you mean by internal ?
The event is a payload that's used between DA Client and DA, not exposed to external. That's why I'm asking how you monitor it in your use case.
asmodeus812 commented
on Mar 14, 2023 AuthorMore actionsAs i mentioned in the op, i am using https://github.com/mfussenegger/nvim-dap. That is the debug client which communicates with with the debugger, and the use case i presented above - i would like to use the exit status of the debugee to control the user interface of the editor. Mathias Fußenegger (@mfussenegger) not sure if this is a valid case ?
mfussenegger commented
on Mar 14, 2023 ContributorMore actionsThe event is a payload that's used between DA Client and DA, not exposed to external. That's why I'm asking how you monitor it in your use case.
nvim-dap allows users to subscribe to the events to run arbitrary custom logic. The specification itself doesn't put any restrictions on how clients might use the data.
Looks like the exit value is currently hard-coded to 0
Line 84 in 31cc033
context.getProtocolServer().sendEvent(new Events.ExitedEvent(0)); Could the
VirtualMachine#process#exitValuebe used to retrieve the actual exit value?testforstephen commented
on Mar 17, 2023 ContributorMore actionsCould the VirtualMachine#process#exitValue be used to retrieve the actual exit value?
Yes, this is the right place to correct the exit value.
Hi Svetlozar Iliev (@asmodeus812), I'm an AI Support assistant here to help with your issue. While the team reviews your request, I wanted to provide some possible tips and documentation that might help you in the meantime.
Suggestions to diagnose and work around this issue:
-
Enable verbose logging of the Java Debug Adapter to confirm whether it ever emits a non-zero exit code:
- In your DAP launch configuration, add
trace = "verbose". - Inspect the adapter messages for an
event exitedpayload (should includebody.exitCode).
- In your DAP launch configuration, add
-
If the
exitCodeis always reported as 0 in the logs, this is a bug in the Java Debug Adapter; please open an issue in the vscode-java-debug repo and include:
• Your sample project ([sample.zip]) and DAP logs (withtrace = "verbose").
• Your DAP client (nvim-dap) version and the adapter version. -
As a temporary workaround, you can explicitly print the exit code in your Java application (e.g.
System.exit(1);) and capture it via your DAP client’s process listener if supported.
The team will respond to your issue shortly. I hope these suggestions are helpful in the meantime. If this comment helped you, please give it a 👍. If the suggestion was not helpful or incorrect, please give it a 👎. Your feedback helps us improve!
-
I am having an issue where the exit code of the debugee is reported as 0 instead of 1 when event_exited completes (fires back), when the debugee exits the session. I am using the latest version of this extension and I am using the following dap plugin in neovim https://github.com/mfussenegger/nvim-dap. I did report the issue first there but the maintiner considers this to be an issue within the actual implementation.
Environment
Steps To Reproduce
Initially reported here - mfussenegger/nvim-dap#886
Sample project for reproduction - sample.zip
{ exitCode = 0, type = "exited" }Current Result
Exit code is 0
Expected Result
Exit code is 1
Additional Information
None