#pragma once // Native crash reporting (task #66 / BETA_TELEMETRY_PLAN.md). // // Most crashes in this project are NATIVE - a SIGSEGV inside JIT-generated // code - so Java's uncaught-exception handler never sees them and the tester // sees only "the game closed". This writes a report the moment it happens. // // What it does NOT do, deliberately: show any UI. A signal handler runs on a // process that has already gone wrong, where only async-signal-safe calls are // legal - no malloc, no JNI, no Activity. It writes one file with write() and // then lets the process die. The report screen is shown by Java on the NEXT // launch, which is how every serious crash reporter handles native crashes. // // The report lands on external storage (Android/data//files/crashes), so // a tester can reach it over USB or a file manager without any permission. #include // Call once, early, with the directory reports should be written to (the app's // external files dir). Creates the directory if needed, pre-builds every string // the handler will need, installs an alternate signal stack so a stack-overflow // crash can still be reported, and hooks the fatal signals. // // Safe to call more than once; only the first call installs anything. void InstallCrashHandler(const char* crashDir, const char* buildStamp); // Tells the handler where guest memory starts, so a host fault address can be // reported as the GUEST address that caused it. Without this a report says // "fault at 0x6f464c459b", which means nothing to anyone; with it the report // also says "guest 0x464c459b", which is the number worth reading. Called by // GuestEngine once its region is mapped. void SetCrashHandlerGuestBase(uint64_t flatBase, uint32_t regionSize);