From bc8778203eefcfca0597abc286de3c36edfbe6e5 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 8 Jul 2019 17:28:07 -0400 Subject: [PATCH 1/8] Common/Watches: std::move strings where applicable Allows calling code to move the std::string into the Watch instances, avoiding copies. --- Source/Core/Common/Debug/Watches.cpp | 16 ++++++++-------- Source/Core/Common/Debug/Watches.h | 8 ++++---- Source/Core/Common/DebugInterface.h | 6 +++--- Source/Core/Core/Debugger/PPCDebugInterface.cpp | 14 +++++++------- Source/Core/Core/Debugger/PPCDebugInterface.h | 6 +++--- Source/Core/Core/HW/DSPLLE/DSPDebugInterface.cpp | 14 +++++++------- Source/Core/Core/HW/DSPLLE/DSPDebugInterface.h | 6 +++--- 7 files changed, 35 insertions(+), 35 deletions(-) diff --git a/Source/Core/Common/Debug/Watches.cpp b/Source/Core/Common/Debug/Watches.cpp index 3668af1626..9114f2e83d 100644 --- a/Source/Core/Common/Debug/Watches.cpp +++ b/Source/Core/Common/Debug/Watches.cpp @@ -9,12 +9,12 @@ namespace Common::Debug { -Watch::Watch(u32 address_, const std::string& name_, Watch::State is_enabled_) - : address(address_), name(name_), is_enabled(is_enabled_) +Watch::Watch(u32 address_, std::string name_, State is_enabled_) + : address(address_), name(std::move(name_)), is_enabled(is_enabled_) { } -std::size_t Watches::SetWatch(u32 address, const std::string& name) +std::size_t Watches::SetWatch(u32 address, std::string name) { const std::size_t size = m_watches.size(); for (std::size_t index = 0; index < size; index++) @@ -25,7 +25,7 @@ std::size_t Watches::SetWatch(u32 address, const std::string& name) return index; } } - m_watches.emplace_back(address, name, Watch::State::Enabled); + m_watches.emplace_back(address, std::move(name), Watch::State::Enabled); return size; } @@ -46,10 +46,10 @@ void Watches::UnsetWatch(u32 address) m_watches.end()); } -void Watches::UpdateWatch(std::size_t index, u32 address, const std::string& name) +void Watches::UpdateWatch(std::size_t index, u32 address, std::string name) { m_watches[index].address = address; - m_watches[index].name = name; + m_watches[index].name = std::move(name); } void Watches::UpdateWatchAddress(std::size_t index, u32 address) @@ -57,9 +57,9 @@ void Watches::UpdateWatchAddress(std::size_t index, u32 address) m_watches[index].address = address; } -void Watches::UpdateWatchName(std::size_t index, const std::string& name) +void Watches::UpdateWatchName(std::size_t index, std::string name) { - m_watches[index].name = name; + m_watches[index].name = std::move(name); } void Watches::EnableWatch(std::size_t index) diff --git a/Source/Core/Common/Debug/Watches.h b/Source/Core/Common/Debug/Watches.h index 1134f20900..fcf5c795bf 100644 --- a/Source/Core/Common/Debug/Watches.h +++ b/Source/Core/Common/Debug/Watches.h @@ -24,19 +24,19 @@ struct Watch std::string name; State is_enabled; - Watch(u32 address, const std::string& name, State is_enabled); + Watch(u32 address, std::string name, State is_enabled); }; class Watches { public: - std::size_t SetWatch(u32 address, const std::string& name); + std::size_t SetWatch(u32 address, std::string name); const Watch& GetWatch(std::size_t index) const; const std::vector& GetWatches() const; void UnsetWatch(u32 address); - void UpdateWatch(std::size_t index, u32 address, const std::string& name); + void UpdateWatch(std::size_t index, u32 address, std::string name); void UpdateWatchAddress(std::size_t index, u32 address); - void UpdateWatchName(std::size_t index, const std::string& name); + void UpdateWatchName(std::size_t index, std::string name); void EnableWatch(std::size_t index); void DisableWatch(std::size_t index); bool HasEnabledWatch(u32 address) const; diff --git a/Source/Core/Common/DebugInterface.h b/Source/Core/Common/DebugInterface.h index e73c44ee28..0368f55f1e 100644 --- a/Source/Core/Common/DebugInterface.h +++ b/Source/Core/Common/DebugInterface.h @@ -22,13 +22,13 @@ protected: public: // Watches - virtual std::size_t SetWatch(u32 address, const std::string& name = "") = 0; + virtual std::size_t SetWatch(u32 address, std::string name = "") = 0; virtual const Common::Debug::Watch& GetWatch(std::size_t index) const = 0; virtual const std::vector& GetWatches() const = 0; virtual void UnsetWatch(u32 address) = 0; - virtual void UpdateWatch(std::size_t index, u32 address, const std::string& name) = 0; + virtual void UpdateWatch(std::size_t index, u32 address, std::string name) = 0; virtual void UpdateWatchAddress(std::size_t index, u32 address) = 0; - virtual void UpdateWatchName(std::size_t index, const std::string& name) = 0; + virtual void UpdateWatchName(std::size_t index, std::string name) = 0; virtual void EnableWatch(std::size_t index) = 0; virtual void DisableWatch(std::size_t index) = 0; virtual bool HasEnabledWatch(u32 address) const = 0; diff --git a/Source/Core/Core/Debugger/PPCDebugInterface.cpp b/Source/Core/Core/Debugger/PPCDebugInterface.cpp index 394a8c4eb7..d8840b5e14 100644 --- a/Source/Core/Core/Debugger/PPCDebugInterface.cpp +++ b/Source/Core/Core/Debugger/PPCDebugInterface.cpp @@ -44,9 +44,9 @@ void PPCPatches::Patch(std::size_t index) } } -std::size_t PPCDebugInterface::SetWatch(u32 address, const std::string& name) +std::size_t PPCDebugInterface::SetWatch(u32 address, std::string name) { - return m_watches.SetWatch(address, name); + return m_watches.SetWatch(address, std::move(name)); } const Common::Debug::Watch& PPCDebugInterface::GetWatch(std::size_t index) const @@ -64,9 +64,9 @@ void PPCDebugInterface::UnsetWatch(u32 address) m_watches.UnsetWatch(address); } -void PPCDebugInterface::UpdateWatch(std::size_t index, u32 address, const std::string& name) +void PPCDebugInterface::UpdateWatch(std::size_t index, u32 address, std::string name) { - return m_watches.UpdateWatch(index, address, name); + return m_watches.UpdateWatch(index, address, std::move(name)); } void PPCDebugInterface::UpdateWatchAddress(std::size_t index, u32 address) @@ -74,9 +74,9 @@ void PPCDebugInterface::UpdateWatchAddress(std::size_t index, u32 address) return m_watches.UpdateWatchAddress(index, address); } -void PPCDebugInterface::UpdateWatchName(std::size_t index, const std::string& name) +void PPCDebugInterface::UpdateWatchName(std::size_t index, std::string name) { - return m_watches.UpdateWatchName(index, name); + return m_watches.UpdateWatchName(index, std::move(name)); } void PPCDebugInterface::EnableWatch(std::size_t index) @@ -121,7 +121,7 @@ void PPCDebugInterface::SetPatch(u32 address, u32 value) void PPCDebugInterface::SetPatch(u32 address, std::vector value) { - m_patches.SetPatch(address, value); + m_patches.SetPatch(address, std::move(value)); } const std::vector& PPCDebugInterface::GetPatches() const diff --git a/Source/Core/Core/Debugger/PPCDebugInterface.h b/Source/Core/Core/Debugger/PPCDebugInterface.h index d0b9a9625d..36ff0f9c32 100644 --- a/Source/Core/Core/Debugger/PPCDebugInterface.h +++ b/Source/Core/Core/Debugger/PPCDebugInterface.h @@ -22,13 +22,13 @@ class PPCDebugInterface final : public Common::DebugInterface public: PPCDebugInterface() {} // Watches - std::size_t SetWatch(u32 address, const std::string& name = "") override; + std::size_t SetWatch(u32 address, std::string name = "") override; const Common::Debug::Watch& GetWatch(std::size_t index) const override; const std::vector& GetWatches() const override; void UnsetWatch(u32 address) override; - void UpdateWatch(std::size_t index, u32 address, const std::string& name) override; + void UpdateWatch(std::size_t index, u32 address, std::string name) override; void UpdateWatchAddress(std::size_t index, u32 address) override; - void UpdateWatchName(std::size_t index, const std::string& name) override; + void UpdateWatchName(std::size_t index, std::string name) override; void EnableWatch(std::size_t index) override; void DisableWatch(std::size_t index) override; bool HasEnabledWatch(u32 address) const override; diff --git a/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.cpp b/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.cpp index a8a16554ed..3a5d2b8c14 100644 --- a/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.cpp +++ b/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.cpp @@ -20,9 +20,9 @@ void DSPPatches::Patch(std::size_t index) PanicAlert("Patch functionality not supported in DSP module."); } -std::size_t DSPDebugInterface::SetWatch(u32 address, const std::string& name) +std::size_t DSPDebugInterface::SetWatch(u32 address, std::string name) { - return m_watches.SetWatch(address, name); + return m_watches.SetWatch(address, std::move(name)); } const Common::Debug::Watch& DSPDebugInterface::GetWatch(std::size_t index) const @@ -40,9 +40,9 @@ void DSPDebugInterface::UnsetWatch(u32 address) m_watches.UnsetWatch(address); } -void DSPDebugInterface::UpdateWatch(std::size_t index, u32 address, const std::string& name) +void DSPDebugInterface::UpdateWatch(std::size_t index, u32 address, std::string name) { - return m_watches.UpdateWatch(index, address, name); + return m_watches.UpdateWatch(index, address, std::move(name)); } void DSPDebugInterface::UpdateWatchAddress(std::size_t index, u32 address) @@ -50,9 +50,9 @@ void DSPDebugInterface::UpdateWatchAddress(std::size_t index, u32 address) return m_watches.UpdateWatchAddress(index, address); } -void DSPDebugInterface::UpdateWatchName(std::size_t index, const std::string& name) +void DSPDebugInterface::UpdateWatchName(std::size_t index, std::string name) { - return m_watches.UpdateWatchName(index, name); + return m_watches.UpdateWatchName(index, std::move(name)); } void DSPDebugInterface::EnableWatch(std::size_t index) @@ -97,7 +97,7 @@ void DSPDebugInterface::SetPatch(u32 address, u32 value) void DSPDebugInterface::SetPatch(u32 address, std::vector value) { - m_patches.SetPatch(address, value); + m_patches.SetPatch(address, std::move(value)); } const std::vector& DSPDebugInterface::GetPatches() const diff --git a/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.h b/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.h index e2d1a5242b..c1cd0507cf 100644 --- a/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.h +++ b/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.h @@ -23,13 +23,13 @@ class DSPDebugInterface final : public Common::DebugInterface public: DSPDebugInterface() {} // Watches - std::size_t SetWatch(u32 address, const std::string& name = "") override; + std::size_t SetWatch(u32 address, std::string name = "") override; const Common::Debug::Watch& GetWatch(std::size_t index) const override; const std::vector& GetWatches() const override; void UnsetWatch(u32 address) override; - void UpdateWatch(std::size_t index, u32 address, const std::string& name) override; + void UpdateWatch(std::size_t index, u32 address, std::string name) override; void UpdateWatchAddress(std::size_t index, u32 address) override; - void UpdateWatchName(std::size_t index, const std::string& name) override; + void UpdateWatchName(std::size_t index, std::string name) override; void EnableWatch(std::size_t index) override; void DisableWatch(std::size_t index) override; bool HasEnabledWatch(u32 address) const override; From b1b9c6aa1e8c04a89f2d6e08960e67665bcabda2 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 8 Jul 2019 17:44:56 -0400 Subject: [PATCH 2/8] Common/DebugInterface: Default virtual destructor While we're at it, we can also default the constructor and destructor of inheriting classes in their respective cpp file to prevent the construction and destruction of non-trivial types being inlined into other regions of code. --- Source/Core/Common/DebugInterface.h | 2 +- Source/Core/Core/Debugger/PPCDebugInterface.cpp | 3 +++ Source/Core/Core/Debugger/PPCDebugInterface.h | 4 +++- Source/Core/Core/HW/DSPLLE/DSPDebugInterface.cpp | 3 +++ Source/Core/Core/HW/DSPLLE/DSPDebugInterface.h | 4 +++- 5 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Source/Core/Common/DebugInterface.h b/Source/Core/Common/DebugInterface.h index 0368f55f1e..28312e4bb7 100644 --- a/Source/Core/Common/DebugInterface.h +++ b/Source/Core/Common/DebugInterface.h @@ -18,7 +18,7 @@ namespace Common class DebugInterface { protected: - virtual ~DebugInterface() {} + virtual ~DebugInterface() = default; public: // Watches diff --git a/Source/Core/Core/Debugger/PPCDebugInterface.cpp b/Source/Core/Core/Debugger/PPCDebugInterface.cpp index d8840b5e14..497ebdb7d6 100644 --- a/Source/Core/Core/Debugger/PPCDebugInterface.cpp +++ b/Source/Core/Core/Debugger/PPCDebugInterface.cpp @@ -44,6 +44,9 @@ void PPCPatches::Patch(std::size_t index) } } +PPCDebugInterface::PPCDebugInterface() = default; +PPCDebugInterface::~PPCDebugInterface() = default; + std::size_t PPCDebugInterface::SetWatch(u32 address, std::string name) { return m_watches.SetWatch(address, std::move(name)); diff --git a/Source/Core/Core/Debugger/PPCDebugInterface.h b/Source/Core/Core/Debugger/PPCDebugInterface.h index 36ff0f9c32..ed86a70592 100644 --- a/Source/Core/Core/Debugger/PPCDebugInterface.h +++ b/Source/Core/Core/Debugger/PPCDebugInterface.h @@ -20,7 +20,9 @@ private: class PPCDebugInterface final : public Common::DebugInterface { public: - PPCDebugInterface() {} + PPCDebugInterface(); + ~PPCDebugInterface() override; + // Watches std::size_t SetWatch(u32 address, std::string name = "") override; const Common::Debug::Watch& GetWatch(std::size_t index) const override; diff --git a/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.cpp b/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.cpp index 3a5d2b8c14..7fbad5dfd9 100644 --- a/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.cpp +++ b/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.cpp @@ -20,6 +20,9 @@ void DSPPatches::Patch(std::size_t index) PanicAlert("Patch functionality not supported in DSP module."); } +DSPDebugInterface::DSPDebugInterface() = default; +DSPDebugInterface::~DSPDebugInterface() = default; + std::size_t DSPDebugInterface::SetWatch(u32 address, std::string name) { return m_watches.SetWatch(address, std::move(name)); diff --git a/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.h b/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.h index c1cd0507cf..2f373408d3 100644 --- a/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.h +++ b/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.h @@ -21,7 +21,9 @@ private: class DSPDebugInterface final : public Common::DebugInterface { public: - DSPDebugInterface() {} + DSPDebugInterface(); + ~DSPDebugInterface() override; + // Watches std::size_t SetWatch(u32 address, std::string name = "") override; const Common::Debug::Watch& GetWatch(std::size_t index) const override; From 457bff92c142fec0f4d55c25ce87e18c910326b9 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 8 Jul 2019 17:53:47 -0400 Subject: [PATCH 3/8] Common/DebugInterface: Use u32 instead of unsigned int consistently Previously u32 was being used for part of the interface and unsigned int was being used for other parts. This makes the interface fully consistent by using only one type. We opt for u32 here given they communicate the same thing (for platforms we care about where int is 32-bit), while also being less to read. --- Source/Core/Common/DebugInterface.h | 34 +++++++++---------- .../Core/Core/Debugger/PPCDebugInterface.cpp | 30 ++++++++-------- Source/Core/Core/Debugger/PPCDebugInterface.h | 31 ++++++++--------- .../Core/Core/HW/DSPLLE/DSPDebugInterface.cpp | 28 +++++++-------- .../Core/Core/HW/DSPLLE/DSPDebugInterface.h | 29 ++++++++-------- 5 files changed, 74 insertions(+), 78 deletions(-) diff --git a/Source/Core/Common/DebugInterface.h b/Source/Core/Common/DebugInterface.h index 28312e4bb7..c17df7e908 100644 --- a/Source/Core/Common/DebugInterface.h +++ b/Source/Core/Common/DebugInterface.h @@ -48,33 +48,31 @@ public: virtual void RemovePatch(std::size_t index) = 0; virtual void ClearPatches() = 0; - virtual std::string Disassemble(unsigned int /*address*/) { return "NODEBUGGER"; } - virtual std::string GetRawMemoryString(int /*memory*/, unsigned int /*address*/) + virtual std::string Disassemble(u32 /*address*/) { return "NODEBUGGER"; } + virtual std::string GetRawMemoryString(int /*memory*/, u32 /*address*/) { return "NODEBUGGER"; } virtual int GetInstructionSize(int /*instruction*/) { return 1; } virtual bool IsAlive() { return true; } - virtual bool IsBreakpoint(unsigned int /*address*/) { return false; } - virtual void SetBreakpoint(unsigned int /*address*/) {} - virtual void ClearBreakpoint(unsigned int /*address*/) {} + virtual bool IsBreakpoint(u32 /*address*/) { return false; } + virtual void SetBreakpoint(u32 /*address*/) {} + virtual void ClearBreakpoint(u32 /*address*/) {} virtual void ClearAllBreakpoints() {} - virtual void ToggleBreakpoint(unsigned int /*address*/) {} + virtual void ToggleBreakpoint(u32 /*address*/) {} virtual void ClearAllMemChecks() {} - virtual bool IsMemCheck(unsigned int /*address*/, size_t /*size*/) { return false; } - virtual void ToggleMemCheck(unsigned int /*address*/, bool /*read*/, bool /*write*/, bool /*log*/) - { - } - virtual unsigned int ReadMemory(unsigned int /*address*/) { return 0; } - virtual void WriteExtraMemory(int /*memory*/, unsigned int /*value*/, unsigned int /*address*/) {} - virtual unsigned int ReadExtraMemory(int /*memory*/, unsigned int /*address*/) { return 0; } - virtual unsigned int ReadInstruction(unsigned int /*address*/) { return 0; } - virtual unsigned int GetPC() { return 0; } - virtual void SetPC(unsigned int /*address*/) {} + virtual bool IsMemCheck(u32 /*address*/, size_t /*size*/) { return false; } + virtual void ToggleMemCheck(u32 /*address*/, bool /*read*/, bool /*write*/, bool /*log*/) {} + virtual u32 ReadMemory(u32 /*address*/) { return 0; } + virtual void WriteExtraMemory(int /*memory*/, u32 /*value*/, u32 /*address*/) {} + virtual u32 ReadExtraMemory(int /*memory*/, u32 /*address*/) { return 0; } + virtual u32 ReadInstruction(u32 /*address*/) { return 0; } + virtual u32 GetPC() { return 0; } + virtual void SetPC(u32 /*address*/) {} virtual void Step() {} virtual void RunToBreakpoint() {} - virtual int GetColor(unsigned int /*address*/) { return 0xFFFFFFFF; } - virtual std::string GetDescription(unsigned int /*address*/) = 0; + virtual int GetColor(u32 /*address*/) { return 0xFFFFFFFF; } + virtual std::string GetDescription(u32 /*address*/) = 0; virtual void Clear() = 0; }; } // namespace Common diff --git a/Source/Core/Core/Debugger/PPCDebugInterface.cpp b/Source/Core/Core/Debugger/PPCDebugInterface.cpp index 497ebdb7d6..d93f369ac3 100644 --- a/Source/Core/Core/Debugger/PPCDebugInterface.cpp +++ b/Source/Core/Core/Debugger/PPCDebugInterface.cpp @@ -162,7 +162,7 @@ void PPCDebugInterface::ClearPatches() m_patches.ClearPatches(); } -std::string PPCDebugInterface::Disassemble(unsigned int address) +std::string PPCDebugInterface::Disassemble(u32 address) { // PowerPC::HostRead_U32 seemed to crash on shutdown if (!IsAlive()) @@ -192,7 +192,7 @@ std::string PPCDebugInterface::Disassemble(unsigned int address) } } -std::string PPCDebugInterface::GetRawMemoryString(int memory, unsigned int address) +std::string PPCDebugInterface::GetRawMemoryString(int memory, u32 address) { if (IsAlive()) { @@ -207,12 +207,12 @@ std::string PPCDebugInterface::GetRawMemoryString(int memory, unsigned int addre return ""; // bad spelling - 8 chars } -unsigned int PPCDebugInterface::ReadMemory(unsigned int address) +u32 PPCDebugInterface::ReadMemory(u32 address) { return PowerPC::HostRead_U32(address); } -unsigned int PPCDebugInterface::ReadExtraMemory(int memory, unsigned int address) +u32 PPCDebugInterface::ReadExtraMemory(int memory, u32 address) { switch (memory) { @@ -226,7 +226,7 @@ unsigned int PPCDebugInterface::ReadExtraMemory(int memory, unsigned int address } } -unsigned int PPCDebugInterface::ReadInstruction(unsigned int address) +u32 PPCDebugInterface::ReadInstruction(u32 address) { return PowerPC::HostRead_Instruction(address); } @@ -236,17 +236,17 @@ bool PPCDebugInterface::IsAlive() return Core::IsRunningAndStarted(); } -bool PPCDebugInterface::IsBreakpoint(unsigned int address) +bool PPCDebugInterface::IsBreakpoint(u32 address) { return PowerPC::breakpoints.IsAddressBreakPoint(address); } -void PPCDebugInterface::SetBreakpoint(unsigned int address) +void PPCDebugInterface::SetBreakpoint(u32 address) { PowerPC::breakpoints.Add(address); } -void PPCDebugInterface::ClearBreakpoint(unsigned int address) +void PPCDebugInterface::ClearBreakpoint(u32 address) { PowerPC::breakpoints.Remove(address); } @@ -256,7 +256,7 @@ void PPCDebugInterface::ClearAllBreakpoints() PowerPC::breakpoints.Clear(); } -void PPCDebugInterface::ToggleBreakpoint(unsigned int address) +void PPCDebugInterface::ToggleBreakpoint(u32 address) { if (PowerPC::breakpoints.IsAddressBreakPoint(address)) PowerPC::breakpoints.Remove(address); @@ -269,12 +269,12 @@ void PPCDebugInterface::ClearAllMemChecks() PowerPC::memchecks.Clear(); } -bool PPCDebugInterface::IsMemCheck(unsigned int address, size_t size) +bool PPCDebugInterface::IsMemCheck(u32 address, size_t size) { return PowerPC::memchecks.GetMemCheck(address, size) != nullptr; } -void PPCDebugInterface::ToggleMemCheck(unsigned int address, bool read, bool write, bool log) +void PPCDebugInterface::ToggleMemCheck(u32 address, bool read, bool write, bool log) { if (!IsMemCheck(address)) { @@ -299,7 +299,7 @@ void PPCDebugInterface::ToggleMemCheck(unsigned int address, bool read, bool wri // ======================================================= // Separate the blocks with colors. // ------------- -int PPCDebugInterface::GetColor(unsigned int address) +int PPCDebugInterface::GetColor(u32 address) { if (!IsAlive()) return 0xFFFFFF; @@ -322,17 +322,17 @@ int PPCDebugInterface::GetColor(unsigned int address) } // ============= -std::string PPCDebugInterface::GetDescription(unsigned int address) +std::string PPCDebugInterface::GetDescription(u32 address) { return g_symbolDB.GetDescription(address); } -unsigned int PPCDebugInterface::GetPC() +u32 PPCDebugInterface::GetPC() { return PowerPC::ppcState.pc; } -void PPCDebugInterface::SetPC(unsigned int address) +void PPCDebugInterface::SetPC(u32 address) { PowerPC::ppcState.pc = address; } diff --git a/Source/Core/Core/Debugger/PPCDebugInterface.h b/Source/Core/Core/Debugger/PPCDebugInterface.h index ed86a70592..16abb1b9df 100644 --- a/Source/Core/Core/Debugger/PPCDebugInterface.h +++ b/Source/Core/Core/Debugger/PPCDebugInterface.h @@ -50,34 +50,33 @@ public: void RemovePatch(std::size_t index) override; void ClearPatches() override; - std::string Disassemble(unsigned int address) override; - std::string GetRawMemoryString(int memory, unsigned int address) override; + std::string Disassemble(u32 address) override; + std::string GetRawMemoryString(int memory, u32 address) override; int GetInstructionSize(int /*instruction*/) override { return 4; } bool IsAlive() override; - bool IsBreakpoint(unsigned int address) override; - void SetBreakpoint(unsigned int address) override; - void ClearBreakpoint(unsigned int address) override; + bool IsBreakpoint(u32 address) override; + void SetBreakpoint(u32 address) override; + void ClearBreakpoint(u32 address) override; void ClearAllBreakpoints() override; - void ToggleBreakpoint(unsigned int address) override; + void ToggleBreakpoint(u32 address) override; void ClearAllMemChecks() override; - bool IsMemCheck(unsigned int address, size_t size = 1) override; - void ToggleMemCheck(unsigned int address, bool read = true, bool write = true, - bool log = true) override; - unsigned int ReadMemory(unsigned int address) override; + bool IsMemCheck(u32 address, size_t size = 1) override; + void ToggleMemCheck(u32 address, bool read = true, bool write = true, bool log = true) override; + u32 ReadMemory(u32 address) override; enum { EXTRAMEM_ARAM = 1, }; - unsigned int ReadExtraMemory(int memory, unsigned int address) override; - unsigned int ReadInstruction(unsigned int address) override; - unsigned int GetPC() override; - void SetPC(unsigned int address) override; + u32 ReadExtraMemory(int memory, u32 address) override; + u32 ReadInstruction(u32 address) override; + u32 GetPC() override; + void SetPC(u32 address) override; void Step() override {} void RunToBreakpoint() override; - int GetColor(unsigned int address) override; - std::string GetDescription(unsigned int address) override; + int GetColor(u32 address) override; + std::string GetDescription(u32 address) override; void Clear() override; diff --git a/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.cpp b/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.cpp index 7fbad5dfd9..9ec83289a8 100644 --- a/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.cpp +++ b/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.cpp @@ -138,13 +138,13 @@ void DSPDebugInterface::ClearPatches() m_patches.ClearPatches(); } -std::string DSPDebugInterface::Disassemble(unsigned int address) +std::string DSPDebugInterface::Disassemble(u32 address) { // we'll treat addresses as line numbers. return Symbols::GetLineText(address); } -std::string DSPDebugInterface::GetRawMemoryString(int memory, unsigned int address) +std::string DSPDebugInterface::GetRawMemoryString(int memory, u32 address) { if (DSPCore_GetState() == State::Stopped) return ""; @@ -177,12 +177,12 @@ std::string DSPDebugInterface::GetRawMemoryString(int memory, unsigned int addre return ""; } -unsigned int DSPDebugInterface::ReadMemory(unsigned int address) +u32 DSPDebugInterface::ReadMemory(u32 address) { return 0; } -unsigned int DSPDebugInterface::ReadInstruction(unsigned int address) +u32 DSPDebugInterface::ReadInstruction(u32 address) { return 0; } @@ -192,7 +192,7 @@ bool DSPDebugInterface::IsAlive() return true; } -bool DSPDebugInterface::IsBreakpoint(unsigned int address) +bool DSPDebugInterface::IsBreakpoint(u32 address) { int real_addr = Symbols::Line2Addr(address); if (real_addr >= 0) @@ -201,7 +201,7 @@ bool DSPDebugInterface::IsBreakpoint(unsigned int address) return false; } -void DSPDebugInterface::SetBreakpoint(unsigned int address) +void DSPDebugInterface::SetBreakpoint(u32 address) { int real_addr = Symbols::Line2Addr(address); @@ -211,7 +211,7 @@ void DSPDebugInterface::SetBreakpoint(unsigned int address) } } -void DSPDebugInterface::ClearBreakpoint(unsigned int address) +void DSPDebugInterface::ClearBreakpoint(u32 address) { int real_addr = Symbols::Line2Addr(address); @@ -226,7 +226,7 @@ void DSPDebugInterface::ClearAllBreakpoints() g_dsp_breakpoints.Clear(); } -void DSPDebugInterface::ToggleBreakpoint(unsigned int address) +void DSPDebugInterface::ToggleBreakpoint(u32 address) { int real_addr = Symbols::Line2Addr(address); if (real_addr >= 0) @@ -238,7 +238,7 @@ void DSPDebugInterface::ToggleBreakpoint(unsigned int address) } } -bool DSPDebugInterface::IsMemCheck(unsigned int address, size_t size) +bool DSPDebugInterface::IsMemCheck(u32 address, size_t size) { return false; } @@ -248,7 +248,7 @@ void DSPDebugInterface::ClearAllMemChecks() PanicAlert("MemCheck functionality not supported in DSP module."); } -void DSPDebugInterface::ToggleMemCheck(unsigned int address, bool read, bool write, bool log) +void DSPDebugInterface::ToggleMemCheck(u32 address, bool read, bool write, bool log) { PanicAlert("MemCheck functionality not supported in DSP module."); } @@ -256,7 +256,7 @@ void DSPDebugInterface::ToggleMemCheck(unsigned int address, bool read, bool wri // ======================================================= // Separate the blocks with colors. // ------------- -int DSPDebugInterface::GetColor(unsigned int address) +int DSPDebugInterface::GetColor(u32 address) { static const int colors[6] = { 0xd0FFFF, // light cyan @@ -287,17 +287,17 @@ int DSPDebugInterface::GetColor(unsigned int address) } // ============= -std::string DSPDebugInterface::GetDescription(unsigned int address) +std::string DSPDebugInterface::GetDescription(u32 address) { return ""; // g_symbolDB.GetDescription(address); } -unsigned int DSPDebugInterface::GetPC() +u32 DSPDebugInterface::GetPC() { return Symbols::Addr2Line(DSP::g_dsp.pc); } -void DSPDebugInterface::SetPC(unsigned int address) +void DSPDebugInterface::SetPC(u32 address) { int new_pc = Symbols::Line2Addr(address); if (new_pc > 0) diff --git a/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.h b/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.h index 2f373408d3..5bc50bca3d 100644 --- a/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.h +++ b/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.h @@ -51,27 +51,26 @@ public: bool HasEnabledPatch(u32 address) const override; void ClearPatches() override; - std::string Disassemble(unsigned int address) override; - std::string GetRawMemoryString(int memory, unsigned int address) override; + std::string Disassemble(u32 address) override; + std::string GetRawMemoryString(int memory, u32 address) override; int GetInstructionSize(int instruction) override { return 1; } bool IsAlive() override; - bool IsBreakpoint(unsigned int address) override; - void SetBreakpoint(unsigned int address) override; - void ClearBreakpoint(unsigned int address) override; + bool IsBreakpoint(u32 address) override; + void SetBreakpoint(u32 address) override; + void ClearBreakpoint(u32 address) override; void ClearAllBreakpoints() override; - void ToggleBreakpoint(unsigned int address) override; + void ToggleBreakpoint(u32 address) override; void ClearAllMemChecks() override; - bool IsMemCheck(unsigned int address, size_t size) override; - void ToggleMemCheck(unsigned int address, bool read = true, bool write = true, - bool log = true) override; - unsigned int ReadMemory(unsigned int address) override; - unsigned int ReadInstruction(unsigned int address) override; - unsigned int GetPC() override; - void SetPC(unsigned int address) override; + bool IsMemCheck(u32 address, size_t size) override; + void ToggleMemCheck(u32 address, bool read = true, bool write = true, bool log = true) override; + u32 ReadMemory(u32 address) override; + u32 ReadInstruction(u32 address) override; + u32 GetPC() override; + void SetPC(u32 address) override; void Step() override {} void RunToBreakpoint() override; - int GetColor(unsigned int address) override; - std::string GetDescription(unsigned int address) override; + int GetColor(u32 address) override; + std::string GetDescription(u32 address) override; void Clear() override; From 98101bbbe4d54e3831800d63023d7c4730776b95 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 8 Jul 2019 18:00:56 -0400 Subject: [PATCH 4/8] Core: Use fmt where applicable for DebugInterface implementations These are trivial enough that they're basically one-to-one conversions with minor changes of syntax. --- Source/Core/Core/Debugger/PPCDebugInterface.cpp | 5 +++-- Source/Core/Core/HW/DSPLLE/DSPDebugInterface.cpp | 9 +++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Source/Core/Core/Debugger/PPCDebugInterface.cpp b/Source/Core/Core/Debugger/PPCDebugInterface.cpp index d93f369ac3..473509a67c 100644 --- a/Source/Core/Core/Debugger/PPCDebugInterface.cpp +++ b/Source/Core/Core/Debugger/PPCDebugInterface.cpp @@ -7,9 +7,10 @@ #include #include +#include + #include "Common/Align.h" #include "Common/GekkoDisassembler.h" -#include "Common/StringUtil.h" #include "Core/Core.h" #include "Core/HW/DSP.h" @@ -199,7 +200,7 @@ std::string PPCDebugInterface::GetRawMemoryString(int memory, u32 address) const bool is_aram = memory != 0; if (is_aram || PowerPC::HostIsRAMAddress(address)) - return StringFromFormat("%08X%s", ReadExtraMemory(memory, address), is_aram ? " (ARAM)" : ""); + return fmt::format("{:08X}{}", ReadExtraMemory(memory, address), is_aram ? " (ARAM)" : ""); return is_aram ? "--ARAM--" : "--------"; } diff --git a/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.cpp b/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.cpp index 9ec83289a8..8ea752fddd 100644 --- a/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.cpp +++ b/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.cpp @@ -7,8 +7,9 @@ #include #include +#include + #include "Common/MsgHandler.h" -#include "Common/StringUtil.h" #include "Core/DSP/DSPCore.h" #include "Core/DSP/DSPMemoryMap.h" #include "Core/HW/DSPLLE/DSPSymbols.h" @@ -156,7 +157,7 @@ std::string DSPDebugInterface::GetRawMemoryString(int memory, u32 address) { case 0: case 0x8: - return StringFromFormat("%04x", dsp_imem_read(address)); + return fmt::format("{:04x}", dsp_imem_read(address)); default: return "--IMEM--"; } @@ -166,9 +167,9 @@ std::string DSPDebugInterface::GetRawMemoryString(int memory, u32 address) { case 0: case 1: - return StringFromFormat("%04x (DMEM)", dsp_dmem_read(address)); + return fmt::format("{:04x} (DMEM)", dsp_dmem_read(address)); case 0xf: - return StringFromFormat("%04x (MMIO)", g_dsp.ifx_regs[address & 0xFF]); + return fmt::format("{:04x} (MMIO)", g_dsp.ifx_regs[address & 0xFF]); default: return "--DMEM--"; } From a9a9b193bb864b540b7db65be2663cd31cb3a793 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 8 Jul 2019 18:07:11 -0400 Subject: [PATCH 5/8] Common/DebugInterface: Use forward declarations where applicable We're allowed (by the standard) to forward declare types within std::vector, so we can replace direct includes with forward declarations and then include the types where they're directly needed. While we're at it, we can remove an unused inclusion of , given nothing in the header uses anything from it. This also revealed an indirect inclusion, which this also resolves. --- Source/Core/Common/DebugInterface.h | 15 +++++++++------ Source/Core/Core/Debugger/PPCDebugInterface.h | 2 ++ Source/Core/Core/HW/DSPLLE/DSPDebugInterface.h | 2 ++ Source/Core/Core/PowerPC/PPCSymbolDB.cpp | 1 + 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Source/Core/Common/DebugInterface.h b/Source/Core/Common/DebugInterface.h index c17df7e908..4ae5fd4174 100644 --- a/Source/Core/Common/DebugInterface.h +++ b/Source/Core/Common/DebugInterface.h @@ -5,13 +5,16 @@ #pragma once #include -#include #include #include #include "Common/CommonTypes.h" -#include "Common/Debug/MemoryPatches.h" -#include "Common/Debug/Watches.h" + +namespace Common::Debug +{ +struct MemoryPatch; +struct Watch; +} // namespace Common::Debug namespace Common { @@ -23,8 +26,8 @@ protected: public: // Watches virtual std::size_t SetWatch(u32 address, std::string name = "") = 0; - virtual const Common::Debug::Watch& GetWatch(std::size_t index) const = 0; - virtual const std::vector& GetWatches() const = 0; + virtual const Debug::Watch& GetWatch(std::size_t index) const = 0; + virtual const std::vector& GetWatches() const = 0; virtual void UnsetWatch(u32 address) = 0; virtual void UpdateWatch(std::size_t index, u32 address, std::string name) = 0; virtual void UpdateWatchAddress(std::size_t index, u32 address) = 0; @@ -40,7 +43,7 @@ public: // Memory Patches virtual void SetPatch(u32 address, u32 value) = 0; virtual void SetPatch(u32 address, std::vector value) = 0; - virtual const std::vector& GetPatches() const = 0; + virtual const std::vector& GetPatches() const = 0; virtual void UnsetPatch(u32 address) = 0; virtual void EnablePatch(std::size_t index) = 0; virtual void DisablePatch(std::size_t index) = 0; diff --git a/Source/Core/Core/Debugger/PPCDebugInterface.h b/Source/Core/Core/Debugger/PPCDebugInterface.h index 16abb1b9df..b0536a4c6c 100644 --- a/Source/Core/Core/Debugger/PPCDebugInterface.h +++ b/Source/Core/Core/Debugger/PPCDebugInterface.h @@ -7,6 +7,8 @@ #include #include +#include "Common/Debug/MemoryPatches.h" +#include "Common/Debug/Watches.h" #include "Common/DebugInterface.h" class PPCPatches : public Common::Debug::MemoryPatches diff --git a/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.h b/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.h index 5bc50bca3d..ab02f342bc 100644 --- a/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.h +++ b/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.h @@ -8,6 +8,8 @@ #include #include "Common/CommonTypes.h" +#include "Common/Debug/MemoryPatches.h" +#include "Common/Debug/Watches.h" #include "Common/DebugInterface.h" namespace DSP::LLE diff --git a/Source/Core/Core/PowerPC/PPCSymbolDB.cpp b/Source/Core/Core/PowerPC/PPCSymbolDB.cpp index f5a84f2d07..1412533bf4 100644 --- a/Source/Core/Core/PowerPC/PPCSymbolDB.cpp +++ b/Source/Core/Core/PowerPC/PPCSymbolDB.cpp @@ -5,6 +5,7 @@ #include "Core/PowerPC/PPCSymbolDB.h" #include +#include #include #include #include From d4d485b692cee326126e003950c582c08de18916 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 8 Jul 2019 18:13:27 -0400 Subject: [PATCH 6/8] Common/DebugInterface: Make return value of GetColor() a u32 At its only usage point, its return value is stored into a u32, and the default implementation returns 0xFFFFFFFF (-1), which would be an unsigned integer. Given all of the bits are used to determine a color, it makes slightly more sense to treat this as an unsigned value as opposed to a signed one. --- Source/Core/Common/DebugInterface.h | 2 +- .../Core/Core/Debugger/PPCDebugInterface.cpp | 19 ++++++++------- Source/Core/Core/Debugger/PPCDebugInterface.h | 2 +- .../Core/Core/HW/DSPLLE/DSPDebugInterface.cpp | 23 ++++++++++--------- .../Core/Core/HW/DSPLLE/DSPDebugInterface.h | 2 +- .../DolphinQt/Debugger/CodeViewWidget.cpp | 4 ++-- 6 files changed, 28 insertions(+), 24 deletions(-) diff --git a/Source/Core/Common/DebugInterface.h b/Source/Core/Common/DebugInterface.h index 4ae5fd4174..0540003c39 100644 --- a/Source/Core/Common/DebugInterface.h +++ b/Source/Core/Common/DebugInterface.h @@ -74,7 +74,7 @@ public: virtual void SetPC(u32 /*address*/) {} virtual void Step() {} virtual void RunToBreakpoint() {} - virtual int GetColor(u32 /*address*/) { return 0xFFFFFFFF; } + virtual u32 GetColor(u32 /*address*/) { return 0xFFFFFFFF; } virtual std::string GetDescription(u32 /*address*/) = 0; virtual void Clear() = 0; }; diff --git a/Source/Core/Core/Debugger/PPCDebugInterface.cpp b/Source/Core/Core/Debugger/PPCDebugInterface.cpp index 473509a67c..245e26cf77 100644 --- a/Source/Core/Core/Debugger/PPCDebugInterface.cpp +++ b/Source/Core/Core/Debugger/PPCDebugInterface.cpp @@ -4,6 +4,7 @@ #include "Core/Debugger/PPCDebugInterface.h" +#include #include #include @@ -300,13 +301,20 @@ void PPCDebugInterface::ToggleMemCheck(u32 address, bool read, bool write, bool // ======================================================= // Separate the blocks with colors. // ------------- -int PPCDebugInterface::GetColor(u32 address) +u32 PPCDebugInterface::GetColor(u32 address) { if (!IsAlive()) return 0xFFFFFF; if (!PowerPC::HostIsRAMAddress(address)) return 0xeeeeee; - static const int colors[6] = { + + Common::Symbol* symbol = g_symbolDB.GetSymbolFromAddr(address); + if (!symbol) + return 0xFFFFFF; + if (symbol->type != Common::Symbol::Type::Function) + return 0xEEEEFF; + + static constexpr std::array colors{ 0xd0FFFF, // light cyan 0xFFd0d0, // light red 0xd8d8FF, // light blue @@ -314,12 +322,7 @@ int PPCDebugInterface::GetColor(u32 address) 0xd0FFd0, // light green 0xFFFFd0, // light yellow }; - Common::Symbol* symbol = g_symbolDB.GetSymbolFromAddr(address); - if (!symbol) - return 0xFFFFFF; - if (symbol->type != Common::Symbol::Type::Function) - return 0xEEEEFF; - return colors[symbol->index % 6]; + return colors[symbol->index % colors.size()]; } // ============= diff --git a/Source/Core/Core/Debugger/PPCDebugInterface.h b/Source/Core/Core/Debugger/PPCDebugInterface.h index b0536a4c6c..07d7d057d8 100644 --- a/Source/Core/Core/Debugger/PPCDebugInterface.h +++ b/Source/Core/Core/Debugger/PPCDebugInterface.h @@ -77,7 +77,7 @@ public: void SetPC(u32 address) override; void Step() override {} void RunToBreakpoint() override; - int GetColor(u32 address) override; + u32 GetColor(u32 address) override; std::string GetDescription(u32 address) override; void Clear() override; diff --git a/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.cpp b/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.cpp index 8ea752fddd..1f9e4f6e2c 100644 --- a/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.cpp +++ b/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.cpp @@ -4,6 +4,7 @@ #include "Core/HW/DSPLLE/DSPDebugInterface.h" +#include #include #include @@ -257,17 +258,8 @@ void DSPDebugInterface::ToggleMemCheck(u32 address, bool read, bool write, bool // ======================================================= // Separate the blocks with colors. // ------------- -int DSPDebugInterface::GetColor(u32 address) +u32 DSPDebugInterface::GetColor(u32 address) { - static const int colors[6] = { - 0xd0FFFF, // light cyan - 0xFFd0d0, // light red - 0xd8d8FF, // light blue - 0xFFd0FF, // light purple - 0xd0FFd0, // light green - 0xFFFFd0, // light yellow - }; - // Scan backwards so we don't miss it. Hm, actually, let's not - it looks pretty good. int addr = -1; for (int i = 0; i < 1; i++) @@ -284,7 +276,16 @@ int DSPDebugInterface::GetColor(u32 address) return 0xFFFFFF; if (symbol->type != Common::Symbol::Type::Function) return 0xEEEEFF; - return colors[symbol->index % 6]; + + static constexpr std::array colors{ + 0xd0FFFF, // light cyan + 0xFFd0d0, // light red + 0xd8d8FF, // light blue + 0xFFd0FF, // light purple + 0xd0FFd0, // light green + 0xFFFFd0, // light yellow + }; + return colors[symbol->index % colors.size()]; } // ============= diff --git a/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.h b/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.h index ab02f342bc..0988abef11 100644 --- a/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.h +++ b/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.h @@ -71,7 +71,7 @@ public: void SetPC(u32 address) override; void Step() override {} void RunToBreakpoint() override; - int GetColor(u32 address) override; + u32 GetColor(u32 address) override; std::string GetDescription(u32 address) override; void Clear() override; diff --git a/Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp b/Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp index 2427101cb7..d8e8fc83d4 100644 --- a/Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp +++ b/Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp @@ -121,8 +121,8 @@ void CodeViewWidget::Update() for (int i = 0; i < rowCount(); i++) { - u32 addr = m_address - ((rowCount() / 2) * 4) + i * 4; - u32 color = PowerPC::debug_interface.GetColor(addr); + const u32 addr = m_address - ((rowCount() / 2) * 4) + i * 4; + const u32 color = PowerPC::debug_interface.GetColor(addr); auto* bp_item = new QTableWidgetItem; auto* addr_item = new QTableWidgetItem(QStringLiteral("%1").arg(addr, 8, 16, QLatin1Char('0'))); From 92c17827267aa2553e11daae3d53d766b54ae5cf Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 8 Jul 2019 18:25:14 -0400 Subject: [PATCH 7/8] Common/DebugInterface: Mark a few member functions as const Quite a few member functions act as a means to query information. Given these don't actually modify object state, they can be made const. --- Source/Core/Common/DebugInterface.h | 22 +++++++++---------- .../Core/Core/Debugger/PPCDebugInterface.cpp | 22 +++++++++---------- Source/Core/Core/Debugger/PPCDebugInterface.h | 22 +++++++++---------- .../Core/Core/HW/DSPLLE/DSPDebugInterface.cpp | 20 ++++++++--------- .../Core/Core/HW/DSPLLE/DSPDebugInterface.h | 20 ++++++++--------- 5 files changed, 53 insertions(+), 53 deletions(-) diff --git a/Source/Core/Common/DebugInterface.h b/Source/Core/Common/DebugInterface.h index 0540003c39..e9ec396b17 100644 --- a/Source/Core/Common/DebugInterface.h +++ b/Source/Core/Common/DebugInterface.h @@ -51,31 +51,31 @@ public: virtual void RemovePatch(std::size_t index) = 0; virtual void ClearPatches() = 0; - virtual std::string Disassemble(u32 /*address*/) { return "NODEBUGGER"; } - virtual std::string GetRawMemoryString(int /*memory*/, u32 /*address*/) + virtual std::string Disassemble(u32 /*address*/) const { return "NODEBUGGER"; } + virtual std::string GetRawMemoryString(int /*memory*/, u32 /*address*/) const { return "NODEBUGGER"; } virtual int GetInstructionSize(int /*instruction*/) { return 1; } - virtual bool IsAlive() { return true; } - virtual bool IsBreakpoint(u32 /*address*/) { return false; } + virtual bool IsAlive() const { return true; } + virtual bool IsBreakpoint(u32 /*address*/) const { return false; } virtual void SetBreakpoint(u32 /*address*/) {} virtual void ClearBreakpoint(u32 /*address*/) {} virtual void ClearAllBreakpoints() {} virtual void ToggleBreakpoint(u32 /*address*/) {} virtual void ClearAllMemChecks() {} - virtual bool IsMemCheck(u32 /*address*/, size_t /*size*/) { return false; } + virtual bool IsMemCheck(u32 /*address*/, size_t /*size*/) const { return false; } virtual void ToggleMemCheck(u32 /*address*/, bool /*read*/, bool /*write*/, bool /*log*/) {} - virtual u32 ReadMemory(u32 /*address*/) { return 0; } + virtual u32 ReadMemory(u32 /*address*/) const { return 0; } virtual void WriteExtraMemory(int /*memory*/, u32 /*value*/, u32 /*address*/) {} - virtual u32 ReadExtraMemory(int /*memory*/, u32 /*address*/) { return 0; } - virtual u32 ReadInstruction(u32 /*address*/) { return 0; } - virtual u32 GetPC() { return 0; } + virtual u32 ReadExtraMemory(int /*memory*/, u32 /*address*/) const { return 0; } + virtual u32 ReadInstruction(u32 /*address*/) const { return 0; } + virtual u32 GetPC() const { return 0; } virtual void SetPC(u32 /*address*/) {} virtual void Step() {} virtual void RunToBreakpoint() {} - virtual u32 GetColor(u32 /*address*/) { return 0xFFFFFFFF; } - virtual std::string GetDescription(u32 /*address*/) = 0; + virtual u32 GetColor(u32 /*address*/) const { return 0xFFFFFFFF; } + virtual std::string GetDescription(u32 /*address*/) const = 0; virtual void Clear() = 0; }; } // namespace Common diff --git a/Source/Core/Core/Debugger/PPCDebugInterface.cpp b/Source/Core/Core/Debugger/PPCDebugInterface.cpp index 245e26cf77..6dc34917a8 100644 --- a/Source/Core/Core/Debugger/PPCDebugInterface.cpp +++ b/Source/Core/Core/Debugger/PPCDebugInterface.cpp @@ -164,7 +164,7 @@ void PPCDebugInterface::ClearPatches() m_patches.ClearPatches(); } -std::string PPCDebugInterface::Disassemble(u32 address) +std::string PPCDebugInterface::Disassemble(u32 address) const { // PowerPC::HostRead_U32 seemed to crash on shutdown if (!IsAlive()) @@ -194,7 +194,7 @@ std::string PPCDebugInterface::Disassemble(u32 address) } } -std::string PPCDebugInterface::GetRawMemoryString(int memory, u32 address) +std::string PPCDebugInterface::GetRawMemoryString(int memory, u32 address) const { if (IsAlive()) { @@ -209,12 +209,12 @@ std::string PPCDebugInterface::GetRawMemoryString(int memory, u32 address) return ""; // bad spelling - 8 chars } -u32 PPCDebugInterface::ReadMemory(u32 address) +u32 PPCDebugInterface::ReadMemory(u32 address) const { return PowerPC::HostRead_U32(address); } -u32 PPCDebugInterface::ReadExtraMemory(int memory, u32 address) +u32 PPCDebugInterface::ReadExtraMemory(int memory, u32 address) const { switch (memory) { @@ -228,17 +228,17 @@ u32 PPCDebugInterface::ReadExtraMemory(int memory, u32 address) } } -u32 PPCDebugInterface::ReadInstruction(u32 address) +u32 PPCDebugInterface::ReadInstruction(u32 address) const { return PowerPC::HostRead_Instruction(address); } -bool PPCDebugInterface::IsAlive() +bool PPCDebugInterface::IsAlive() const { return Core::IsRunningAndStarted(); } -bool PPCDebugInterface::IsBreakpoint(u32 address) +bool PPCDebugInterface::IsBreakpoint(u32 address) const { return PowerPC::breakpoints.IsAddressBreakPoint(address); } @@ -271,7 +271,7 @@ void PPCDebugInterface::ClearAllMemChecks() PowerPC::memchecks.Clear(); } -bool PPCDebugInterface::IsMemCheck(u32 address, size_t size) +bool PPCDebugInterface::IsMemCheck(u32 address, size_t size) const { return PowerPC::memchecks.GetMemCheck(address, size) != nullptr; } @@ -301,7 +301,7 @@ void PPCDebugInterface::ToggleMemCheck(u32 address, bool read, bool write, bool // ======================================================= // Separate the blocks with colors. // ------------- -u32 PPCDebugInterface::GetColor(u32 address) +u32 PPCDebugInterface::GetColor(u32 address) const { if (!IsAlive()) return 0xFFFFFF; @@ -326,12 +326,12 @@ u32 PPCDebugInterface::GetColor(u32 address) } // ============= -std::string PPCDebugInterface::GetDescription(u32 address) +std::string PPCDebugInterface::GetDescription(u32 address) const { return g_symbolDB.GetDescription(address); } -u32 PPCDebugInterface::GetPC() +u32 PPCDebugInterface::GetPC() const { return PowerPC::ppcState.pc; } diff --git a/Source/Core/Core/Debugger/PPCDebugInterface.h b/Source/Core/Core/Debugger/PPCDebugInterface.h index 07d7d057d8..a12f6ef00f 100644 --- a/Source/Core/Core/Debugger/PPCDebugInterface.h +++ b/Source/Core/Core/Debugger/PPCDebugInterface.h @@ -52,33 +52,33 @@ public: void RemovePatch(std::size_t index) override; void ClearPatches() override; - std::string Disassemble(u32 address) override; - std::string GetRawMemoryString(int memory, u32 address) override; + std::string Disassemble(u32 address) const override; + std::string GetRawMemoryString(int memory, u32 address) const override; int GetInstructionSize(int /*instruction*/) override { return 4; } - bool IsAlive() override; - bool IsBreakpoint(u32 address) override; + bool IsAlive() const override; + bool IsBreakpoint(u32 address) const override; void SetBreakpoint(u32 address) override; void ClearBreakpoint(u32 address) override; void ClearAllBreakpoints() override; void ToggleBreakpoint(u32 address) override; void ClearAllMemChecks() override; - bool IsMemCheck(u32 address, size_t size = 1) override; + bool IsMemCheck(u32 address, size_t size = 1) const override; void ToggleMemCheck(u32 address, bool read = true, bool write = true, bool log = true) override; - u32 ReadMemory(u32 address) override; + u32 ReadMemory(u32 address) const override; enum { EXTRAMEM_ARAM = 1, }; - u32 ReadExtraMemory(int memory, u32 address) override; - u32 ReadInstruction(u32 address) override; - u32 GetPC() override; + u32 ReadExtraMemory(int memory, u32 address) const override; + u32 ReadInstruction(u32 address) const override; + u32 GetPC() const override; void SetPC(u32 address) override; void Step() override {} void RunToBreakpoint() override; - u32 GetColor(u32 address) override; - std::string GetDescription(u32 address) override; + u32 GetColor(u32 address) const override; + std::string GetDescription(u32 address) const override; void Clear() override; diff --git a/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.cpp b/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.cpp index 1f9e4f6e2c..ae2c567dc6 100644 --- a/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.cpp +++ b/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.cpp @@ -140,13 +140,13 @@ void DSPDebugInterface::ClearPatches() m_patches.ClearPatches(); } -std::string DSPDebugInterface::Disassemble(u32 address) +std::string DSPDebugInterface::Disassemble(u32 address) const { // we'll treat addresses as line numbers. return Symbols::GetLineText(address); } -std::string DSPDebugInterface::GetRawMemoryString(int memory, u32 address) +std::string DSPDebugInterface::GetRawMemoryString(int memory, u32 address) const { if (DSPCore_GetState() == State::Stopped) return ""; @@ -179,22 +179,22 @@ std::string DSPDebugInterface::GetRawMemoryString(int memory, u32 address) return ""; } -u32 DSPDebugInterface::ReadMemory(u32 address) +u32 DSPDebugInterface::ReadMemory(u32 address) const { return 0; } -u32 DSPDebugInterface::ReadInstruction(u32 address) +u32 DSPDebugInterface::ReadInstruction(u32 address) const { return 0; } -bool DSPDebugInterface::IsAlive() +bool DSPDebugInterface::IsAlive() const { return true; } -bool DSPDebugInterface::IsBreakpoint(u32 address) +bool DSPDebugInterface::IsBreakpoint(u32 address) const { int real_addr = Symbols::Line2Addr(address); if (real_addr >= 0) @@ -240,7 +240,7 @@ void DSPDebugInterface::ToggleBreakpoint(u32 address) } } -bool DSPDebugInterface::IsMemCheck(u32 address, size_t size) +bool DSPDebugInterface::IsMemCheck(u32 address, size_t size) const { return false; } @@ -258,7 +258,7 @@ void DSPDebugInterface::ToggleMemCheck(u32 address, bool read, bool write, bool // ======================================================= // Separate the blocks with colors. // ------------- -u32 DSPDebugInterface::GetColor(u32 address) +u32 DSPDebugInterface::GetColor(u32 address) const { // Scan backwards so we don't miss it. Hm, actually, let's not - it looks pretty good. int addr = -1; @@ -289,12 +289,12 @@ u32 DSPDebugInterface::GetColor(u32 address) } // ============= -std::string DSPDebugInterface::GetDescription(u32 address) +std::string DSPDebugInterface::GetDescription(u32 address) const { return ""; // g_symbolDB.GetDescription(address); } -u32 DSPDebugInterface::GetPC() +u32 DSPDebugInterface::GetPC() const { return Symbols::Addr2Line(DSP::g_dsp.pc); } diff --git a/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.h b/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.h index 0988abef11..3dcba99005 100644 --- a/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.h +++ b/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.h @@ -53,26 +53,26 @@ public: bool HasEnabledPatch(u32 address) const override; void ClearPatches() override; - std::string Disassemble(u32 address) override; - std::string GetRawMemoryString(int memory, u32 address) override; + std::string Disassemble(u32 address) const override; + std::string GetRawMemoryString(int memory, u32 address) const override; int GetInstructionSize(int instruction) override { return 1; } - bool IsAlive() override; - bool IsBreakpoint(u32 address) override; + bool IsAlive() const override; + bool IsBreakpoint(u32 address) const override; void SetBreakpoint(u32 address) override; void ClearBreakpoint(u32 address) override; void ClearAllBreakpoints() override; void ToggleBreakpoint(u32 address) override; void ClearAllMemChecks() override; - bool IsMemCheck(u32 address, size_t size) override; + bool IsMemCheck(u32 address, size_t size) const override; void ToggleMemCheck(u32 address, bool read = true, bool write = true, bool log = true) override; - u32 ReadMemory(u32 address) override; - u32 ReadInstruction(u32 address) override; - u32 GetPC() override; + u32 ReadMemory(u32 address) const override; + u32 ReadInstruction(u32 address) const override; + u32 GetPC() const override; void SetPC(u32 address) override; void Step() override {} void RunToBreakpoint() override; - u32 GetColor(u32 address) override; - std::string GetDescription(u32 address) override; + u32 GetColor(u32 address) const override; + std::string GetDescription(u32 address) const override; void Clear() override; From d2d7bf5c3b5f515932ecaea11bb2ac2b15beb3a3 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 8 Jul 2019 18:33:17 -0400 Subject: [PATCH 8/8] Common/DebugInterface: Remove GetInstructionSize() This is completely unused, so it can be removed. --- Source/Core/Common/DebugInterface.h | 1 - Source/Core/Core/Debugger/PPCDebugInterface.h | 1 - Source/Core/Core/HW/DSPLLE/DSPDebugInterface.h | 1 - 3 files changed, 3 deletions(-) diff --git a/Source/Core/Common/DebugInterface.h b/Source/Core/Common/DebugInterface.h index e9ec396b17..fd9d93f8f9 100644 --- a/Source/Core/Common/DebugInterface.h +++ b/Source/Core/Common/DebugInterface.h @@ -56,7 +56,6 @@ public: { return "NODEBUGGER"; } - virtual int GetInstructionSize(int /*instruction*/) { return 1; } virtual bool IsAlive() const { return true; } virtual bool IsBreakpoint(u32 /*address*/) const { return false; } virtual void SetBreakpoint(u32 /*address*/) {} diff --git a/Source/Core/Core/Debugger/PPCDebugInterface.h b/Source/Core/Core/Debugger/PPCDebugInterface.h index a12f6ef00f..54b4f7e867 100644 --- a/Source/Core/Core/Debugger/PPCDebugInterface.h +++ b/Source/Core/Core/Debugger/PPCDebugInterface.h @@ -54,7 +54,6 @@ public: std::string Disassemble(u32 address) const override; std::string GetRawMemoryString(int memory, u32 address) const override; - int GetInstructionSize(int /*instruction*/) override { return 4; } bool IsAlive() const override; bool IsBreakpoint(u32 address) const override; void SetBreakpoint(u32 address) override; diff --git a/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.h b/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.h index 3dcba99005..078b3299c6 100644 --- a/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.h +++ b/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.h @@ -55,7 +55,6 @@ public: std::string Disassemble(u32 address) const override; std::string GetRawMemoryString(int memory, u32 address) const override; - int GetInstructionSize(int instruction) override { return 1; } bool IsAlive() const override; bool IsBreakpoint(u32 address) const override; void SetBreakpoint(u32 address) override;