示例#1
0
/*
 * Null exception - catches bad memory accesses.
 */
static void
nullException(SIGNAL_ARGS(sig, ctx))
{
        void *stackptr;
  
	DEFINEFRAME();
	/* Restore the signal handler if necessary */
	restoreSyncSignalHandler(sig, nullException);

	/* Clean up the synchronous signal state (just unblock this signal) */
	unblockSignal(sig);

	EXCEPTIONFRAME(frame, ctx);
#if defined(STACK_POINTER)
	stackptr = (void *)STACK_POINTER(GET_SIGNAL_CONTEXT_POINTER(ctx));
#if defined(STACK_GROWS_UP)
	if (currentJThread != NULL && stackptr >= currentJThread->stackEnd)
#else
	if (currentJThread != NULL && stackptr <= currentJThread->stackBase)
#endif
	  stackOverflowHandler(EXCEPTIONFRAMEPTR);
	else
#endif // STACK_POINTER
	  nullHandler(EXCEPTIONFRAMEPTR);
}
static void profileTimerHandler(SIGNAL_ARGS(sig UNUSED, sc))
{
	SIGNAL_CONTEXT_POINTER(scp) = GET_SIGNAL_CONTEXT_POINTER(sc);
	char *addr = (char *)SIGNAL_PC(scp);

	if( kaffe_memory_samples && xProfRecord )
	{
		if( profiler_sample_override_pc )
		{
			profiler_sample_overrides++;
			/* Use the override address */
			addr = profiler_sample_override_pc;
			/* Null it out to stop false positives */
			profiler_sample_override_pc = 0;
		}
		memoryHit(kaffe_memory_samples, addr);
	}
}