Example #1
0
void UnexpectedExceptionHandler()
{
	type_info *pException = abi::__cxa_current_exception_type();
	char const *pName = pException->name();
	int iStatus = -1;
	char *pDem = abi::__cxa_demangle( pName, 0, 0, &iStatus );

	const RString error = ssprintf("Unhandled exception: %s", iStatus? pName:pDem);
#if defined(CRASH_HANDLER)
	sm_crash( error );
#endif
}
Example #2
0
extern "C" void __assert_perror_fail( int errnum, const char *file, unsigned int line, const char *function ) throw()
{
	const RString error = ssprintf( "Assertion failure: %s: %s", function, strerror(errnum) );

#if defined(CRASH_HANDLER)
	Checkpoints::SetCheckpoint( file, line, error );
	sm_crash( strerror(errnum) );
#else

	DoEmergencyShutdown();

	_exit(0);
#endif
}
Example #3
0
/* ARGSUSED */
void
sm_simu_crash_svc(void *myidp)
{
	int i;
	struct mon_entry *monitor_q;
	int found = 0;

	/* Only one crash should be running at a time. */
	mutex_lock(&crash_lock);
	if (debug)
		(void) printf("proc sm_simu_crash\n");
	if (in_crash) {
		cond_wait(&crash_finish, &crash_lock);
		mutex_unlock(&crash_lock);
		return;
	} else {
		in_crash = 1;
	}
	mutex_unlock(&crash_lock);

	for (i = 0; i < MAX_HASHSIZE; i++) {
		mutex_lock(&mon_table[i].lock);
		monitor_q = mon_table[i].sm_monhdp;
		if (monitor_q != (struct mon_entry *)NULL) {
			mutex_unlock(&mon_table[i].lock);
			found = 1;
			break;
		}
		mutex_unlock(&mon_table[i].lock);
	}
	/*
	 * If there are entries found in the monitor table,
	 * initiate a crash, else zero out the in_crash variable.
	 */
	if (found) {
		mutex_lock(&crash_lock);
		die = 1;
		/* Signal sm_retry() thread if sleeping. */
		cond_signal(&retrywait);
		mutex_unlock(&crash_lock);
		rw_wrlock(&thr_rwlock);
		sm_crash();
		rw_unlock(&thr_rwlock);
	} else {
		mutex_lock(&crash_lock);
		in_crash = 0;
		mutex_unlock(&crash_lock);
	}
}
Example #4
0
extern "C" void __assert_fail( const char *assertion, const char *file, unsigned int line, const char *function ) throw()
{
	const RString error = ssprintf( "Assertion failure: %s: %s", function, assertion );

#if defined(CRASH_HANDLER)
	Checkpoints::SetCheckpoint( file, line, error );
	sm_crash( assertion );
#else
	/* It'd be nice to just throw an exception here, but throwing an exception
	 * through C code sometimes explodes. */

	DoEmergencyShutdown();

	_exit(0);
#endif
}
Example #5
0
void Checkpoints::SetCheckpoint( const char *file, int line, const char *message )
{
	ThreadSlot *slot = GetCurThreadSlot();
	if( slot == NULL )
		slot = GetUnknownThreadSlot();
	/* We can't ASSERT here, since that uses checkpoints. */
	if( slot == NULL )
		sm_crash( "GetUnknownThreadSlot() returned NULL" );

	slot->Checkpoints[slot->CurCheckpoint].Set( file, line, message );

	if( g_LogCheckpoints )
		LOG->Trace( "%s", slot->Checkpoints[slot->CurCheckpoint].FormattedBuf );

	++slot->CurCheckpoint;
	slot->NumCheckpoints = max( slot->NumCheckpoints, slot->CurCheckpoint );
	slot->CurCheckpoint %= CHECKPOINT_COUNT;
}