From a333d24910cff912a99ca21cdc15e70e7c222c5e Mon Sep 17 00:00:00 2001 From: Ren Baoshuo Date: Sun, 4 Oct 2020 15:26:53 +0800 Subject: [PATCH] [Add] Debug (Linux) --- .vscode/launch.json | 29 +++++++++++++++++++++++++---- .vscode/tasks.json | 36 +++++++++++++++++++++++++++++++----- 2 files changed, 56 insertions(+), 9 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 88c643d9..346cd37a 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,12 +1,33 @@ { - // 使用 IntelliSense 了解相关属性。 + // 使用 IntelliSense 了解相关属性。 // 悬停以查看现有属性的描述。 // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ + { + "name": "[Linux] C++ Launch (GDB)", + "type": "cppdbg", + "request": "launch", + "program": "${fileDirname}/${fileBasenameNoExtension}.exe", + "args": [], + "stopAtEntry": false, + "cwd": "${workspaceFolder}", + "environment": [], + "externalConsole": false, + "MIMode": "gdb", + "miDebuggerPath": "/usr/bin/gdb", + "setupCommands": [ + { + "description": "为 gdb 启用整齐打印", + "text": "-enable-pretty-printing", + "ignoreFailures": true + } + ], + "preLaunchTask": "build" + }, { - "name": "C++ Launch (GDB)", + "name": "[Windows] C++ Launch (GDB)", "type": "cppdbg", "request": "launch", "program": "${fileDirname}\\${fileBasenameNoExtension}.exe", @@ -24,7 +45,7 @@ "ignoreFailures": true } ], - "preLaunchTask": "C/C++: g++.exe build active file" + "preLaunchTask": "build" } ] -} \ No newline at end of file +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 3cb7f6c1..a5e03bdd 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -4,7 +4,6 @@ { "label": "build", "type": "shell", - // 编译参数 ggc -g ${file} -o ${fileDirname}${fileBasenameNoExtension}.exe "windows": { "command": "g++", "args": [ @@ -15,12 +14,21 @@ "--save-temps" ] }, - // 控制台输出的错误信息 + "linux": { + "command": "/usr/bin/g++", + "args": [ + "-g", + "\"${file}\"", + "-o", + "\"${fileDirname}/${fileBasenameNoExtension}.exe\"", + "--save-temps" + ] + }, "problemMatcher": { "owner": "cpp", "fileLocation": [ "relative", - "." // ${workspaceFolder} + "." ], "pattern": { "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$", @@ -35,13 +43,31 @@ "kind": "build", "isDefault": true }, - // 终端面板配置 "presentation": { "echo": true, "reveal": "always", "focus": false, - "panel": "shared" // 控制面板是否在任务中共享面板,shared=共享,new=新面板 + "panel": "shared" } } + // , + // { + // "type": "shell", + // "label": "C/C++: g++ build active file", + // "command": "/usr/bin/g++", + // "args": [ + // "-g", + // "${file}", + // "-o", + // "${fileDirname}/${fileBasenameNoExtension}" + // ], + // "options": { + // "cwd": "${workspaceFolder}" + // }, + // "problemMatcher": [ + // "$gcc" + // ], + // "group": "build" + // } ] } \ No newline at end of file