首页 > 其他分享 >VSCode-Add_Configuration后launch.json为空的解决办法

VSCode-Add_Configuration后launch.json为空的解决办法

时间:2022-10-28 18:25:51浏览次数:51  
标签:exe launch VSCode text gdb json Add

VSCode - Add Configuration后launch.json为空的解决办法

今天需要使用VSCode debug一个程序,点击菜单栏的“Run”-"Add Configuration" 选项,准备生成一个默认的launch.json文件,结果出来的json文件是这个样子的:

image-20221028175403019

以前不是可以自动生成 launch.json 的么?

没办法,只能手动点击上图的“Add Configuratioin”按钮,手动添加json文件:

image-20221028175544913

结果生成的文件如下:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) 启动",
            "type": "cppdbg",
            "request": "launch",
            "program": "输入程序名称,例如 ${workspaceFolder}/a.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath": "/path/to/gdb",
            "setupCommands": [
                {
                    "description": "为 gdb 启用整齐打印",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
                {
                    "description":  "将反汇编风格设置为 Intel",
                    "text": "-gdb-set disassembly-flavor intel",
                    "ignoreFailures": true
                }
            ]
        }


    ]
}

有几个地方需要手动修改下:

  • program: 就是要运行的程序名字,打开 tasks.json, 复制生成的程序名字即可:

    image-20221028175907812

  • miDebuggerPath: 就是gdb调试器的路径,这里修改成:E:\\msys64\\mingw64\\bin\\gdb.exe就是gdb调试器所在的路径;

  • 添加一个preLaunchTask项,拷贝tasks.json中的label项:

    image-20221028180226471
    复制到 launch.jsonpreLaunchTask 项中:

    image-20221028180836120

最终修改后的launch.json 文件如下:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) 启动",
            "type": "cppdbg",
            "request": "launch",
            "preLaunchTask": "C/C++: g++.exe 生成活动文件",
            "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath": "E:\\msys64\\mingw64\\bin\\gdb.exe",
            "setupCommands": [
                {
                    "description": "为 gdb 启用整齐打印",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
                {
                    "description":  "将反汇编风格设置为 Intel",
                    "text": "-gdb-set disassembly-flavor intel",
                    "ignoreFailures": true
                }
            ]
        }


    ]
}

不明白为什么要把这个功能改成现在这样。。。

标签:exe,launch,VSCode,text,gdb,json,Add
From: https://www.cnblogs.com/yongdaimi/p/16836992.html

相关文章

  • 模拟腾讯返回的json数据
     模拟腾讯返回的json数据 $(document).ready(function(){$("#SubmitButton").click(function(){alert("ajax准备......
  • 腾讯返回json数据转换
     腾讯返回json数据转换 #region----远程获取微信小程序二维码的流----///<summary>///远程获取微信小程序二维码的流///</summary>......
  • C#对象转json
     objectobj=new{Provider=appointmentErpStoreEntity.ProvinceName,City=appointmen......
  • C#后端接收前端json数组
    C#后端接收前端json数组方案一:///<summary>///(APP端)查询购物车选中商品的总价///</summary>publicclassCartTotalPriceRequestDto{/......
  • VSCode-配置c_cpp环境
    VSCode-配置c_cpp环境mac下VSCode配置cpp环境记录:一.环境macOS:10.14VSCode:1.44.2Xcode:11.3.1(会用到Xcode的工具链,如lldb、clang)二.安装插件编辑、调试C/C++......
  • 浅析package.json
    package.json用来描述项目及项目所依赖的模块信息。全文以npm为例package.json与package-lock.json的关系版本指定~会匹配最近的小版本依赖包,比如~1.2.......
  • js对象封装 Json字符
    不废话直接上代码:functionobjUserNickName(UserName,NickName){this.UserName=UserName;this.NickName=NickName;}objuser1=newobjUserNickName();objuser......
  • VSCode-多文件编译执行
    VSCode-配置多文件编译默认VSCode只能编译单个文件,若多个文件一起编译,经常会报undefinedreference找不到引用的错误,比如下面的问题:这个时候即使你把所有的cppcode......
  • notepad++格式化json
    1、JsonView插件地址:https://百度网盘/s/11LJU_9ZI0H5TUOPMbE7jRg   验证码:rsjk​2、使用插件把插件放入到notepad++的安装目录下的plugin下3、使用notepad++格式化json......
  • dotnet6使用System.Text.Json替代Newtonsoft.Json
    HowtoserializeanddeserializeJSONusingC#-.NET|MicrosoftLearn //序列化和反序列号范例usingSystem.Text.Json;usingSystem.Text.Encodings.Web;usin......