diff --git a/Core/Debugger/DebugInterface.h b/Core/Debugger/DebugInterface.h index 11559e20b7..a209c8fdeb 100644 --- a/Core/Debugger/DebugInterface.h +++ b/Core/Debugger/DebugInterface.h @@ -26,21 +26,19 @@ struct MemMap; class DebugInterface { public: - virtual u32 GetHi() = 0; - virtual u32 GetLo() = 0; - virtual u32 GetLLBit() = 0; - virtual u32 GetFPCond() = 0; + virtual u32 GetPC() const = 0; + virtual u32 GetRA() const = 0; + virtual u32 GetHi() const = 0; + virtual u32 GetLo() const = 0; + virtual u32 GetLLBit() const = 0; + virtual u32 GetFPCond() const = 0; + virtual u32 GetGPR32Value(int reg) const = 0; + virtual void SetPC(u32 _pc) = 0; virtual void SetHi(u32 val) = 0; virtual void SetLo(u32 val) = 0; - virtual u32 GetGPR32Value(int reg) = 0; - virtual u32 GetPC() = 0; - virtual void SetPC(u32 _pc) = 0; - virtual u32 GetRA() = 0; - - // More stuff for debugger - virtual u32 GetRegValue(int cat, int index) = 0; + virtual u32 GetRegValue(int cat, int index) const = 0; + virtual void PrintRegValue(int cat, int index, char *out, size_t outSize) const = 0; virtual void SetRegValue(int cat, int index, u32 value) {} - virtual void PrintRegValue(int cat, int index, char *out, size_t outSize) = 0; }; diff --git a/Core/HLE/KernelThreadDebugInterface.h b/Core/HLE/KernelThreadDebugInterface.h index dbab6d57e1..5e8cee5b22 100644 --- a/Core/HLE/KernelThreadDebugInterface.h +++ b/Core/HLE/KernelThreadDebugInterface.h @@ -23,17 +23,20 @@ class KernelThreadDebugInterface : public DebugInterface { public: - KernelThreadDebugInterface(PSPThreadContext &t) : ctx(t) { - } + KernelThreadDebugInterface(PSPThreadContext &t) : ctx(t) {} - u32 GetGPR32Value(int reg) override { return ctx.r[reg]; } - u32 GetPC() override { return ctx.pc; } - u32 GetRA() override { return ctx.r[MIPS_REG_RA]; } - u32 GetLLBit() override { return 0; } - u32 GetFPCond() override { return ctx.fpcond; } + u32 GetGPR32Value(int reg) const override { return ctx.r[reg]; } + u32 GetHi() const override { return ctx.hi; } + u32 GetLo() const override { return ctx.lo; } + u32 GetPC() const override { return ctx.pc; } + u32 GetRA() const override { return ctx.r[MIPS_REG_RA]; } + u32 GetLLBit() const override { return 0; } + u32 GetFPCond() const override { return ctx.fpcond; } void SetPC(u32 _pc) override { ctx.pc = _pc; } + void SetHi(u32 val) override { ctx.hi = val; } + void SetLo(u32 val) override { ctx.lo = val; } - void PrintRegValue(int cat, int index, char *out, size_t outSize) override { + void PrintRegValue(int cat, int index, char *out, size_t outSize) const override { switch (cat) { case 0: snprintf(out, outSize, "%08X", ctx.r[index]); break; case 1: snprintf(out, outSize, "%f", ctx.f[index]); break; @@ -41,23 +44,7 @@ public: } } - u32 GetHi() override { - return ctx.hi; - } - - u32 GetLo() override { - return ctx.lo; - } - - void SetHi(u32 val) override { - ctx.hi = val; - } - - void SetLo(u32 val) override { - ctx.lo = val; - } - - u32 GetRegValue(int cat, int index) override { + u32 GetRegValue(int cat, int index) const override { switch (cat) { case 0: return ctx.r[index]; case 1: return ctx.fi[index]; diff --git a/Core/MIPS/MIPSDebugInterface.cpp b/Core/MIPS/MIPSDebugInterface.cpp index 650096975e..129b4cabfb 100644 --- a/Core/MIPS/MIPSDebugInterface.cpp +++ b/Core/MIPS/MIPSDebugInterface.cpp @@ -54,7 +54,7 @@ enum ReferenceIndexType { class MipsExpressionFunctions : public IExpressionFunctions { public: - MipsExpressionFunctions(DebugInterface *_cpu): cpu(_cpu) {} + MipsExpressionFunctions(const DebugInterface *_cpu): cpu(_cpu) {} bool parseReference(char* str, uint32_t& referenceIndex) override { @@ -199,7 +199,7 @@ public: } private: - DebugInterface *cpu; + const DebugInterface *cpu; }; unsigned int MIPSDebugInterface::readMemory(unsigned int address) { @@ -282,12 +282,12 @@ std::string MIPSDebugInterface::GetRegName(int cat, int index) { return "???"; } -bool initExpression(DebugInterface *debug, const char* exp, PostfixExpression& dest) { +bool initExpression(const DebugInterface *debug, const char* exp, PostfixExpression& dest) { MipsExpressionFunctions funcs(debug); return initPostfixExpression(exp, &funcs, dest); } -bool parseExpression(DebugInterface *debug, PostfixExpression& exp, u32& dest) { +bool parseExpression(const DebugInterface *debug, PostfixExpression& exp, u32& dest) { MipsExpressionFunctions funcs(debug); return parsePostfixExpression(exp, &funcs, dest); } diff --git a/Core/MIPS/MIPSDebugInterface.h b/Core/MIPS/MIPSDebugInterface.h index d6dc40963f..f71687316b 100644 --- a/Core/MIPS/MIPSDebugInterface.h +++ b/Core/MIPS/MIPSDebugInterface.h @@ -39,13 +39,13 @@ public: int getColor(unsigned int address, bool darkMode) const; std::string getDescription(unsigned int address); - u32 GetGPR32Value(int reg) override { return cpu->r[reg]; } - float GetFPR32Value(int reg) { return cpu->f[reg]; } + u32 GetGPR32Value(int reg) const override { return cpu->r[reg]; } + float GetFPR32Value(int reg) const { return cpu->f[reg]; } void SetGPR32Value(int reg, u32 value) { cpu->r[reg] = value; } - u32 GetPC() override { return cpu->pc; } - u32 GetRA() override { return cpu->r[MIPS_REG_RA]; } - u32 GetFPCond() override { return cpu->fpcond; } + u32 GetPC() const override { return cpu->pc; } + u32 GetRA() const override { return cpu->r[MIPS_REG_RA]; } + u32 GetFPCond() const override { return cpu->fpcond; } void SetPC(u32 _pc) override { cpu->pc = _pc; } static const char *GetCategoryName(int cat) { @@ -59,7 +59,7 @@ public: } static std::string GetRegName(int cat, int index); - void PrintRegValue(int cat, int index, char *out, size_t outSize) override { + void PrintRegValue(int cat, int index, char *out, size_t outSize) const override { switch (cat) { case 0: snprintf(out, outSize, "%08X", cpu->r[index]); break; case 1: snprintf(out, outSize, "%f", cpu->f[index]); break; @@ -67,15 +67,15 @@ public: } } - u32 GetHi() override { + u32 GetHi() const override { return cpu->hi; } - u32 GetLLBit() override { + u32 GetLLBit() const override { return cpu->llBit; } - u32 GetLo() override { + u32 GetLo() const override { return cpu->lo; } @@ -87,7 +87,7 @@ public: cpu->lo = val; } - u32 GetRegValue(int cat, int index) override { + u32 GetRegValue(int cat, int index) const override { switch (cat) { case 0: return cpu->r[index]; @@ -124,6 +124,6 @@ public: } }; -bool initExpression(DebugInterface *debug, const char* exp, PostfixExpression& dest); -bool parseExpression(DebugInterface *debug, PostfixExpression& exp, u32& dest); +bool initExpression(const DebugInterface *debug, const char* exp, PostfixExpression& dest); +bool parseExpression(const DebugInterface *debug, PostfixExpression& exp, u32& dest); void DisAsm(u32 pc, char *out, size_t outSize);