34 lines
1.4 KiB
C++
34 lines
1.4 KiB
C++
#ifndef FACE_SDK_CRASH_HANDLER_H
|
|
#define FACE_SDK_CRASH_HANDLER_H
|
|
|
|
#include <string>
|
|
|
|
namespace CrashHandler {
|
|
|
|
// Install signal handlers for SIGSEGV / SIGABRT / SIGBUS / SIGFPE / SIGILL.
|
|
//
|
|
// On a fatal signal we:
|
|
// 1) Switch to a pre-allocated 64KB sigaltstack so we still have stack
|
|
// space even if the original thread's stack was the cause.
|
|
// 2) Write a self-contained crash record to <internalDataPath>/face_sdk_crash.log
|
|
// (and also try to append it to the DebugLog file passed in).
|
|
// The record contains: signal name, si_code, si_addr, pid, tid,
|
|
// a synchronous unwound backtrace (PC + module + offset for each frame),
|
|
// and the value of any extra context the caller registered via setNote().
|
|
// 3) Re-raise the original signal with the default handler so that the
|
|
// Android tombstone pipeline still produces /data/tombstones/* files.
|
|
//
|
|
// Safe to call once. Subsequent calls are no-ops. Must be called AFTER
|
|
// DebugLog::init() so we know the log directory.
|
|
void install(const std::string& internalDataPath,
|
|
const std::string& debugLogPath = "");
|
|
|
|
// Optional short note (<= 256 chars) appended to every crash dump from now on.
|
|
// Useful to record "current frame index", "current motion", etc. so we know
|
|
// what was happening at the moment of the crash. Async-signal-safe to read.
|
|
void setNote(const char* note);
|
|
|
|
} // namespace CrashHandler
|
|
|
|
#endif // FACE_SDK_CRASH_HANDLER_H
|