diff --git a/UI/ImDebugger/ImDebugger.cpp b/UI/ImDebugger/ImDebugger.cpp index bb445690e3..ec407ee1fd 100644 --- a/UI/ImDebugger/ImDebugger.cpp +++ b/UI/ImDebugger/ImDebugger.cpp @@ -2171,275 +2171,6 @@ void ImDebugger::SnapshotGPU(GPUDebugInterface *gpuDebug) { pixelViewer_.Snapshot(); } -void ImMemWindow::Draw(MIPSDebugInterface *mipsDebug, ImConfig &cfg, ImControl &control, int index) { - ImGui::SetNextWindowSize(ImVec2(520, 600), ImGuiCond_FirstUseEver); - if (!ImGui::Begin(Title(index), &cfg.memViewOpen[index])) { - ImGui::End(); - return; - } - - // Toolbars - - ImGui::InputScalar("Go to addr: ", ImGuiDataType_U32, &gotoAddr_, NULL, NULL, "%08X"); - if (ImGui::IsItemDeactivatedAfterEdit()) { - memView_.gotoAddr(gotoAddr_); - } - ImGui::SameLine(); - if (ImGui::SmallButton("Go")) { - memView_.gotoAddr(gotoAddr_); - } - - ImVec2 size(0, -ImGui::GetFrameHeightWithSpacing()); - - auto node = [&](const char *title, uint32_t start, uint32_t len) { - if (ImGui::TreeNode(title)) { - if (ImGui::Selectable("(start)", cfg.selectedMemoryBlock == start)) { - cfg.selectedMemoryBlock = start; - GotoAddr(start); - } - const std::vector info = FindMemInfo(start, len); - for (auto &iter : info) { - ImGui::PushID(iter.start); - if (ImGui::Selectable(iter.tag.c_str(), cfg.selectedMemoryBlock == iter.start)) { - cfg.selectedMemoryBlock = iter.start; - GotoAddr(iter.start); - } - ImGui::PopID(); - } - const u32 end = start + len; - if (ImGui::Selectable("(end)", cfg.selectedMemoryBlock == end)) { - cfg.selectedMemoryBlock = end; - GotoAddr(end); - } - ImGui::TreePop(); - } - }; - - // Main views - list of interesting addresses to the left, memory view to the right. - if (ImGui::BeginChild("addr_list", ImVec2(200.0f, size.y), ImGuiChildFlags_ResizeX)) { - node("Scratch", 0x00010000, 0x00004000); - node("Kernel RAM", 0x08000000, 0x00800000); - node("User RAM" , 0x08800000, 0x01800000); - node("VRAM", 0x04000000, 0x00200000); - } - - ImGui::EndChild(); - - ImGui::SameLine(); - if (ImGui::BeginChild("memview", size)) { - memView_.Draw(ImGui::GetWindowDrawList()); - } - ImGui::EndChild(); - - StatusBar(memView_.StatusMessage()); - - ImGui::End(); -} - -const char *ImMemWindow::Title(int index) { - static const char *const titles[4] = { "Memory 1", "Memory 2", "Memory 3", "Memory 4" }; - return titles[index]; -} - -void ImDisasmWindow::Draw(MIPSDebugInterface *mipsDebug, ImConfig &cfg, ImControl &control, CoreState coreState) { - disasmView_.setDebugger(mipsDebug); - - ImGui::SetNextWindowSize(ImVec2(520, 600), ImGuiCond_FirstUseEver); - if (!ImGui::Begin(Title(), &cfg.disasmOpen)) { - ImGui::End(); - return; - } - - if (ImGui::IsWindowFocused()) { - // Process stepping keyboard shortcuts. - if (ImGui::IsKeyPressed(ImGuiKey_F10)) { - u32 stepSize = disasmView_.getInstructionSizeAt(mipsDebug->GetPC()); - Core_RequestCPUStep(CPUStepType::Over, stepSize); - } - if (ImGui::IsKeyPressed(ImGuiKey_F11)) { - u32 stepSize = disasmView_.getInstructionSizeAt(mipsDebug->GetPC()); - Core_RequestCPUStep(CPUStepType::Into, stepSize); - } - } - - if (coreState == CORE_STEPPING_GE || coreState == CORE_RUNNING_GE) { - ImGui::Text("!!! Currently stepping the GE"); - ImGui::SameLine(); - if (ImGui::SmallButton("Open Ge Debugger")) { - cfg.geDebuggerOpen = true; - ImGui::SetWindowFocus("GE Debugger"); - } - } - - ImGui::BeginDisabled(coreState != CORE_STEPPING_CPU); - if (ImGui::SmallButton("Run")) { - Core_Resume(); - } - ImGui::EndDisabled(); - - ImGui::SameLine(); - ImGui::BeginDisabled(coreState != CORE_RUNNING_CPU); - if (ImGui::SmallButton("Pause")) { - Core_Break(BreakReason::DebugBreak); - } - ImGui::EndDisabled(); - - ImGui::BeginDisabled(coreState != CORE_STEPPING_CPU); - - ImGui::SameLine(); - ImGui::Text("Step: "); - ImGui::SameLine(); - - if (ImGui::SmallButton("Into")) { - u32 stepSize = disasmView_.getInstructionSizeAt(mipsDebug->GetPC()); - Core_RequestCPUStep(CPUStepType::Into, stepSize); - } - if (ImGui::IsItemHovered()) { - ImGui::SetTooltip("F11"); - } - - ImGui::SameLine(); - if (ImGui::SmallButton("Over")) { - u32 stepSize = disasmView_.getInstructionSizeAt(mipsDebug->GetPC()); - Core_RequestCPUStep(CPUStepType::Over, stepSize); - } - if (ImGui::IsItemHovered()) { - ImGui::SetTooltip("F10"); - } - - ImGui::SameLine(); - if (ImGui::SmallButton("Out")) { - Core_RequestCPUStep(CPUStepType::Out, 0); - } - - /* - ImGui::SameLine(); - if (ImGui::SmallButton("Frame")) { - Core_RequestCPUStep(CPUStepType::Frame, 0); - }*/ - - ImGui::SameLine(); - if (ImGui::SmallButton("Syscall")) { - hleDebugBreak(); - Core_Resume(); - } - - ImGui::SameLine(); - ImGui::SmallButton("Skim"); - if (ImGui::IsItemActive()) { - u32 stepSize = disasmView_.getInstructionSizeAt(mipsDebug->GetPC()); - Core_RequestCPUStep(CPUStepType::Into, stepSize); - } - - ImGui::EndDisabled(); - - ImGui::SameLine(); - if (ImGui::SmallButton("Goto PC")) { - disasmView_.GotoPC(); - } - ImGui::SameLine(); - if (ImGui::SmallButton("Goto RA")) { - disasmView_.GotoRA(); - } - - if (ImGui::BeginPopup("disSearch")) { - if (ImGui::IsWindowAppearing()) { - ImGui::SetKeyboardFocusHere(); - } - if (ImGui::InputText("Search", searchTerm_, sizeof(searchTerm_), ImGuiInputTextFlags_EnterReturnsTrue)) { - disasmView_.Search(searchTerm_); - ImGui::CloseCurrentPopup(); - } - ImGui::EndPopup(); - } - - ImGui::SameLine(); - if (ImGui::SmallButton("Search")) { - // Open a small popup - ImGui::OpenPopup("disSearch"); - ImGui::Shortcut(ImGuiKey_F | ImGuiMod_Ctrl); - } - - ImGui::SameLine(); - if (ImGui::SmallButton("Next")) { - disasmView_.SearchNext(true); - } - - ImGui::SameLine(); - if (ImGui::SmallButton("Settings")) { - ImGui::OpenPopup("disSettings"); - } - - if (ImGui::BeginPopup("disSettings")) { - ImGui::Checkbox("Follow PC", &disasmView_.followPC_); - ImGui::EndPopup(); - } - - ImGui::SetNextItemWidth(100); - if (ImGui::InputScalar("Go to addr: ", ImGuiDataType_U32, &gotoAddr_, NULL, NULL, "%08X")) { - disasmView_.setCurAddress(gotoAddr_); - disasmView_.scrollAddressIntoView(); - } - ImGui::SameLine(); - if (ImGui::Button("Go")) { - disasmView_.setCurAddress(gotoAddr_); - disasmView_.scrollAddressIntoView(); - } - - BreakReason breakReason = Core_BreakReason(); - ImGui::SameLine(); - ImGui::TextUnformatted(BreakReasonToString(breakReason)); - - ImVec2 avail = ImGui::GetContentRegionAvail(); - avail.y -= ImGui::GetTextLineHeightWithSpacing(); - - if (ImGui::BeginChild("left", ImVec2(150.0f, avail.y), ImGuiChildFlags_ResizeX)) { - if (symCache_.empty() || symsDirty_) { - symCache_ = g_symbolMap->GetAllActiveSymbols(SymbolType::ST_FUNCTION); - symsDirty_ = false; - } - - if (selectedSymbol_ >= 0 && selectedSymbol_ < symCache_.size()) { - auto &sym = symCache_[selectedSymbol_]; - if (ImGui::TreeNode("Edit Symbol", "Edit %s", sym.name.c_str())) { - if (ImGui::InputText("Name", selectedSymbolName_, sizeof(selectedSymbolName_), ImGuiInputTextFlags_EnterReturnsTrue)) { - g_symbolMap->SetLabelName(selectedSymbolName_, sym.address); - symsDirty_ = true; - } - ImGui::Text("%08x (size: %0d)", sym.address, sym.size); - ImGui::TreePop(); - } - } - - if (ImGui::BeginListBox("##symbols", ImGui::GetContentRegionAvail())) { - ImGuiListClipper clipper; - clipper.Begin((int)symCache_.size(), -1); - while (clipper.Step()) { - for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) { - if (ImGui::Selectable(symCache_[i].name.c_str(), selectedSymbol_ == i)) { - disasmView_.gotoAddr(symCache_[i].address); - disasmView_.scrollAddressIntoView(); - truncate_cpy(selectedSymbolName_, symCache_[i].name.c_str()); - selectedSymbol_ = i; - } - } - } - clipper.End(); - ImGui::EndListBox(); - } - } - ImGui::EndChild(); - - ImGui::SameLine(); - if (ImGui::BeginChild("right", ImVec2(0.0f, avail.y))) { - disasmView_.Draw(ImGui::GetWindowDrawList(), control); - } - ImGui::EndChild(); - - StatusBar(disasmView_.StatusBarText()); - ImGui::End(); -} - void ImDebugger::DeviceLost() { pixelViewer_.DeviceLost(); geDebugger_.DeviceLost(); diff --git a/UI/ImDebugger/ImDebugger.h b/UI/ImDebugger/ImDebugger.h index 9d7c29f7c0..a568cc884f 100644 --- a/UI/ImDebugger/ImDebugger.h +++ b/UI/ImDebugger/ImDebugger.h @@ -31,76 +31,6 @@ class MIPSDebugInterface; class GPUDebugInterface; struct ImConfig; -// Corresponds to the CDisasm dialog -class ImDisasmWindow { -public: - void Draw(MIPSDebugInterface *mipsDebug, ImConfig &cfg, ImControl &control, CoreState coreState); - ImDisasmView &View() { - return disasmView_; - } - void NotifyStep() { - disasmView_.NotifyStep(); - } - void DirtySymbolMap() { - symsDirty_ = true; - } - const char *Title() const { - return "CPU Debugger"; - } - -private: - // We just keep the state directly in the window. Can refactor later. - - enum { - INVALID_ADDR = 0xFFFFFFFF, - }; - - u32 gotoAddr_ = 0x08800000; - - // Symbol cache - std::vector symCache_; - bool symsDirty_ = true; - int selectedSymbol_ = -1; - char selectedSymbolName_[128]; - - ImDisasmView disasmView_; - char searchTerm_[64]{}; -}; - -// Corresponds to the CMemView dialog -class ImMemWindow { -public: - void Draw(MIPSDebugInterface *mipsDebug, ImConfig &cfg, ImControl &control, int index); - ImMemView &View() { - return memView_; - } - void DirtySymbolMap() { - symsDirty_ = true; - } - void GotoAddr(u32 addr) { - gotoAddr_ = addr; - memView_.gotoAddr(addr); - } - static const char *Title(int index); - -private: - // We just keep the state directly in the window. Can refactor later. - enum { - INVALID_ADDR = 0xFFFFFFFF, - }; - - // Symbol cache - std::vector symCache_; - bool symsDirty_ = true; - int selectedSymbol_ = -1; - char selectedSymbolName_[128]; - - ImMemView memView_; - char searchTerm_[64]{}; - - u32 gotoAddr_ = 0x08800000; -}; - // Snapshot of the MIPS CPU and other things we want to show diffs off. struct ImSnapshotState { u32 gpr[32]; diff --git a/UI/ImDebugger/ImDisasmView.cpp b/UI/ImDebugger/ImDisasmView.cpp index 85736b79ee..a720b4b9da 100644 --- a/UI/ImDebugger/ImDisasmView.cpp +++ b/UI/ImDebugger/ImDisasmView.cpp @@ -5,6 +5,7 @@ #include "Common/Log.h" #include "Common/Math/geom2d.h" #include "Core/Core.h" +#include "Core/HLE/HLE.h" #include "Core/Debugger/DebugInterface.h" #include "Core/Debugger/DisassemblyManager.h" #include "Core/Debugger/Breakpoints.h" @@ -1152,3 +1153,203 @@ u32 ImDisasmView::getInstructionSizeAt(u32 address) { u32 next = g_disassemblyManager.getNthNextAddress(start, 1); return next - address; } + + +void ImDisasmWindow::Draw(MIPSDebugInterface *mipsDebug, ImConfig &cfg, ImControl &control, CoreState coreState) { + disasmView_.setDebugger(mipsDebug); + + ImGui::SetNextWindowSize(ImVec2(520, 600), ImGuiCond_FirstUseEver); + if (!ImGui::Begin(Title(), &cfg.disasmOpen)) { + ImGui::End(); + return; + } + + if (ImGui::IsWindowFocused()) { + // Process stepping keyboard shortcuts. + if (ImGui::IsKeyPressed(ImGuiKey_F10)) { + u32 stepSize = disasmView_.getInstructionSizeAt(mipsDebug->GetPC()); + Core_RequestCPUStep(CPUStepType::Over, stepSize); + } + if (ImGui::IsKeyPressed(ImGuiKey_F11)) { + u32 stepSize = disasmView_.getInstructionSizeAt(mipsDebug->GetPC()); + Core_RequestCPUStep(CPUStepType::Into, stepSize); + } + } + + if (coreState == CORE_STEPPING_GE || coreState == CORE_RUNNING_GE) { + ImGui::Text("!!! Currently stepping the GE"); + ImGui::SameLine(); + if (ImGui::SmallButton("Open Ge Debugger")) { + cfg.geDebuggerOpen = true; + ImGui::SetWindowFocus("GE Debugger"); + } + } + + ImGui::BeginDisabled(coreState != CORE_STEPPING_CPU); + if (ImGui::SmallButton("Run")) { + Core_Resume(); + } + ImGui::EndDisabled(); + + ImGui::SameLine(); + ImGui::BeginDisabled(coreState != CORE_RUNNING_CPU); + if (ImGui::SmallButton("Pause")) { + Core_Break(BreakReason::DebugBreak); + } + ImGui::EndDisabled(); + + ImGui::BeginDisabled(coreState != CORE_STEPPING_CPU); + + ImGui::SameLine(); + ImGui::Text("Step: "); + ImGui::SameLine(); + + if (ImGui::SmallButton("Into")) { + u32 stepSize = disasmView_.getInstructionSizeAt(mipsDebug->GetPC()); + Core_RequestCPUStep(CPUStepType::Into, stepSize); + } + if (ImGui::IsItemHovered()) { + ImGui::SetTooltip("F11"); + } + + ImGui::SameLine(); + if (ImGui::SmallButton("Over")) { + u32 stepSize = disasmView_.getInstructionSizeAt(mipsDebug->GetPC()); + Core_RequestCPUStep(CPUStepType::Over, stepSize); + } + if (ImGui::IsItemHovered()) { + ImGui::SetTooltip("F10"); + } + + ImGui::SameLine(); + if (ImGui::SmallButton("Out")) { + Core_RequestCPUStep(CPUStepType::Out, 0); + } + + /* + ImGui::SameLine(); + if (ImGui::SmallButton("Frame")) { + Core_RequestCPUStep(CPUStepType::Frame, 0); + }*/ + + ImGui::SameLine(); + if (ImGui::SmallButton("Syscall")) { + hleDebugBreak(); + Core_Resume(); + } + + ImGui::SameLine(); + ImGui::SmallButton("Skim"); + if (ImGui::IsItemActive()) { + u32 stepSize = disasmView_.getInstructionSizeAt(mipsDebug->GetPC()); + Core_RequestCPUStep(CPUStepType::Into, stepSize); + } + + ImGui::EndDisabled(); + + ImGui::SameLine(); + if (ImGui::SmallButton("Goto PC")) { + disasmView_.GotoPC(); + } + ImGui::SameLine(); + if (ImGui::SmallButton("Goto RA")) { + disasmView_.GotoRA(); + } + + if (ImGui::BeginPopup("disSearch")) { + if (ImGui::IsWindowAppearing()) { + ImGui::SetKeyboardFocusHere(); + } + if (ImGui::InputText("Search", searchTerm_, sizeof(searchTerm_), ImGuiInputTextFlags_EnterReturnsTrue)) { + disasmView_.Search(searchTerm_); + ImGui::CloseCurrentPopup(); + } + ImGui::EndPopup(); + } + + ImGui::SameLine(); + if (ImGui::SmallButton("Search")) { + // Open a small popup + ImGui::OpenPopup("disSearch"); + ImGui::Shortcut(ImGuiKey_F | ImGuiMod_Ctrl); + } + + ImGui::SameLine(); + if (ImGui::SmallButton("Next")) { + disasmView_.SearchNext(true); + } + + ImGui::SameLine(); + if (ImGui::SmallButton("Settings")) { + ImGui::OpenPopup("disSettings"); + } + + if (ImGui::BeginPopup("disSettings")) { + ImGui::Checkbox("Follow PC", &disasmView_.followPC_); + ImGui::EndPopup(); + } + + ImGui::SetNextItemWidth(100); + if (ImGui::InputScalar("Go to addr: ", ImGuiDataType_U32, &gotoAddr_, NULL, NULL, "%08X")) { + disasmView_.setCurAddress(gotoAddr_); + disasmView_.scrollAddressIntoView(); + } + ImGui::SameLine(); + if (ImGui::Button("Go")) { + disasmView_.setCurAddress(gotoAddr_); + disasmView_.scrollAddressIntoView(); + } + + BreakReason breakReason = Core_BreakReason(); + ImGui::SameLine(); + ImGui::TextUnformatted(BreakReasonToString(breakReason)); + + ImVec2 avail = ImGui::GetContentRegionAvail(); + avail.y -= ImGui::GetTextLineHeightWithSpacing(); + + if (ImGui::BeginChild("left", ImVec2(150.0f, avail.y), ImGuiChildFlags_ResizeX)) { + if (symCache_.empty() || symsDirty_) { + symCache_ = g_symbolMap->GetAllActiveSymbols(SymbolType::ST_FUNCTION); + symsDirty_ = false; + } + + if (selectedSymbol_ >= 0 && selectedSymbol_ < symCache_.size()) { + auto &sym = symCache_[selectedSymbol_]; + if (ImGui::TreeNode("Edit Symbol", "Edit %s", sym.name.c_str())) { + if (ImGui::InputText("Name", selectedSymbolName_, sizeof(selectedSymbolName_), ImGuiInputTextFlags_EnterReturnsTrue)) { + g_symbolMap->SetLabelName(selectedSymbolName_, sym.address); + symsDirty_ = true; + } + ImGui::Text("%08x (size: %0d)", sym.address, sym.size); + ImGui::TreePop(); + } + } + + if (ImGui::BeginListBox("##symbols", ImGui::GetContentRegionAvail())) { + ImGuiListClipper clipper; + clipper.Begin((int)symCache_.size(), -1); + while (clipper.Step()) { + for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) { + if (ImGui::Selectable(symCache_[i].name.c_str(), selectedSymbol_ == i)) { + disasmView_.gotoAddr(symCache_[i].address); + disasmView_.scrollAddressIntoView(); + truncate_cpy(selectedSymbolName_, symCache_[i].name.c_str()); + selectedSymbol_ = i; + } + } + } + clipper.End(); + ImGui::EndListBox(); + } + } + ImGui::EndChild(); + + ImGui::SameLine(); + if (ImGui::BeginChild("right", ImVec2(0.0f, avail.y))) { + disasmView_.Draw(ImGui::GetWindowDrawList(), control); + } + ImGui::EndChild(); + + StatusBar(disasmView_.StatusBarText()); + ImGui::End(); +} diff --git a/UI/ImDebugger/ImDisasmView.h b/UI/ImDebugger/ImDisasmView.h index f859e3a4f0..b092c1df69 100644 --- a/UI/ImDebugger/ImDisasmView.h +++ b/UI/ImDebugger/ImDisasmView.h @@ -174,3 +174,39 @@ private: u32 funcBegin_ = 0; char funcNameTemp_[128]{}; }; + +// Corresponds to the CDisasm dialog +class ImDisasmWindow { +public: + void Draw(MIPSDebugInterface *mipsDebug, ImConfig &cfg, ImControl &control, CoreState coreState); + ImDisasmView &View() { + return disasmView_; + } + void NotifyStep() { + disasmView_.NotifyStep(); + } + void DirtySymbolMap() { + symsDirty_ = true; + } + const char *Title() const { + return "CPU Debugger"; + } + +private: + // We just keep the state directly in the window. Can refactor later. + + enum { + INVALID_ADDR = 0xFFFFFFFF, + }; + + u32 gotoAddr_ = 0x08800000; + + // Symbol cache + std::vector symCache_; + bool symsDirty_ = true; + int selectedSymbol_ = -1; + char selectedSymbolName_[128]; + + ImDisasmView disasmView_; + char searchTerm_[64]{}; +}; diff --git a/UI/ImDebugger/ImMemView.cpp b/UI/ImDebugger/ImMemView.cpp index b353fdb720..881d81179a 100644 --- a/UI/ImDebugger/ImMemView.cpp +++ b/UI/ImDebugger/ImMemView.cpp @@ -893,3 +893,73 @@ void ImMemDumpWindow::Draw(ImConfig &cfg, MIPSDebugInterface *debug) { ImGui::End(); } + +void ImMemWindow::Draw(MIPSDebugInterface *mipsDebug, ImConfig &cfg, ImControl &control, int index) { + ImGui::SetNextWindowSize(ImVec2(520, 600), ImGuiCond_FirstUseEver); + if (!ImGui::Begin(Title(index), &cfg.memViewOpen[index])) { + ImGui::End(); + return; + } + + // Toolbars + + ImGui::InputScalar("Go to addr: ", ImGuiDataType_U32, &gotoAddr_, NULL, NULL, "%08X"); + if (ImGui::IsItemDeactivatedAfterEdit()) { + memView_.gotoAddr(gotoAddr_); + } + ImGui::SameLine(); + if (ImGui::SmallButton("Go")) { + memView_.gotoAddr(gotoAddr_); + } + + ImVec2 size(0, -ImGui::GetFrameHeightWithSpacing()); + + auto node = [&](const char *title, uint32_t start, uint32_t len) { + if (ImGui::TreeNode(title)) { + if (ImGui::Selectable("(start)", cfg.selectedMemoryBlock == start)) { + cfg.selectedMemoryBlock = start; + GotoAddr(start); + } + const std::vector info = FindMemInfo(start, len); + for (auto &iter : info) { + ImGui::PushID(iter.start); + if (ImGui::Selectable(iter.tag.c_str(), cfg.selectedMemoryBlock == iter.start)) { + cfg.selectedMemoryBlock = iter.start; + GotoAddr(iter.start); + } + ImGui::PopID(); + } + const u32 end = start + len; + if (ImGui::Selectable("(end)", cfg.selectedMemoryBlock == end)) { + cfg.selectedMemoryBlock = end; + GotoAddr(end); + } + ImGui::TreePop(); + } + }; + + // Main views - list of interesting addresses to the left, memory view to the right. + if (ImGui::BeginChild("addr_list", ImVec2(200.0f, size.y), ImGuiChildFlags_ResizeX)) { + node("Scratch", 0x00010000, 0x00004000); + node("Kernel RAM", 0x08000000, 0x00800000); + node("User RAM", 0x08800000, 0x01800000); + node("VRAM", 0x04000000, 0x00200000); + } + + ImGui::EndChild(); + + ImGui::SameLine(); + if (ImGui::BeginChild("memview", size)) { + memView_.Draw(ImGui::GetWindowDrawList()); + } + ImGui::EndChild(); + + StatusBar(memView_.StatusMessage()); + + ImGui::End(); +} + +const char *ImMemWindow::Title(int index) { + static const char *const titles[4] = { "Memory 1", "Memory 2", "Memory 3", "Memory 4" }; + return titles[index]; +} diff --git a/UI/ImDebugger/ImMemView.h b/UI/ImDebugger/ImMemView.h index 750f64aa1c..eafcbad267 100644 --- a/UI/ImDebugger/ImMemView.h +++ b/UI/ImDebugger/ImMemView.h @@ -148,3 +148,37 @@ private: char filename_[1024]; std::string errorMsg_; }; + +// Corresponds to the CMemView dialog +class ImMemWindow { +public: + void Draw(MIPSDebugInterface *mipsDebug, ImConfig &cfg, ImControl &control, int index); + ImMemView &View() { + return memView_; + } + void DirtySymbolMap() { + symsDirty_ = true; + } + void GotoAddr(u32 addr) { + gotoAddr_ = addr; + memView_.gotoAddr(addr); + } + static const char *Title(int index); + +private: + // We just keep the state directly in the window. Can refactor later. + enum { + INVALID_ADDR = 0xFFFFFFFF, + }; + + // Symbol cache + std::vector symCache_; + bool symsDirty_ = true; + int selectedSymbol_ = -1; + char selectedSymbolName_[128]; + + ImMemView memView_; + char searchTerm_[64]{}; + + u32 gotoAddr_ = 0x08800000; +};