From d12204e7302b8f3bd521c782094338733abfded1 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Tue, 27 May 2025 13:22:49 +0200 Subject: feat!: better crash reporting. Signed-off-by: Amlal El Mahrouss --- dev/LibCompiler/Util/LCClUtils.h | 48 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 45 insertions(+), 3 deletions(-) (limited to 'dev/LibCompiler/Util') diff --git a/dev/LibCompiler/Util/LCClUtils.h b/dev/LibCompiler/Util/LCClUtils.h index c88339d..8e7c4d7 100644 --- a/dev/LibCompiler/Util/LCClUtils.h +++ b/dev/LibCompiler/Util/LCClUtils.h @@ -9,6 +9,7 @@ #include #include #include +#include #include #define kZero64Section ".zero64" @@ -51,18 +52,59 @@ inline void print_warning(std::string reason, std::string file) noexcept { /// @internal /// @brief Handler for SIGSEGV signal. -inline void drv_segfault_handler(std::int32_t id) { +inline void drvi_crash_handler(std::int32_t id) { + LibCompiler::STLString verbose_header = "LIBCOMPILER CRASH REPORT - "; + verbose_header += kDistVersion; + verbose_header += " - "; + verbose_header += LibCompiler::current_date(); + + for (auto& ch : verbose_header) { + std::cout << '='; + } + + std::cout << std::endl; + + std::cout << verbose_header << std::endl; + + for (auto& ch : verbose_header) { + std::cout << '='; + } + + std::cout << std::endl; + + kStdOut << "DATE: " << LibCompiler::current_date() << std::endl; + kStdOut << "VERSION: " << kDistVersion << std::endl; + kStdOut << "ERRNO: " << errno << std::endl; + kStdOut << "ERRNO(STRING): " << strerror(errno) << std::endl; + + switch (id) { case SIGSEGV: { - kStdErr << "SIGSEGV: Please report this on the GitHub issues page." << kBlank << std::endl; + kStdOut << "SIGSEGV: Segmentation Fault." << kBlank << std::endl; break; } case SIGABRT: { - kStdErr << "SIGABRT: Please report this on the GitHub issues page." << kBlank << std::endl; + kStdOut << "SIGABRT: Aborted." << kBlank << std::endl; break; } } + std::cout << kWhite; + + for (auto& ch : verbose_header) { + std::cout << '='; + } + + std::cout << std::endl; + + std::cout << verbose_header << std::endl; + + for (auto& ch : verbose_header) { + std::cout << '='; + } + + std::cout << std::endl; + std::exit(LIBCOMPILER_EXEC_ERROR); } } // namespace Detail -- cgit v1.2.3