diff --git a/thermosphere/src/gdb/hvisor_gdb_defines_internal.hpp b/thermosphere/src/gdb/hvisor_gdb_defines_internal.hpp index 4bfc7e6cf..453079a80 100644 --- a/thermosphere/src/gdb/hvisor_gdb_defines_internal.hpp +++ b/thermosphere/src/gdb/hvisor_gdb_defines_internal.hpp @@ -30,17 +30,19 @@ // IDA seems to want additional bytes as well. // 1024 is fine enough to put all regs in the 'T' stop reply packets // Add 4 to this for the actual allocated size, for $#, see below. -#define GDB_BUF_LEN 0x800 -#define GDB_WORK_BUF_LEN 0x1000 +#define GDB_BUF_LEN 0x800 +#define GDB_WORK_BUF_LEN 0x1000 -#define GDB_HANDLER(name) Handle##name -#define GDB_QUERY_HANDLER(name) GDB_HANDLER(Query##name) -#define GDB_VERBOSE_HANDLER(name) GDB_HANDLER(Verbose##name) -#define GDB_REMOTE_COMMAND_HANDLER(name) GDB_HANDLER(RemoteCommand##name) -#define GDB_XFER_HANDLER(name) GDB_HANDLER(Xfer##name) +#define GDB_HANDLER(name) Handle##name +#define GDB_QUERY_HANDLER(name) GDB_HANDLER(Query##name) +#define GDB_VERBOSE_HANDLER(name) GDB_HANDLER(Verbose##name) +#define GDB_REMOTE_COMMAND_HANDLER(name) GDB_HANDLER(RemoteCommand##name) +#define GDB_XFER_HANDLER(name) GDB_HANDLER(Xfer##name) #define GDB_DEFINE_HANDLER(name) int Context::GDB_HANDLER(name)() #define GDB_DEFINE_QUERY_HANDLER(name) GDB_DEFINE_HANDLER(Query##name) #define GDB_DEFINE_VERBOSE_HANDLER(name) GDB_DEFINE_HANDLER(Verbose##name) #define GDB_DEFINE_REMOTE_COMMAND_HANDLER(name) GDB_DEFINE_HANDLER(RemoteCommand##name) #define GDB_DECLARE_XFER_HANDLER(name) GDB_DEFINE_HANDLER(Xfer##name) + +#define GDB_TEST_NO_CMD_DATA() do { if (!m_commandData.empty()) return ReplyErrno(EILSEQ); } while (false) diff --git a/thermosphere/src/gdb/hvisor_gdb_regs.cpp b/thermosphere/src/gdb/hvisor_gdb_regs.cpp index f6b70c613..5efc61165 100644 --- a/thermosphere/src/gdb/hvisor_gdb_regs.cpp +++ b/thermosphere/src/gdb/hvisor_gdb_regs.cpp @@ -75,6 +75,7 @@ namespace ams::hvisor::gdb { GDB_DEFINE_HANDLER(ReadRegisters) { ENSURE(m_selectedCoreId == currentCoreCtx->coreId); + GDB_TEST_NO_CMD_DATA(); ExceptionStackFrame *frame = currentCoreCtx->guestFrame; FpuRegisterCache *fpuRegCache = fpuReadRegisters(); diff --git a/thermosphere/src/gdb/hvisor_gdb_thread.cpp b/thermosphere/src/gdb/hvisor_gdb_thread.cpp index abde4d81e..6873d2d47 100644 --- a/thermosphere/src/gdb/hvisor_gdb_thread.cpp +++ b/thermosphere/src/gdb/hvisor_gdb_thread.cpp @@ -96,11 +96,14 @@ namespace ams::hvisor::gdb { GDB_DEFINE_QUERY_HANDLER(CurrentThreadId) { + GDB_TEST_NO_CMD_DATA(); return SendFormattedPacket("QC%x", 1 + currentCoreCtx->coreId); } GDB_DEFINE_QUERY_HANDLER(fThreadInfo) { + GDB_TEST_NO_CMD_DATA(); + // We have made our GDB packet big enough to list all the thread ids (coreIds + 1 for each coreId) char *buf = GetInPlaceOutputBuffer(); size_t n = 0; @@ -117,6 +120,8 @@ namespace ams::hvisor::gdb { GDB_DEFINE_QUERY_HANDLER(sThreadInfo) { + GDB_TEST_NO_CMD_DATA(); + // We have made our GDB packet big enough to list all the thread ids (coreIds + 1 for each coreId) in fThreadInfo // Note: we assume GDB doesn't accept notifications during the sequence transfer... return SendPacket("l");