vscode + cygwin gdb 調試C/C++ 配置

http://blog.csdn.net/c_duoduo/article/details/51615381c++

cygwin設置

  • cygwin安裝路徑設置到Windows的path環境變量中:
    A:\cygwin\bin
    使得在cmd中可使用gcc/g++命令

visual studio code 配置

  • 設置.vscode下的文件
  • 修改launch.json文件配置,使用如下的代碼覆蓋default
    值得注意的是,」miDebuggerPath」的路徑仍是Windows類型的路徑a:/cygwin/bin/gdb.exe
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "C++ Launch (GDB)",                 // 配置名稱,將會在啓動配置的下拉菜單中顯示
            "type": "cppdbg",                           // 配置類型,這裏只能爲cppdbg
            "request": "launch",                        // 請求配置類型,能夠爲launch(啓動)或attach(附加)
            "launchOptionType": "Local",                // 調試器啓動類型,這裏只能爲Local
            "targetArchitecture": "x86",                // 生成目標架構,通常爲x86或x64,能夠爲x86, arm, arm64, mips, x64, amd64, x86_64
            "program": "${file}.exe",                   // 將要進行調試的程序的路徑
            "miDebuggerPath":"a:/cygwin/bin/gdb.exe", // miDebugger的路徑,注意這裏要與cygwin/MinGw的路徑對應
            "args": ["blackkitty",  "1221", "# #"],     // 程序調試時傳遞給程序的命令行參數,通常設爲空便可
            "stopAtEntry": false,                       // 設爲true時程序將暫停在程序入口處,通常設置爲false
            "cwd": "${workspaceRoot}",                  // 調試程序時的工做目錄,通常爲${workspaceRoot}即代碼所在目錄
            "externalConsole": true,                    // 調試時是否顯示控制檯窗口,通常設置爲true顯示控制檯
            "preLaunchTask": "gcc"                    // 調試會話開始前執行的任務,通常爲編譯程序,c++爲g++, c爲gcc
        }
    ]
}
  • Tasks.json文件設置
{
    "version": "0.1.0",
    "command": "gcc",//對應"preLaunchTask"c++爲g++, c爲gcc
    "args": ["-g","${file}","-o","${file}.exe"],    // 編譯命令參數
    "problemMatcher": {
        "owner": "cpp",
        "fileLocation": ["relative", "${workspaceRoot}"],
        "pattern": {
            "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
            "file": 1,
            "line": 2,
            "column": 3,
            "severity": 4,
            "message": 5
        }
    }
}

  • 這裏設置的「program」編譯出的程序名是含後綴名.c.cpp的exe程序。怎麼設置不要後綴名?
相關文章
相關標籤/搜索