mirror of
https://github.com/cemu-project/Cemu.git
synced 2024-11-25 18:46:55 +01:00
Add SIGINT handler on posix systems (#145)
This commit is contained in:
parent
b1844a8753
commit
a3b1af4e3d
@ -11,18 +11,19 @@ target_sources(CemuCommon
|
|||||||
PRIVATE
|
PRIVATE
|
||||||
windows/platform.cpp
|
windows/platform.cpp
|
||||||
windows/platform.h
|
windows/platform.h
|
||||||
|
ExceptionHandler/ExceptionHandler_win32.cpp
|
||||||
)
|
)
|
||||||
else()
|
else()
|
||||||
target_sources(CemuCommon
|
target_sources(CemuCommon
|
||||||
PRIVATE
|
PRIVATE
|
||||||
unix/platform.cpp
|
unix/platform.cpp
|
||||||
unix/platform.h
|
unix/platform.h
|
||||||
|
ExceptionHandler/ExceptionHandler_posix.cpp
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_sources(CemuCommon
|
target_sources(CemuCommon
|
||||||
PRIVATE
|
PRIVATE
|
||||||
ExceptionHandler/ExceptionHandler.cpp
|
|
||||||
ExceptionHandler/ExceptionHandler.h
|
ExceptionHandler/ExceptionHandler.h
|
||||||
)
|
)
|
||||||
|
|
||||||
|
36
src/Common/ExceptionHandler/ExceptionHandler_posix.cpp
Normal file
36
src/Common/ExceptionHandler/ExceptionHandler_posix.cpp
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
#include <signal.h>
|
||||||
|
#include <execinfo.h>
|
||||||
|
|
||||||
|
void handler_SIGSEGV(int sig)
|
||||||
|
{
|
||||||
|
printf("SIGSEGV!\n");
|
||||||
|
|
||||||
|
void *array[32];
|
||||||
|
size_t size;
|
||||||
|
|
||||||
|
// get void*'s for all entries on the stack
|
||||||
|
size = backtrace(array, 32);
|
||||||
|
|
||||||
|
// print out all the frames to stderr
|
||||||
|
fprintf(stderr, "Error: signal %d:\n", sig);
|
||||||
|
backtrace_symbols_fd(array, size, STDERR_FILENO);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void handler_SIGINT(int sig)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Received when pressing CTRL + C in a console
|
||||||
|
* Ideally should be exiting cleanly after saving settings but currently
|
||||||
|
* there's no clean exit pathway (at least on linux) and exiting the app
|
||||||
|
* by any mean ends up with a SIGABRT from the standard library destroying
|
||||||
|
* threads.
|
||||||
|
*/
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExceptionHandler_init()
|
||||||
|
{
|
||||||
|
signal(SIGSEGV, handler_SIGSEGV);
|
||||||
|
signal(SIGINT, handler_SIGINT);
|
||||||
|
}
|
@ -1,12 +1,6 @@
|
|||||||
#include "Common/precompiled.h"
|
#include "Common/precompiled.h"
|
||||||
#include "Cafe/CafeSystem.h"
|
#include "Cafe/CafeSystem.h"
|
||||||
|
|
||||||
#if BOOST_OS_LINUX || BOOST_OS_MACOS
|
|
||||||
#include <signal.h>
|
|
||||||
#include <execinfo.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if BOOST_OS_WINDOWS
|
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#include <Dbghelp.h>
|
#include <Dbghelp.h>
|
||||||
#include <shellapi.h>
|
#include <shellapi.h>
|
||||||
@ -16,16 +10,11 @@
|
|||||||
#include "Cafe/OS/libs/coreinit/coreinit_Thread.h"
|
#include "Cafe/OS/libs/coreinit/coreinit_Thread.h"
|
||||||
#include "Cafe/HW/Espresso/PPCState.h"
|
#include "Cafe/HW/Espresso/PPCState.h"
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
extern uint32 currentBaseApplicationHash;
|
extern uint32 currentBaseApplicationHash;
|
||||||
extern uint32 currentUpdatedApplicationHash;
|
extern uint32 currentUpdatedApplicationHash;
|
||||||
|
|
||||||
#if BOOST_OS_WINDOWS
|
|
||||||
|
|
||||||
LONG handleException_SINGLE_STEP(PEXCEPTION_POINTERS pExceptionInfo)
|
LONG handleException_SINGLE_STEP(PEXCEPTION_POINTERS pExceptionInfo)
|
||||||
{
|
{
|
||||||
|
|
||||||
return EXCEPTION_CONTINUE_SEARCH;
|
return EXCEPTION_CONTINUE_SEARCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -416,27 +405,3 @@ void ExceptionHandler_init()
|
|||||||
AddVectoredExceptionHandler(1, VectoredExceptionHandler);
|
AddVectoredExceptionHandler(1, VectoredExceptionHandler);
|
||||||
SetErrorMode(SEM_FAILCRITICALERRORS);
|
SetErrorMode(SEM_FAILCRITICALERRORS);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
|
|
||||||
void handler_SIGSEGV(int sig)
|
|
||||||
{
|
|
||||||
printf("SIGSEGV!\n");
|
|
||||||
|
|
||||||
void *array[32];
|
|
||||||
size_t size;
|
|
||||||
|
|
||||||
// get void*'s for all entries on the stack
|
|
||||||
size = backtrace(array, 32);
|
|
||||||
|
|
||||||
// print out all the frames to stderr
|
|
||||||
fprintf(stderr, "Error: signal %d:\n", sig);
|
|
||||||
backtrace_symbols_fd(array, size, STDERR_FILENO);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ExceptionHandler_init()
|
|
||||||
{
|
|
||||||
signal(SIGSEGV, handler_SIGSEGV);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
@ -399,11 +399,4 @@ void CemuApp::ActivateApp(wxActivateEvent& event)
|
|||||||
event.Skip();
|
event.Skip();
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
CemuApp& wxGetAppWrapper()
|
|
||||||
{
|
|
||||||
return *static_cast<CemuApp*>(wxApp::GetInstance());
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user