-
Notifications
You must be signed in to change notification settings - Fork 454
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
Add script mode and ability to connect to externally launched CMake process. #3277
Conversation
…tuation, set up env for script debugging
…ebug types, and stub validation in code
NOTE: This should not be merged before we release 1.15. |
External debugging worked as expected. Configure debugging still cannot be stopped if the pipe never connects. This only happens if you trick code to use a different CMake which only reacts like CMake without the debugger; e.g. set
|
* `external` | ||
* required | ||
* `pipeName` - Name of the pipe (on Windows) or domain socket (on Unix) to use for debugger communication. | ||
* optional |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this get an optional "command" : []
field/array? So that VS code executes the command I would normally use to start the cmake pipe externally?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To help me think through the possible design implications, could you go into more detail regarding your use case for the external
mode?
What kind of external processes are you expecting? It is a CMake invocation? Or is it invoking something else that internally invokes CMake?
What are you expecting or hoping to use in the "command"
field?
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a CMake invocation? Or is it invoking something else that internally invokes CMake?
Could be both of those.
What are you expecting or hoping to use in the "command" field?
For example I could write a (CMake) script (not the debug target) which does the following:
- FetchContent vcpkg
- bootstrap vcpkg
- vcpkg install (with some additional options to pass on the debugger pipe info)
- vcpkg internally calls
cmake -P
which could be debugged - vcpkg internally calls
cmake
in configure mode which could be debugged
The intention of having a command
field is to automate the process. E.g.
"command" : ["cmake", "-P", "my-internal-cmake-caller-script.cmake", "-DDEBUGGER_PIPE_NAME=<name_of_debugger_pipe>"]
DEBUGGER_PIPE_NAME
is internally passed on to some process calling cmake. (doesn't really matter what it is)
But if "command" is added "workingDir" probably also makes sense to define where the command is executed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That being said I am also happy with the current approach. It is just that it takes more manual labor for startup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understood. I wonder if using a preLaunchTask
is what you want. This way the pre launch task can be fully arbitrary. Do you think using that would suit your needs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't know about that. If there is a possibility to detach then probably yes if it needs to return than probably no. Need to read up on that first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just tested and found that if you set up a tasks.json task with the following settings as part of that task:
"isBackground": true,
// This task is run before some debug tasks.
// Problem is, it's a watch script, and since it never exits, VSCode
// complains. All this is needed so VSCode just lets it run.
"problemMatcher": [
{
"pattern": [
{
"regexp": ".",
"file": 1,
"location": 2,
"message": 3
}
],
"background": {
"activeOnStart": true,
"beginsPattern": ".",
"endsPattern": ".",
}
}
]
then you can successfully have a preLaunch task.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm I need some delay or some retry count to connect the debugger to the pipe since the debugger wants to start before the prelaunch task reached the point where the pipe is opened. (That being said: Hitting the run button simply twice works as expected; somehow vs code sees that the task is still running and does not rerun it.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK I think there is nothing to do here. I can just define a task and let it run via VS Code directly instead of manually typing it. Never used task since I mainly use CMake presets. Would be nice if there is a way to somehow get the pipename from a task.json via some variable.
This may be because I haven't done any handling of variables. To confirm, could you attempt it again by putting either a relative or full path? UPDATE: Actually, this seems to already be natively handled from launch.json. I realized I wasn't handling a case where |
If you give me a new |
This PR was a timely discovery for me; I need to debug a cmake issue with several subprocess invocations of cmake. Is there an existing mechanism to get .vsix files for this branch? I was able to attach the debugger to the initial cmake process via configure/reconfigure with CMake debugger, but am not yet having success with an external to attach to a subprocess. I pulled the branch and was able to create a .vsix - I haven't done much with VSCode extensions at all. |
One item I noted, it seems like an extension can provide seed/snippets via the Add Configuration UI, though I'm not familiar with the mechanism/API. |
@benmcmorran @snehara99 This PR is ready for review and testing. |
…/microsoft/vscode-cmake-tools into dev/gcampbell/ScriptModeDebugger
@snehara99 @benmcmorran ping for review. |
package.json
Outdated
"request": "launch", | ||
"name": "%cmake-tools.debugger.script.snippet.body.name%", | ||
"cmakeDebugType": "script", | ||
"scriptPath": "^\"\\${workspaceFolder}/<...>\"" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the ^
for? Does this act as a regex? If it's not, we can probably hardcode something like <script>.cmake
even though it won't exist just to make the example clearer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@benmcmorran ping for review.
Specifically, #3277 (comment)
@gcampbell-msft Is this waiting on something? |
We are pending another code review. Our team hopes to get on this in the next week or two, thank you for the ping! |
Merging without tests because they passed prior to the changelog changes, and the changelog doesn't affect tests. |
This change addresses item #3248 as well as adding functionality.
This updates the options that are available in launch.json for the
cmake
debug type.The following changes are proposed:
cmakeDebugType
to the launch.json that defines whether the user is trying to debug under the three available modes:configure
,external
,script
.cmake
is initiated.cmakeDebugType
isexternal
regarding dapLog. We can simply assign it unconditionally, knowing that it will be ignored in theexternal
mode. Inscript
andconfigure
it will be used as normal.The purpose of this change is to add the ability to debug externally launched CMake processes or debug Cmake scripts.