diff --git a/source/CmdLine.cpp b/source/CmdLine.cpp index 3c07d40e..b0fbb1fa 100644 --- a/source/CmdLine.cpp +++ b/source/CmdLine.cpp @@ -777,6 +777,13 @@ bool ProcessCmdLine(LPSTR lpCmdLine) { g_cmdLine.useAltCpuEmulation = true; } + else if (strcmp(lpCmdLine, "-debugger-auto-run") == 0) + { + lpCmdLine = GetCurrArg(lpNextArg); + lpNextArg = GetNextArg(lpNextArg); + + g_cmdLine.debuggerAutoRunScriptFilename = lpCmdLine; + } else // unsupported { LogFileOutput("Unsupported arg: %s\n", lpCmdLine); diff --git a/source/CmdLine.h b/source/CmdLine.h index 30a37bb3..0066e61e 100644 --- a/source/CmdLine.h +++ b/source/CmdLine.h @@ -126,7 +126,8 @@ struct CmdLine bool auxSlotEmpty; SS_CARDTYPE auxSlotInsert; std::string sBootSectorFileName; - size_t nBootSectorFileSize; + size_t nBootSectorFileSize; + std::string debuggerAutoRunScriptFilename; }; bool ProcessCmdLine(LPSTR lpCmdLine); diff --git a/source/Debugger/Debug.cpp b/source/Debugger/Debug.cpp index 0b9c1979..4a2b7678 100644 --- a/source/Debugger/Debug.cpp +++ b/source/Debugger/Debug.cpp @@ -360,6 +360,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA static bool g_bScriptReadOk = false; + static std::string g_sAutoRunScriptFilename("DebuggerAutoRun.txt"); + // Private ________________________________________________________________________________________ @@ -9093,11 +9095,9 @@ void DebugInitialize () { doneAutoRun = true; - const std::string debuggerAutoRunName = "DebuggerAutoRun.txt"; - // Look in g_sCurrentDir, otherwise try g_sProgramDir - std::string pathname = g_sCurrentDir + debuggerAutoRunName; + std::string pathname = g_sCurrentDir + g_sAutoRunScriptFilename; errno_t error = strncpy_s(g_aArgs[1].sArg, MAX_PATH, pathname.c_str(), pathname.size()); if (error != 0) { @@ -9111,7 +9111,7 @@ void DebugInitialize () if (!g_bScriptReadOk) { - pathname = g_sProgramDir + debuggerAutoRunName; + pathname = g_sProgramDir + g_sAutoRunScriptFilename; error = strncpy_s(g_aArgs[1].sArg, MAX_PATH, pathname.c_str(), pathname.size()); if (error != 0) { @@ -9829,3 +9829,10 @@ bool IsDebugSteppingAtFullSpeed (void) { return (g_nAppMode == MODE_STEPPING) && g_bDebugFullSpeed; } + + +//=========================================================================== +void DebugSetAutoRunScript (std::string& sAutoRunScriptFilename) +{ + g_sAutoRunScriptFilename = sAutoRunScriptFilename; +} diff --git a/source/Debugger/Debug.h b/source/Debugger/Debug.h index 35c3bdab..efc5373a 100644 --- a/source/Debugger/Debug.h +++ b/source/Debugger/Debug.h @@ -192,3 +192,4 @@ bool DebuggerCheckMemBreakpoints(WORD nAddress, WORD nSize, bool isDmaToMemory); void ClearTempBreakpoints(); + void DebugSetAutoRunScript(std::string& sAutoRunScriptFilename); diff --git a/source/Windows/AppleWin.cpp b/source/Windows/AppleWin.cpp index 56a5b26c..a0533649 100644 --- a/source/Windows/AppleWin.cpp +++ b/source/Windows/AppleWin.cpp @@ -930,6 +930,9 @@ static void RepeatInitialization(void) if (g_cmdLine.useAltCpuEmulation) ForceAltCpuEmulation(); + if (!g_cmdLine.debuggerAutoRunScriptFilename.empty()) + DebugSetAutoRunScript(g_cmdLine.debuggerAutoRunScriptFilename); + // Call DebugInitialize() after SetCurrentImageDir() DebugInitialize(); LogFileOutput("Main: DebugInitialize()\n");