zoukankan      html  css  js  c++  java
  • VSCODE 针对调试C语言时一闪而过解决办法

    针对调试C语言时一闪而过解决办法

    前提:

    已经按照 C/C++

    已经安装 MINGW(并配置完成)

    原因:

     主要是因为tasks的配置没有写对

    解决办法:

    tasks.json

    {
        // See https://go.microsoft.com/fwlink/?LinkId=733558
        // for the documentation about the tasks.json format
        "version": "2.0.0",
        "command": "gcc",
        //gcc 编译条件
        //gcc gdb-sample.c -o gdb-sample -g
        "args": [
            "${file}",
            "-o",
            "${fileDirname}/${fileBasenameNoExtension}",
            "-g",
        ],
    }

    最主要的就是args这个参数了

    配合GCC编译调试条件填写即可

    gcc gdb-sample.c -o gdb-sample -g

    gcc="command": "gcc"

    gdb-sample.c=源文件 也就是 "${file}"

    -o=编译条件

    gdb-sample="生成文件",可以写成"${fileDirname}/${fileBasenameNoExtension}",

    -g=调试条件

    Launch.json

    {
        // 使用 IntelliSense 了解相关属性。 
        // 悬停以查看现有属性的描述。
        // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
        "version": "0.2.0",
        "configurations": [
            {
                "name": "(gdb) Launch",
                "type": "cppdbg",
                "request": "launch",
                "targetArchitecture": "x64",
                "program": "${fileDirname}/${fileBasenameNoExtension}.exe",
                "args": [],
                "stopAtEntry": false,
                "cwd": "${workspaceFolder}",
                "environment": [],
                "externalConsole": false,
                "MIMode": "gdb",
                "miDebuggerPath": "C:\MinGW\bin\gdb.exe",
                "setupCommands": [
                    {
                        "description": "Enable pretty-printing for gdb",
                        "text": "-enable-pretty-printing",
                        "ignoreFailures": true
                    }
                ],
                "preLaunchTask": "gcc"
            }
        ]
    }

     launch最主要就是两个

    miDebugggerPath=这个是gdb所在的位置,仔细填写即可

    program=这个则是调试可运行程序所在的位置。

    对于具体的vscode的条件编写可以参考https://code.visualstudio.com/docs/editor/variables-reference【可配合谷歌浏览器实时翻译】

  • 相关阅读:
    MySql使用游标Cursor循环(While)更新数据
    初试TinyIoCContainer笔记
    用Razor做静态页面生成器
    在CentOS6.5上安装MariaDB
    mono的远程调试
    mono3.2.3+Jexus5.5+openSuSE13.1的asp.net
    mono3.2和monodevelop4.0在ubuntu12.04上两天的苦战
    第一节知识点:.net与c#的概念
    支付宝支付功能(使用支付宝sdk)
    vs2017/vs2019 去掉 单击aspx文件预览页面
  • 原文地址:https://www.cnblogs.com/T-ARF/p/9766142.html
Copyright © 2011-2022 走看看