Skip to content
Permalink
Browse files

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.
  • Loading branch information...
lioncash committed Jul 8, 2019
1 parent d4d485b commit 92c17827267aa2553e11daae3d53d766b54ae5cf
@@ -51,31 +51,31 @@ class DebugInterface
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
@@ -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 "<unknwn>"; // 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;
}
@@ -52,33 +52,33 @@ class PPCDebugInterface final : public Common::DebugInterface
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;

@@ -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);
}
@@ -53,26 +53,26 @@ class DSPDebugInterface final : public Common::DebugInterface
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;

0 comments on commit 92c1782

Please sign in to comment.
You can’t perform that action at this time.