Make the ImDebugger a bit less crash prone outside of games

This commit is contained in:
Henrik Rydgård committed 2026-08-07 22:40:05 +02:00
1 parent b4c476d5ed
commit 8d2c1e7a66
5 files changed
+258 -223

No files matched your search

+231 -197
View File
@@ -10,6 +10,7 @@
#include "Common/Data/Text/StringWriter.h"
#include "Common/Log/LogManager.h"
#include "Common/TimeUtil.h"
#include "Common/Data/Text/I18n.h"
#include "Core/Config.h"
#include "Core/System.h"
#include "Core/SaveState.h"
@@ -2383,6 +2384,34 @@ void ImDebugger::Frame(MIPSDebugInterface *mipsDebug, GPUCommon *gpuDebug, Draw:
ImControl control{};
if (ImGui::BeginMainMenuBar()) {
if (ImGui::BeginMenu("File")) {
if (ImGui::MenuItem("Load")) {
System_BrowseForFile(reqToken_, "Load", BrowseFileType::BOOTABLE, [this](std::string_view responseString, int) {
Path path(responseString);
System_PostUIMessage(UIMessage::REQUEST_GAME_BOOT, path.ToString());
});
}
ImGui::Separator();
if (ImGui::MenuItem("Exit")) {
System_ExitApp();
}
ImGui::EndMenu();
}
if (ImGui::BeginMenu("Emulation")) {
if (ImGui::MenuItem("Pause")) {
System_PostUIMessage(UIMessage::REQUEST_GAME_PAUSE);
}
if (ImGui::MenuItem("Stop")) {
System_PostUIMessage(UIMessage::REQUEST_GAME_STOP);
}
if (ImGui::MenuItem("Reset")) {
System_PostUIMessage(UIMessage::REQUEST_GAME_RESET);
}
ImGui::Separator();
ImGui::EndMenu();
}
if (ImGui::BeginMenu("Debug")) {
switch (coreState) {
case CoreState::CORE_STEPPING_CPU:
@@ -2399,9 +2428,9 @@ void ImDebugger::Frame(MIPSDebugInterface *mipsDebug, GPUCommon *gpuDebug, Draw:
break;
}
ImGui::Separator();
ImGui::MenuItemInverted("Break on load", nullptr, &g_Config.bAutoRun);
ImGui::MenuItem("Ignore bad memory accesses", nullptr, &g_Config.bIgnoreBadMemAccess);
ImGui::MenuItem("Break on frame timeout", nullptr, &g_Config.bBreakOnFrameTimeout);
ImGui::MenuItem("Don't break on start", nullptr, &g_Config.bAutoRun); // should really invert this bool!
ImGui::MenuItem("Fast memory", nullptr, &g_Config.bFastMemory);
ImGui::Separator();
if (ImGui::MenuItem("Take screenshot")) {
@@ -2422,121 +2451,128 @@ void ImDebugger::Frame(MIPSDebugInterface *mipsDebug, GPUCommon *gpuDebug, Draw:
}
ImGui::EndMenu();
}
if (ImGui::BeginMenu("Core")) {
ImGui::MenuItem("Scheduler", nullptr, &cfg_.schedulerOpen);
ImGui::MenuItem("Time", nullptr, &cfg_.timeOpen);
ImGui::EndMenu();
}
if (ImGui::BeginMenu("CPU")) {
ImGui::MenuItem("CPU debugger", nullptr, &cfg_.disasmOpen);
ImGui::MenuItem("GPR regs", nullptr, &cfg_.gprOpen);
ImGui::MenuItem("FPR regs", nullptr, &cfg_.fprOpen);
ImGui::MenuItem("VFPU regs", nullptr, &cfg_.vfpuOpen);
ImGui::Separator();
ImGui::MenuItem("Callstacks", nullptr, &cfg_.callstackOpen);
ImGui::MenuItem("Breakpoints", nullptr, &cfg_.breakpointsOpen);
ImGui::MenuItem("Watch", nullptr, &cfg_.watchOpen);
ImGui::MenuItem("JIT viewer", nullptr, &cfg_.jitViewerOpen);
ImGui::EndMenu();
}
if (ImGui::BeginMenu("Symbols")) {
ImGui::MenuItem("Symbol browser", nullptr, &cfg_.symbolsOpen);
ImGui::Separator();
if (ImGui::MenuItem("Load .ppmap...")) {
System_BrowseForFile(reqToken_, "Load PPSSPP symbol map", BrowseFileType::SYMBOL_MAP, [this](std::string_view responseString, int) {
Path path(responseString);
if (!g_symbolMap->LoadSymbolMap(path)) {
ERROR_LOG(Log::Common, "Failed to load symbol map");
}
if (PSP_IsInited()) {
if (ImGui::BeginMenu("Core")) {
ImGui::MenuItem("Scheduler", nullptr, &cfg_.schedulerOpen);
ImGui::MenuItem("Time", nullptr, &cfg_.timeOpen);
ImGui::EndMenu();
}
if (ImGui::BeginMenu("CPU")) {
ImGui::MenuItem("CPU debugger", nullptr, &cfg_.disasmOpen);
ImGui::MenuItem("GPR regs", nullptr, &cfg_.gprOpen);
ImGui::MenuItem("FPR regs", nullptr, &cfg_.fprOpen);
ImGui::MenuItem("VFPU regs", nullptr, &cfg_.vfpuOpen);
ImGui::Separator();
ImGui::MenuItem("Callstacks", nullptr, &cfg_.callstackOpen);
ImGui::MenuItem("Breakpoints", nullptr, &cfg_.breakpointsOpen);
ImGui::MenuItem("Watch", nullptr, &cfg_.watchOpen);
ImGui::MenuItem("JIT viewer", nullptr, &cfg_.jitViewerOpen);
ImGui::EndMenu();
}
if (ImGui::BeginMenu("Symbols")) {
ImGui::MenuItem("Symbol browser", nullptr, &cfg_.symbolsOpen);
ImGui::Separator();
if (ImGui::MenuItem("Load .ppmap...")) {
System_BrowseForFile(reqToken_, "Load PPSSPP symbol map", BrowseFileType::SYMBOL_MAP, [this](std::string_view responseString, int) {
Path path(responseString);
if (!g_symbolMap->LoadSymbolMap(path)) {
ERROR_LOG(Log::Common, "Failed to load symbol map");
}
disasm_.DirtySymbolMap();
});
}
if (ImGui::MenuItem("Save .ppmap...")) {
System_BrowseForFileSave(reqToken_, "Save PPSSPP symbol map", "symbols.ppmap", BrowseFileType::SYMBOL_MAP, [](std::string_view responseString, int) {
Path path(responseString);
if (!g_symbolMap->SaveSymbolMap(path)) {
ERROR_LOG(Log::Common, "Failed to save symbol map");
}
});
}
if (ImGui::MenuItem("Load No$ .sym...")) {
System_BrowseForFile(reqToken_, "Load No$ symbol map", BrowseFileType::SYMBOL_MAP, [this](std::string_view responseString, int) {
Path path(responseString);
if (!g_symbolMap->LoadNocashSym(path)) {
ERROR_LOG(Log::Common, "Failed to load No$ symbol map");
}
disasm_.DirtySymbolMap();
});
}
if (ImGui::MenuItem("Save No$ .sym...")) {
System_BrowseForFileSave(reqToken_, "Save No$ symbol map", "symbols.sym", BrowseFileType::SYMBOL_MAP, [](std::string_view responseString, int) {
Path path(responseString);
if (!g_symbolMap->SaveNocashSym(path)) {
ERROR_LOG(Log::Common, "Failed to save No$ symbol map");
}
});
}
ImGui::Separator();
ImGui::MenuItem("Compress .ppmap files", nullptr, &g_Config.bCompressSymbols);
if (ImGui::MenuItem("Reset symbol map")) {
g_symbolMap->Clear();
disasm_.DirtySymbolMap();
});
// NotifyDebuggerMapLoaded();
}
ImGui::EndMenu();
}
if (ImGui::MenuItem("Save .ppmap...")) {
System_BrowseForFileSave(reqToken_, "Save PPSSPP symbol map", "symbols.ppmap", BrowseFileType::SYMBOL_MAP, [](std::string_view responseString, int) {
Path path(responseString);
if (!g_symbolMap->SaveSymbolMap(path)) {
ERROR_LOG(Log::Common, "Failed to save symbol map");
}
});
if (ImGui::BeginMenu("Memory")) {
for (int i = 0; i < 4; i++) {
char title[64];
snprintf(title, sizeof(title), "Memory %d", i + 1);
ImGui::MenuItem(title, nullptr, &cfg_.memViewOpen[i]);
}
ImGui::MenuItem("Memory Dumper", nullptr, &cfg_.memDumpOpen);
ImGui::EndMenu();
}
if (ImGui::MenuItem("Load No$ .sym...")) {
System_BrowseForFile(reqToken_, "Load No$ symbol map", BrowseFileType::SYMBOL_MAP, [this](std::string_view responseString, int) {
Path path(responseString);
if (!g_symbolMap->LoadNocashSym(path)) {
ERROR_LOG(Log::Common, "Failed to load No$ symbol map");
}
disasm_.DirtySymbolMap();
});
if (ImGui::BeginMenu("OS HLE")) {
ImGui::MenuItem("HLE module browser", nullptr, &cfg_.hleModulesOpen);
ImGui::MenuItem("File System Browser", nullptr, &cfg_.filesystemBrowserOpen);
ImGui::MenuItem("Kernel Objects", nullptr, &cfg_.kernelObjectsOpen);
ImGui::MenuItem("Threads", nullptr, &cfg_.threadsOpen);
ImGui::MenuItem("Modules", nullptr, &cfg_.modulesOpen);
ImGui::MenuItem("Utility Modules", nullptr, &cfg_.utilityModulesOpen);
ImGui::EndMenu();
}
if (ImGui::MenuItem("Save No$ .sym...")) {
System_BrowseForFileSave(reqToken_, "Save No$ symbol map", "symbols.sym", BrowseFileType::SYMBOL_MAP, [](std::string_view responseString, int) {
Path path(responseString);
if (!g_symbolMap->SaveNocashSym(path)) {
ERROR_LOG(Log::Common, "Failed to save No$ symbol map");
}
});
if (ImGui::BeginMenu("Graphics")) {
ImGui::MenuItem("GE Debugger", nullptr, &cfg_.geDebuggerOpen);
ImGui::MenuItem("GE State", nullptr, &cfg_.geStateOpen);
ImGui::MenuItem("GE Vertices", nullptr, &cfg_.geVertsOpen);
ImGui::MenuItem("Display Output", nullptr, &cfg_.displayOpen);
ImGui::MenuItem("Textures", nullptr, &cfg_.texturesOpen);
ImGui::MenuItem("Framebuffers", nullptr, &cfg_.framebuffersOpen);
ImGui::MenuItem("Pixel Viewer", nullptr, &cfg_.pixelViewerOpen);
// More to come here...
ImGui::EndMenu();
}
ImGui::Separator();
ImGui::MenuItem("Compress .ppmap files", nullptr, &g_Config.bCompressSymbols);
if (ImGui::MenuItem("Reset symbol map")) {
g_symbolMap->Clear();
disasm_.DirtySymbolMap();
// NotifyDebuggerMapLoaded();
if (ImGui::BeginMenu("Audio/Video")) {
ImGui::MenuItem("SasAudio mixer", nullptr, &cfg_.sasAudioOpen);
ImGui::MenuItem("Raw audio channels", nullptr, &cfg_.audioChannelsOpen);
ImGui::MenuItem("AV Decoder contexts", nullptr, &cfg_.mediaDecodersOpen);
ImGui::Separator();
ImGui::MenuItem("Audio output / buffer", nullptr, &cfg_.audioOutOpen);
ImGui::EndMenu();
}
ImGui::EndMenu();
}
if (ImGui::BeginMenu("Memory")) {
for (int i = 0; i < 4; i++) {
char title[64];
snprintf(title, sizeof(title), "Memory %d", i + 1);
ImGui::MenuItem(title, nullptr, &cfg_.memViewOpen[i]);
if (ImGui::BeginMenu("Network")) {
ImGui::MenuItem("ApCtl", nullptr, &cfg_.apctlOpen);
ImGui::MenuItem("Sockets", nullptr, &cfg_.socketsOpen);
ImGui::MenuItem("NP", nullptr, &cfg_.npOpen);
ImGui::MenuItem("AdHoc", nullptr, &cfg_.adhocOpen);
ImGui::EndMenu();
}
ImGui::MenuItem("Memory Dumper", nullptr, &cfg_.memDumpOpen);
ImGui::EndMenu();
}
if (ImGui::BeginMenu("OS HLE")) {
ImGui::MenuItem("HLE module browser", nullptr, &cfg_.hleModulesOpen);
ImGui::MenuItem("File System Browser", nullptr, &cfg_.filesystemBrowserOpen);
ImGui::MenuItem("Kernel Objects", nullptr, &cfg_.kernelObjectsOpen);
ImGui::MenuItem("Threads", nullptr, &cfg_.threadsOpen);
ImGui::MenuItem("Modules", nullptr, &cfg_.modulesOpen);
ImGui::MenuItem("Utility Modules",nullptr, &cfg_.utilityModulesOpen);
ImGui::EndMenu();
}
if (ImGui::BeginMenu("Graphics")) {
ImGui::MenuItem("GE Debugger", nullptr, &cfg_.geDebuggerOpen);
ImGui::MenuItem("GE State", nullptr, &cfg_.geStateOpen);
ImGui::MenuItem("GE Vertices", nullptr, &cfg_.geVertsOpen);
ImGui::MenuItem("Display Output", nullptr, &cfg_.displayOpen);
ImGui::MenuItem("Textures", nullptr, &cfg_.texturesOpen);
ImGui::MenuItem("Framebuffers", nullptr, &cfg_.framebuffersOpen);
ImGui::MenuItem("Pixel Viewer", nullptr, &cfg_.pixelViewerOpen);
// More to come here...
ImGui::EndMenu();
}
if (ImGui::BeginMenu("Audio/Video")) {
ImGui::MenuItem("SasAudio mixer", nullptr, &cfg_.sasAudioOpen);
ImGui::MenuItem("Raw audio channels", nullptr, &cfg_.audioChannelsOpen);
ImGui::MenuItem("AV Decoder contexts", nullptr, &cfg_.mediaDecodersOpen);
ImGui::Separator();
ImGui::MenuItem("Audio output / buffer", nullptr, &cfg_.audioOutOpen);
ImGui::EndMenu();
}
if (ImGui::BeginMenu("Network")) {
ImGui::MenuItem("ApCtl", nullptr, &cfg_.apctlOpen);
ImGui::MenuItem("Sockets", nullptr, &cfg_.socketsOpen);
ImGui::MenuItem("NP", nullptr, &cfg_.npOpen);
ImGui::MenuItem("AdHoc", nullptr, &cfg_.adhocOpen);
ImGui::EndMenu();
}
if (ImGui::BeginMenu("Tools")) {
ImGui::MenuItem("Lua Console", nullptr, &cfg_.luaConsoleOpen);
ImGui::MenuItem("Log", nullptr, &cfg_.logOpen);
ImGui::MenuItem("Log channels", nullptr, &cfg_.logConfigOpen);
ImGui::MenuItem("Debug stats", nullptr, &cfg_.debugStatsOpen);
ImGui::Separator();
ImGui::MenuItem("ParamSFO viewer", nullptr, &cfg_.paramSFOOpen);
if (PSP_IsInited()) {
ImGui::MenuItem("ParamSFO viewer", nullptr, &cfg_.paramSFOOpen);
}
ImGui::MenuItem("Struct viewer", nullptr, &cfg_.structViewerOpen);
ImGui::MenuItem("Atrac Tool", nullptr, &cfg_.atracToolOpen);
ImGui::EndMenu();
@@ -2575,97 +2611,89 @@ void ImDebugger::Frame(MIPSDebugInterface *mipsDebug, GPUCommon *gpuDebug, Draw:
ImGui::ShowStyleEditor();
}
if (cfg_.disasmOpen) {
disasm_.Draw(mipsDebug, cfg_, control, coreState);
}
if (cfg_.gprOpen) {
DrawGPRs(cfg_, control, mipsDebug, snapshot_);
}
if (cfg_.fprOpen) {
DrawFPRs(cfg_, control, mipsDebug, snapshot_);
}
if (cfg_.vfpuOpen) {
DrawVFPU(cfg_, control, mipsDebug, snapshot_);
}
if (cfg_.breakpointsOpen) {
DrawBreakpointsView(mipsDebug, cfg_);
}
if (cfg_.filesystemBrowserOpen) {
DrawFilesystemBrowser(cfg_);
}
if (cfg_.audioChannelsOpen) {
DrawAudioChannels(cfg_, control);
}
if (cfg_.audioOutOpen) {
DrawAudioOut(cfg_, control);
}
if (cfg_.sasAudioOpen) {
DrawSasAudio(cfg_);
}
if (cfg_.kernelObjectsOpen) {
DrawKernelObjects(cfg_);
}
if (cfg_.threadsOpen) {
DrawThreadView(cfg_, control);
}
if (cfg_.callstackOpen) {
DrawCallStacks(mipsDebug, cfg_, control);
}
if (cfg_.modulesOpen) {
DrawModules(mipsDebug, cfg_, control);
}
if (cfg_.symbolsOpen) {
DrawSymbols(mipsDebug, cfg_, control);
}
if (cfg_.utilityModulesOpen) {
DrawUtilityModules(cfg_, control);
}
if (cfg_.mediaDecodersOpen) {
DrawMediaDecodersView(cfg_, control);
}
if (cfg_.hleModulesOpen) {
DrawHLEModules(cfg_);
}
if (cfg_.atracToolOpen) {
atracToolWindow_.Draw(cfg_);
}
if (gpuDebug) {
if (cfg_.framebuffersOpen) {
DrawFramebuffersWindow(cfg_, gpuDebug->GetFramebufferManagerCommon());
}
if (cfg_.texturesOpen) {
DrawTexturesWindow(cfg_, gpuDebug->GetTextureCacheCommon());
}
}
if (cfg_.logConfigOpen) {
DrawLogConfig(cfg_);
}
if (cfg_.logOpen) {
logWindow_.Draw(cfg_);
}
if (PSP_IsInited()) {
if (cfg_.disasmOpen) {
disasm_.Draw(mipsDebug, cfg_, control, coreState);
}
if (cfg_.gprOpen) {
DrawGPRs(cfg_, control, mipsDebug, snapshot_);
}
if (cfg_.fprOpen) {
DrawFPRs(cfg_, control, mipsDebug, snapshot_);
}
if (cfg_.vfpuOpen) {
DrawVFPU(cfg_, control, mipsDebug, snapshot_);
}
if (cfg_.breakpointsOpen) {
DrawBreakpointsView(mipsDebug, cfg_);
}
if (cfg_.filesystemBrowserOpen) {
DrawFilesystemBrowser(cfg_);
}
if (cfg_.audioChannelsOpen) {
DrawAudioChannels(cfg_, control);
}
if (cfg_.audioOutOpen) {
DrawAudioOut(cfg_, control);
}
if (cfg_.sasAudioOpen) {
DrawSasAudio(cfg_);
}
if (cfg_.kernelObjectsOpen) {
DrawKernelObjects(cfg_);
}
if (cfg_.threadsOpen) {
DrawThreadView(cfg_, control);
}
if (cfg_.callstackOpen) {
DrawCallStacks(mipsDebug, cfg_, control);
}
if (cfg_.modulesOpen) {
DrawModules(mipsDebug, cfg_, control);
}
if (cfg_.symbolsOpen) {
DrawSymbols(mipsDebug, cfg_, control);
}
if (cfg_.utilityModulesOpen) {
DrawUtilityModules(cfg_, control);
}
if (cfg_.mediaDecodersOpen) {
DrawMediaDecodersView(cfg_, control);
}
if (cfg_.hleModulesOpen) {
DrawHLEModules(cfg_);
}
if (cfg_.atracToolOpen) {
atracToolWindow_.Draw(cfg_);
}
if (gpuDebug) {
if (cfg_.framebuffersOpen) {
DrawFramebuffersWindow(cfg_, gpuDebug->GetFramebufferManagerCommon());
}
if (cfg_.texturesOpen) {
DrawTexturesWindow(cfg_, gpuDebug->GetTextureCacheCommon());
}
}
if (cfg_.jitViewerOpen) {
jitViewer_.Draw(cfg_, control);
}
@@ -2677,13 +2705,7 @@ void ImDebugger::Frame(MIPSDebugInterface *mipsDebug, GPUCommon *gpuDebug, Draw:
if (cfg_.debugStatsOpen) {
DrawDebugStatsWindow(cfg_);
}
}
if (cfg_.structViewerOpen) {
structViewer_.Draw(cfg_, control, mipsDebug);
}
if (PSP_IsInited()) {
if (cfg_.paramSFOOpen) {
DrawParamSFO(cfg_, control);
}
@@ -2743,6 +2765,18 @@ void ImDebugger::Frame(MIPSDebugInterface *mipsDebug, GPUCommon *gpuDebug, Draw:
}
}
if (cfg_.logConfigOpen) {
DrawLogConfig(cfg_);
}
if (cfg_.logOpen) {
logWindow_.Draw(cfg_);
}
if (cfg_.structViewerOpen) {
structViewer_.Draw(cfg_, control, mipsDebug);
}
if (cfg_.internalsOpen) {
DrawInternals(cfg_);
}