feat: Added stacktrace printing on crashes (#892)

* feat: Added simple stack trace output

* feat: Added backtrace wrapper

* build: Added libbacktrace include dirs to build

* build: Fixed libbacktrace variables

* build: More backtrace variable fixes

* build: Try to find backtrace include

* build: Get backtrace header from cmake script

* feat: Added backtrace support for execinfo

* feat: Added support for StackWalk on Windows
This commit is contained in:
Nik
2023-01-17 21:38:56 +01:00
committed by GitHub
parent 3ddef07284
commit 48a57cd981
9 changed files with 985 additions and 6 deletions

View File

@@ -9,8 +9,7 @@
#include <hex/helpers/utils.hpp>
#include <hex/helpers/fs.hpp>
#include <hex/helpers/logger.hpp>
#include <llvm/Demangle/Demangle.h>
#include <hex/helpers/stacktrace.hpp>
#include <chrono>
#include <csignal>
@@ -19,6 +18,7 @@
#include <cassert>
#include <romfs/romfs.hpp>
#include <llvm/Demangle/Demangle.h>
#include <imgui.h>
#define IMGUI_DEFINE_MATH_OPERATORS
@@ -78,8 +78,15 @@ namespace hex {
log::fatal("Uncaught exception thrown!");
}
// Let's not loop on this...
std::signal(signalNumber, nullptr);
std::signal(signalNumber, SIG_DFL);
for (const auto &stackFrame : stacktrace::getStackTrace()) {
if (stackFrame.line == 0)
log::fatal(" {}", stackFrame.function);
else
log::fatal(" ({}:{}) | {}", stackFrame.file, stackFrame.line, stackFrame.function);
}
#if defined(DEBUG)
assert(!"Debug build, triggering breakpoint");
@@ -89,6 +96,8 @@ namespace hex {
}
Window::Window() {
stacktrace::initialize();
{
for (const auto &[argument, value] : ImHexApi::System::getInitArguments()) {
if (argument == "no-plugins") {