[Debug] Add cvar to support dumping xex file for debugging

This commit is contained in:
Herman S.
2026-02-02 10:43:20 +09:00
parent be10bbd946
commit 6673cd2d5a
2 changed files with 16 additions and 0 deletions
+3
View File
@@ -91,6 +91,9 @@ DEFINE_CVar(launch_data, "",
"Used internally for title-to-title launches.",
"General", true, std::string);
DEFINE_bool(dump_xex, false, "Dump the main XEX to current directory on launch",
"General");
DEFINE_bool(allow_game_relative_writes, false,
"Not useful to non-developers. Allows code to write to paths "
"relative to game://. Used for "
+13
View File
@@ -10,11 +10,14 @@
#include "xenia/kernel/user_module.h"
#include "xenia/base/byte_stream.h"
#include "xenia/base/filesystem.h"
#include "xenia/base/logging.h"
#include "xenia/base/xxhash.h"
#include "xenia/cpu/elf_module.h"
#include "xenia/emulator.h"
DECLARE_bool(dump_xex);
namespace xe {
namespace kernel {
@@ -156,6 +159,16 @@ X_STATUS UserModule::LoadFromMemory(const void* addr, const size_t length) {
// Runtime takes ownership.
auto xex_module =
std::make_unique<cpu::XexModule>(processor, kernel_state());
if (cvars::dump_xex) {
auto dump_name = name_ + ".xex";
auto dump_file = xe::filesystem::OpenFile(dump_name, "wb");
if (dump_file) {
fwrite(addr, 1, length, dump_file);
fclose(dump_file);
XELOGI("Dumped XEX '{}' ({} bytes)", dump_name, length);
}
}
if (!xex_module->Load(name_, path_, addr, length)) {
return X_STATUS_UNSUCCESSFUL;
}