Skip to content

Commit

Permalink
bugfix: Refactor JIT exception handling (#1168)
Browse files Browse the repository at this point in the history
  • Loading branch information
midwan committed Nov 14, 2023
1 parent ae4e0ba commit 991f200
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 22 deletions.
1 change: 0 additions & 1 deletion src/osdep/gui/PanelRAM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,6 @@ void RefreshPanelRAM()
}
}


bool HelpPanelRAM(std::vector<std::string>& helptext)
{
helptext.clear();
Expand Down
42 changes: 21 additions & 21 deletions src/osdep/sigsegv_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,16 +159,6 @@ static int handle_exception(mcontext_t sigcont, long fault_addr)
break;
}

// Did the error happen in compiled code?
if (fault_pc >= uintptr(compiled_code) && fault_pc < uintptr(current_compile_p))
output_log(_T("Error in compiled code.\n"));
else if (fault_pc >= uintptr(popallspace) && fault_pc < uintptr(popallspace + POPALLSPACE_SIZE))
output_log(_T("Error in popallspace code.\n"));
else {
output_log(_T("Error not in JIT code.\n"));
break;
}

// Get Amiga address of illegal memory address
long amiga_addr = long(fault_addr) - long(regs.natmem_offset);

Expand Down Expand Up @@ -196,6 +186,16 @@ static int handle_exception(mcontext_t sigcont, long fault_addr)
break;
}

// Did the error happen in compiled code?
if (fault_pc >= uintptr(compiled_code) && fault_pc < uintptr(current_compile_p))
output_log(_T("Error in compiled code.\n"));
else if (fault_pc >= uintptr(popallspace) && fault_pc < uintptr(popallspace + POPALLSPACE_SIZE))
output_log(_T("Error in popallspace code.\n"));
else {
output_log(_T("Error not in JIT code.\n"));
break;
}

// Get memory bank of address
addrbank* ab = &get_mem_bank(amiga_addr);
if (ab)
Expand Down Expand Up @@ -602,16 +602,6 @@ static int handle_exception(unsigned long* pregs, long fault_addr)
break;
}

// Did the error happen in compiled code?
if ((uae_u8*)fault_pc >= compiled_code && (uae_u8*)fault_pc < current_compile_p)
output_log(_T("Error in compiled code.\n"));
else if ((uae_u8*)fault_pc >= popallspace && (uae_u8*)fault_pc < popallspace + POPALLSPACE_SIZE)
output_log(_T("Error in popallspace code.\n"));
else {
output_log(_T("Error not in JIT code.\n"));
break;
}

// Get Amiga address of illegal memory address
auto amiga_addr = (long)fault_addr - (long)regs.natmem_offset;

Expand All @@ -630,7 +620,17 @@ static int handle_exception(unsigned long* pregs, long fault_addr)
handled = HANDLE_EXCEPTION_A4000RAM;
break;
}


// Did the error happen in compiled code?
if ((uae_u8*)fault_pc >= compiled_code && (uae_u8*)fault_pc < current_compile_p)
output_log(_T("Error in compiled code.\n"));
else if ((uae_u8*)fault_pc >= popallspace && (uae_u8*)fault_pc < popallspace + POPALLSPACE_SIZE)
output_log(_T("Error in popallspace code.\n"));
else {
output_log(_T("Error not in JIT code.\n"));
break;
}

// Get memory bank of address
auto* ab = &get_mem_bank(amiga_addr);
if (ab)
Expand Down

0 comments on commit 991f200

Please sign in to comment.