From 138fa9eb3196dd401ff843972e1dc7cf429a208c Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Sun, 15 Mar 2020 16:30:25 +0100 Subject: [PATCH] Add winedbg support behind a feature flag I had something similar saved as a stash since I did not want to make things more complicated by adding feature flags, but this should be fine. --- README.md | 16 ++++++++++------ meson.build | 9 +++++++++ meson_options.txt | 1 + src/plugin/host-bridge.cpp | 26 +++++++++++++++++++++++++- 4 files changed, 45 insertions(+), 7 deletions(-) create mode 100644 meson_options.txt diff --git a/README.md b/README.md index 4c875b6d..ff2d89f6 100644 --- a/README.md +++ b/README.md @@ -123,12 +123,16 @@ instance of Carla with gdb attached: env YABRIDGE_DEBUG_FILE=/tmp/yabridge.log YABRIDGE_DEBUG_LEVEL=1 carla --gdb ``` -Doing the same thing with the Wine VST host is also possible but it's a bit -tricky. I have not had any success with attaching winedbg to running processes. -The only thing that seems to work is to modify `host-bridge.cpp` to not launch -`yabridge-host.exe` normally, but to instead start a new (detached) terminal -emulator process running the Wine host through `winedbg --gdb`. I wouldn't -recommended doing this if you can avoid it. +Doing the same thing for the Wine VST host can be a bit trick., You'll need to +launch winedbg in a seperate detached terminal emulator so it doesn't with the +plugin, and winedbg can be a bit picky in the arguments it accepts. I've already +set this up behind a feature flag for KDE Plasma. Other desktop environments and +window managers will require some slight modifications in +`src/plugin/host-bridge.cpp`. To enable this, simply run: + +```shell +meson configure build -Duse-winedbg=true +``` ## Rationale diff --git a/meson.build b/meson.build index 864f5516..a61a04e1 100644 --- a/meson.build +++ b/meson.build @@ -15,6 +15,13 @@ if not meson.get_compiler('cpp').compiles(winelib_check) error('You need to set up a cross compiler, check the README for more information.') endif +# This provides an easy way to start the Wine VST host using winedbg since it +# can be quite a pain to set up +compiler_options = [] +if get_option('use-winedbg') + compiler_options += '-DUSE_WINEDBG' +endif + # The application consists of a VST plugin (yabridge) that calls a winelib # program (yabridge-host) that can host Windows VST plugins. More information # about the way these two components work together can be found in the readme @@ -39,6 +46,7 @@ shared_library( native : true, include_directories : include_dir, dependencies : [boost_dep, bitsery_dep, threads_dep], + cpp_args : compiler_options, link_args : ['-ldl'] ) @@ -53,5 +61,6 @@ executable( native : false, include_directories : include_dir, dependencies : [boost_dep, bitsery_dep, wine_threads_dep], + cpp_args : compiler_options, link_args : [] ) diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 00000000..93e61071 --- /dev/null +++ b/meson_options.txt @@ -0,0 +1 @@ +option('use-winedbg', type : 'boolean', value : false) diff --git a/src/plugin/host-bridge.cpp b/src/plugin/host-bridge.cpp index 263d79c9..e800b796 100644 --- a/src/plugin/host-bridge.cpp +++ b/src/plugin/host-bridge.cpp @@ -25,6 +25,10 @@ #include #include +#ifdef USE_WINEDBG +#include +#endif + #include "../common/communication.h" #include "../common/events.h" @@ -86,6 +90,7 @@ HostBridge::HostBridge(audioMasterCallback host_callback) create_logger_prefix(socket_endpoint.path()))), wine_stdout(io_context), wine_stderr(io_context), +#ifndef USE_WINEDBG vst_host(vst_host_path, // The Wine VST host needs to know which plugin to load // and which Unix domain socket to connect to @@ -93,7 +98,26 @@ HostBridge::HostBridge(audioMasterCallback host_callback) socket_endpoint.path(), bp::env = set_wineprefix(), bp::std_out = wine_stdout, - bp::std_err = wine_stderr) { + bp::std_err = wine_stderr) +#else + // This is set up for KDE Plasma. Other desktop environments and window + // managers require some slight modifications to spawn a detached terminal + // emulator. + vst_host("/usr/bin/kstart5", + "konsole", + "--", + "-e", + "winedbg", + "--gdb", + vst_host_path.string() + ".so", + vst_plugin_path.filename(), + socket_endpoint.path(), + bp::env = set_wineprefix(), + // winedbg has no reliable way to escape spaces, so we'll start + // the process in the plugin's directory + bp::start_dir = vst_plugin_path.parent_path()) +#endif +{ logger.log("Initializing yabridge using '" + vst_host_path.string() + "'"); logger.log("plugin: '" + vst_plugin_path.string() + "'"); logger.log("socket: '" + socket_endpoint.path() + "'");