Exemple #1
0
void CCrashHandler::Init ( const SString& strInServerPath )
{
    SString strServerPath = strInServerPath;
    if ( strServerPath == "" )
        strServerPath = GetSystemCurrentDirectory();
    ms_strDumpPath = PathJoin( strServerPath, SERVER_DUMP_PATH );

    // Set a global filter
    #ifdef WIN32
        SetCrashHandlerFilter ( HandleExceptionGlobal );
    #else
        // Prepare initial dumpfile name
        time_t pTime = time( NULL );
        struct tm* tm = localtime( &pTime );
        SString strFilename( "server_%s_%04d%02d%02d_%02d%02d.dmp",
                                        MTA_DM_BUILDTAG_LONG,
                                        tm->tm_year + 1900,
                                        tm->tm_mon + 1,
                                        tm->tm_mday,
                                        tm->tm_hour,
                                        tm->tm_min
                                    );
        ms_strDumpPathFilename = PathJoin( ms_strDumpPath, strFilename );
        MakeSureDirExists( ms_strDumpPathFilename );

        #ifdef WITH_BACKTRACE_ONLY
            signal ( SIGSEGV, HandleExceptionGlobal );
        #else
            google_breakpad::MinidumpDescriptor descriptor( ms_strDumpPath );
            static google_breakpad::ExceptionHandler eh( descriptor, NULL, DumpCallback, NULL, true, -1 );
        #endif
    #endif
}
///////////////////////////////////////////////////////////////
//
// CCrashDumpWriter::SetHandlers
//
// Static function. Initialize handlers for crash situations
//
///////////////////////////////////////////////////////////////
void CCrashDumpWriter::SetHandlers( void )
{
#ifndef MTA_DEBUG
    _set_invalid_parameter_handler( CCrashDumpWriter::HandleInvalidParameter );
    SetCrashHandlerFilter ( CCrashDumpWriter::HandleExceptionGlobal );
    CCrashDumpWriter::ReserveMemoryKBForCrashDumpProcessing( 500 );
#endif
}
void CCrashHandler::Init ( void )
{
    // Set a global filter
    #ifdef WIN32
    SetCrashHandlerFilter ( HandleExceptionGlobal );
    #else
    signal ( SIGSEGV, HandleExceptionGlobal );
    #endif
}