Debugging on Windows/VSCode/gdb (Not all breakpoints work)

I’m dipping my toes into plugin development and it’s a blast. Actually ChatGPT is doing most of the heavy lifting between us, but we’re on our way and it’s fun. My part is to make mistakes so I’m trying to setup the debugger (VSCode + gdb).

I found a working launch.json to connect gdb to the rack process.

    "configurations": [
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "C:/Program Files/VCV/Rack2Pro/Rack.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [{ "name" : "PATH", "value" : "C:/Users/ds/Documents/Rack-SDK/dep/bin;C:/msys64/mingw64/bin;${env.PATH}" }],
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath": "C:/msys64/mingw64/bin/gdb.exe",
            "setupCommands": [
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                    "description": "Set Disassembly Flavor to Intel",
                    "text": "-gdb-set disassembly-flavor intel",
                    "ignoreFailures": true
    "version": "2.0.0"

Editing and commenting out $(STRIP) -s dist/$(SLUG)/$(TARGET) as @Richie suggested was what finally made it work.

However, it does stop one some breakpoints but not all. On top of that, some variables when I hover over them or add them to the watch window return the message .

I edited the Makefile to disable optimization and include all debug information

CFLAGS += -O0 -g3
CXXFLAGS += -O0 -g3

but the problem remains.

Does anyone know how to fix this?


Today I learned about -Og:

Optimize debugging experience. -Og should be the optimization level of choice for the standard edit-compile-debug cycle, offering a reasonable level of optimization while maintaining fast compilation and a good debugging experience. It is a better choice than -O0 for producing debuggable code […]

See whether that helps. I’d be interested to hear whether it makes a difference!


The problem was I had forgotten to update the Rack-SDK. Updating it solved the erratic behavior.

There’s still more variables optimized out than I would like, but at least it’s working.

I didn’t notice any difference (yet) between -O0 and -Og. Going to dig a bit deeper in disabling all optimizations using -Q -O0 --help=optimizers and report back if something comes out of it. Thanks for thinking along.

1 Like

I have noticed making my own build of rack and using the make run launch option actually finds some bugs (by code crash) the SDK won’t (using a normal rack launch) so perhaps ./Rack -d to launch?

1 Like