![]() |
QElectroTech 0.200.1-dev
|
The CrashHandler class Discussion #644, step 4: on a fatal crash, flush the in-memory LogRing to a fixed file before the process dies, so the last N log lines leading up to the crash survive it – today they only exist in memory and are lost with the process. More...
#include <crashhandler.h>

Static Public Member Functions | |
| static void | install (const LogRing *ring, const QString &dump_path) |
Private Member Functions | |
| CrashHandler ()=delete | |
The CrashHandler class Discussion #644, step 4: on a fatal crash, flush the in-memory LogRing to a fixed file before the process dies, so the last N log lines leading up to the crash survive it – today they only exist in memory and are lost with the process.
This is the highest-risk piece of the whole logging rework (the discussion's own words: "lands last, behind its own switch"), so its invariants are worth restating plainly:
Tested in this environment: POSIX/Linux only (sigaction, sigaltstack, SIGSEGV/SIGABRT/SIGBUS/SIGFPE/SIGILL). The Windows path (SetUnhandledExceptionFilter) and macOS-specific behaviour (signal handling itself is POSIX and shares the Linux code path, but sandbox profiles can affect where the dump file may be written) are implemented per the discussion's guidance but could not be exercised here – there is no Windows or macOS build available in this sandbox. Please sanity-check both before relying on them in the field.
|
privatedelete |
|
static |
Installs the crash handler. Must be called from normal (non-signal) startup code, after the LogRing it will dump exists, and only once. ring must outlive the process (in practice: the LogRing owned by QetLogger's function-local static instance, which is never destroyed before exit). dump_path is resolved and copied into a fixed-size internal buffer here; nothing under the actual signal/exception path touches QString.

