diff --git a/source/window/win_window.cpp b/source/window/win_window.cpp index 263424747..28a9a6d12 100644 --- a/source/window/win_window.cpp +++ b/source/window/win_window.cpp @@ -319,10 +319,14 @@ ImGui::SetCursorPosX(ImGui::GetWindowWidth() - buttonSize.x * 6); #if defined(DEBUG) if (ImGui::TitleBarButton(ICON_VS_DEBUG, buttonSize)) { - if (ImGui::GetIO().KeyCtrl && ImGui::GetIO().KeyShift) { + if (ImGui::GetIO().KeyCtrl) { // Explicitly trigger a segfault by writing to an invalid memory location // Used for debugging crashes *reinterpret_cast(0x10) = 0x10; + } else if (ImGui::GetIO().KeyShift) { + // Explicitly trigger an abort by throwing an uncaught exception + // Used for debugging exception errors + throw std::runtime_error("Debug Error"); } else { hex::openWebpage("https://imhex.werwolv.net/debug"); } diff --git a/source/window/window.cpp b/source/window/window.cpp index 51b47d8f2..47966b865 100644 --- a/source/window/window.cpp +++ b/source/window/window.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include @@ -259,9 +260,19 @@ namespace hex { auto signalHandler = [](int signalNumber) { EventManager::post(signalNumber); + if (std::uncaught_exceptions() > 0) { + log::fatal("Uncaught exception thrown!"); + } + // Let's not loop on this... std::signal(signalNumber, nullptr); - std::raise(signalNumber); + + #if defined(DEBUG) + assert(false); + #else + std::raise(signalNumber); + #endif + }; std::signal(SIGTERM, signalHandler);