Debug in VSCode with Rack-SDK?

@Vortico
Here happens the same thing with the same confuguration system,
Rack executed with GDB from VSCODE, it does not unzip the plugin in the default local folder.
I want to add that VSCODE:
when the plugin is unzipped and present, it works fine, I can debug with GDB without problem.

@Richie
Please you could post your configuration files for Visual Studio so I could try it?

1 Like

@flowstoner Sure: my Rack checkout is in C:\src\Rack\Rack, with the executable at C:\src\Rack\Rack\Rack.exe. My launch.vs.json is in C:\src\Rack\Rack\.vs and looks like this:

{
    "version": "0.2.1",
    "defaults": {},
    "configurations": [
        {
            "type": "cppdbg",
            "name": "Rack.exe",
            "project": "Rack.exe",
            "cwd": "${workspaceRoot}",
            "program": "${debugInfo.target}",
            "MIMode": "gdb",
            "miDebuggerPath": "${env.MINGW_PREFIX}\\bin\\gdb.exe",
            /*"externalConsole": true,*/
            "args": [
                "-d"
            ]
        }
    ]
}

One thing to beware of: the default .gitignore for Rack includes Rack.exe, which prevents Visual Studio from showing it in Solution Explorer. It took me a while to figure out why I couldn’t see it!

1 Like

@Richie Thanks!
This is to launch and debug Rack itself with GDB, but with the -d flag Rack not load any external module, only the core one,
ours problems is that Rack(no -d flag) not unzip the plugin when loaded with GDB.

Anyway, now visual studio correctly supports the intellisense with gcc? the last time I tried to configure it didn’t work properly. If you use it and confirm that it works well, could you also share your .json configuration?

1 Like

@flowstoner: I have no configuration for IntelliSense. I’m using the Open Folder feature of Visual Studio with my Rack checkout and it all just works.

1 Like

@Richie Ok, need to try Visual Studio again. What version are you using, VS2017 15.x ?

Yes: VS2017 Community, 15.9.7.

2 Likes

We have lots of stuff now. We just need the @Vortico answer of why its unable to unzip :smile:

1 Like

This is an old post but I got debugging working in part thanks to it. So i guess I will share how i did it.

I have a “Rack-SDK” folder and inside it a “.vscode” folder with this files.

settings.json

{
  {
    "terminal.integrated.shell.windows": "c:\\msys64\\usr\\bin\\bash.exe",
    "terminal.integrated.shellArgs.windows": ["--login"],
    "terminal.integrated.env.windows": {
        "CHERE_INVOKING": "1",
        "MSYSTEM": "MINGW64"
    }
}

task.json

{
  {
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Build VCV Rack plugin",
            "type": "shell",
            "command": "make install -j4",
            "options": {
                "cwd": "${workspaceFolder}/plugins/LomasModules",
                "env": {
                    "PATH": "C:\\msys64\\usr\\bin\\;C:\\msys64\\mingw64\\bin"
                }
            },
            "problemMatcher": {
                "owner": "cpp",
                "fileLocation": [
                    "absolute"
                ],
                "pattern": {
                    "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
                    "file": 1,
                    "line": 2,
                    "column": 3,
                    "severity": 4,
                    "message": 5
                }
            }
        },
        {
            "label": "Build VCV Rack plugin & lauch Rack",
            "type": "process",
            "command": "C:\\Program Files\\VCV\\Rack\\Rack.exe",
            "problemMatcher": [],
            "dependsOn": ["Build VCV Rack plugin"],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

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",
            "program": "C:\\Program Files\\VCV\\Rack\\Rack.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "externalConsole": true,
            "MIMode": "gdb",
            "miDebuggerPath": "C:/msys64/mingw64/bin/gdb.exe",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "Build VCV Rack plugin"
        }
    ]
}

After those files gdb started running but line breakpoints did not work. The key was what @Richie said:

ifdef ARCH_MAC
	$(STRIP) -S dist/$(SLUG)/$(TARGET)
else
	# RJH $(STRIP) -s dist/$(SLUG)/$(TARGET)
endif

After commenting that line the breakpoints are working.

If you want to use the files you will have to change the plugin relative path “${workspaceFolder}/plugins/LomasModules” to point to your plugin folder. Also you may need to change the paths to gdb, gcc, and rack. I have MSYS2 on c: and Rack on Program Files.

3 Likes

Okay then. I’m going ahead and share my debug config for MacOS. I didn’t use the SDK but checked out the complete VCVRack from github and compiled it.

Using the C/C++ Extension from Microsoft.

Rack/.vscode/c_cpp_properties.json

{
  "configurations": [
    {
      "name": "Mac",
      "includePath": ["${workspaceFolder}/**"],
      "defines": [],
      "macFrameworkPath": [
        "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks",
      ],
      "compilerPath": "/usr/bin/clang",
      "cStandard": "c11",
      "cppStandard": "c++11",
      "intelliSenseMode": "clang-x64"
    }
  ],
  "version": 4
}

Rack/.vscode/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": "(lldb) Launch",
      "type": "cppdbg",
      "request": "launch",
      "program": "Rack",
      "args": ["-d"],
      "stopAtEntry": false,
      "cwd": "${workspaceFolder}",
      "environment": [],
      "externalConsole": false,
      "MIMode": "lldb"
    }
  ]
}

I’m not using a launch task, just using the terminal for executing make make dep for Plugins but not installing them. I’m running Rack from the source folder of rack and the plugins subdirectory. Works like a charm. And you have two isolated environments, when running Rack in development mode with "args": ["-d"].

2 Likes

Yep! This worked for me as well. I’ve got my plugin debugging working after removing the $(STRIP) command. strip -s removes the debugger symbols as commented in compile.mk and confirmed here. I’ve added a makefile argument that I set from the command line to alternate between stripping and not stripping depending on if I want to debug or not.

Thanks for the confirmation @lomasmodules and the help @Richie! Now I can really dive into some fun!

FYI:

I’ve written a more detailed article on how I got my Windows environment setup for step by step debugging and building. Hope it helps!

4 Likes

Could some kind, patient individual talk me through how to get VS Code debugging working under linux please?

Ok, could someone help me just to get the damn thing to build upon hitting F5? If I can get that working perhaps I’ll be able to sort the debugging out myself.

c_ccp_properties.json:

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**",
                "/home/ewen/Rack/**",
                "/home/ewen/Rack-SDK/dep/**",
                "/home/ewen/Rack-SDK/include/**"
            ],
            "defines": [],
            "compilerPath": "/usr/bin/gcc",
            "cStandard": "c11",
            "cppStandard": "c++17",
            "intelliSenseMode": "gcc-x64"
        }
    ],
    "version": 4
}

tasks.json:

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build vcv rack plugin",
            "type": "shell",
            "command": "make install",
            "options": {
                "cwd": "${workspaceRoot}",
                "env": {
                    "RACK_DIR": "/home/ewen/Rack-SDK/**"
                }
            },
            "group": {
                "kind": "build",
                "isDefault": true
            }
        },
        {
            "type": "shell",
            "label": "g++ build active file",
            "command": "/usr/bin/g++",
            "args": [
                "-g",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "options": {
                "cwd": "/usr/bin"
            }
        }
    ]
}

Output:

> Executing task in folder RacketScience: /usr/bin/g++ -g /home/ewen/Rack/plugins/RacketScience/src/RSPhaseOne.cpp -o /home/ewen/Rack/plugins/RacketScience/src/RSPhaseOne <

In file included from /home/ewen/Rack/plugins/RacketScience/src/RSPhaseOne.cpp:3:0:
/home/ewen/Rack/plugins/RacketScience/src/plugin.hpp:2:10: fatal error: rack.hpp: No such file or directory
 #include <rack.hpp>
          ^~~~~~~~~~
compilation terminated.
The terminal process terminated with exit code: 1

Running make install in the terminal works fine.

Clueless, frustrated & grateful for any assistance.

In task.json try to put your plugin folder

“cwd”: “${workspaceRoot}/plugins/pluginname”

I use ctrl+B to run it, not F5.

Thanks, no change.

I use emacs, but from looking at the json, why do you have a ** after the Rack-SDK directory?

env": {
                    "RACK_DIR": "/home/ewen/Rack-SDK/**"
                }

That looks wrong. I thought ** expanded directories.

If RACK_DIR is set wrong you won’t find rack.hpp

Thanks, amended, no change.

Oh sorry looking more closely: It looks like you are running the second (g++) command not the first (make install). The one time I used VSCODe I did remember having to pick the right task. Are you sure that second blob of json isn’t running? That has none of the env set up to build at all.

The command line shown (g++ foo.cpp) won’t work; you want to just issue a make to get all the makefile stuff included.

Thanks, that appears to be the case, no idea how to specify which one runs.

Ctrl shift b I think? Or a menu to run a build task? That’s from a quick google and remembering the one day I tried to switch from emacs

1 Like

And there was much rejoicing!!! Thank you :slight_smile:

Now to try & get the debugger debuggering.

1 Like