aboutsummaryrefslogtreecommitdiff
path: root/src/core/debugger/gdbstub.cpp
diff options
context:
space:
mode:
authorTakoroka <137927095+Takoroka@users.noreply.github.com>2026-10-28 12:31:45 -0400
committerTakoroka <137927095+Takoroka@users.noreply.github.com>2026-10-28 12:31:45 -0400
commitdb57ec047ba0e0fd73224b86736a4b40d425b802 (patch)
treecbcc976e0c8c54babc6fab14b0da28cf87a86e8c /src/core/debugger/gdbstub.cpp
parentb4268e6e67e6f4e11e0a5548b364f108fbaeabb1 (diff)
debugger: monitor handles lists each handle's type and service event name
gdbrsp.py gains raw and monitor commands.
Diffstat (limited to 'src/core/debugger/gdbstub.cpp')
-rw-r--r--src/core/debugger/gdbstub.cpp23
1 files changed, 22 insertions, 1 deletions
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<u8>& 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<Kernel::KReadableEvent*>(); readable != nullptr) {
+ name = Service::KernelHelpers::ServiceContext::GetEventName(readable->GetParent());
+ } else if (auto* event = object->DynamicCast<Kernel::KEvent*>(); 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<const u8> reply_span{reinterpret_cast<u8*>(&reply.front()), reply.size()};