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