microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issue with escaping characters in launch.json arguments

HenrikBach1 opened this issue · comments

Environment

  • OS and version: 22.04.4 LTS (Jammy Jellyfish)

  • VS Code:
    Version: 1.89.1
    Commit: dc96b837cf6bb4af9cd736aa3af08cf8279f7685
    Date: 2024-05-07T05:16:23.416Z
    Electron: 28.2.8
    ElectronBuildId: 27744544
    Chromium: 120.0.6099.291
    Node.js: 18.18.2
    V8: 12.0.267.19-electron.0
    OS: Linux x64 6.5.0-35-generic snap

  • C/C++ extension:
    C/C++ v1.20.5
    C/C++ Extension Pack v1.3.0

  • GDB / LLDB version:
    GNU gdb (Ubuntu 12.1-0ubuntu1~22.04) 12.1
    Command 'lldb' not found

Bug Summary and Steps to Reproduce

Description:
When configuring launch.json in VSCode, I am encountering an issue with properly escaping double quotes in my arguments. My current configuration looks like this:

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Launch Program",
      "type": "cppdbg",
      "request": "launch",
      "program": "${workspaceFolder}/program.exe",
      # args under discussion
      "cwd": "${workspaceFolder}",
      "externalConsole": false,
      "MIMode": "gdb"
    }
  ]
}

Args under discussion
The result in arg I want is command "file":

  1. The first and most obvious args that I tried was "args": ["-g", "command \"file\"'"] resulting in running code that arg becomes: command file and which is not as expected command "file".
  2. The second was "args": ["-g", "command \\\"file\\\"'"] resulting in running code that arg becomes: command \"file\", which is as expected.
  3. The third try was "args": ["-g", "command "file""] which isn't correct/allowed launch.json syntax, which is also expected.

Isn't there a bug luring around here in the first attempt?

Thank you in advance
Henrik Bach

Debugger Configurations

{
            "name": "Debug C Program",
            "type": "cppdbg", // Run
            "request": "launch",
            "program": "${workspaceFolder}/src/cvechecker",
            # args under discussion
            ,"stopAtEntry": true,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "make-build",
            "miDebuggerPath": "/usr/bin/gdb", // Adjust this path if necessary
            "logging": {
                "engineLogging": true
            }
        }

Debugger Logs

N/A

Other Extensions

N/A

Additional Information

No response