Install a Void::Stacktrace crash handler at plugin init
ts3plugin_init() sets a std::terminate handler that captures and prints a symbolized stack trace (with source snippets) before aborting — useful for diagnosing crashes in the hot-reloadable plugin. Link Void::Stacktrace. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
df1ea8d53f
commit
7c58af92cd
2 files changed
+18
-1
No files matched your search
+2
-1
@@ -31,13 +31,14 @@ target_compile_definitions(EchoionPlugin PUBLIC PLUGIN=1)
|
|||||||
# - ApiOpaque (OpaqueHandle for type-safe void*)
|
# - ApiOpaque (OpaqueHandle for type-safe void*)
|
||||||
# - ApiPluginInterface (IPluginInterface to implement)
|
# - ApiPluginInterface (IPluginInterface to implement)
|
||||||
# - ApiCoreInterface (ICoreInterface to call Core - decoupled)
|
# - ApiCoreInterface (ICoreInterface to call Core - decoupled)
|
||||||
target_link_libraries(EchoionPlugin PRIVATE
|
target_link_libraries(EchoionPlugin PRIVATE
|
||||||
Echoion::ApiBase
|
Echoion::ApiBase
|
||||||
Echoion::ApiPlugin
|
Echoion::ApiPlugin
|
||||||
Echoion::ApiOpaque
|
Echoion::ApiOpaque
|
||||||
Echoion::ApiPluginInterface
|
Echoion::ApiPluginInterface
|
||||||
Echoion::ApiLogger
|
Echoion::ApiLogger
|
||||||
Echoion::ApiCoreInterface
|
Echoion::ApiCoreInterface
|
||||||
|
Void::Stacktrace
|
||||||
)
|
)
|
||||||
|
|
||||||
find_package(dylib CONFIG REQUIRED)
|
find_package(dylib CONFIG REQUIRED)
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include "echoion/plugin/PluginInterface.hpp"
|
#include "echoion/plugin/PluginInterface.hpp"
|
||||||
#include "teamspeak/public_errors.h"
|
#include "teamspeak/public_errors.h"
|
||||||
#include <CoreInterface.hpp>
|
#include <CoreInterface.hpp>
|
||||||
|
#include <Void/Stacktrace/Stacktrace.hpp>
|
||||||
#include <PluginTypes.hpp>
|
#include <PluginTypes.hpp>
|
||||||
#include <Types.hpp>
|
#include <Types.hpp>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
@@ -254,6 +255,21 @@ namespace Echoion::Plugin
|
|||||||
TS3_PLUGIN_API int ts3plugin_init()
|
TS3_PLUGIN_API int ts3plugin_init()
|
||||||
{
|
{
|
||||||
std::cout << "[Echoion] Plugin init started" << std::endl;
|
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);
|
g_deferredInitThread = std::jthread(deferredInitialization);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user