Try to get Windows NT bootstrapping with the latest compiler changes

SEH is broken
release
U-C4\Administrator 2007-09-23 23:52:58 -05:00
parent 17ebe7fe47
commit 5e663a91d8
2 changed files with 32 additions and 29 deletions

View File

@ -23,31 +23,40 @@ DEFINE_PRIMITIVE(cd)
SetCurrentDirectory(unbox_u16_string());
}
void seh_call(void (*func)(), exception_handler_t *handler)
long exception_handler(PEXCEPTION_RECORD rec, void *frame, void *ctx, void *dispatch)
{
CONTEXT *c = (CONTEXT*)ctx;
void *esp = NULL;
if(in_code_heap_p(c->Eip))
esp = (void*)c->Esp;
printf("ExceptionCode = 0x%08x\n", rec->ExceptionCode);
printf("AccessViolationCode = 0x%08x\n", EXCEPTION_ACCESS_VIOLATION);
printf("DivideByZeroCode1 = 0x%08x\n", EXCEPTION_FLT_DIVIDE_BY_ZERO);
printf("DivideByZeroCode2 = 0x%08x\n", EXCEPTION_INT_DIVIDE_BY_ZERO);
printf("addr=0x%08x\n", rec->ExceptionInformation[1]);
printf("eax=0x%08x\n", c->Eax);
printf("eax=0x%08x\n", c->Ebx);
printf("eip=0x%08x\n", c->Eip);
printf("esp=0x%08x\n", c->Esp);
printf("calculated esp: 0x%08x\n", esp);
if(rec->ExceptionCode == EXCEPTION_ACCESS_VIOLATION)
memory_protection_error(rec->ExceptionInformation[1], esp);
else if(rec->ExceptionCode == EXCEPTION_FLT_DIVIDE_BY_ZERO
|| rec->ExceptionCode == EXCEPTION_INT_DIVIDE_BY_ZERO)
general_error(ERROR_DIVIDE_BY_ZERO,F,F,esp);
else
signal_error(11,esp);
return -1; /* unreachable */
}
void c_to_factor_toplevel(CELL quot)
{
exception_record_t record;
asm volatile("mov %%fs:0, %0" : "=r" (record.next_handler));
asm volatile("mov %0, %%fs:0" : : "r" (&record));
record.handler_func = handler;
func();
record.handler_func = exception_handler;
c_to_factor(quot);
asm volatile("mov %0, %%fs:0" : "=r" (record.next_handler));
}
long exception_handler(PEXCEPTION_RECORD rec, void *frame, void *ctx, void *dispatch)
{
if(rec->ExceptionCode == EXCEPTION_ACCESS_VIOLATION)
memory_protection_error(
rec->ExceptionInformation[1],
native_stack_pointer());
else if(rec->ExceptionCode == EXCEPTION_FLT_DIVIDE_BY_ZERO
|| rec->ExceptionCode == EXCEPTION_INT_DIVIDE_BY_ZERO)
general_error(ERROR_DIVIDE_BY_ZERO,F,F,false,(void*)rec->ExceptionInformation[1]);
else
signal_error(11,(void*)rec->ExceptionInformation[1]);
return -1; /* unreachable */
}
void run_toplevel(void)
{
seh_call(run, exception_handler);
}

View File

@ -51,7 +51,7 @@ void ffi_dlopen (F_DLL *dll, bool error)
{
dll->dll = NULL;
if(error)
general_error(ERROR_FFI,F,
general_error(ERROR_FFI,F,F,
tag_object(get_error_message()));
else
return;
@ -204,9 +204,3 @@ void sleep_millis(DWORD msec)
{
Sleep(msec);
}
void run(void)
{
interpreter();
}