Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
hrydgard
GitHub Repository: hrydgard/ppsspp
Path: blob/master/Core/HLE/KernelThreadDebugInterface.h
3186 views
1
// Copyright (c) 2018- PPSSPP Project.
2
3
// This program is free software: you can redistribute it and/or modify
4
// it under the terms of the GNU General Public License as published by
5
// the Free Software Foundation, version 2.0 or later versions.
6
7
// This program is distributed in the hope that it will be useful,
8
// but WITHOUT ANY WARRANTY; without even the implied warranty of
9
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
// GNU General Public License 2.0 for more details.
11
12
// A copy of the GPL 2.0 should have been included with the program.
13
// If not, see http://www.gnu.org/licenses/
14
15
// Official git repository and contact information can be found at
16
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
17
18
#pragma once
19
20
#include <cstdio>
21
#include "Core/HLE/PSPThreadContext.h"
22
#include "Core/MIPS/MIPSDebugInterface.h"
23
24
struct PSPThreadContext;
25
26
class KernelThreadDebugInterface : public DebugInterface {
27
public:
28
KernelThreadDebugInterface(PSPThreadContext *t) : ctx(*t) {}
29
30
u32 GetGPR32Value(int reg) const override { return ctx.r[reg]; }
31
u32 GetHi() const override { return ctx.hi; }
32
u32 GetLo() const override { return ctx.lo; }
33
u32 GetPC() const override { return ctx.pc; }
34
u32 GetRA() const override { return ctx.r[MIPS_REG_RA]; }
35
u32 GetLLBit() const override { return 0; }
36
u32 GetFPCond() const override { return ctx.fpcond; }
37
void SetPC(u32 _pc) override { ctx.pc = _pc; }
38
void SetHi(u32 val) override { ctx.hi = val; }
39
void SetLo(u32 val) override { ctx.lo = val; }
40
41
void PrintRegValue(int cat, int index, char *out, size_t outSize) const override {
42
switch (cat) {
43
case 0: snprintf(out, outSize, "%08X", ctx.r[index]); break;
44
case 1: snprintf(out, outSize, "%f", ctx.f[index]); break;
45
case 2: snprintf(out, outSize, "N/A"); break;
46
}
47
}
48
49
u32 GetRegValue(int cat, int index) const override {
50
switch (cat) {
51
case 0: return ctx.r[index];
52
case 1: return ctx.fi[index];
53
case 2: return ctx.vi[voffset[index]];
54
default: return 0;
55
}
56
}
57
58
void SetRegValue(int cat, int index, u32 value) override {
59
switch (cat) {
60
case 0:
61
if (index != 0)
62
ctx.r[index] = value;
63
break;
64
65
case 1:
66
ctx.fi[index] = value;
67
break;
68
69
case 2:
70
ctx.vi[voffset[index]] = value;
71
break;
72
73
default:
74
break;
75
}
76
}
77
78
protected:
79
PSPThreadContext &ctx;
80
};
81
82