VsCode:在launch.json命令中转义widnows路径

问题描述 投票:0回答:1

我使用Vscode + CMake + arm-none-eabi + openocd 在linux 中进行开发。 我无法将此设置迁移到 Windows。这是相关片段:

{
"version": "0.2.0",
"configurations": [
    {
    ...
      "setupCommands": [
      ...
        { "text": "-file-exec-and-symbols ${command:cmake.launchTargetPath}", "description": "load file", "ignoreFailures": false},
      ...
      ],
    ...
    }
  ...
  ]
}

${command:cmake.launchTargetPath}
返回带有
'\'
分隔符的 Windows 路径,当作为 gdb 参数传递时,该分隔符被解释为转义字符。

"C:\\some\path\output.elf"
被传递为
"C:\somepathoutput.elf"

visual-studio-code cmake gdb openocd
1个回答
0
投票
  • 安装命令变量扩展

  • 使用转换命令定义一个输入,将反斜杠转换为斜杠。

  • 使用转换后的输入而不是原始命令

    { “版本”:“0.2.0”, “配置”:[ { “设置命令”:[ { "text": "-file-exec-and-symbols ${command:cmake.launchTargetPath}", “描述”:“加载文件”, “ignoreFailures”:错误 } ] } ], “输入”:[ { "id": "启动目标路径", “类型”:“命令”, "command": "扩展名.commandvariable.transform", “参数”:{ "text": "${command:cmake.launchTargetPath}", “寻找”: ”\”, “代替”: ”/”, “标志”:“g” } } ] }

© www.soinside.com 2019 - 2024. All rights reserved.