From e66516eb50a361ad45a0aa69fc0747eaf24cd156 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sat, 23 Nov 2024 00:17:00 +0100 Subject: [PATCH] ImDebugger: Add ability to rename function symbols --- Common/GPU/Vulkan/thin3d_vulkan.cpp | 3 +++ Common/GPU/thin3d.h | 2 +- Common/Log/ConsoleListener.cpp | 1 + GPU/Common/FramebufferManagerCommon.cpp | 2 ++ UI/ImDebugger/ImDebugger.cpp | 27 ++++++++++++++++++++----- UI/ImDebugger/ImDebugger.h | 2 ++ UI/ImDebugger/ImDisasmView.cpp | 2 +- ext/lua | 2 +- 8 files changed, 33 insertions(+), 8 deletions(-) diff --git a/Common/GPU/Vulkan/thin3d_vulkan.cpp b/Common/GPU/Vulkan/thin3d_vulkan.cpp index d485ccdfe9..ad64afe5e7 100644 --- a/Common/GPU/Vulkan/thin3d_vulkan.cpp +++ b/Common/GPU/Vulkan/thin3d_vulkan.cpp @@ -1723,6 +1723,9 @@ public: void UpdateTag(const char *newTag) override { buf_->UpdateTag(newTag); } + const char *Tag() const override { + return buf_->Tag(); + } private: VKRFramebuffer *buf_; }; diff --git a/Common/GPU/thin3d.h b/Common/GPU/thin3d.h index 2ef869e207..d2fe0d9222 100644 --- a/Common/GPU/thin3d.h +++ b/Common/GPU/thin3d.h @@ -457,7 +457,7 @@ public: int MultiSampleLevel() const { return multiSampleLevel_; } virtual void UpdateTag(const char *tag) {} - virtual const char *Tag() { return "(no name)"; } + virtual const char *Tag() const { return "(no name)"; } protected: int width_ = -1, height_ = -1, layers_ = 1, multiSampleLevel_ = 0; diff --git a/Common/Log/ConsoleListener.cpp b/Common/Log/ConsoleListener.cpp index e1c49461fe..c1428a8883 100644 --- a/Common/Log/ConsoleListener.cpp +++ b/Common/Log/ConsoleListener.cpp @@ -153,6 +153,7 @@ void ConsoleListener::Close() { if (thread_.joinable()) { logPendingWritePos_.store((u32)-1, std::memory_order_release); SetEvent(hTriggerEvent); + // If we seem hung here, it's just that you made a selection in the debug console, blocking output. thread_.join(); } if (hTriggerEvent) { diff --git a/GPU/Common/FramebufferManagerCommon.cpp b/GPU/Common/FramebufferManagerCommon.cpp index a1d09625fe..c658170964 100644 --- a/GPU/Common/FramebufferManagerCommon.cpp +++ b/GPU/Common/FramebufferManagerCommon.cpp @@ -3703,4 +3703,6 @@ void FramebufferManagerCommon::DrawImGuiDebug(int &selected) const { ImGui::PopID(); } ImGui::EndTable(); + + // Now, draw the actual framebuffer image. This could be refined a lot. } diff --git a/UI/ImDebugger/ImDebugger.cpp b/UI/ImDebugger/ImDebugger.cpp index 9e21c8c14b..022ec93b24 100644 --- a/UI/ImDebugger/ImDebugger.cpp +++ b/UI/ImDebugger/ImDebugger.cpp @@ -514,6 +514,7 @@ void ImDisasmWindow::Draw(MIPSDebugInterface *mipsDebug, bool *open, CoreState c if (ImGui::SmallButton("Search")) { // Open a small popup ImGui::OpenPopup("disSearch"); + ImGui::Shortcut(ImGuiKey_F | ImGuiMod_Ctrl); } ImGui::SameLine(); @@ -535,19 +536,35 @@ void ImDisasmWindow::Draw(MIPSDebugInterface *mipsDebug, bool *open, CoreState c ImGui::TableSetupColumn("right", ImGuiTableColumnFlags_WidthStretch); ImGui::TableNextRow(); ImGui::TableSetColumnIndex(0); + + if (symCache_.empty() || symsDirty_) { + symCache_ = g_symbolMap->GetAllSymbols(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(); + } + } + ImVec2 sz = ImGui::GetContentRegionAvail(); if (ImGui::BeginListBox("##symbols", ImVec2(150.0, sz.y - ImGui::GetTextLineHeightWithSpacing() * 2))) { - if (symCache_.empty() || symsDirty_) { - symCache_ = g_symbolMap->GetAllSymbols(SymbolType::ST_FUNCTION); - symsDirty_ = false; - } 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(), false)) { + 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; } } } diff --git a/UI/ImDebugger/ImDebugger.h b/UI/ImDebugger/ImDebugger.h index 5e70c02383..75aa976612 100644 --- a/UI/ImDebugger/ImDebugger.h +++ b/UI/ImDebugger/ImDebugger.h @@ -42,6 +42,8 @@ private: // Symbol cache std::vector symCache_; bool symsDirty_ = true; + int selectedSymbol_ = -1; + char selectedSymbolName_[128]; ImDisasmView disasmView_; char searchTerm_[64]{}; diff --git a/UI/ImDebugger/ImDisasmView.cpp b/UI/ImDebugger/ImDisasmView.cpp index 36a47931c7..e7c7b0561f 100644 --- a/UI/ImDebugger/ImDisasmView.cpp +++ b/UI/ImDebugger/ImDisasmView.cpp @@ -565,7 +565,7 @@ void ImDisasmView::ProcessKeyboardShortcuts() { if (io.KeyMods & ImGuiMod_Ctrl) { if (ImGui::IsKeyPressed(ImGuiKey_F)) { // Toggle the find popup - ImGui::OpenPopup("disSearch"); + // ImGui::OpenPopup("disSearch"); } if (ImGui::IsKeyPressed(ImGuiKey_C) || ImGui::IsKeyPressed(ImGuiKey_Insert)) { CopyInstructions(selectRangeStart_, selectRangeEnd_, CopyInstructionsMode::DISASM); diff --git a/ext/lua b/ext/lua index f3271af11a..7648485f14 160000 --- a/ext/lua +++ b/ext/lua @@ -1 +1 @@ -Subproject commit f3271af11ab8591164b871e36520a7210964f3f6 +Subproject commit 7648485f14e8e5ee45e8e39b1eb4d3206dbd405a