vscode launch&attach及常用插件使用必備指南

.vscode下創建文件launch.json

{
    // 使用 IntelliSense 瞭解相關屬性。 
    // 懸停以查看現有屬性的描述。
    // 欲瞭解更多信息,請訪問: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "attach lightdb process",
            "type": "cppdbg",
            "request": "attach",
            "name": "attach",
            "program": "/home/zjh/stage/lightdb-x/bin/lightdb",
            "processId": "${command:pickProcess}",
            "cwd": "${workspaceFolder}"
        },
        {
            "name": "start lightdb master",
            "type": "cppdbg",
            "request": "launch",
            "program": "/home/zjh/stage/lightdb-x/bin/lightdb",
            "args": ["-D","stage/lightdb-x/test_incre"],
            "stopAtEntry": false,
            "cwd": "/home/zjh",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "爲 gdb 啓用整齊打印",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
                {
                    "description":  "將反彙編風格設置爲 Intel",
                    "text": "-gdb-set disassembly-flavor intel",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}

tasks.json

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "echo helloworld",
            "type": "shell",
            "command": "echo aaa",
            "problemMatcher": [],
            "group": "test"
        },
        {
            "type": "shell",
            "label": "gcc default",
            "command": "gcc",
            "args": [
                "-I${workspaceFolder}/src/include",
                "${file}",
                "-g", // -g 生成調試信息,不然 無法使用斷點
                "-o",
                
                "${fileDirname}/${fileBasenameNoExtension}.out"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "調試器生成的任務。"
        },
        {
            "type": "shell",
            "label": "gcc",
            "command": "gcc",
            "args": [
                "-I${workspaceFolder}/src/include",
                "${file}",
                "-g", // -g 生成調試信息,不然 無法使用斷點
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}.out"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "test",
                "isDefault": true
            },
            "detail": "調試器生成的任務。"
        },
        {
            "type": "shell",
            "label": "g++",
            "command": "g++",
            "args": [
                "-I${workspaceFolder}/src/include",
                "${file}",
                "-g", // -g 生成調試信息,不然 無法使用斷點
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}.out"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "調試器生成的任務。"
        }
    ]
}

上述已經同時包含launch和attach。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章