From c5f45c6f9af9f45244f62f5e2564b54dee558360 Mon Sep 17 00:00:00 2001 From: Maxim Poliakovski Date: Thu, 19 Aug 2021 11:29:44 +0200 Subject: [PATCH] SIGINT invokes the built-in debugger. --- main.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/main.cpp b/main.cpp index c3a3a2c..915a894 100644 --- a/main.cpp +++ b/main.cpp @@ -29,6 +29,7 @@ along with this program. If not, see . #include "utils/profiler.h" #include "ppcemu.h" #include +#include #include #include #include @@ -40,6 +41,15 @@ along with this program. If not, see . using namespace std; +void sigint_handler(int signum) { + enter_debugger(); + + LOG_F(INFO, "Shutting down..."); + + delete gMachineObj.release(); + exit(0); +} + static string appDescription = string( "\nDingusPPC - Prototype 5bf5 (8/23/2020) " "\nWritten by divingkatae and maximumspatium " @@ -118,10 +128,8 @@ int main(int argc, char** argv) { loguru::init(argc, argv); loguru::add_file("dingusppc.log", loguru::Append, 0); } else { - loguru::g_preamble_uptime = false; loguru::g_stderr_verbosity = loguru::Verbosity_INFO; loguru::init(argc, argv); - loguru::add_file("exceptions.log", loguru::Truncate, -7); } if (*machine_opt) { @@ -163,6 +171,9 @@ int main(int argc, char** argv) { goto bail; } + // redirect SIGINT to our own handler + signal(SIGINT, sigint_handler); + #ifdef SDL if (SDL_Init(SDL_INIT_AUDIO)){ LOG_F(ERROR, "SDL_Init error: %s", SDL_GetError());