MS VS-Code C++ debugging

Aman Datta
Jun 15, 2022

--

This tutorial covers following tasks.
How to remote debug C++ application in VS-Code.

Install following extensions
- ms-vscode.cpptools (https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools)
- ms-vscode-remote.remote-ssh (https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools)

Now write your C++ code (code.cpp)and compile using following command

g++ code.cpp -o code -g

Note: code is the compiled binary name.

Add new run configuration in launch.json

Example 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": [{"name": "(gdb) Launch","type": "cppdbg","request": "launch","cwd" : ".","program": "${workspaceFolder}/code","MIMode": "gdb","logging": { "engineLogging": true, "trace": true, "traceResponse": true }}]}

Now switch to ide code editor cpp file and press F5 to start debugging session

--

--