`cuda-gdb` adapter cannot start debugging without arguments when used with CMake Tools
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 76/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- typescript
- Domain
- tooling
Research direction
Start in src/debugger/cudaGdbSession.ts around lines 684-686 and inspect how an empty args array is handled for LaunchRequest. Reproduce with the provided CMake Tools configuration and argc/argv program, then verify that CMake: Debug produces argc == 1 with no empty argument.
Written by the indexing model from the issue text.
Description
Problem
When using the cuda-gdb debug adapter from NVIDIA Nsight VS Code Edition, if args in the launch/debug configuration is an empty array:
{
"type": "cuda-gdb",
"request": "launch",
"program": "<path-to-program>",
"args": []
}
the debuggee program will receive one empty string argument, instead of “no arguments”.
That is, the program does not see:
argc == 1, argv[0] == <program>
but instead sees:
argc == 2, argv[0] == <program>, argv[1] == ""
If writing launch.json manually, this issue can be worked around by simply not writing args in the launch configuration object, to express “launch without arguments”.
However, when this plugin is used together with CMake Tools, the de facto standard CMake support extension in VS Code, CMake Tools always provides args in the dynamically generated launch configuration, with the default value being [].
The args semantics expected by CMake Tools are that an empty args array represents no arguments. In this case, the NVIDIA Nsight VS Code Edition plugin cannot start Debug in the expected no-argument way.
Reproduction steps
Prepare a minimal program that prints argc and argv:
#include <iostream>
int main(int argc, char** argv) {
std::cout << "argc = " << argc << "\n";
for (int i = 0; i < argc; ++i) {
std::cout << "argv[" << i << "] = [" << argv[i] << "]\n";
}
return 0;
}
After configuring the CMake Tools extension in .vscode/settings.json, invoke NVIDIA Nsight VS Code Edition for debugging:
"cmake.debugConfig": {
"type": "cuda-gdb",
"request": "launch",
"debuggerPath": "/opt/cuda/bin/cuda-gdb",
"breakOnLaunch": false
}
Run the command CMake: Debug from Ctrl + Shift + P to start debugging. After that, the program will output something like:
argc = 2
argv[0] = [<program>]
argv[1] = []
Expected behavior
The program receives no arguments, and argc == 1.
Suggested fix
Consider modifying the check in src/debugger/cudaGdbSession.ts. Currently, the condition being used is args.args && requestType === 'LaunchRequest'.
[] is truthy, causing the branch to be taken, and [] is converted into one empty string argument "". In fact, when it is [], this branch should not be entered.
Related information
You can check other implementations that support the Debug Adapter Protocol to see the correct semantic convention: for example, lldb-dap interprets an empty args array as empty arguments:
- Dominant language
- TypeScript
- Stars
- 105
- Forks
- 20
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from NVIDIA/nsight-vscode-edition
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
-
Difficulty 4/5 3-5 days Newbie friendliness 30/100
NVIDIA/nsight-vscode-edition#59 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 30/100
NVIDIA/nsight-vscode-edition#56 · 5 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
NVIDIA/nsight-vscode-edition#51 · 1 comment ·
All issues in NVIDIA/nsight-vscode-edition
Similar issues
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 91/100
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 95/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Automattic/studio#4908 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100