-
Notifications
You must be signed in to change notification settings - Fork 344
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
Support running command before attaching debugger #120
Comments
We probably need a new a concept like |
@fbricon @gorkem
|
For node.js debugging we've solved the problem by allowing any program/script to be used in a launch configuration. The only requirement is that the program/script opens a debug port at the end and then the debugger can attach to it. Example: first a regular config for a node.js program: {
"type": "node",
"request": "launch",
"name": "Launch test.js",
"program": "${workspaceFolder}/test.js"
} Here And in the following we set {
"type": "node",
"request": "launch",
"name": "Launch mocha tests",
"runtimeExecutable": "mocha"
} (you can find this in our docu here) So we have basically generalised the launch config to support two phases:
Maybe you could use a similar approach for Java, e.g. something like this: {
"type": "java",
"name": "Debug Maven tests",
"request": "launch",
"runtimeExecutable": "mvn",
"runtimeArgs": [ "-Dmaven.surefire.debug", "test" ],
"port": 5005
} |
@weinand Thanks for the suggestion. Got it. if java debugger sends |
Yes, your understanding is correct. Here are some additional details: There are basically two ways a DA can run a target (the
This means the DA cannot really know whether the launching of the target was successful and whether the target is ready for debugging. For this reason the DA starts trying repeatedly to attach to the debug port (and it times out after 20 seconds). Please note that the DA makes no difference between launching a regular java runtime (e.g. |
Understand, i think i got the answer. Thanks again. |
find no resource to finish it yet, add it to backlog. |
Any updates? Here is a scenario that by specifying prelaunchtask to execute "mvnDebug" in the "attach" config, I want to debug in one-click. But prelaunchTask seems not to work with background command, as mentioned in microsoft/vscode-maven#49 (comment) And any ideas about the use case for mvnDebug users? |
If the Below is the tasks.json spring-boot sample:
And launch.json sample:
|
This is a good workaround but there's still the issue of the VS Code popup telling you that errors exist and you have to click "Debug Anyway" to continue. Maybe we can get a "successMatcher" instead, that attaches the debugger automatically when it matches "endsPattern"? |
It's possible to debug tests running from a Maven build by calling
mvn -Dmaven.surefire.debug test
, then attaching the debugger to a remote Java process on port 5005, likeSo this requires 2 separate actions from the user. Ideally, one would define a new 'surefire-debug' task for
mvn -Dmaven.surefire.debug test
and add"preLaunchTask": "surefire-debug"
to the launch configuration. The problem is running that command doesn't return an exit code, since it's waiting for a debugger to attach, so the prelaunch task never finishes and the debugger never kicks in: you're stuck.So it'd be nice if the debugger detected port 5005 is responding, before the preLaunchTask finishes.
If preLaunchTasks absolutely must finish before the debugger kicks in, then we might need to have a preLaunchCommand (or whatever better name) instead. Debugger bootstrap waits until port 5005 responds following execution of preLaunchCommand, then proceeds.
The text was updated successfully, but these errors were encountered: