main: add a SIGUSR1 handler to allow dynamic triggering of debug bits

This commit is contained in:
Paul Davis 2022-06-13 13:48:37 -06:00
parent 32b41037b5
commit d060348df0
1 changed files with 27 additions and 2 deletions

View File

@ -173,6 +173,19 @@ Click OK to exit %1."), PROGRAM_NAME, AudioEngine::instance()->current_backend_n
return false; /* do not call again */
}
#ifndef NDEBUG
static void
sigusr1_handler (int /* signal */)
{
cerr << "SIGUSR1 received in thread " << pthread_name() << endl;
char const * adf = g_getenv ("ARDOUR_DEBUG_FLAGS");
if (!adf) {
return;
}
PBD::parse_debug_options (adf);
}
#endif
#ifndef PLATFORM_WINDOWS
static void
sigpipe_handler (int /*signal*/)
@ -309,9 +322,11 @@ int main (int argc, char *argv[])
{
#ifndef NDEBUG
const char *adf;
const char * adf;
if ((adf = g_getenv ("ARDOUR_DEBUG_FLAGS"))) {
PBD::parse_debug_options (adf);
if (!g_getenv ("ARDOUR_DEBUG_ON_SIGUSR1")) {
PBD::parse_debug_options (adf);
}
}
#endif /* NDEBUG */
}
@ -402,6 +417,16 @@ int main (int argc, char *argv[])
}
#endif
#ifndef NDEBUG
if (g_getenv ("ARDOUR_DEBUG_ON_SIGUSR1")) {
if (::signal (SIGUSR1, sigusr1_handler)) {
cerr << _("Cannot install SIGUSR1 error handler") << endl;
} else {
cerr << _("Installed SIGUSR1 debug handler") << endl;
}
}
#endif
DEBUG_TRACE (DEBUG::Locale, string_compose ("main() locale '%1'\n", setlocale (LC_NUMERIC, NULL)));
if (UIConfiguration::instance().pre_gui_init ()) {