From 0753d537676a9df2ca43ffd54fd8989d3b4fd86e Mon Sep 17 00:00:00 2001 From: Fire Cube Date: Wed, 21 May 2025 22:37:16 +0200 Subject: [PATCH] impl --- CMakeLists.txt | 2 + src/core/devtools/layer.cpp | 8 ++++ src/core/devtools/widget/module_list.cpp | 51 ++++++++++++++++++++++++ src/core/devtools/widget/module_list.h | 47 ++++++++++++++++++++++ src/core/linker.cpp | 4 ++ 5 files changed, 112 insertions(+) create mode 100644 src/core/devtools/widget/module_list.cpp create mode 100644 src/core/devtools/widget/module_list.h diff --git a/CMakeLists.txt b/CMakeLists.txt index ef2425aff..423b413d7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -621,6 +621,8 @@ set(DEV_TOOLS src/core/devtools/layer.cpp src/core/devtools/widget/imgui_memory_editor.h src/core/devtools/widget/memory_map.cpp src/core/devtools/widget/memory_map.h + src/core/devtools/widget/module_list.cpp + src/core/devtools/widget/module_list.h src/core/devtools/widget/reg_popup.cpp src/core/devtools/widget/reg_popup.h src/core/devtools/widget/reg_view.cpp diff --git a/src/core/devtools/layer.cpp b/src/core/devtools/layer.cpp index a93178de5..cc14b0f7a 100644 --- a/src/core/devtools/layer.cpp +++ b/src/core/devtools/layer.cpp @@ -18,6 +18,7 @@ #include "widget/frame_graph.h" #include "widget/memory_map.h" #include "widget/shader_list.h" +#include "widget/module_list.h" extern std::unique_ptr presenter; @@ -40,6 +41,7 @@ static bool just_opened_options = false; static Widget::MemoryMapViewer memory_map; static Widget::ShaderList shader_list; +static Widget::ModuleList module_list; // clang-format off static std::string help_text = @@ -108,6 +110,9 @@ void L::DrawMenuBar() { if (MenuItem("Memory map")) { memory_map.open = true; } + if (MenuItem("Module list")) { + module_list.open = true; + } ImGui::EndMenu(); } @@ -256,6 +261,9 @@ void L::DrawAdvanced() { if (shader_list.open) { shader_list.Draw(); } + if (module_list.open) { + module_list.Draw(); + } } void L::DrawSimple() { diff --git a/src/core/devtools/widget/module_list.cpp b/src/core/devtools/widget/module_list.cpp new file mode 100644 index 000000000..ea08d9607 --- /dev/null +++ b/src/core/devtools/widget/module_list.cpp @@ -0,0 +1,51 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "module_list.h" + +#include + +#include "common.h" +#include "core/debug_state.h" +#include "imgui/imgui_std.h" + +using namespace ImGui; + +namespace Core::Devtools::Widget { + +void ModuleList::Draw() { + { + std::scoped_lock lock(s_modules_mutex); + modules.clear(); + for (const auto& entry : s_modules) { + ModuleInfo info; + info.name = entry.name; + modules.push_back(info); + } + } + + SetNextWindowSize({500.0f, 600.0f}, ImGuiCond_FirstUseEver); + if (!Begin("LLE Module List", &open)) { + End(); + return; + } + + if (BeginTable("ModuleTable", 1, + ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable | ImGuiTableFlags_Sortable | + ImGuiTableFlags_RowBg)) { + TableSetupColumn("Modulname", ImGuiTableColumnFlags_WidthStretch); + TableHeadersRow(); + + for (const auto& module : modules) { + TableNextRow(); + + TableSetColumnIndex(0); + TextUnformatted(module.name.c_str()); + } + EndTable(); + } + + End(); +} + +} // namespace Core::Devtools::Widget \ No newline at end of file diff --git a/src/core/devtools/widget/module_list.h b/src/core/devtools/widget/module_list.h new file mode 100644 index 000000000..2e2dcd6f8 --- /dev/null +++ b/src/core/devtools/widget/module_list.h @@ -0,0 +1,47 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include +#include +#include +#include +#include + +namespace Core::Devtools::Widget { + +class ModuleList { +public: + ModuleList() = default; + ~ModuleList() = default; + + void Draw(); + bool open = false; + char search_box[256] = ""; + + static void AddModule(const std::string& name) { + if (name == "eboot.bin") { + return; + } + std::scoped_lock lock(s_modules_mutex); + s_modules.push_back({name}); + } + +private: + + struct ModuleInfo { + std::string name; + }; + + struct ModuleListEntry { + std::string name; + }; + + static inline std::vector s_modules; + static inline std::mutex s_modules_mutex; + + std::vector modules; +}; + +} // namespace Core::Devtools::Widget \ No newline at end of file diff --git a/src/core/linker.cpp b/src/core/linker.cpp index eced87968..15115f0f0 100644 --- a/src/core/linker.cpp +++ b/src/core/linker.cpp @@ -12,6 +12,7 @@ #include "common/thread.h" #include "core/aerolib/aerolib.h" #include "core/aerolib/stubs.h" +#include "core/devtools/widget/module_list.h" #include "core/libraries/kernel/memory.h" #include "core/libraries/kernel/threads.h" #include "core/linker.h" @@ -147,6 +148,9 @@ s32 Linker::LoadModule(const std::filesystem::path& elf_name, bool is_dynamic) { num_static_modules += !is_dynamic; m_modules.emplace_back(std::move(module)); + + Core::Devtools::Widget::ModuleList::AddModule(elf_name.filename().string()); + return m_modules.size() - 1; }