CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
Path: blob/master/Core/MIPS/MIPSDebugInterface.h
Views: 1401
// Copyright (c) 2012- PPSSPP Project.12// This program is free software: you can redistribute it and/or modify3// it under the terms of the GNU General Public License as published by4// the Free Software Foundation, version 2.0 or later versions.56// This program is distributed in the hope that it will be useful,7// but WITHOUT ANY WARRANTY; without even the implied warranty of8// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9// GNU General Public License 2.0 for more details.1011// A copy of the GPL 2.0 should have been included with the program.12// If not, see http://www.gnu.org/licenses/1314// Official git repository and contact information can be found at15// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.1617#pragma once1819#include <string>20#include <cstring>21#include <cstdio>22#include "Core/MIPS/MIPS.h"23#include "Core/Debugger/DebugInterface.h"2425class MIPSDebugInterface : public DebugInterface26{27MIPSState *cpu;28public:29MIPSDebugInterface(MIPSState *_cpu) { cpu = _cpu; }30int getInstructionSize(int instruction) override { return 4; }31bool isAlive() override;32bool isBreakpoint(unsigned int address) override;33void setBreakpoint(unsigned int address) override;34void clearBreakpoint(unsigned int address) override;35void clearAllBreakpoints() override;36void toggleBreakpoint(unsigned int address) override;37unsigned int readMemory(unsigned int address) override;38unsigned int getPC() override { return cpu->pc; }39void setPC(unsigned int address) override { cpu->pc = address; }40void step() override {}41void runToBreakpoint() override;42int getColor(unsigned int address) override;43std::string getDescription(unsigned int address) override;44bool initExpression(const char* exp, PostfixExpression& dest) override;45bool parseExpression(PostfixExpression& exp, u32& dest) override;4647//overridden functions48const char *GetName() override;49u32 GetGPR32Value(int reg) override { return cpu->r[reg]; }50u32 GetPC() override { return cpu->pc; }51u32 GetLR() override { return cpu->r[MIPS_REG_RA]; }52void DisAsm(u32 pc, char *out, size_t outSize) override;53void SetPC(u32 _pc) override { cpu->pc = _pc; }5455const char *GetCategoryName(int cat) override {56static const char *const names[3] = { "GPR", "FPU", "VFPU" };57return names[cat];58}59int GetNumCategories() override { return 3; }60int GetNumRegsInCategory(int cat) override {61static int r[3] = { 32, 32, 128 };62return r[cat];63}64std::string GetRegName(int cat, int index) override;6566void PrintRegValue(int cat, int index, char *out, size_t outSize) override {67switch (cat) {68case 0: snprintf(out, outSize, "%08X", cpu->r[index]); break;69case 1: snprintf(out, outSize, "%f", cpu->f[index]); break;70case 2: snprintf(out, outSize, "N/A"); break;71}72}7374u32 GetHi() override {75return cpu->hi;76}7778u32 GetLo() override {79return cpu->lo;80}8182void SetHi(u32 val) override {83cpu->hi = val;84}8586void SetLo(u32 val) override {87cpu->lo = val;88}8990u32 GetRegValue(int cat, int index) override {91switch (cat) {92case 0:93return cpu->r[index];9495case 1:96return cpu->fi[index];9798case 2:99return cpu->vi[voffset[index]];100101default:102return 0;103}104}105106void SetRegValue(int cat, int index, u32 value) override {107switch (cat) {108case 0:109if (index != 0)110cpu->r[index] = value;111break;112113case 1:114cpu->fi[index] = value;115break;116117case 2:118cpu->vi[voffset[index]] = value;119break;120121default:122break;123}124}125};126127128