From 3a740d793330f3a5df710bd21fb7a4a265ef0be6 Mon Sep 17 00:00:00 2001 From: x1nixmzeng Date: Sun, 11 Oct 2020 12:13:03 +0100 Subject: [PATCH] Report relaunching with another Xbe to the debugger --- src/common/CxbxDebugger.cpp | 31 +++++++++++++++++--------- src/common/CxbxDebugger.h | 1 + src/core/kernel/exports/EmuKrnlHal.cpp | 27 +++++++++++++++++++--- 3 files changed, 45 insertions(+), 14 deletions(-) diff --git a/src/common/CxbxDebugger.cpp b/src/common/CxbxDebugger.cpp index 7719c2b55..3f9d4f801 100644 --- a/src/common/CxbxDebugger.cpp +++ b/src/common/CxbxDebugger.cpp @@ -37,19 +37,19 @@ namespace CxbxDebugger // Note: Keep the top 3-bits empty as they are used internally enum ReportType : DWORD { - // Debugger report codes: + HLECACHE_FILE = 0x1000, - HLECACHE_FILE = 0x00deed00, - KERNEL_PATCH = 0x00deed01, - FILE_OPENED = 0x00deed02, - FILE_READ = 0x00deed03, - FILE_CLOSED = 0x00deed04, - DEBUGGER_INIT = 0x00deed05, - FILE_WRITE = 0x00deed06, + KERNEL_PATCH = 0x2000, - // Debugger query codes: + FILE_OPENED = 0x3000, + FILE_READ = 0x3001, + FILE_WRITE = 0x3002, + FILE_CLOSED = 0x3003, - OVERRIDE_EXCEPTION = 0x00ceed01, + DEBUGGER_INIT = 0x400, + DEBUGGER_NEW_TARGET = 0x401, + + OVERRIDE_EXCEPTION = 0x500, }; bool IsAttached() @@ -130,6 +130,7 @@ namespace CxbxDebugger case Internal::FILE_READ: case Internal::FILE_CLOSED: case Internal::DEBUGGER_INIT: + case Internal::DEBUGGER_NEW_TARGET: return true; case Internal::OVERRIDE_EXCEPTION: @@ -148,12 +149,20 @@ namespace CxbxDebugger { Internal::ReportHelper Report(Internal::DEBUGGER_INIT); - Report.Add(0); // unused Report.AddString(XbeTitle); Report.Send(); } + void ReportNewTarget(const char* CommandLine) + { + Internal::ReportHelper Report(Internal::DEBUGGER_NEW_TARGET); + + Report.AddString(CommandLine); + + Report.Send(); + } + void ReportHLECacheFile(const char* Filename) { Internal::ReportHelper Report(Internal::HLECACHE_FILE); diff --git a/src/common/CxbxDebugger.h b/src/common/CxbxDebugger.h index aca7f886c..acdc2f25b 100644 --- a/src/common/CxbxDebugger.h +++ b/src/common/CxbxDebugger.h @@ -36,6 +36,7 @@ namespace CxbxDebugger // Report helpers: void ReportDebuggerInit(const char* XbeTitle); + void ReportNewTarget(const char* CommandLine); void ReportHLECacheFile(const char* Filename); void ReportKernelPatch(const char* ImportName, DWORD Address); diff --git a/src/core/kernel/exports/EmuKrnlHal.cpp b/src/core/kernel/exports/EmuKrnlHal.cpp index 043ccf87c..32b751348 100644 --- a/src/core/kernel/exports/EmuKrnlHal.cpp +++ b/src/core/kernel/exports/EmuKrnlHal.cpp @@ -46,6 +46,7 @@ #include "common/util/strConverter.hpp" // for utf16_to_ascii #include "core\kernel\memory-manager\VMManager.h" #include "common/util/cliConfig.hpp" +#include "common/CxbxDebugger.h" #include // for std::replace #include @@ -588,11 +589,31 @@ XBSYSAPI EXPORTNUM(49) xbox::void_xt DECLSPEC_NORETURN NTAPI xbox::HalReturnToFi g_VMManager.SavePersistentMemory(); // Some titles (Xbox Dashboard and retail/demo discs) use ";" as a current directory path seperator - // This process is handled during initialization. No speical handling here required. + // This process is handled during initialization. No special handling here required. cli_config::SetLoad(XbePath); - if (!CxbxExec(false, nullptr, false)) { - CxbxKrnlCleanup("Could not launch %s", XbePath.c_str()); + + bool Debugging{ false }; + g_EmuShared->GetDebuggingFlag(&Debugging); + + if (Debugging) + { + std::string cliCommands; + if (!cli_config::GenCMD(cliCommands)) + { + CxbxKrnlCleanup("Could not launch %s", XbePath.c_str()); + } + + CxbxDebugger::ReportNewTarget(cliCommands.c_str()); + + // The debugger will execute this process + } + else + { + if (!CxbxExec(false, nullptr, false)) + { + CxbxKrnlCleanup("Could not launch %s", XbePath.c_str()); + } } // This is a requirement to have shared memory buffers remain alive and transfer to new emulation process.