Debugging in VS Code
This chapter will provide an example configuration for debugging PROS programs from VS Code.
Start by installing the Microsoft C/C++ extension. Then add the following to .vscode/tasks.json in your project folder. Create the .vscode folder and that file if they don’t exist yet. If you already have a tasks.json, add the new task to it instead of replacing the file.
{
"version": "2.0.0",
"tasks": [
{
"label": "v5gdb server",
"type": "process",
"command": "v5gdb",
"args": ["--tcp=127.0.0.1:3333"],
"isBackground": true,
"presentation": {
"panel": "dedicated",
"clear": false
},
"problemMatcher": {
"owner": "v5gdb",
"pattern": { "regexp": "^\\b$" },
"background": {
"activeOnStart": true,
"beginsPattern": "^",
"endsPattern": "Listening on "
}
}
}
]
}
Create the following launch configuration in .vscode/launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to V5 (v5gdb)",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/bin/hot.package.elf",
"cwd": "${workspaceFolder}",
"MIMode": "gdb",
"miDebuggerServerAddress": "127.0.0.1:3333",
"stopAtConnect": true,
"preLaunchTask": "v5gdb server",
"setupCommands": [
{ "text": "-enable-pretty-printing", "ignoreFailures": true },
{ "text": "mem 0x100000 0x2c00000 ro cache" },
{ "text": "mem 0x2c00000 0x8000000 rw cache" },
{ "text": "set dcache line-size 1024" },
{ "text": "add-symbol-file ${workspaceFolder}/bin/cold.package.elf", "ignoreFailures": true }
]
}
]
}
The mem and set dcache commands make reading memory faster. See TCP Server mode for details.
Start the program as normal, then press F5 to start debugging it.