I work fine with debugging without adding a file, however, I do not know how to deal with it with file added.
The commands are as follows:
g++ -g --std=c++11 lab1.cpp -o lab1
./lab1 ./tests/extracredit-test-0.txt
The following are my task.json
and launch.json
. I wonder how to modify it to support debugging with the file added.
launch.json
{ // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387"version": "0.2.0","configurations": [ {"preLaunchTask": "build active file","name": "CodeLLDB","type": "lldb","request": "launch","program": "${fileDirname}/${fileBasenameNoExtension}","args": [], }, {"preLaunchTask": "build active file","name": "(lldb) Launch","type": "cppdbg","request": "launch","program": "${fileDirname}/${fileBasenameNoExtension}","args": [],"stopAtEntry": false,"cwd": "${workspaceFolder}","environment": [],"externalConsole": false,"MIMode": "lldb" }, {"name": "GDB","type": "cppdbg","request": "launch","program": "${fileDirname}/${fileBasenameNoExtension}","cwd": "${workspaceFolder}","MIMode": "gdb" } ]}
task.json
// Available variables which can be used inside of strings.// ${workspaceRoot}: the root folder of the team // ${file}: the current opened file // ${fileBasename}: the current opened file's basename // ${fileDirname}: the current opened file's dirname // ${fileExtname}: the current opened file's extension // ${cwd}: the current working directory of the spawned process{"version": "2.0.0","tasks": [ {"label": "build active file","type": "shell","command": "g++ --std=c++11 ${file} -g -o ${fileDirname}/${fileBasenameNoExtension}","group": {"kind": "build","isDefault": true },"presentation": {"echo": true,"reveal": "always","focus": false,"panel": "shared" },"osx": {"command": "g++ --std=c++11 ${file} -g -o ${fileDirname}/${fileBasenameNoExtension}", },"windows": {"command": "g++","args": ["-ggdb","\"${file}\"","--std=c++11","-o","\"${fileDirname}\\${fileBasenameNoExtension}\"" ] } } ]}