Linux VSCodeデバッグC++

6778 ワード

VSCodeはC++の構成をデバッグします.ここでlaunchを修正しました.jsonとtask.jsonファイル.この設定は、現在のファイルをコンパイルし、プロジェクトフォルダの下でa.out実行可能ファイルを生成するために使用されます.複数のファイルエンジニアリングをコンパイルおよび単一ステップでデバッグする必要がある場合は、Makefile.txtまたはCMakeLists.txtファイルは、可変式の実行可能ファイルを生成した後、実行可能ファイルを単一ステップでデバッグします.
launch.json
修正しました
"program": "${workspaceFolder}/a.out",
"preLaunchTask": "g++",

変更後は次のようになります.
{
    //    IntelliSense       。 
    //             。
    //        ,   : https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/a.out",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": true,
            "MIMode": "gdb",
            "preLaunchTask": "g++",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}

task.json
{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "g++",
            "type": "shell",
            "command": "g++",
            "args": [
                "${file}",
                "-o",
                "${workspaceRoot}/a.out"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}