sys: Trigger breakpoint in debug mode when a signal is raised
This commit is contained in:
parent
b9034523b5
commit
1b853c6a84
@ -319,10 +319,14 @@
|
|||||||
ImGui::SetCursorPosX(ImGui::GetWindowWidth() - buttonSize.x * 6);
|
ImGui::SetCursorPosX(ImGui::GetWindowWidth() - buttonSize.x * 6);
|
||||||
#if defined(DEBUG)
|
#if defined(DEBUG)
|
||||||
if (ImGui::TitleBarButton(ICON_VS_DEBUG, buttonSize)) {
|
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
|
// Explicitly trigger a segfault by writing to an invalid memory location
|
||||||
// Used for debugging crashes
|
// Used for debugging crashes
|
||||||
*reinterpret_cast<u8*>(0x10) = 0x10;
|
*reinterpret_cast<u8*>(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 {
|
} else {
|
||||||
hex::openWebpage("https://imhex.werwolv.net/debug");
|
hex::openWebpage("https://imhex.werwolv.net/debug");
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
#include <romfs/romfs.hpp>
|
#include <romfs/romfs.hpp>
|
||||||
|
|
||||||
@ -259,9 +260,19 @@ namespace hex {
|
|||||||
auto signalHandler = [](int signalNumber) {
|
auto signalHandler = [](int signalNumber) {
|
||||||
EventManager::post<EventAbnormalTermination>(signalNumber);
|
EventManager::post<EventAbnormalTermination>(signalNumber);
|
||||||
|
|
||||||
|
if (std::uncaught_exceptions() > 0) {
|
||||||
|
log::fatal("Uncaught exception thrown!");
|
||||||
|
}
|
||||||
|
|
||||||
// Let's not loop on this...
|
// Let's not loop on this...
|
||||||
std::signal(signalNumber, nullptr);
|
std::signal(signalNumber, nullptr);
|
||||||
std::raise(signalNumber);
|
|
||||||
|
#if defined(DEBUG)
|
||||||
|
assert(false);
|
||||||
|
#else
|
||||||
|
std::raise(signalNumber);
|
||||||
|
#endif
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
std::signal(SIGTERM, signalHandler);
|
std::signal(SIGTERM, signalHandler);
|
||||||
|
Loading…
Reference in New Issue
Block a user