Add a self-contained, thread-safe crash/error log (common/CrashLog) that
survives process death, plus instrumentation at key lifecycle points so a
crash log reveals the system state that led to it.
- CrashLog.{h,cpp}: append-only eve.log recorder with initSystemLogging,
recordLogEvent, recordCrashEvent (try-lock safe for crash handlers) and
crashLogPath. EVE_LOG_DIR overrides the location.
- CrashHandler.h: unhandled-exception backtrace is now also written to
eve.log, not only stderr.
- main.cpp: open the log before anything can fail.
- Run.cpp: record run start + top-level failures; bind eve.log() so scripts
share the same crash log.
- vulkan/Graphics.cpp: log GPU identity/driver/caps and graphics init
milestones (swapchain/pipelines) - the likeliest hard-crash area.
- load.nut: boot milestones (modules, window+vulkan, game script) and a
periodic frame-count marker to locate how far the loop got.
- test/crashlog.cpp: init/record/crash coverage.
46 lines
1.5 KiB
C++
46 lines
1.5 KiB
C++
#include "zeroerr/assert.h"
|
|
#include "zeroerr/unittest.h"
|
|
|
|
#include "common/CrashLog.h"
|
|
|
|
#include <filesystem>
|
|
#include <fstream>
|
|
#include <iterator>
|
|
#include <string>
|
|
|
|
using namespace eve;
|
|
|
|
TEST_CASE("crashLog.initAndRecord") {
|
|
const std::filesystem::path dir =
|
|
std::filesystem::temp_directory_path() / "eve_crashlog_test";
|
|
std::error_code ec;
|
|
std::filesystem::create_directories(dir, ec);
|
|
|
|
eve::initSystemLogging(dir.string());
|
|
CHECK(!eve::crashLogPath().empty());
|
|
|
|
eve::recordLogEvent("error", "boom-test");
|
|
|
|
std::ifstream in(eve::crashLogPath());
|
|
CHECK(in.good());
|
|
const std::string content((std::istreambuf_iterator<char>(in)),
|
|
std::istreambuf_iterator<char>());
|
|
CHECK(content.find("boom-test") != std::string::npos);
|
|
CHECK(content.find("error") != std::string::npos);
|
|
CHECK(content.find("session start") != std::string::npos);
|
|
}
|
|
|
|
TEST_CASE("crashLog.recordCrashEvent") {
|
|
const std::filesystem::path dir =
|
|
std::filesystem::temp_directory_path() / "eve_crashlog_test";
|
|
eve::recordCrashEvent("[crash] code=0xC0000005 at 0x0\nframe0\n");
|
|
|
|
std::ifstream in(eve::crashLogPath());
|
|
CHECK(in.good());
|
|
const std::string content((std::istreambuf_iterator<char>(in)),
|
|
std::istreambuf_iterator<char>());
|
|
CHECK(content.find("code=0xC0000005") != std::string::npos);
|
|
CHECK(content.find("frame0") != std::string::npos);
|
|
CHECK(content.find("crash") != std::string::npos);
|
|
}
|