2012-11-01 15:19:01 +00:00
|
|
|
// Copyright (c) 2012- PPSSPP Project.
|
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
2012-11-04 22:01:49 +00:00
|
|
|
// the Free Software Foundation, version 2.0 or later versions.
|
2012-11-01 15:19:01 +00:00
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License 2.0 for more details.
|
|
|
|
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
|
|
|
|
// Official git repository and contact information can be found at
|
|
|
|
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2014-01-26 05:40:23 +00:00
|
|
|
#include <string>
|
2014-03-15 19:03:33 +00:00
|
|
|
#include <cstring>
|
|
|
|
#include <cstdio>
|
|
|
|
#include "Core/MIPS/MIPS.h"
|
2013-12-29 23:11:29 +00:00
|
|
|
#include "Core/Debugger/DebugInterface.h"
|
2012-11-01 15:19:01 +00:00
|
|
|
|
|
|
|
class MIPSDebugInterface : public DebugInterface
|
|
|
|
{
|
|
|
|
MIPSState *cpu;
|
|
|
|
public:
|
2014-12-08 20:14:35 +00:00
|
|
|
MIPSDebugInterface(MIPSState *_cpu) { cpu = _cpu; }
|
|
|
|
const char *disasm(unsigned int address, unsigned int align) 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;
|
|
|
|
void clearAllBreakpoints() override;
|
|
|
|
void toggleBreakpoint(unsigned int address) override;
|
|
|
|
unsigned int readMemory(unsigned int address) override;
|
|
|
|
unsigned int getPC() override { return cpu->pc; }
|
|
|
|
void setPC(unsigned int address) override { cpu->pc = address; }
|
|
|
|
void step() override {}
|
|
|
|
void runToBreakpoint() override;
|
|
|
|
int getColor(unsigned int address) override;
|
|
|
|
std::string getDescription(unsigned int address) override;
|
|
|
|
bool initExpression(const char* exp, PostfixExpression& dest) override;
|
|
|
|
bool parseExpression(PostfixExpression& exp, u32& dest) override;
|
2012-11-01 15:19:01 +00:00
|
|
|
|
|
|
|
//overridden functions
|
2014-12-08 20:14:35 +00:00
|
|
|
const char *GetName() override;
|
|
|
|
int GetGPRSize() override { return GPR_SIZE_32; }
|
|
|
|
u32 GetGPR32Value(int reg) override { return cpu->r[reg]; }
|
|
|
|
u32 GetPC() override { return cpu->pc; }
|
|
|
|
u32 GetLR() override { return cpu->r[MIPS_REG_RA]; }
|
|
|
|
void SetPC(u32 _pc) override { cpu->pc = _pc; }
|
|
|
|
|
|
|
|
const char *GetCategoryName(int cat) override
|
2012-11-01 15:19:01 +00:00
|
|
|
{
|
|
|
|
const char *names[3] = {("GPR"),("FPU"),("VFPU")};
|
|
|
|
return names[cat];
|
|
|
|
}
|
2014-12-08 20:14:35 +00:00
|
|
|
int GetNumCategories() override { return 3; }
|
|
|
|
int GetNumRegsInCategory(int cat) override
|
2012-11-01 15:19:01 +00:00
|
|
|
{
|
|
|
|
int r[3] = {32,32,32};
|
|
|
|
return r[cat];
|
|
|
|
}
|
2014-12-08 20:14:35 +00:00
|
|
|
const char *GetRegName(int cat, int index) override;
|
2012-11-01 15:19:01 +00:00
|
|
|
|
2014-12-08 20:14:35 +00:00
|
|
|
void PrintRegValue(int cat, int index, char *out) override
|
2012-11-01 15:19:01 +00:00
|
|
|
{
|
|
|
|
switch (cat)
|
|
|
|
{
|
2014-12-08 20:14:35 +00:00
|
|
|
case 0: sprintf(out, "%08X", cpu->r[index]); break;
|
|
|
|
case 1: sprintf(out, "%f", cpu->f[index]); break;
|
|
|
|
case 2: sprintf(out, "N/A"); break;
|
2012-11-01 15:19:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-08 20:14:35 +00:00
|
|
|
u32 GetHi() override
|
2013-07-31 08:24:24 +00:00
|
|
|
{
|
|
|
|
return cpu->hi;
|
|
|
|
}
|
|
|
|
|
2014-12-08 20:14:35 +00:00
|
|
|
u32 GetLo() override
|
2013-07-31 08:24:24 +00:00
|
|
|
{
|
|
|
|
return cpu->lo;
|
|
|
|
}
|
|
|
|
|
2014-12-08 20:14:35 +00:00
|
|
|
void SetHi(u32 val) override
|
2013-07-31 08:24:24 +00:00
|
|
|
{
|
|
|
|
cpu->hi = val;
|
|
|
|
}
|
|
|
|
|
2014-12-08 20:14:35 +00:00
|
|
|
void SetLo(u32 val) override
|
2013-07-31 08:24:24 +00:00
|
|
|
{
|
|
|
|
cpu->lo = val;
|
|
|
|
}
|
|
|
|
|
2014-12-08 20:14:35 +00:00
|
|
|
u32 GetRegValue(int cat, int index) override
|
2012-11-01 15:19:01 +00:00
|
|
|
{
|
2013-06-11 19:36:59 +00:00
|
|
|
u32 temp;
|
2013-02-23 20:30:18 +00:00
|
|
|
switch (cat)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
return cpu->r[index];
|
2013-11-17 09:36:25 +00:00
|
|
|
|
2013-02-23 20:30:18 +00:00
|
|
|
case 1:
|
2013-06-11 19:36:59 +00:00
|
|
|
memcpy(&temp, &cpu->f[index], 4);
|
|
|
|
return temp;
|
2013-02-23 20:30:18 +00:00
|
|
|
|
|
|
|
case 2:
|
2013-11-27 21:45:17 +00:00
|
|
|
memcpy(&temp, &cpu->v[voffset[index]], 4);
|
2013-06-11 19:36:59 +00:00
|
|
|
return temp;
|
2013-02-23 20:30:18 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
2012-11-01 15:19:01 +00:00
|
|
|
}
|
|
|
|
|
2014-12-08 20:14:35 +00:00
|
|
|
void SetRegValue(int cat, int index, u32 value) override
|
2013-02-23 20:25:51 +00:00
|
|
|
{
|
2013-02-23 20:30:18 +00:00
|
|
|
switch (cat)
|
|
|
|
{
|
|
|
|
case 0:
|
2013-11-16 09:59:49 +00:00
|
|
|
if (index != 0)
|
|
|
|
cpu->r[index] = value;
|
2013-02-23 20:30:18 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
2013-06-11 19:36:59 +00:00
|
|
|
memcpy(&cpu->f[index], &value, 4);
|
2013-02-23 20:30:18 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
2013-11-27 21:45:17 +00:00
|
|
|
memcpy(&cpu->v[voffset[index]], &value, 4);
|
2013-02-23 20:30:18 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2013-02-23 20:25:51 +00:00
|
|
|
}
|
2012-11-01 15:19:01 +00:00
|
|
|
};
|