From db57ec047ba0e0fd73224b86736a4b40d425b802 Mon Sep 17 00:00:00 2001 From: Takoroka <137927095+Takoroka@users.noreply.github.com> Date: Wed, 28 Oct 2026 12:31:45 -0400 Subject: debugger: monitor handles lists each handle's type and service event name gdbrsp.py gains raw and monitor commands. --- src/core/debugger/gdbstub.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'src/core/debugger/gdbstub.cpp') diff --git a/src/core/debugger/gdbstub.cpp b/src/core/debugger/gdbstub.cpp index 44ddf11c39..71af2acee3 100644 --- a/src/core/debugger/gdbstub.cpp +++ b/src/core/debugger/gdbstub.cpp @@ -25,7 +25,10 @@ #include "core/debugger/gdbstub_arch.h" #include "core/hle/kernel/k_page_table.h" #include "core/hle/kernel/k_process.h" +#include "core/hle/kernel/k_event.h" +#include "core/hle/kernel/k_readable_event.h" #include "core/hle/kernel/k_thread.h" +#include "core/hle/service/kernel_helpers.h" #include "core/loader/loader.h" #include "core/memory.h" @@ -731,8 +734,26 @@ void GDBStub::HandleRcmd(const std::vector& command) { break; cur_addr = next_address; } + } else if (command_str == "handles" || command_str == "get handles") { + // Every handle of the process: its object type and, for service events, their name. + reply = "Handles:\n"; + auto& handle_table = debug_process->GetHandleTable(); + for (size_t i = 0; i < handle_table.GetTableSize(); ++i) { + Kernel::Handle handle{}; + auto object = handle_table.GetObjectByIndex(system.Kernel(), std::addressof(handle), i); + if (object.IsNull()) { + continue; + } + std::string name; + if (auto* readable = object->DynamicCast(); readable != nullptr) { + name = Service::KernelHelpers::ServiceContext::GetEventName(readable->GetParent()); + } else if (auto* event = object->DynamicCast(); event != nullptr) { + name = Service::KernelHelpers::ServiceContext::GetEventName(event); + } + reply += fmt::format(" {:#010x} {} {}\n", handle, object->GetTypeObj().GetName(), name); + } } else { - reply += "Commands: fastmem, info, mappings\n"; + reply += "Commands: fastmem, info, mappings, handles\n"; } std::span reply_span{reinterpret_cast(&reply.front()), reply.size()}; -- cgit v1.2.3