# Launch.json 'args' not passing correctly

**URL:** <https://forums.developer.nvidia.com/t/launch-json-args-not-passing-correctly/315386>\
**Category:** Nsight Visual Studio Code Edition\
**Tags:** debugger, vscode, cuda\
**Created:** [December 2, 2024, 4:01pm UTC](https://forums.developer.nvidia.com/t/launch-json-args-not-passing-correctly/315386 "2024-12-02T16:01:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jsev24](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@jsev24](https://forums.developer.nvidia.com/u/jsev24)\
**Post date:** [December 2, 2024, 4:01pm UTC](https://forums.developer.nvidia.com/t/launch-json-args-not-passing-correctly/315386/1 "2024-12-02T16:01:53Z")

</div>

This has had me confused for a while, was stopping me from using the debugger. Found a workaround but still can’t quite solve the why of it. The following line in launch.json wouldn’t pass my “args”:[“”,…] array correctly

CASE 1: `"args": ["arg1", "arg2"], // correct way to pass args?` CASE 1, doesn’t work.  
CASE 2: `"args": ["arg1 arg2"], // incorrect way to pass args?` CASE 2, works.

**CASE 1 example:**

```auto
"args": ["arg1", "arg2"], // correct way to pass args? CASE 1

```

with verbose on, gdb reports the following with **“;”** in between the args in -exec-arguments

```auto
Type "apropos word" to search for commands related to "word".
GDB command: 0 -gdb-set non-stop off
GDB result: 0 done
GDB command: 1 -gdb-set mi-async on
GDB result: 1 done
GDB command: 2 -file-exec-and-symbols "/path/to/executable/test"
GDB result: 2 done
GDB command: 3 -enable-pretty-printing
GDB result: 3 done
GDB command: 4 -exec-arguments arg1;arg2
GDB result: 4 done

```

and trying to print argv in main() gives this:

```auto
Number of arguments: 2
To client: {"seq":0,"type":"event","event":"output","body":{"category":"stdout","output":"Argument 0: /path/to/executable/test\n"}}
Argument 0: /path/to/executable/test
To client: {"seq":0,"type":"event","event":"output","body":{"category":"stdout","output":"Argument 1: arg1\n"}}
Argument 1: arg1
To client: {"seq":0,"type":"event","event":"output","body":{"category":"stdout","output":"argc 2\n"}}

```

**CASE 2 example:**

```auto
"args": ["arg1 arg2"], // incorrect way to pass args? CASE 2

```

with verbose on, gdb reports the following -exec-arguments

```auto
To client: {"seq":0,"type":"event","event":"output","body":{"category":"stdout","output":"For help, type \"help\".\n"}}
For help, type "help".
To client: {"seq":0,"type":"event","event":"output","body":{"category":"stdout","output":"Type \"apropos word\" to search for commands related to \"word\".\n"}}
Type "apropos word" to search for commands related to "word".
GDB command: 0 -gdb-set non-stop off
GDB result: 0 done
GDB command: 1 -gdb-set mi-async on
GDB result: 1 done
GDB command: 2 -file-exec-and-symbols "/path/to/executable/test"
GDB result: 2 done
GDB command: 3 -enable-pretty-printing
GDB result: 3 done
GDB command: 4 -exec-arguments arg1 arg2
GDB result: 4 done

```

and trying to print argv in main() gives this:

```auto
Number of arguments: 3
To client: {"seq":0,"type":"event","event":"output","body":{"category":"stdout","output":"Argument 0: /path/to/executable/test\n"}}
Argument 0: /path/to/executable/test
To client: {"seq":0,"type":"event","event":"output","body":{"category":"stdout","output":"Argument 1: arg1\n"}}
Argument 1: arg1
To client: {"seq":0,"type":"event","event":"output","body":{"category":"stdout","output":"Argument 2: arg2\n"}}
Argument 2: arg2

```

**Full launch.json**

```json
{
    "version": "0.2.0",
        "configurations": [
          

          {
            "name": "CUDA C++: Launch",
            "type": "cuda-gdb",
            "request": "launch",   
            "program": "${workspaceFolder}/test",
            //"args": ["arg1", "arg2"], // correct way to pass args? CASE 1
            "args": ["arg1 arg2"], // incorrect way to pass args? CASE 2
            "stopAtEntry": false,                     
            "verboseLogging": true      
          }
        ]
      
}

```

**main entry and print**

```auto
int main(int argc, char **argv) {
  

  std::cout << "Number of arguments: " << argc << std::endl;

    for (int i = 0; i < argc; ++i) {
        std::cout << "Argument " << i << ": " << argv[i] << std::endl;
    }

```

**Versions:**  
Ubuntu 22.04.5 LTS; 6.8.0-49-generic

nvcc: NVIDIA (R) Cuda compiler driver Built on Thu\_Nov\_18\_09:45:30\_PST\_2021  
Cuda compilation tools, release 11.5, V11.5.119  
Build cuda\_11.5.r11.5/compiler.30672275\_0

Nsight VSCE v2024.1.34572442

Compiled with g++ -g -O0 for .cpp files, nvcc -g -G -0O for .cu files

g++/gcc 9.5.0

**Additional gdb version details:**

> **Summary**
>
> Logger successfully initialized
> 
> Confirmed that we are on a Linux system
> 
> cuda-gdb found and accessible
> 
> Calling launch request in super class
> 
> GDB notify async: thread-group-added,id=“i1”
> 
> To client: {“seq”:0,“type”:“event”,“event”:“output”,“body”:{“category”:“stdout”,“output”:“NVIDIA (R) CUDA Debugger\n”}}
> 
> NVIDIA (R) CUDA Debugger
> 
> To client: {“seq”:0,“type”:“event”,“event”:“output”,“body”:{“category”:“stdout”,“output”:“11.5 release\nPortions Copyright (C) 2007-”}}
> 
> 11.5 release Portions Copyright (C) 2007-To client: {“seq”:0,“type”:“event”,“event”:“output”,“body”:{“category”:“stdout”,“output”:“2021 NVIDIA Corporation\n”}}
> 
> 2021 NVIDIA Corporation
> 
> To client: {“seq”:0,“type”:“event”,“event”:“output”,“body”:{“category”:“stdout”,“output”:“GNU gdb (GDB) 10.1\n”}}
> 
> GNU gdb (GDB) 10.1
> 
> To client: {“seq”:0,“type”:“event”,“event”:“output”,“body”:{“category”:“stdout”,“output”:“Copyright (C) 2020 Free Software Foundation, Inc.\n”}}
> 
> Copyright (C) 2020 Free Software Foundation, Inc.
> 
> To client: {“seq”:0,“type”:“event”,“event”:“output”,“body”:{“category”:“stdout”,“output”:“License GPLv3+: GNU GPL version 3 or later [http://gnu.org/licenses/gpl.html](http://gnu.org/licenses/gpl.html)\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law.”}}
> 
> License GPLv3+: GNU GPL version 3 or later [http://gnu.org/licenses/gpl.html](http://gnu.org/licenses/gpl.html) This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.To client: {“seq”:0,“type”:“event”,“event”:“output”,“body”:{“category”:“stdout”,“output”:“\nType "show copying" and "show warranty" for details.\n”}}

---

<div class="post-metadata">

**Author:** ![veraj](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/veraj/32/256893_2.png) [@veraj](https://forums.developer.nvidia.com/u/veraj)\
**Post date:** [December 6, 2024, 9:51am UTC](https://forums.developer.nvidia.com/t/launch-json-args-not-passing-correctly/315386/2 "2024-12-06T09:51:19Z")

</div>

Hi, @jsev24

Thanks for reporting this !  
This is a known issue and we have a internal bug for tracking. If there is any update, I will let you know.

---

<div class="post-metadata">

**Author:** ![veraj](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/veraj/32/256893_2.png) [@veraj](https://forums.developer.nvidia.com/u/veraj)\
**Post date:** [May 26, 2025, 6:29am UTC](https://forums.developer.nvidia.com/t/launch-json-args-not-passing-correctly/315386/4 "2025-05-26T06:29:24Z")

</div>

Please note this issue will be fixed in our next release. Feel free to have a try then.

---

<div class="post-metadata">

**Author:** ![veraj](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/veraj/32/256893_2.png) [@veraj](https://forums.developer.nvidia.com/u/veraj)\
**Post date:** [June 25, 2025, 6:29am UTC](https://forums.developer.nvidia.com/t/launch-json-args-not-passing-correctly/315386/5 "2025-06-25T06:29:59Z")

</div>

Closed on June 25, 2025, 6:29am UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
