13
0

Print stacktrace when plugin-scanner app crashes

This commit is contained in:
Robin Gareus 2021-07-12 04:00:43 +02:00
parent 7d39205350
commit 6af9b0194e
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
3 changed files with 83 additions and 0 deletions

View File

@ -21,6 +21,7 @@
#include <cstdio>
#include <getopt.h>
#include <iostream>
#include <signal.h>
#include <string>
#include <strings.h>
@ -28,6 +29,7 @@
#include "pbd/transmitter.h"
#include "pbd/receiver.h"
#include "pbd/pbd.h"
#include "pbd/stacktrace.h"
using namespace std;
@ -94,6 +96,14 @@ scan_auv2 (CAComponentDescription& desc, bool force, bool verbose)
return true;
}
static void
sig_handler (int sig)
{
fprintf (stderr, "Error: signal %d\n", sig);
PBD::stacktrace (cerr, 15, 2);
::exit (EXIT_FAILURE);
}
static void
usage ()
{
@ -186,6 +196,11 @@ main (int argc, char **argv)
verbose = false;
}
signal (SIGSEGV, sig_handler);
signal (SIGBUS, sig_handler);
signal (SIGILL, sig_handler);
#endif
bool err = false;
CFStringRef s_type = CFStringCreateWithCString (kCFAllocatorDefault, argv[optind++], kCFStringEncodingUTF8);

View File

@ -23,6 +23,12 @@
#include <iostream>
#include <string>
#ifdef PLATFORM_WINDOWS
#include <windows.h>
#else
#include <signal.h>
#endif
#ifdef COMPILER_MSVC
#include <sys/utime.h>
#else
@ -38,6 +44,7 @@
#include "pbd/transmitter.h"
#include "pbd/receiver.h"
#include "pbd/pbd.h"
#include "pbd/stacktrace.h"
#include "pbd/win_console.h"
#include "pbd/xml++.h"
@ -123,6 +130,25 @@ scan_vst2 (std::string const& path, ARDOUR::PluginType type, bool force, bool ve
return true;
}
#ifdef PLATFORM_WINDOWS
static LONG WINAPI
crash_handler (EXCEPTION_POINTERS* exception_info)
{
// TODO consider DrMingw if HAVE_DRMINGW
fprintf (stderr, "Error: %x\n", exception_info->ExceptionRecord->ExceptionCode);
PBD::stacktrace (cerr, 15, 2);
return EXCEPTION_CONTINUE_SEARCH;
}
#else
static void
sig_handler (int sig)
{
fprintf (stderr, "Error: signal %d\n", sig);
PBD::stacktrace (cerr, 15, 2);
::exit (EXIT_FAILURE);
}
#endif
static void
usage ()
{
@ -224,6 +250,14 @@ main (int argc, char **argv)
bool err = false;
#ifdef PLATFORM_WINDOWS
::SetUnhandledExceptionFilter (crash_handler);
#else
signal (SIGSEGV, sig_handler);
signal (SIGBUS, sig_handler);
signal (SIGILL, sig_handler);
#endif
while (optind < argc) {
const char* dllpath = argv[optind++];
const size_t slen = strlen (dllpath);

View File

@ -22,6 +22,12 @@
#include <iostream>
#include <string>
#ifdef PLATFORM_WINDOWS
#include <windows.h>
#else
#include <signal.h>
#endif
#ifdef COMPILER_MSVC
#include <sys/utime.h>
#else
@ -32,6 +38,7 @@
#include "pbd/transmitter.h"
#include "pbd/receiver.h"
#include "pbd/pbd.h"
#include "pbd/stacktrace.h"
#include "pbd/win_console.h"
#include "pbd/xml++.h"
@ -110,6 +117,25 @@ scan_vst3 (std::string const& bundle_path, bool force, bool verbose)
return true;
}
#ifdef PLATFORM_WINDOWS
static LONG WINAPI
crash_handler (EXCEPTION_POINTERS* exception_info)
{
// TODO consider DrMingw if HAVE_DRMINGW
fprintf (stderr, "Error: %x\n", exception_info->ExceptionRecord->ExceptionCode);
PBD::stacktrace (cerr, 15, 2);
return EXCEPTION_CONTINUE_SEARCH;
}
#else
static void
sig_handler (int sig)
{
fprintf (stderr, "Error: signal %d\n", sig);
PBD::stacktrace (cerr, 15, 2);
::exit (EXIT_FAILURE);
}
#endif
static void
usage ()
{
@ -209,6 +235,14 @@ main (int argc, char **argv)
verbose = false;
}
#ifdef PLATFORM_WINDOWS
::SetUnhandledExceptionFilter (crash_handler);
#else
signal (SIGSEGV, sig_handler);
signal (SIGBUS, sig_handler);
signal (SIGILL, sig_handler);
#endif
bool err = false;
while (optind < argc) {