From ffb7fde46fcc8dcc274557c231d2ba26743d073d Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Mon, 21 Oct 2019 16:33:51 +1100 Subject: [PATCH] debug/crash: temporarily disable backtrace reporting We're using breakpad for a few projects. It has much better functionality. --- backtrace_win32.cpp | 3 ++- debug/crash_posix.cpp | 4 ++++ debug/crash_win32.cpp | 30 +++++++++++++++++++++++++++++- 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/backtrace_win32.cpp b/backtrace_win32.cpp index c7b7f231..22635ec3 100644 --- a/backtrace_win32.cpp +++ b/backtrace_win32.cpp @@ -46,7 +46,8 @@ backtrace::backtrace (void) /////////////////////////////////////////////////////////////////////////////// std::ostream& -debug::operator <<(std::ostream &os, ::cruft::backtrace const &rhs) { +debug::operator <<(std::ostream &os, ::cruft::backtrace const &rhs) +{ static auto process = GetCurrentProcess (); CHECK (ready); diff --git a/debug/crash_posix.cpp b/debug/crash_posix.cpp index aaa8eefb..575244be 100644 --- a/debug/crash_posix.cpp +++ b/debug/crash_posix.cpp @@ -53,6 +53,9 @@ void dumping_handler (int sig, siginfo_t *info, void *ucontext) void cruft::debug::init_crash_handler () { + // Keep this disabled for the time being as most projects we're using + // employ breakpad which has better functionality. +#if 0 struct sigaction new_handler {}; memset (&new_handler, 0, sizeof (new_handler)); new_handler.sa_flags = SA_SIGINFO; @@ -67,4 +70,5 @@ cruft::debug::init_crash_handler () ) ); } +#endif } diff --git a/debug/crash_win32.cpp b/debug/crash_win32.cpp index 92540852..4f8f29c7 100644 --- a/debug/crash_win32.cpp +++ b/debug/crash_win32.cpp @@ -8,9 +8,37 @@ #include "crash.hpp" +#include "assert.hpp" + +#include "../backtrace.hpp" +#include "../win32/windows.hpp" + +#include + + +/////////////////////////////////////////////////////////////////////////////// +static LPTOP_LEVEL_EXCEPTION_FILTER previous_handler; + + +/////////////////////////////////////////////////////////////////////////////// +static LONG __stdcall +backtrace_handler (EXCEPTION_POINTERS *data) +{ + std::clog << cruft::backtrace () << '\n'; + + if (previous_handler) + return previous_handler (data); + else + return EXCEPTION_CONTINUE_SEARCH; +} + + /////////////////////////////////////////////////////////////////////////////// void cruft::debug::init_crash_handler (void) { - +#if 0 + CHECK (!previous_handler); + previous_handler = SetUnhandledExceptionFilter (backtrace_handler); +#endif }