aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorlat9nq <lat9nq@gmail.com>2022-06-30 12:40:01 -0400
committerlat9nq <lat9nq@gmail.com>2022-06-30 12:47:40 -0400
commitf1ca3b7ff31025dae83e9977fcc8b37947bd1d5a (patch)
treeddf286ecf5ce028c6a7b2ee845b81cefeb4c5073 /src
parentd3da378c46e88b208ac839d1120bf4b99f32ff98 (diff)
gdbstub_arch: Directly access SP register
Currently to access the SP register, RegRead and RegWrite rely on a out-of-bounds array access to reach the next element in a struct. As of writing only git versions of GCC catch this error. Specify the SP register when we want to access it in these functions.
Diffstat (limited to 'src')
-rw-r--r--src/core/debugger/gdbstub_arch.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/core/debugger/gdbstub_arch.cpp b/src/core/debugger/gdbstub_arch.cpp
index 750c353b99..4bef09bd7f 100644
--- a/src/core/debugger/gdbstub_arch.cpp
+++ b/src/core/debugger/gdbstub_arch.cpp
@@ -191,8 +191,10 @@ std::string GDBStubA64::RegRead(const Kernel::KThread* thread, size_t id) const
const auto& gprs{context.cpu_registers};
const auto& fprs{context.vector_registers};
- if (id <= SP_REGISTER) {
+ if (id < SP_REGISTER) {
return ValueToHex(gprs[id]);
+ } else if (id == SP_REGISTER) {
+ return ValueToHex(context.sp);
} else if (id == PC_REGISTER) {
return ValueToHex(context.pc);
} else if (id == PSTATE_REGISTER) {
@@ -215,8 +217,10 @@ void GDBStubA64::RegWrite(Kernel::KThread* thread, size_t id, std::string_view v
auto& context{thread->GetContext64()};
- if (id <= SP_REGISTER) {
+ if (id < SP_REGISTER) {
context.cpu_registers[id] = HexToValue<u64>(value);
+ } else if (id == SP_REGISTER) {
+ context.sp = HexToValue<u64>(value);
} else if (id == PC_REGISTER) {
context.pc = HexToValue<u64>(value);
} else if (id == PSTATE_REGISTER) {