mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-27 06:47:45 +00:00
28 lines
602 B
C++
28 lines
602 B
C++
#ifndef SAPPHIRE_SIGNALHANDLER_H
|
|
#define SAPPHIRE_SIGNALHANDLER_H
|
|
|
|
|
|
// based on: https://oroboro.com/stack-trace-on-crash/
|
|
|
|
namespace Sapphire::Common::Util
|
|
{
|
|
|
|
/*!
|
|
* @brief Provides cross platform stack trace dumping.
|
|
*
|
|
* Statically init it somewhere so it registers the signal handlers before main runs and you're good to go.
|
|
*/
|
|
class CrashHandler
|
|
{
|
|
public:
|
|
CrashHandler();
|
|
virtual ~CrashHandler() = default;
|
|
|
|
private:
|
|
static void signalHandler( int sigNum );
|
|
|
|
static void printStackTrace( unsigned int max_frames = 63 );
|
|
};
|
|
}
|
|
|
|
#endif //SAPPHIRE_CRASHHANDLER_H
|