diff --git a/Common/System/System.h b/Common/System/System.h index f364ec45d4..6c4922a6c7 100644 --- a/Common/System/System.h +++ b/Common/System/System.h @@ -163,6 +163,8 @@ enum SystemProperty { SYSPROP_CAN_JIT, + SYSPROP_HAS_DEBUGGER, + SYSPROP_KEYBOARD_LAYOUT, SYSPROP_SKIP_UI, diff --git a/Core/Debugger/SymbolMap.cpp b/Core/Debugger/SymbolMap.cpp index d866f008bd..6cac800719 100644 --- a/Core/Debugger/SymbolMap.cpp +++ b/Core/Debugger/SymbolMap.cpp @@ -206,12 +206,12 @@ bool SymbolMap::LoadSymbolMap(const Path &filename) { return started; } -void SymbolMap::SaveSymbolMap(const Path &filename) const { +bool SymbolMap::SaveSymbolMap(const Path &filename) const { std::lock_guard guard(lock_); // Don't bother writing a blank file. if (!File::Exists(filename) && functions.empty() && data.empty()) { - return; + return true; } // TODO(scoped): Use gzdopen @@ -222,7 +222,7 @@ void SymbolMap::SaveSymbolMap(const Path &filename) const { #endif if (f == Z_NULL) - return; + return false; gzprintf(f, ".text\n"); @@ -241,6 +241,7 @@ void SymbolMap::SaveSymbolMap(const Path &filename) const { gzprintf(f, "%08x %08x %x %i %s\n", e.start, e.size, e.module, ST_DATA, GetLabelNameRel(e.start, e.module)); } gzclose(f); + return true; } bool SymbolMap::LoadNocashSym(const Path &filename) { diff --git a/Core/Debugger/SymbolMap.h b/Core/Debugger/SymbolMap.h index c0ee42ee75..defe069838 100644 --- a/Core/Debugger/SymbolMap.h +++ b/Core/Debugger/SymbolMap.h @@ -71,7 +71,7 @@ public: void SortSymbols(); bool LoadSymbolMap(const Path &filename); - void SaveSymbolMap(const Path &filename) const; + bool SaveSymbolMap(const Path &filename) const; bool LoadNocashSym(const Path &filename); void SaveNocashSym(const Path &filename) const; diff --git a/Core/Host.cpp b/Core/Host.cpp index 2a35248f03..81fb73f9bf 100644 --- a/Core/Host.cpp +++ b/Core/Host.cpp @@ -15,14 +15,6 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. -#include - #include "Core/Host.h" -#include "Core/Debugger/SymbolMap.h" Host *host = nullptr; - -bool Host::AttemptLoadSymbolMap() { - g_symbolMap->Clear(); - return false; -} diff --git a/Core/Host.h b/Core/Host.h index 34267e9652..d62d6e27dd 100644 --- a/Core/Host.h +++ b/Core/Host.h @@ -31,9 +31,6 @@ public: virtual void PollControllers() {} virtual void ToggleDebugConsoleVisibility() {} - virtual bool AttemptLoadSymbolMap(); - virtual void SaveSymbolMap() {} - virtual bool CreateDesktopShortcut(std::string argumentPath, std::string title) {return false;} virtual void NotifyUserMessage(const std::string &message, float duration = 1.0f, u32 color = 0x00FFFFFF, const char *id = nullptr) {} diff --git a/Core/System.cpp b/Core/System.cpp index bd02850911..66f1546611 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -35,13 +35,14 @@ #include "Common/System/System.h" #include "Common/System/Request.h" #include "Common/File/Path.h" +#include "Common/File/FileUtil.h" +#include "Common/File/DirListing.h" #include "Common/Math/math_util.h" #include "Common/Thread/ThreadUtil.h" #include "Common/Data/Encoding/Utf8.h" - -#include "Common/File/FileUtil.h" #include "Common/TimeUtil.h" #include "Common/GraphicsContext.h" + #include "Core/MemFault.h" #include "Core/HDRemaster.h" #include "Core/MIPS/MIPS.h" @@ -173,6 +174,40 @@ bool CPU_HasPendingAction() { void CPU_Shutdown(); +static Path SymbolMapFilename(const Path ¤tFilename, const char *ext) { + File::FileInfo info{}; + // can't fail, definitely exists if it gets this far + File::GetFileInfo(currentFilename, &info); + if (info.isDirectory) { + return currentFilename / (std::string(".ppsspp-symbols") + ext); + } + return currentFilename.WithReplacedExtension(ext); +}; + +static bool LoadSymbolsIfSupported() { + if (System_GetPropertyBool(SYSPROP_HAS_DEBUGGER)) { + if (!g_symbolMap) + return false; + + bool result1 = g_symbolMap->LoadSymbolMap(SymbolMapFilename(PSP_CoreParameter().fileToStart, ".ppmap")); + // Load the old-style map file. + if (!result1) + result1 = g_symbolMap->LoadSymbolMap(SymbolMapFilename(PSP_CoreParameter().fileToStart, ".map")); + bool result2 = g_symbolMap->LoadNocashSym(SymbolMapFilename(PSP_CoreParameter().fileToStart, ".sym")); + return result1 || result2; + } else { + g_symbolMap->Clear(); + return true; + } +} + +static bool SaveSymbolMapIfSupported() { + if (g_symbolMap) { + return g_symbolMap->SaveSymbolMap(SymbolMapFilename(PSP_CoreParameter().fileToStart, ".ppmap")); + } + return false; +} + bool DiscIDFromGEDumpPath(const Path &path, FileLoader *fileLoader, std::string *id) { using namespace GPURecord; @@ -283,7 +318,7 @@ bool CPU_Init(std::string *errorString) { } mipsr4k.Reset(); - host->AttemptLoadSymbolMap(); + LoadSymbolsIfSupported(); CoreTiming::Init(); @@ -324,7 +359,7 @@ void CPU_Shutdown() { PSPLoaders_Shutdown(); if (g_Config.bAutoSaveSymbolMap) { - host->SaveSymbolMap(); + SaveSymbolMapIfSupported(); } Replacement_Shutdown(); diff --git a/Qt/QtHost.cpp b/Qt/QtHost.cpp index 9528d4a5ac..7c323cfc9d 100644 --- a/Qt/QtHost.cpp +++ b/Qt/QtHost.cpp @@ -16,7 +16,3 @@ // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. #include "Qt/QtHost.h" - -Path QtHost::SymbolMapFilename(Path currentFilename) { - return currentFilename.WithReplacedExtension(".map"); -} diff --git a/Qt/QtHost.h b/Qt/QtHost.h index 275a99bcb8..a78ae11a2d 100644 --- a/Qt/QtHost.h +++ b/Qt/QtHost.h @@ -32,11 +32,6 @@ public: void UpdateSound() override {} - bool AttemptLoadSymbolMap() override { - auto fn = SymbolMapFilename(PSP_CoreParameter().fileToStart); - return g_symbolMap->LoadSymbolMap(fn); - } - void PrepareShutdown() { auto fn = SymbolMapFilename(PSP_CoreParameter().fileToStart); g_symbolMap->SaveSymbolMap(fn); diff --git a/UI/HostTypes.h b/UI/HostTypes.h index 0ee6325d9a..05c8e40158 100644 --- a/UI/HostTypes.h +++ b/UI/HostTypes.h @@ -18,6 +18,7 @@ #pragma once #include "Core/Host.h" +#include "Common/System/NativeApp.h" #include "UI/OnScreenDisplay.h" class NativeHost : public Host { @@ -26,8 +27,6 @@ public: void UpdateSound() override {} - bool AttemptLoadSymbolMap() override {return false;} - void NotifyUserMessage(const std::string &message, float duration = 1.0f, u32 color = 0x00FFFFFF, const char *id = nullptr) override { osm.Show(message, duration, color, -1, true, id); } diff --git a/UWP/UWPHost.cpp b/UWP/UWPHost.cpp index 5048a95868..d03c78eb65 100644 --- a/UWP/UWPHost.cpp +++ b/UWP/UWPHost.cpp @@ -48,12 +48,6 @@ UWPHost::~UWPHost() { } -void UWPHost::SetConsolePosition() { -} - -void UWPHost::UpdateConsolePosition() { -} - void UWPHost::UpdateSound() { } @@ -83,29 +77,6 @@ void UWPHost::PollControllers() { */ } -static Path SymbolMapFilename(const Path ¤tFilename, const char *ext) { - File::FileInfo info; - // can't fail, definitely exists if it gets this far - File::GetFileInfo(currentFilename, &info); - if (info.isDirectory) { - return currentFilename / (std::string(".ppsspp-symbols") + ext); - } - return currentFilename.WithReplacedExtension(ext); -} - -bool UWPHost::AttemptLoadSymbolMap() { - bool result1 = g_symbolMap->LoadSymbolMap(SymbolMapFilename(PSP_CoreParameter().fileToStart, ".ppmap")); - // Load the old-style map file. - if (!result1) - result1 = g_symbolMap->LoadSymbolMap(SymbolMapFilename(PSP_CoreParameter().fileToStart, ".map")); - bool result2 = g_symbolMap->LoadNocashSym(SymbolMapFilename(PSP_CoreParameter().fileToStart, ".sym")); - return result1 || result2; -} - -void UWPHost::SaveSymbolMap() { - g_symbolMap->SaveSymbolMap(SymbolMapFilename(PSP_CoreParameter().fileToStart, ".ppmap")); -} - void UWPHost::ToggleDebugConsoleVisibility() { // N/A } diff --git a/UWP/UWPHost.h b/UWP/UWPHost.h index 244a6af3f0..9341ce2bdd 100644 --- a/UWP/UWPHost.h +++ b/UWP/UWPHost.h @@ -16,18 +16,10 @@ public: void UpdateSound() override; - bool AttemptLoadSymbolMap() override; - void SaveSymbolMap() override; - void ToggleDebugConsoleVisibility() override; void NotifyUserMessage(const std::string &message, float duration = 1.0f, u32 color = 0x00FFFFFF, const char *id = nullptr) override; - GraphicsContext *GetGraphicsContext() { return nullptr; } - private: - void SetConsolePosition(); - void UpdateConsolePosition(); - std::list> input; }; diff --git a/Windows/WindowsHost.cpp b/Windows/WindowsHost.cpp index 339f62e158..f737c585e0 100644 --- a/Windows/WindowsHost.cpp +++ b/Windows/WindowsHost.cpp @@ -155,32 +155,6 @@ void WindowsHost::PollControllers() { HLEPlugins::PluginDataAxis[JOYSTICK_AXIS_MOUSE_REL_Y] = g_mouseDeltaY; } -static Path SymbolMapFilename(const Path ¤tFilename, const char *ext) { - File::FileInfo info{}; - // can't fail, definitely exists if it gets this far - File::GetFileInfo(currentFilename, &info); - if (info.isDirectory) { - return currentFilename / (std::string(".ppsspp-symbols") + ext); - } - return currentFilename.WithReplacedExtension(ext); -} - -bool WindowsHost::AttemptLoadSymbolMap() { - if (!g_symbolMap) - return false; - bool result1 = g_symbolMap->LoadSymbolMap(SymbolMapFilename(PSP_CoreParameter().fileToStart, ".ppmap")); - // Load the old-style map file. - if (!result1) - result1 = g_symbolMap->LoadSymbolMap(SymbolMapFilename(PSP_CoreParameter().fileToStart, ".map")); - bool result2 = g_symbolMap->LoadNocashSym(SymbolMapFilename(PSP_CoreParameter().fileToStart, ".sym")); - return result1 || result2; -} - -void WindowsHost::SaveSymbolMap() { - if (g_symbolMap) - g_symbolMap->SaveSymbolMap(SymbolMapFilename(PSP_CoreParameter().fileToStart, ".ppmap")); -} - // http://msdn.microsoft.com/en-us/library/aa969393.aspx HRESULT CreateLink(LPCWSTR lpszPathObj, LPCWSTR lpszArguments, LPCWSTR lpszPathLink, LPCWSTR lpszDesc) { HRESULT hres; diff --git a/Windows/WindowsHost.h b/Windows/WindowsHost.h index e93af1e28a..353996987a 100644 --- a/Windows/WindowsHost.h +++ b/Windows/WindowsHost.h @@ -34,9 +34,6 @@ public: void PollControllers() override; - bool AttemptLoadSymbolMap() override; - void SaveSymbolMap() override; - void ToggleDebugConsoleVisibility() override; bool CreateDesktopShortcut(std::string argumentPath, std::string title) override; diff --git a/Windows/main.cpp b/Windows/main.cpp index 561e374dc1..b78970e879 100644 --- a/Windows/main.cpp +++ b/Windows/main.cpp @@ -351,6 +351,7 @@ float System_GetPropertyFloat(SystemProperty prop) { bool System_GetPropertyBool(SystemProperty prop) { switch (prop) { + case SYSPROP_HAS_DEBUGGER: case SYSPROP_HAS_FILE_BROWSER: case SYSPROP_HAS_FOLDER_BROWSER: case SYSPROP_HAS_OPEN_DIRECTORY: diff --git a/headless/StubHost.h b/headless/StubHost.h index 280997f4d7..2da7c55797 100644 --- a/headless/StubHost.h +++ b/headless/StubHost.h @@ -28,10 +28,6 @@ public: virtual bool InitGraphics(std::string *error_message, GraphicsContext **ctx, GPUCore core) {return false;} virtual void ShutdownGraphics() {} - void UpdateSound() override {} - - bool AttemptLoadSymbolMap() override { g_symbolMap->Clear(); return false; } - void SendDebugOutput(const std::string &output) override { if (output.find('\n') != output.npos) { DoFlushDebugOutput(); diff --git a/libretro/libretro.cpp b/libretro/libretro.cpp index 453ac93eba..88b38fb7e5 100644 --- a/libretro/libretro.cpp +++ b/libretro/libretro.cpp @@ -396,7 +396,6 @@ class LibretroHost : public Host int samples = __AudioMix(audio, hostAttemptBlockSize, SAMPLERATE); AudioBufferWrite(audio, samples); } - bool AttemptLoadSymbolMap() override { return false; } }; class PrintfLogger : public LogListener