diff --git a/CMakeLists.txt b/CMakeLists.txt index 14cc008..5c972fb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,13 +31,14 @@ target_compile_definitions(EchoionPlugin PUBLIC PLUGIN=1) # - ApiOpaque (OpaqueHandle for type-safe void*) # - ApiPluginInterface (IPluginInterface to implement) # - ApiCoreInterface (ICoreInterface to call Core - decoupled) -target_link_libraries(EchoionPlugin PRIVATE +target_link_libraries(EchoionPlugin PRIVATE Echoion::ApiBase Echoion::ApiPlugin Echoion::ApiOpaque Echoion::ApiPluginInterface Echoion::ApiLogger Echoion::ApiCoreInterface + Void::Stacktrace ) find_package(dylib CONFIG REQUIRED) diff --git a/src/Plugin.cpp b/src/Plugin.cpp index 1f669ab..7fca35f 100644 --- a/src/Plugin.cpp +++ b/src/Plugin.cpp @@ -3,6 +3,7 @@ #include "echoion/plugin/PluginInterface.hpp" #include "teamspeak/public_errors.h" #include +#include #include #include #include @@ -254,6 +255,21 @@ namespace Echoion::Plugin TS3_PLUGIN_API int ts3plugin_init() { std::cout << "[Echoion] Plugin init started" << std::endl; + + // Install a terminate handler that dumps a symbolized stack trace + // (with source snippets) before the process dies — invaluable for + // diagnosing crashes in a hot-reloadable plugin. + static std::once_flag terminateOnce; + std::call_once(terminateOnce, [] { + std::set_terminate([] { + std::cerr << "[Echoion] FATAL: std::terminate — stack trace:\n"; + const auto frames = Void::Stacktrace::capture_stacktrace(); + std::cerr << Void::Stacktrace::format_stacktrace(frames) + << std::endl; + std::abort(); + }); + }); + g_deferredInitThread = std::jthread(deferredInitialization); return 0; }