From 46f196cb3f4654acd25af0a4248e8c2010ef8127 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Mon, 20 Sep 2021 20:48:08 +0200 Subject: [PATCH] sys: Added debug function to crash ImHex --- source/window/win_window.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/source/window/win_window.cpp b/source/window/win_window.cpp index 8ddfea13e..ade1fcd9b 100644 --- a/source/window/win_window.cpp +++ b/source/window/win_window.cpp @@ -222,8 +222,15 @@ ImGui::SetCursorPosX(ImGui::GetWindowWidth() - buttonSize.x * 6); #if defined(DEBUG) - if (ImGui::TitleBarButton(ICON_VS_DEBUG, buttonSize)) - hex::openWebpage("https://imhex.werwolv.net/debug"); + if (ImGui::TitleBarButton(ICON_VS_DEBUG, buttonSize)) { + if (ImGui::GetIO().KeyCtrl && ImGui::GetIO().KeyShift) { + // Explicitly trigger a segfault by writing to an invalid memory location + // Used for debugging crashes + *reinterpret_cast(0x10) = 0x10; + } else { + hex::openWebpage("https://imhex.werwolv.net/debug"); + } + } ImGui::InfoTooltip("hex.menu.debug_build"_lang); #endif if (ImGui::TitleBarButton(ICON_VS_SMILEY, buttonSize))