Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
hrydgard
GitHub Repository: hrydgard/ppsspp
Path: blob/master/GPU/Debugger/Breakpoints.h
3186 views
1
// Copyright (c) 2013- 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 <string>
21
#include <set>
22
#include <mutex>
23
#include <unordered_map>
24
#include "Common/CommonTypes.h"
25
#include "Common/Math/expression_parser.h"
26
#include "GPU/Common/GPUDebugInterface.h"
27
28
struct GECmdInfo;
29
30
class GPUBreakpoints {
31
public:
32
GPUBreakpoints();
33
34
bool IsBreakpoint(u32 pc, u32 op);
35
36
bool IsAddressBreakpoint(u32 addr, bool &temp);
37
bool IsAddressBreakpoint(u32 addr);
38
bool IsCmdBreakpoint(u8 cmd, bool &temp) const;
39
bool IsCmdBreakpoint(u8 cmd) const;
40
bool IsOpBreakpoint(u32 op, bool &temp) const;
41
bool IsOpBreakpoint(u32 op) const;
42
bool IsTextureBreakpoint(u32 addr, bool &temp);
43
bool IsTextureBreakpoint(u32 addr);
44
bool IsRenderTargetBreakpoint(u32 addr, bool &temp);
45
bool IsRenderTargetBreakpoint(u32 addr);
46
47
void AddAddressBreakpoint(u32 addr, bool temp = false);
48
void AddCmdBreakpoint(u8 cmd, bool temp = false);
49
void AddTextureBreakpoint(u32 addr, bool temp = false);
50
void AddTextureChangeTempBreakpoint();
51
void AddRenderTargetBreakpoint(u32 addr, bool temp = false);
52
// Quick way to trigger GE debugger statically.
53
void AddAnyTempBreakpoint();
54
55
void RemoveAddressBreakpoint(u32 addr);
56
void RemoveCmdBreakpoint(u8 cmd);
57
void RemoveTextureBreakpoint(u32 addr);
58
void RemoveTextureChangeTempBreakpoint();
59
void RemoveRenderTargetBreakpoint(u32 addr);
60
61
bool SetAddressBreakpointCond(u32 addr, const std::string &expression, std::string *error);
62
bool GetAddressBreakpointCond(u32 addr, std::string *expression);
63
bool SetCmdBreakpointCond(u8 cmd, const std::string &expression, std::string *error);
64
bool GetCmdBreakpointCond(u8 cmd, std::string *expression);
65
66
void UpdateLastTexture(u32 addr);
67
68
void ClearAllBreakpoints();
69
void ClearTempBreakpoints();
70
71
bool HasBreakpoints() const {
72
return hasBreakpoints_;
73
}
74
75
struct BreakpointInfo {
76
bool isConditional = false;
77
PostfixExpression expression;
78
std::string expressionString;
79
};
80
81
bool ToggleCmdBreakpoint(const GECmdInfo &info);
82
83
private:
84
void AddNonTextureTempBreakpoints();
85
void CheckForTextureChange(u32 op, u32 addr);
86
bool HasAnyBreakpoints() const;
87
bool IsTextureCmdBreakpoint(u32 op);
88
bool IsRenderTargetCmdBreakpoint(u32 op);
89
bool HitAddressBreakpoint(u32 pc, u32 op);
90
bool HitOpBreakpoint(u32 op);
91
92
std::mutex breaksLock;
93
94
bool breakCmds[256]{};
95
BreakpointInfo breakCmdsInfo[256]{};
96
std::unordered_map<u32, BreakpointInfo> breakPCs;
97
std::set<u32> breakTextures;
98
std::set<u32> breakRenderTargets;
99
// Small optimization to avoid a lock/lookup for the common case.
100
size_t breakPCsCount = 0;
101
size_t breakTexturesCount = 0;
102
size_t breakRenderTargetsCount = 0;
103
104
// If these are set, the above are also, but they should be temporary.
105
bool breakCmdsTemp[256];
106
std::set<u32> breakPCsTemp;
107
std::set<u32> breakTexturesTemp;
108
std::set<u32> breakRenderTargetsTemp;
109
bool textureChangeTemp = false;
110
111
u32 lastTexture = 0xFFFFFFFF;
112
std::vector<bool> nonTextureCmds;
113
114
bool hasBreakpoints_ = false; // cached value of HasAnyBreakpoints().
115
};
116
117