From bc8778203eefcfca0597abc286de3c36edfbe6e5 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 8 Jul 2019 17:28:07 -0400 Subject: Common/Watches: std::move strings where applicable Allows calling code to move the std::string into the Watch instances, avoiding copies. --- Source/Core/Common/DebugInterface.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Source/Core/Common/DebugInterface.h') 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; -- cgit v1.2.3 From b1b9c6aa1e8c04a89f2d6e08960e67665bcabda2 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 8 Jul 2019 17:44:56 -0400 Subject: 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 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Source/Core/Common/DebugInterface.h') 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 -- cgit v1.2.3 From 457bff92c142fec0f4d55c25ce87e18c910326b9 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 8 Jul 2019 17:53:47 -0400 Subject: 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 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) (limited to 'Source/Core/Common/DebugInterface.h') 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 -- cgit v1.2.3 From a9a9b193bb864b540b7db65be2663cd31cb3a793 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 8 Jul 2019 18:07:11 -0400 Subject: 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 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'Source/Core/Common/DebugInterface.h') 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; -- cgit v1.2.3 From d4d485b692cee326126e003950c582c08de18916 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 8 Jul 2019 18:13:27 -0400 Subject: 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 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Source/Core/Common/DebugInterface.h') 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; }; -- cgit v1.2.3 From 92c17827267aa2553e11daae3d53d766b54ae5cf Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 8 Jul 2019 18:25:14 -0400 Subject: 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 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'Source/Core/Common/DebugInterface.h') 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 -- cgit v1.2.3 From d2d7bf5c3b5f515932ecaea11bb2ac2b15beb3a3 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 8 Jul 2019 18:33:17 -0400 Subject: Common/DebugInterface: Remove GetInstructionSize() This is completely unused, so it can be removed. --- Source/Core/Common/DebugInterface.h | 1 - 1 file changed, 1 deletion(-) (limited to 'Source/Core/Common/DebugInterface.h') 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*/) {} -- cgit v1.2.3