SIGINT invokes the built-in debugger.

This commit is contained in:
Maxim Poliakovski 2021-08-19 11:29:44 +02:00
parent a8f400287a
commit c5f45c6f9a

View File

@ -29,6 +29,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
#include "utils/profiler.h" #include "utils/profiler.h"
#include "ppcemu.h" #include "ppcemu.h"
#include <cinttypes> #include <cinttypes>
#include <csignal>
#include <cstring> #include <cstring>
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
@ -40,6 +41,15 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
using namespace std; using namespace std;
void sigint_handler(int signum) {
enter_debugger();
LOG_F(INFO, "Shutting down...");
delete gMachineObj.release();
exit(0);
}
static string appDescription = string( static string appDescription = string(
"\nDingusPPC - Prototype 5bf5 (8/23/2020) " "\nDingusPPC - Prototype 5bf5 (8/23/2020) "
"\nWritten by divingkatae and maximumspatium " "\nWritten by divingkatae and maximumspatium "
@ -118,10 +128,8 @@ int main(int argc, char** argv) {
loguru::init(argc, argv); loguru::init(argc, argv);
loguru::add_file("dingusppc.log", loguru::Append, 0); loguru::add_file("dingusppc.log", loguru::Append, 0);
} else { } else {
loguru::g_preamble_uptime = false;
loguru::g_stderr_verbosity = loguru::Verbosity_INFO; loguru::g_stderr_verbosity = loguru::Verbosity_INFO;
loguru::init(argc, argv); loguru::init(argc, argv);
loguru::add_file("exceptions.log", loguru::Truncate, -7);
} }
if (*machine_opt) { if (*machine_opt) {
@ -163,6 +171,9 @@ int main(int argc, char** argv) {
goto bail; goto bail;
} }
// redirect SIGINT to our own handler
signal(SIGINT, sigint_handler);
#ifdef SDL #ifdef SDL
if (SDL_Init(SDL_INIT_AUDIO)){ if (SDL_Init(SDL_INIT_AUDIO)){
LOG_F(ERROR, "SDL_Init error: %s", SDL_GetError()); LOG_F(ERROR, "SDL_Init error: %s", SDL_GetError());