Hey does anyone have a fix for the VSCode gdb debugger running inside of the IDE at some point won't observe breakpoints and the red dots turn to little grey circles.
It might be good information that I've had this happen whether the program is a git repo program, a clone or stand-alone. Just at some point the breakpoints stop working almost as thought there comes to be some kind of disconnect between the files that are .cpp and .o and .exe or something. Like some symbol table or something gets out of validity or something.
I've tried cloning directories and I've tried making new directories. I've tried cloning and pushing into brand new repos and I've tried cutting all ties with other programs and git and just using a tar ball without any git stuff in it to reproduce that program and either immediately or eventually my breakpoints lately will stop working in the way described, with the little grey circle.
Here's my tasks.json and launch.json:
{
"version": "2.0.0",
"tasks": [
{
"label": "g++ build active file",
"type": "shell",
"command": "/usr/bin/g++",
"args": [
"-g",
"${workspaceFolder}/src/main.cpp",
"${workspaceFolder}/src/Cmd.cpp",
"${workspaceFolder}/src/Command.cpp",
"${workspaceFolder}/src/EthernetFrame.cpp",
"${workspaceFolder}/src/RxObserver.cpp",
"${workspaceFolder}/src/COM.cpp",
"-o",
"${workspaceFolder}/cmd",
"-I${workspaceFolder}/include",
"-I/usr/include/jsoncpp", // Corrected JSON include path
"-L/usr/lib", // Add this if needed
"-lnet",
"-lpcap",
"-lpthread",
"-ljsoncpp"
],
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": ["$gcc"],
"detail": "Generated task to build the project"
}
]
}
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug (g++ - Build and Debug active file)",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/cmd",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false, // Use the integrated terminal instead of an external console
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"miDebuggerPath": "/usr/bin/gdb",
"preLaunchTask": "g++ build active file",
"serverLaunchTimeout": 10000,
"filterStdout": true,
"filterStderr": true,
"sourceFileMap": {
"/usr/local/cmd/src": "${workspaceFolder}/src",
"/usr/local/cmd/include": "${workspaceFolder}/include"
}
}
]
}
I've seen this happen before – it’s usually a symptom of a stale or mismatched build. My advice is:
Clean Build: Make sure you’re doing a clean build so that the binary’s debug symbols are up-to-date. Sometimes lingering .o or executable files cause a disconnect.
Source File Mapping: Double-check your "sourceFileMap"
settings to ensure gdb is looking at the correct source directories.
Restart Debugger: Occasionally, simply stopping the debugger (or even VS Code) and starting it again resolves the issue.
If these steps don’t help, it might be worth trying to remove and re-add the breakpoints manually.