mirror of
https://github.com/kanjitalk755/macemu.git
synced 2024-10-06 21:56:22 +00:00
- video_vosh.h (Screen_fault_handler): Move unrecoverable fault case to...
- main_unix.cpp (sigsegv_dump_state): ... Here. - sigsegv.h (sigsegv_fault_handler_t): Rename from sigsegv_handler_t. - sigsegv.h (sigsegv_state_dumper_t): New.
This commit is contained in:
parent
d5be07f449
commit
39d97f5b04
@ -196,6 +196,30 @@ char *strdup(const char *s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Dump state when everything went wrong after a SEGV
|
||||||
|
*/
|
||||||
|
|
||||||
|
static void sigsegv_dump_state(sigsegv_address_t fault_address, sigsegv_address_t fault_instruction)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "do_handle_screen_fault: unhandled address %p", fault_address);
|
||||||
|
if (fault_instruction != SIGSEGV_INVALID_PC)
|
||||||
|
fprintf(stderr, " [IP=%p]", fault_instruction);
|
||||||
|
fprintf(stderr, "\n");
|
||||||
|
#if EMULATED_68K
|
||||||
|
uaecptr nextpc;
|
||||||
|
extern void m68k_dumpstate(uaecptr *nextpc);
|
||||||
|
m68k_dumpstate(&nextpc);
|
||||||
|
#endif
|
||||||
|
VideoQuitFullScreen();
|
||||||
|
#ifdef ENABLE_MON
|
||||||
|
char *arg[4] = {"mon", "-m", "-r", NULL};
|
||||||
|
mon(3, arg);
|
||||||
|
QuitEmulator();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Main program
|
* Main program
|
||||||
*/
|
*/
|
||||||
@ -290,6 +314,9 @@ int main(int argc, char **argv)
|
|||||||
sigsegv_set_ignore_state(true);
|
sigsegv_set_ignore_state(true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Register dump state function when we got mad after a segfault
|
||||||
|
sigsegv_set_dump_state(sigsegv_dump_state);
|
||||||
|
|
||||||
// Read RAM size
|
// Read RAM size
|
||||||
RAMSize = PrefsFindInt32("ramsize") & 0xfff00000; // Round down to 1MB boundary
|
RAMSize = PrefsFindInt32("ramsize") & 0xfff00000; // Round down to 1MB boundary
|
||||||
if (RAMSize < 1024*1024) {
|
if (RAMSize < 1024*1024) {
|
||||||
|
@ -44,10 +44,10 @@ typedef RETSIGTYPE (*signal_handler)(int);
|
|||||||
static bool sigsegv_ignore_fault = false;
|
static bool sigsegv_ignore_fault = false;
|
||||||
|
|
||||||
// User's SIGSEGV handler
|
// User's SIGSEGV handler
|
||||||
static sigsegv_handler_t sigsegv_user_handler = 0;
|
static sigsegv_fault_handler_t sigsegv_fault_handler = 0;
|
||||||
|
|
||||||
// Function called to dump state if we can't handle the fault
|
// Function called to dump state if we can't handle the fault
|
||||||
static sigsegv_handler_t sigsegv_dump_state = 0;
|
static sigsegv_state_dumper_t sigsegv_state_dumper = 0;
|
||||||
|
|
||||||
// Actual SIGSEGV handler installer
|
// Actual SIGSEGV handler installer
|
||||||
static bool sigsegv_do_install_handler(int sig);
|
static bool sigsegv_do_install_handler(int sig);
|
||||||
@ -488,7 +488,7 @@ static void sigsegv_handler(SIGSEGV_FAULT_HANDLER_ARGLIST)
|
|||||||
bool fault_recovered = false;
|
bool fault_recovered = false;
|
||||||
|
|
||||||
// Call user's handler and reinstall the global handler, if required
|
// Call user's handler and reinstall the global handler, if required
|
||||||
if (sigsegv_user_handler(fault_address, fault_instruction)) {
|
if (sigsegv_fault_handler(fault_address, fault_instruction)) {
|
||||||
#if (defined(HAVE_SIGACTION) ? defined(SIGACTION_NEED_REINSTALL) : defined(SIGNAL_NEED_REINSTALL))
|
#if (defined(HAVE_SIGACTION) ? defined(SIGACTION_NEED_REINSTALL) : defined(SIGNAL_NEED_REINSTALL))
|
||||||
sigsegv_do_install_handler(sig);
|
sigsegv_do_install_handler(sig);
|
||||||
#endif
|
#endif
|
||||||
@ -509,8 +509,8 @@ static void sigsegv_handler(SIGSEGV_FAULT_HANDLER_ARGLIST)
|
|||||||
#undef FAULT_HANDLER
|
#undef FAULT_HANDLER
|
||||||
|
|
||||||
// We can't do anything with the fault_address, dump state?
|
// We can't do anything with the fault_address, dump state?
|
||||||
if (sigsegv_dump_state != 0)
|
if (sigsegv_state_dumper != 0)
|
||||||
sigsegv_dump_state(fault_address, fault_instruction);
|
sigsegv_state_dumper(fault_address, fault_instruction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -557,10 +557,10 @@ static bool sigsegv_do_install_handler(int sig)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool sigsegv_install_handler(sigsegv_handler_t handler)
|
bool sigsegv_install_handler(sigsegv_fault_handler_t handler)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_SIGSEGV_RECOVERY
|
#ifdef HAVE_SIGSEGV_RECOVERY
|
||||||
sigsegv_user_handler = handler;
|
sigsegv_fault_handler = handler;
|
||||||
bool success = true;
|
bool success = true;
|
||||||
#define FAULT_HANDLER(sig) success = success && sigsegv_do_install_handler(sig);
|
#define FAULT_HANDLER(sig) success = success && sigsegv_do_install_handler(sig);
|
||||||
SIGSEGV_ALL_SIGNALS
|
SIGSEGV_ALL_SIGNALS
|
||||||
@ -580,7 +580,7 @@ bool sigsegv_install_handler(sigsegv_handler_t handler)
|
|||||||
void sigsegv_deinstall_handler(void)
|
void sigsegv_deinstall_handler(void)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_SIGSEGV_RECOVERY
|
#ifdef HAVE_SIGSEGV_RECOVERY
|
||||||
sigsegv_user_handler = 0;
|
sigsegv_fault_handler = 0;
|
||||||
#define FAULT_HANDLER(sig) signal(sig, SIG_DFL);
|
#define FAULT_HANDLER(sig) signal(sig, SIG_DFL);
|
||||||
SIGSEGV_ALL_SIGNALS
|
SIGSEGV_ALL_SIGNALS
|
||||||
#undef FAULT_HANDLER
|
#undef FAULT_HANDLER
|
||||||
@ -602,9 +602,9 @@ void sigsegv_set_ignore_state(bool ignore_fault)
|
|||||||
* Set callback function when we cannot handle the fault
|
* Set callback function when we cannot handle the fault
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void sigsegv_set_dump_state(sigsegv_handler_t handler)
|
void sigsegv_set_dump_state(sigsegv_state_dumper_t handler)
|
||||||
{
|
{
|
||||||
sigsegv_dump_state = handler;
|
sigsegv_state_dumper = handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,10 +28,13 @@
|
|||||||
typedef char * sigsegv_address_t;
|
typedef char * sigsegv_address_t;
|
||||||
|
|
||||||
// Type of a SIGSEGV handler. Returns boolean expressing successful operation
|
// Type of a SIGSEGV handler. Returns boolean expressing successful operation
|
||||||
typedef bool (*sigsegv_handler_t)(sigsegv_address_t fault_address, sigsegv_address_t instruction_address);
|
typedef bool (*sigsegv_fault_handler_t)(sigsegv_address_t fault_address, sigsegv_address_t instruction_address);
|
||||||
|
|
||||||
|
// Type of a SIGSEGV state dump function
|
||||||
|
typedef void (*sigsegv_state_dumper_t)(sigsegv_address_t fault_address, sigsegv_address_t instruction_address);
|
||||||
|
|
||||||
// Install a SIGSEGV handler. Returns boolean expressing success
|
// Install a SIGSEGV handler. Returns boolean expressing success
|
||||||
extern bool sigsegv_install_handler(sigsegv_handler_t handler);
|
extern bool sigsegv_install_handler(sigsegv_fault_handler_t handler);
|
||||||
|
|
||||||
// Remove the user SIGSEGV handler, revert to default behavior
|
// Remove the user SIGSEGV handler, revert to default behavior
|
||||||
extern void sigsegv_uninstall_handler(void);
|
extern void sigsegv_uninstall_handler(void);
|
||||||
@ -40,7 +43,7 @@ extern void sigsegv_uninstall_handler(void);
|
|||||||
extern void sigsegv_set_ignore_state(bool ignore_fault);
|
extern void sigsegv_set_ignore_state(bool ignore_fault);
|
||||||
|
|
||||||
// Set callback function when we cannot handle the fault
|
// Set callback function when we cannot handle the fault
|
||||||
extern void sigsegv_set_dump_state(sigsegv_handler_t handler);
|
extern void sigsegv_set_dump_state(sigsegv_state_dumper_t handler);
|
||||||
|
|
||||||
// Define an address that is bound to be invalid for a program counter
|
// Define an address that is bound to be invalid for a program counter
|
||||||
const sigsegv_address_t SIGSEGV_INVALID_PC = (sigsegv_address_t)(-1);
|
const sigsegv_address_t SIGSEGV_INVALID_PC = (sigsegv_address_t)(-1);
|
||||||
|
@ -29,10 +29,6 @@
|
|||||||
#include "sigsegv.h"
|
#include "sigsegv.h"
|
||||||
#include "vm_alloc.h"
|
#include "vm_alloc.h"
|
||||||
|
|
||||||
#ifdef ENABLE_MON
|
|
||||||
# include "mon.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Variables for Video on SEGV support
|
// Variables for Video on SEGV support
|
||||||
static uint8 *the_host_buffer; // Host frame buffer in VOSF mode
|
static uint8 *the_host_buffer; // Host frame buffer in VOSF mode
|
||||||
|
|
||||||
@ -269,21 +265,6 @@ static bool screen_fault_handler(sigsegv_address_t fault_address, sigsegv_addres
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Otherwise, we don't know how to handle the fault, let it crash */
|
/* Otherwise, we don't know how to handle the fault, let it crash */
|
||||||
fprintf(stderr, "do_handle_screen_fault: unhandled address %p", fault_address);
|
|
||||||
if (fault_instruction != SIGSEGV_INVALID_PC)
|
|
||||||
fprintf(stderr, " [IP=%p]", fault_instruction);
|
|
||||||
fprintf(stderr, "\n");
|
|
||||||
#if EMULATED_68K
|
|
||||||
uaecptr nextpc;
|
|
||||||
extern void m68k_dumpstate(uaecptr *nextpc);
|
|
||||||
m68k_dumpstate(&nextpc);
|
|
||||||
#endif
|
|
||||||
VideoQuitFullScreen();
|
|
||||||
#ifdef ENABLE_MON
|
|
||||||
char *arg[4] = {"mon", "-m", "-r", NULL};
|
|
||||||
mon(3, arg);
|
|
||||||
QuitEmulator();
|
|
||||||
#endif
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user