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.
This commit is contained in:
Robbert van der Helm
2020-03-15 16:30:25 +01:00
parent 454cef76e7
commit 138fa9eb31
4 changed files with 45 additions and 7 deletions
+10 -6
View File
@@ -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
+9
View File
@@ -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 : []
)
+1
View File
@@ -0,0 +1 @@
option('use-winedbg', type : 'boolean', value : false)
+25 -1
View File
@@ -25,6 +25,10 @@
#include <iostream>
#include <random>
#ifdef USE_WINEDBG
#include <boost/process/start_dir.hpp>
#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() + "'");