Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
hrydgard
GitHub Repository: hrydgard/ppsspp
Path: blob/master/UI/ImDebugger/ImDebugger.h
4779 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
125
// We use a separate ini file from the main PPSSPP config.
126
void LoadConfig(const Path &iniFile);
127
void SaveConfig(const Path &iniFile);
128
129
void SyncConfig(IniFile *ini, bool save);
130
};
131
132
struct Track;
133
class ImAtracToolWindow {
134
public:
135
void Draw(ImConfig &cfg);
136
void Load();
137
138
char atracPath_[1024]{};
139
std::unique_ptr<Track> track_;
140
std::string error_;
141
std::string data_;
142
};
143
144
class ImWatchWindow {
145
public:
146
ImWatchWindow();
147
void Draw(ImConfig &cfg, ImControl &control, MIPSDebugInterface *mipsDebug);
148
private:
149
std::vector<WatchInfo> watches_;
150
151
char editBuffer_[256];
152
int editingWatchIndex_ = -1;
153
int editingColumn_ = 0;
154
bool setEditFocus_ = false;
155
};
156
157
class ImLogWindow {
158
public:
159
ImLogWindow() {}
160
void Draw(ImConfig &cfg);
161
162
private:
163
bool AutoScroll = true; // Keep scrolling if already at the bottom.
164
};
165
166
enum class ImCmd {
167
NONE = 0,
168
TRIGGER_FIND_POPUP,
169
SHOW_IN_CPU_DISASM,
170
SHOW_IN_GE_DISASM,
171
SHOW_IN_MEMORY_VIEWER, // param is address, param2 is viewer index
172
SHOW_IN_PIXEL_VIEWER, // param is address, param2 is stride, |0x80000000 if depth, param3 is w/h
173
SHOW_IN_MEMORY_DUMPER, // param is address, param2 is size, param3 is mode
174
};
175
176
struct ImCommand {
177
ImCmd cmd;
178
uint32_t param;
179
uint32_t param2;
180
uint32_t param3;
181
};
182
183
struct ImControl {
184
ImCommand command;
185
};
186
187
class ImDebugger {
188
public:
189
ImDebugger();
190
~ImDebugger();
191
192
void Frame(MIPSDebugInterface *mipsDebug, GPUDebugInterface *gpuDebug, Draw::DrawContext *draw);
193
194
// Should be called just before starting a step or run, so that things can
195
// save state that they can later compare with, to highlight changes.
196
void Snapshot(MIPSState *mips);
197
void SnapshotGPU(GPUDebugInterface *mips);
198
199
// Call from the outside.
200
void PostCmd(ImCommand cmd) {
201
externalCommand_ = cmd;
202
}
203
void DeviceLost();
204
205
private:
206
Path ConfigPath();
207
208
RequesterToken reqToken_;
209
210
ImDisasmWindow disasm_;
211
ImGeDebuggerWindow geDebugger_;
212
ImGeStateWindow geStateWindow_;
213
ImMemWindow mem_[4]; // We support 4 separate instances of the memory viewer.
214
ImStructViewer structViewer_;
215
ImGePixelViewerWindow pixelViewer_;
216
ImMemDumpWindow memDumpWindow_;
217
ImWatchWindow watchWindow_;
218
ImAtracToolWindow atracToolWindow_;
219
ImConsole luaConsole_;
220
ImLogWindow logWindow_;
221
ImJitViewerWindow jitViewer_;
222
223
ImSnapshotState newSnapshot_;
224
ImSnapshotState snapshot_;
225
226
int lastCpuStepCount_ = -1;
227
int lastGpuStepCount_ = -1;
228
229
// Open variables.
230
ImConfig cfg_{};
231
232
ImCommand externalCommand_;
233
};
234
235
// Simple custom controls and utilities.
236
void ImClickableValue(const char *id, uint32_t value, ImControl &control, ImCmd cmd);
237
void ImClickableValueFloat(const char *id, float value);
238
void ShowInWindowMenuItems(uint32_t addr, ImControl &control);
239
void ShowInMemoryViewerMenuItem(uint32_t addr, ImControl &control);
240
void ShowInMemoryDumperMenuItem(uint32_t addr, uint32_t size, MemDumpMode mode, ImControl &control);
241
void StatusBar(std::string_view str);
242
inline const char *BoolStr(bool s) { return s ? "true" : "false"; }
243
244