Beispiel #1
0
LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo) {
  int code = exceptionInfo->ExceptionRecord->ExceptionCode;

  if (code == EXCEPTION_BREAKPOINT) {
    // This exception is called when an assertion fails (__asm { int 3} is executed).
    // It is therefore imperative we continue the search hereby enabling
    // spawning of a Just-in-time debugger.
    return EXCEPTION_CONTINUE_SEARCH;
  }

  lprintf("Exception caught \"%s\".\n", exception_name(code));

  if (code == EXCEPTION_STACK_OVERFLOW) {
    lprintf("  Oops, we encounted a stack overflow.\n");
    lprintf("  You should check your program for infinite recursion!\n");
    suspend_process_at_stack_overflow(
      (int*)  exceptionInfo->ContextRecord->Esp,
      (int*)  exceptionInfo->ContextRecord->Ebp,
      (char*) exceptionInfo->ContextRecord->Eip);
    lprintf("  Coutinue execution ??????????????\n");
  } else {
    // Do not report vm state when getting stack overflow
    report_vm_state();
  }

  if (os::message_box("Exception caught", "Do you want a stack trace?")) {
    trace_stack_at_exception((int*)    exceptionInfo->ContextRecord->Esp,
                             (int*)    exceptionInfo->ContextRecord->Ebp,
			     (char*)   exceptionInfo->ContextRecord->Eip);
  }
  return EXCEPTION_CONTINUE_SEARCH;
}
Beispiel #2
0
void
x86_fatal_exception(iframe* frame)
{
	char name[32];
	panic("Fatal exception \"%s\" occurred! Error code: 0x%lx\n",
		exception_name(frame->vector, name, sizeof(name)), frame->error_code);
}
Beispiel #3
0
void
x86_invalid_exception(iframe* frame)
{
	Thread* thread = thread_get_current_thread();
	char name[32];
	panic("unhandled trap 0x%lx (%s) at ip 0x%lx, thread %" B_PRId32 "!\n",
		frame->vector, exception_name(frame->vector, name, sizeof(name)),
		frame->ip, thread ? thread->id : -1);
}
Beispiel #4
0
static void
  add_exceptiondesc (Exception e, struct buffer_s *data, /* OUT */ list referenced)
{
  printmToBuffer (data, "(exception %s %s \"\"",
		  interface_name(exception_interface(e)), exception_name(e));
  if ((e->type != NULL) && (type_ur_kind(e->type) != void_Type)) {
    print0ToBuffer (data, " ");
    add_typeref (e->type, data, referenced);
  } else {
    print0ToBuffer (data, " void");
  }
  print0ToBuffer (data, ")");
}
Beispiel #5
0
static void add_exnref (Exception exn, struct buffer_s *data, list referenced)
{
  print0ToBuffer (data, "(exn ");
  if (exn->corba_rep_id != NULL) {
    print0ToBuffer(data, "(id ");
    add_quoted_string(exn->corba_rep_id, data);
    print0ToBuffer(data, ")");
  } else {
    printmToBuffer (data, "(ref %s %s)", interface_name(exception_interface(exn)), exception_name(exn));
    add_entity (ExceptionE, exn, referenced);
  }
  printmToBuffer (data, ")");
}
Beispiel #6
0
void sleh_fatal(vc4_saved_state_t* pcb, uint32_t n) {
	printf("Fatal VPU Exception: %s\n", exception_name(n));

	printf("VPU registers:\n");

	printf(
		REGISTER_FORMAT_STRING("   "),
		pcb->r0,
		pcb->r1,
		pcb->r2,
		pcb->r3,
		pcb->r4,
		pcb->r5,
		pcb->r6,
		pcb->r7,
		pcb->r8,
		pcb->r9, 
		pcb->r10,
		pcb->r11,
		pcb->r12,
		pcb->r13,
		pcb->r14,
		pcb->r15,
		pcb->pc,
		pcb->lr,
		pcb->sr
	);

	printf("Exception info:\n");

	printf(
		"   src0: 0x%08x src1: 0x%08x vaddr: 0x%08x\n"
		"      C: 0x%08x    S: 0x%08x\n",
		IC0_SRC0,
		IC0_SRC1,
		IC0_VADDR,
		IC0_C,
		IC0_S
	);

	printf("We are hanging here ...\n");
	
	hang_cpu();
}
Beispiel #7
0
void
x86_unexpected_exception(iframe* frame)
{
	debug_exception_type type;
	uint32 signalNumber;
	int32 signalCode;
	addr_t signalAddress = 0;
	int32 signalError = B_ERROR;

	switch (frame->vector) {
		case 0:		// Divide Error Exception (#DE)
			type = B_DIVIDE_ERROR;
			signalNumber = SIGFPE;
			signalCode = FPE_INTDIV;
			signalAddress = frame->ip;
			break;

		case 4:		// Overflow Exception (#OF)
			type = B_OVERFLOW_EXCEPTION;
			signalNumber = SIGFPE;
			signalCode = FPE_INTOVF;
			signalAddress = frame->ip;
			break;

		case 5:		// BOUND Range Exceeded Exception (#BR)
			type = B_BOUNDS_CHECK_EXCEPTION;
			signalNumber = SIGTRAP;
			signalCode = SI_USER;
			break;

		case 6:		// Invalid Opcode Exception (#UD)
			type = B_INVALID_OPCODE_EXCEPTION;
			signalNumber = SIGILL;
			signalCode = ILL_ILLOPC;
			signalAddress = frame->ip;
			break;

		case 13: 	// General Protection Exception (#GP)
			type = B_GENERAL_PROTECTION_FAULT;
			signalNumber = SIGILL;
			signalCode = ILL_PRVOPC;	// or ILL_PRVREG
			signalAddress = frame->ip;
			break;

		case 16: 	// x87 FPU Floating-Point Error (#MF)
			type = B_FLOATING_POINT_EXCEPTION;
			signalNumber = SIGFPE;
			signalCode = FPE_FLTDIV;
				// TODO: Determine the correct cause via the FPU status
				// register!
			signalAddress = frame->ip;
			break;

		case 17: 	// Alignment Check Exception (#AC)
			type = B_ALIGNMENT_EXCEPTION;
			signalNumber = SIGBUS;
			signalCode = BUS_ADRALN;
			// TODO: Also get the address (from where?). Since we don't enable
			// alignment checking this exception should never happen, though.
			signalError = EFAULT;
			break;

		case 19: 	// SIMD Floating-Point Exception (#XF)
			type = B_FLOATING_POINT_EXCEPTION;
			signalNumber = SIGFPE;
			signalCode = FPE_FLTDIV;
				// TODO: Determine the correct cause via the MXCSR register!
			signalAddress = frame->ip;
			break;

		default:
			x86_invalid_exception(frame);
			return;
	}

	if (IFRAME_IS_USER(frame)) {
		struct sigaction action;
		Thread* thread = thread_get_current_thread();

		enable_interrupts();

		// If the thread has a signal handler for the signal, we simply send it
		// the signal. Otherwise we notify the user debugger first.
		if ((sigaction(signalNumber, NULL, &action) == 0
				&& action.sa_handler != SIG_DFL
				&& action.sa_handler != SIG_IGN)
			|| user_debug_exception_occurred(type, signalNumber)) {
			Signal signal(signalNumber, signalCode, signalError,
				thread->team->id);
			signal.SetAddress((void*)signalAddress);
			send_signal_to_thread(thread, signal, 0);
		}
	} else {
		char name[32];
		panic("Unexpected exception \"%s\" occurred in kernel mode! "
			"Error code: 0x%lx\n",
			exception_name(frame->vector, name, sizeof(name)),
			frame->error_code);
	}
}