Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
hrydgard
GitHub Repository: hrydgard/ppsspp
Path: blob/master/UI/ImDebugger/ImDebugger.h
5656 views
1
#pragma once
2
3
#include <vector>
4
#include <string>
5
#include <set>
6
7
#include "ext/imgui/imgui.h"
8
9
#include "Common/CommonTypes.h"
10
#include "Common/Log.h"
11
#include "Common/System/Request.h"
12
13
#include "Core/Core.h"
14
#include "Core/HLE/SocketManager.h"
15
16
#include "Core/Debugger/DisassemblyManager.h"
17
#include "Core/Debugger/DebugInterface.h"
18
#include "Core/Debugger/Watch.h"
19
20
#include "UI/ImDebugger/ImDisasmView.h"
21
#include "UI/ImDebugger/ImMemView.h"
22
#include "UI/ImDebugger/ImStructViewer.h"
23
#include "UI/ImDebugger/ImJitViewer.h"
24
#include "UI/ImDebugger/ImGe.h"
25
#include "UI/ImDebugger/ImConsole.h"
26
27
// This is the main state container of the whole Dear ImGUI-based in-game cross-platform debugger.
28
//
29
// Code conventions for ImGUI in PPSSPP
30
// * If windows/objects need state, prefix the class name with Im and just store straight in parent struct
31
32
class MIPSDebugInterface;
33
class GPUDebugInterface;
34
struct ImConfig;
35
36
// Snapshot of the MIPS CPU and other things we want to show diffs off.
37
struct ImSnapshotState {
38
u32 gpr[32];
39
float fpr[32];
40
float vpr[128];
41
u32 pc;
42
u32 lo;
43
u32 hi;
44
u32 ll;
45
};
46
47
class IniFile;
48
49
struct ImConfig {
50
// Defaults for saved settings are set in SyncConfig.
51
bool disasmOpen;
52
bool demoOpen;
53
bool gprOpen;
54
bool fprOpen;
55
bool vfpuOpen;
56
bool threadsOpen;
57
bool callstackOpen;
58
bool breakpointsOpen;
59
bool symbolsOpen;
60
bool modulesOpen;
61
bool hleModulesOpen;
62
bool mediaDecodersOpen;
63
bool structViewerOpen;
64
bool framebuffersOpen;
65
bool texturesOpen;
66
bool displayOpen;
67
bool styleEditorOpen;
68
bool filesystemBrowserOpen;
69
bool kernelObjectsOpen;
70
bool audioChannelsOpen;
71
bool debugStatsOpen;
72
bool geDebuggerOpen;
73
bool geStateOpen;
74
bool geVertsOpen;
75
bool schedulerOpen;
76
bool timeOpen;
77
bool watchOpen;
78
bool pixelViewerOpen;
79
bool npOpen;
80
bool socketsOpen;
81
bool apctlOpen;
82
bool adhocOpen;
83
bool memDumpOpen;
84
bool internalsOpen;
85
bool sasAudioOpen;
86
bool logConfigOpen;
87
bool logOpen;
88
bool utilityModulesOpen;
89
bool atracToolOpen;
90
bool memViewOpen[4];
91
bool luaConsoleOpen;
92
bool audioOutOpen;
93
bool paramSFOOpen;
94
bool jitViewerOpen;
95
96
// HLE explorer settings
97
// bool filterByUsed = true;
98
99
// Various selections
100
int selectedModuleId = 0;
101
int selectedSymbolModule = 0;
102
int selectedUtilityModule = 0;
103
int selectedThread = 0;
104
int selectedKernelObject = 0;
105
int selectedFramebuffer = -1;
106
int selectedBreakpoint = -1;
107
int selectedMemCheck = -1;
108
int selectedAtracCtx = 0;
109
int selectedMp3Ctx = 0;
110
int selectedAacCtx = 0;
111
int selectedMemoryBlock = 0;
112
u32 selectedMpegCtx = 0;
113
114
uint64_t selectedTexAddr = 0;
115
116
bool realtimePixelPreview = false;
117
int breakCount = 0;
118
119
bool displayLatched = false;
120
int requesterToken;
121
122
bool sasShowAllVoices = false;
123
124
float fbViewerZoom = 1.0f;
125
126
127
// We use a separate ini file from the main PPSSPP config.
128
void LoadConfig(const Path &iniFile);
129
void SaveConfig(const Path &iniFile);
130
131
void SyncConfig(IniFile *ini, bool save);
132
};
133
134
struct Track;
135
class ImAtracToolWindow {
136
public:
137
void Draw(ImConfig &cfg);
138
void Load();
139
140
char atracPath_[1024]{};
141
std::unique_ptr<Track> track_;
142
std::string error_;
143
std::string data_;
144
};
145
146
class ImWatchWindow {
147
public:
148
ImWatchWindow();
149
void Draw(ImConfig &cfg, ImControl &control, MIPSDebugInterface *mipsDebug);
150
private:
151
std::vector<WatchInfo> watches_;
152
153
char editBuffer_[256];
154
int editingWatchIndex_ = -1;
155
int editingColumn_ = 0;
156
bool setEditFocus_ = false;
157
};
158
159
class ImLogWindow {
160
public:
161
ImLogWindow() {}
162
void Draw(ImConfig &cfg);
163
164
private:
165
bool AutoScroll = true; // Keep scrolling if already at the bottom.
166
};
167
168
enum class ImCmd {
169
NONE = 0,
170
TRIGGER_FIND_POPUP,
171
SHOW_IN_CPU_DISASM,
172
SHOW_IN_GE_DISASM,
173
SHOW_IN_MEMORY_VIEWER, // param is address, param2 is viewer index
174
SHOW_IN_PIXEL_VIEWER, // param is address, param2 is stride, |0x80000000 if depth, param3 is w/h
175
SHOW_IN_MEMORY_DUMPER, // param is address, param2 is size, param3 is mode
176
};
177
178
struct ImCommand {
179
ImCmd cmd;
180
uint32_t param;
181
uint32_t param2;
182
uint32_t param3;
183
};
184
185
struct ImControl {
186
ImCommand command;
187
};
188
189
class ImDebugger {
190
public:
191
ImDebugger();
192
~ImDebugger();
193
194
void Frame(MIPSDebugInterface *mipsDebug, GPUDebugInterface *gpuDebug, Draw::DrawContext *draw);
195
196
// Should be called just before starting a step or run, so that things can
197
// save state that they can later compare with, to highlight changes.
198
void Snapshot(MIPSState *mips);
199
void SnapshotGPU(GPUDebugInterface *mips);
200
201
// Call from the outside.
202
void PostCmd(ImCommand cmd) {
203
externalCommand_ = cmd;
204
}
205
void DeviceLost();
206
207
private:
208
Path ConfigPath();
209
210
RequesterToken reqToken_;
211
212
ImDisasmWindow disasm_;
213
ImGeDebuggerWindow geDebugger_;
214
ImGeStateWindow geStateWindow_;
215
ImMemWindow mem_[4]; // We support 4 separate instances of the memory viewer.
216
ImStructViewer structViewer_;
217
ImGePixelViewerWindow pixelViewer_;
218
ImMemDumpWindow memDumpWindow_;
219
ImWatchWindow watchWindow_;
220
ImAtracToolWindow atracToolWindow_;
221
ImConsole luaConsole_;
222
ImLogWindow logWindow_;
223
ImJitViewerWindow jitViewer_;
224
225
ImSnapshotState newSnapshot_;
226
ImSnapshotState snapshot_;
227
228
int lastCpuStepCount_ = -1;
229
int lastGpuStepCount_ = -1;
230
231
// Open variables.
232
ImConfig cfg_{};
233
234
ImCommand externalCommand_;
235
};
236
237
// Simple custom controls and utilities.
238
void ImClickableValue(const char *id, uint32_t value, ImControl &control, ImCmd cmd);
239
void ImClickableValueFloat(const char *id, float value);
240
void ShowInWindowMenuItems(uint32_t addr, ImControl &control);
241
void ShowInMemoryViewerMenuItem(uint32_t addr, ImControl &control);
242
void ShowInMemoryDumperMenuItem(uint32_t addr, uint32_t size, MemDumpMode mode, ImControl &control);
243
void StatusBar(std::string_view str);
244
inline const char *BoolStr(bool s) { return s ? "true" : "false"; }
245
246