summaryrefslogtreecommitdiffstats
path: root/src/core/debugger/gdbstub.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/debugger/gdbstub.cpp')
-rw-r--r--src/core/debugger/gdbstub.cpp54
1 files changed, 37 insertions, 17 deletions
diff --git a/src/core/debugger/gdbstub.cpp b/src/core/debugger/gdbstub.cpp
index a64a9ac64..945ec528e 100644
--- a/src/core/debugger/gdbstub.cpp
+++ b/src/core/debugger/gdbstub.cpp
@@ -11,6 +11,7 @@
#include "common/hex_util.h"
#include "common/logging/log.h"
#include "common/scope_exit.h"
+#include "common/settings.h"
#include "core/arm/arm_interface.h"
#include "core/core.h"
#include "core/debugger/gdbstub.h"
@@ -95,7 +96,7 @@ static std::string EscapeXML(std::string_view data) {
GDBStub::GDBStub(DebuggerBackend& backend_, Core::System& system_)
: DebuggerFrontend(backend_), system{system_} {
- if (system.CurrentProcess()->Is64BitProcess()) {
+ if (system.ApplicationProcess()->Is64BitProcess()) {
arch = std::make_unique<GDBStubA64>();
} else {
arch = std::make_unique<GDBStubA32>();
@@ -339,15 +340,15 @@ void GDBStub::HandleBreakpointInsert(std::string_view command) {
success = true;
break;
case BreakpointType::WriteWatch:
- success = system.CurrentProcess()->InsertWatchpoint(system, addr, size,
- Kernel::DebugWatchpointType::Write);
+ success = system.ApplicationProcess()->InsertWatchpoint(system, addr, size,
+ Kernel::DebugWatchpointType::Write);
break;
case BreakpointType::ReadWatch:
- success = system.CurrentProcess()->InsertWatchpoint(system, addr, size,
- Kernel::DebugWatchpointType::Read);
+ success = system.ApplicationProcess()->InsertWatchpoint(system, addr, size,
+ Kernel::DebugWatchpointType::Read);
break;
case BreakpointType::AccessWatch:
- success = system.CurrentProcess()->InsertWatchpoint(
+ success = system.ApplicationProcess()->InsertWatchpoint(
system, addr, size, Kernel::DebugWatchpointType::ReadOrWrite);
break;
case BreakpointType::Hardware:
@@ -390,15 +391,15 @@ void GDBStub::HandleBreakpointRemove(std::string_view command) {
break;
}
case BreakpointType::WriteWatch:
- success = system.CurrentProcess()->RemoveWatchpoint(system, addr, size,
- Kernel::DebugWatchpointType::Write);
+ success = system.ApplicationProcess()->RemoveWatchpoint(system, addr, size,
+ Kernel::DebugWatchpointType::Write);
break;
case BreakpointType::ReadWatch:
- success = system.CurrentProcess()->RemoveWatchpoint(system, addr, size,
- Kernel::DebugWatchpointType::Read);
+ success = system.ApplicationProcess()->RemoveWatchpoint(system, addr, size,
+ Kernel::DebugWatchpointType::Read);
break;
case BreakpointType::AccessWatch:
- success = system.CurrentProcess()->RemoveWatchpoint(
+ success = system.ApplicationProcess()->RemoveWatchpoint(
system, addr, size, Kernel::DebugWatchpointType::ReadOrWrite);
break;
case BreakpointType::Hardware:
@@ -481,7 +482,7 @@ static std::optional<std::string> GetNameFromThreadType64(Core::Memory::Memory&
static std::optional<std::string> GetThreadName(Core::System& system,
const Kernel::KThread* thread) {
- if (system.CurrentProcess()->Is64BitProcess()) {
+ if (system.ApplicationProcess()->Is64BitProcess()) {
return GetNameFromThreadType64(system.Memory(), thread);
} else {
return GetNameFromThreadType32(system.Memory(), thread);
@@ -554,7 +555,7 @@ void GDBStub::HandleQuery(std::string_view command) {
SendReply(fmt::format("TextSeg={:x}", main->first));
} else {
SendReply(fmt::format("TextSeg={:x}",
- system.CurrentProcess()->PageTable().GetCodeRegionStart()));
+ system.ApplicationProcess()->PageTable().GetCodeRegionStart()));
}
} else if (command.starts_with("Xfer:libraries:read::")) {
Loader::AppLoader::Modules modules;
@@ -728,10 +729,28 @@ void GDBStub::HandleRcmd(const std::vector<u8>& command) {
std::string_view command_str{reinterpret_cast<const char*>(&command[0]), command.size()};
std::string reply;
- auto* process = system.CurrentProcess();
+ auto* process = system.ApplicationProcess();
auto& page_table = process->PageTable();
- if (command_str == "get info") {
+ const char* commands = "Commands:\n"
+ " get fastmem\n"
+ " get info\n"
+ " get mappings\n";
+
+ if (command_str == "get fastmem") {
+ if (Settings::IsFastmemEnabled()) {
+ const auto& impl = page_table.PageTableImpl();
+ const auto region = reinterpret_cast<uintptr_t>(impl.fastmem_arena);
+ const auto region_bits = impl.current_address_space_width_in_bits;
+ const auto region_size = 1ULL << region_bits;
+
+ reply = fmt::format("Region bits: {}\n"
+ "Host address: {:#x} - {:#x}\n",
+ region_bits, region, region + region_size - 1);
+ } else {
+ reply = "Fastmem is not enabled.\n";
+ }
+ } else if (command_str == "get info") {
Loader::AppLoader::Modules modules;
system.GetAppLoader().ReadNSOModules(modules);
@@ -787,9 +806,10 @@ void GDBStub::HandleRcmd(const std::vector<u8>& command) {
cur_addr = next_address;
}
} else if (command_str == "help") {
- reply = "Commands:\n get info\n get mappings\n";
+ reply = commands;
} else {
- reply = "Unknown command.\nCommands:\n get info\n get mappings\n";
+ reply = "Unknown command.\n";
+ reply += commands;
}
std::span<const u8> reply_span{reinterpret_cast<u8*>(&reply.front()), reply.size()};