Skip to content

Debugging plug ins

p0nce edited this page Dec 12, 2021 · 10 revisions

Debugging

With Visual Studio on Windows

You can use Visual Studio + the VisualD extension to have working debugging on Windows. Generate a .sln solution file with dub generate visuald or dub generate -a x86_64 visuald for 32-bit or 64-bit plugins respectively. Launch a host program from there. You are now attached.

With Visual Studio Code on macOS

  • VSCode has an extension called CodeLLDB
  • In your launch.json you can add something like this:
{
    "name": "macOS - Reaper",
    "type": "lldb",
    "request": "launch",
            "program": "/Applications/REAPER64.app/Contents/MacOS/REAPER",
            "args": [],
}

With Visual Studio Code on Linux

You can use Visual Studio Code and the native-debug extension

Break this glass if you can't debug on Windows

tl;dr Use dplug.core.nogc.debugLog for printf-debugging.

When everything fails, you can use the OutputDebugMessageA Win32 API as a sort of printf replacement, and launch dbgview.exe as an Administrator. This enables a barebones print-based debugging.

Warning: Visual Studio may capture the Debug Output to put it in its Output window, in which case dbgview.exe will be silent.

Break this glass if you can't debug on macOS

tl;dr Use dplug.core.nogc.debugLog for printf-debugging.

LLDB usually saves the day. lldb -- /Applications/MyHost.app will launch a LLDB session from the command-line. At startup, the file .lldbinit is taken as an input command list, this can improve scriptability. You can then use core.stdc.stdio.printf to debug.

What if you can't attach to the host program? On recent macOS, auval cannot be launched from a debugger due to System Integrity Protection.

  1. Copy /usr/bin/auvaltool elsewhere e.g. ~/auvaltool, as long as "Debug Executable" is unchecked.
  2. Codesign the copied auvaltool with your own Mac Developer ID: codesign -fs "XXXXXXXXXX" ~/auvaltool
  3. You can now hit breakpoint and step through the program.

Special consideration for debugging with Carla

  • On Windows, Carla is a self-extracting ZIP. Rename Carla.exe to Carla.zip and unpack it.
  • Carla may also redirect stdout to its internal log console.