microsoft / microsoft/vscode-cpptools

Issue with escaping characters in launch.json arguments

Open
#12,350 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

debugger help wanted investigate: repro Language Service
Dominant language
TypeScript
Stars
6.2k
Forks
1.7k
Avg merge
14h 46m
Merged PRs (30d)
61

Description

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 not what I want, but which is as expected.
  3. The third try was "args": ["-g", "command "file""] which isn't correct/allowed launch.json syntax.

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the supplied launch.json configuration with the three argument-escaping variants and inspect the argument received by the program. There are no named source files or tests in the report; done means establishing the expected escaping behavior and documenting or fixing the path that produces the incorrect argument.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, vscode
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.