From e5c4e2c51bcffc02c4e0f2441d84d96f9cca8873 Mon Sep 17 00:00:00 2001 From: sh95014 <95387068+sh95014@users.noreply.github.com> Date: Fri, 2 Jun 2023 09:28:04 -0700 Subject: [PATCH] Allow alternate directory for built-in symbols (#1230) * allow an alternate directory for built-in symbol tables -- needed because macOS apps are a bundle (tree of directories) and resources are packaged somewhere within, not necessarily in the same directory as the executable. * use tabs * add parentheses --- source/Core.cpp | 1 + source/Core.h | 1 + source/Debugger/Debugger_Symbols.cpp | 9 ++++++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/source/Core.cpp b/source/Core.cpp index 1d7860c9..9def69c0 100644 --- a/source/Core.cpp +++ b/source/Core.cpp @@ -61,6 +61,7 @@ AppMode_e g_nAppMode = MODE_LOGO; std::string g_sStartDir; // NB. AppleWin.exe maybe relative to this! (GH#663) std::string g_sProgramDir; // Directory of where AppleWin executable resides std::string g_sCurrentDir; // Also Starting Dir. Debugger uses this when load/save +std::string g_sBuiltinSymbolsDir; // Alternate directory for built-in debug symbols bool g_bRestart = false; diff --git a/source/Core.h b/source/Core.h index 5c32bc84..c3fb14ea 100644 --- a/source/Core.h +++ b/source/Core.h @@ -38,6 +38,7 @@ extern AppMode_e g_nAppMode; extern std::string g_sStartDir; extern std::string g_sProgramDir; extern std::string g_sCurrentDir; +extern std::string g_sBuiltinSymbolsDir; bool SetCurrentImageDir(const std::string& pszImageDir); diff --git a/source/Debugger/Debugger_Symbols.cpp b/source/Debugger/Debugger_Symbols.cpp index 9bf79b4f..c5dd4a7b 100644 --- a/source/Debugger/Debugger_Symbols.cpp +++ b/source/Debugger/Debugger_Symbols.cpp @@ -749,8 +749,15 @@ Update_t CmdSymbolsLoad (int nArgs) // Debugger will call us with 0 args on startup as a way to pre-load symbol tables if (! nArgs) { - sFileName += g_sFileNameSymbols[ iSymbolTable ]; + sFileName = g_sProgramDir + g_sFileNameSymbols[ iSymbolTable ]; nSymbols = ParseSymbolTable( sFileName, (SymbolTable_Index_e) iSymbolTable ); + + // Try optional alternate location + if ((nSymbols == 0) && !g_sBuiltinSymbolsDir.empty()) + { + sFileName = g_sBuiltinSymbolsDir + g_sFileNameSymbols[ iSymbolTable ]; + nSymbols = ParseSymbolTable( sFileName, (SymbolTable_Index_e) iSymbolTable ); + } } int iArg = 1;