mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2025-01-03 11:11:14 +00:00
thermosphere: gdb: add missing command list entries, fix warnings again
This commit is contained in:
parent
0509fa57ca
commit
cf0b052590
11 changed files with 31 additions and 23 deletions
|
@ -42,14 +42,14 @@
|
||||||
#include "../software_breakpoints.h"
|
#include "../software_breakpoints.h"
|
||||||
#include "../watchpoints.h"
|
#include "../watchpoints.h"
|
||||||
|
|
||||||
static TEMPORARY u8 g_gdbWorkBuffer[GDB_WORK_BUF_LEN];
|
static TEMPORARY char g_gdbWorkBuffer[GDB_WORK_BUF_LEN];
|
||||||
|
|
||||||
static const struct{
|
static const struct{
|
||||||
char command;
|
char command;
|
||||||
GDBCommandHandler handler;
|
GDBCommandHandler handler;
|
||||||
} gdbCommandHandlers[] = {
|
} gdbCommandHandlers[] = {
|
||||||
{ '?', GDB_HANDLER(GetStopReason) },
|
{ '?', GDB_HANDLER(GetStopReason) },
|
||||||
{ '!', GDB_HANDLER(EnableExtendedMode) },
|
{ '!', GDB_HANDLER(EnableExtendedMode) }, // note: stubbed
|
||||||
{ 'c', GDB_HANDLER(ContinueOrStepDeprecated) },
|
{ 'c', GDB_HANDLER(ContinueOrStepDeprecated) },
|
||||||
{ 'C', GDB_HANDLER(ContinueOrStepDeprecated) },
|
{ 'C', GDB_HANDLER(ContinueOrStepDeprecated) },
|
||||||
{ 'D', GDB_HANDLER(Detach) },
|
{ 'D', GDB_HANDLER(Detach) },
|
||||||
|
@ -64,6 +64,8 @@ static const struct{
|
||||||
{ 'P', GDB_HANDLER(WriteRegister) },
|
{ 'P', GDB_HANDLER(WriteRegister) },
|
||||||
{ 'q', GDB_HANDLER(ReadQuery) },
|
{ 'q', GDB_HANDLER(ReadQuery) },
|
||||||
{ 'Q', GDB_HANDLER(WriteQuery) },
|
{ 'Q', GDB_HANDLER(WriteQuery) },
|
||||||
|
{ 's', GDB_HANDLER(ContinueOrStepDeprecated) },
|
||||||
|
{ 'S', GDB_HANDLER(ContinueOrStepDeprecated) },
|
||||||
{ 'T', GDB_HANDLER(IsThreadAlive) },
|
{ 'T', GDB_HANDLER(IsThreadAlive) },
|
||||||
{ 'v', GDB_HANDLER(VerboseCommand) },
|
{ 'v', GDB_HANDLER(VerboseCommand) },
|
||||||
{ 'X', GDB_HANDLER(WriteMemoryRaw) },
|
{ 'X', GDB_HANDLER(WriteMemoryRaw) },
|
||||||
|
@ -91,7 +93,7 @@ static int GDB_ProcessPacket(GDBContext *ctx, size_t len)
|
||||||
|
|
||||||
// Handle the packet...
|
// Handle the packet...
|
||||||
if (ctx->buffer[0] == '\x03') {
|
if (ctx->buffer[0] == '\x03') {
|
||||||
GDB_HandleBreak(ctx);
|
GDB_BreakAllCores(ctx);
|
||||||
ret = 0;
|
ret = 0;
|
||||||
} else {
|
} else {
|
||||||
GDBCommandHandler handler = GDB_GetCommandHandler(ctx->buffer[1]);
|
GDBCommandHandler handler = GDB_GetCommandHandler(ctx->buffer[1]);
|
||||||
|
@ -226,7 +228,7 @@ void GDB_DetachFromContext(GDBContext *ctx)
|
||||||
ctx->currentHioRequestTargetAddr = 0;
|
ctx->currentHioRequestTargetAddr = 0;
|
||||||
memset(&ctx->currentHioRequest, 0, sizeof(PackedGdbHioRequest));
|
memset(&ctx->currentHioRequest, 0, sizeof(PackedGdbHioRequest));
|
||||||
|
|
||||||
debugManagerSetReportingFalse(true);
|
debugManagerSetReportingEnabled(false);
|
||||||
debugManagerContinueCores(getActiveCoreMask());
|
debugManagerContinueCores(getActiveCoreMask());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ static int GDB_ParseExceptionFrame(char *out, const DebugEventInfo *info, int si
|
||||||
u32 coreId = info->coreId;
|
u32 coreId = info->coreId;
|
||||||
ExceptionStackFrame *frame = info->frame;
|
ExceptionStackFrame *frame = info->frame;
|
||||||
|
|
||||||
int n = sprintf(out, "T%02xthread:%lx;core:%lx;", sig, 1 + coreId, coreId);
|
int n = sprintf(out, "T%02xthread:%x;core:%x;", sig, 1 + coreId, coreId);
|
||||||
|
|
||||||
// Dump the GPRs & sp & pc & cpsr (cpsr is 32-bit in the xml desc)
|
// Dump the GPRs & sp & pc & cpsr (cpsr is 32-bit in the xml desc)
|
||||||
// For performance reasons, we don't include the FPU registers here
|
// For performance reasons, we don't include the FPU registers here
|
||||||
|
@ -83,13 +83,14 @@ static int GDB_ParseExceptionFrame(char *out, const DebugEventInfo *info, int si
|
||||||
out + n,
|
out + n,
|
||||||
"1f:%016lx;20:%016lx;21:%08x",
|
"1f:%016lx;20:%016lx;21:%08x",
|
||||||
__builtin_bswap64(*exceptionGetSpPtr(frame)),
|
__builtin_bswap64(*exceptionGetSpPtr(frame)),
|
||||||
__builitin_bswap32((u32)frame->spsr_el2)
|
__builtin_bswap64(frame->elr_el2),
|
||||||
|
__builtin_bswap32((u32)frame->spsr_el2)
|
||||||
);
|
);
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GDB_SendStopReply(GDBContext *ctx, DebugEventInfo *info, bool asNotification)
|
int GDB_SendStopReply(GDBContext *ctx, const DebugEventInfo *info, bool asNotification)
|
||||||
{
|
{
|
||||||
char *buf = ctx->buffer + 1;
|
char *buf = ctx->buffer + 1;
|
||||||
int n;
|
int n;
|
||||||
|
@ -149,7 +150,7 @@ int GDB_SendStopReply(GDBContext *ctx, DebugEventInfo *info, bool asNotification
|
||||||
// the only notable exceptions we get are stop point/single step events from the debugee (basically classes 0x3x)
|
// the only notable exceptions we get are stop point/single step events from the debugee (basically classes 0x3x)
|
||||||
switch(ec) {
|
switch(ec) {
|
||||||
case Exception_BreakpointLowerEl: {
|
case Exception_BreakpointLowerEl: {
|
||||||
n += GDB_ParseExceptionFrame(buf + n, ctx, SIGTRAP);
|
n += GDB_ParseExceptionFrame(buf + n, info, SIGTRAP);
|
||||||
strcat(buf, "hwbreak:;");
|
strcat(buf, "hwbreak:;");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,7 +163,7 @@ int GDB_SendStopReply(GDBContext *ctx, DebugEventInfo *info, bool asNotification
|
||||||
if (!cr.enabled) {
|
if (!cr.enabled) {
|
||||||
DEBUG("GDB: oops, unhandled watchpoint for core id %u, far=%016lx\n", info->coreId, info->frame->far_el2);
|
DEBUG("GDB: oops, unhandled watchpoint for core id %u, far=%016lx\n", info->coreId, info->frame->far_el2);
|
||||||
} else {
|
} else {
|
||||||
n += GDB_ParseExceptionFrame(buf + n, ctx, SIGTRAP);
|
n += GDB_ParseExceptionFrame(buf + n, info, SIGTRAP);
|
||||||
sprintf(buf + n, "%swatch:%016lx;", kinds[cr.lsc], info->frame->far_el2);
|
sprintf(buf + n, "%swatch:%016lx;", kinds[cr.lsc], info->frame->far_el2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -171,7 +172,7 @@ int GDB_SendStopReply(GDBContext *ctx, DebugEventInfo *info, bool asNotification
|
||||||
// if the guest has inserted some of them manually...
|
// if the guest has inserted some of them manually...
|
||||||
case Exception_SoftwareBreakpointA64:
|
case Exception_SoftwareBreakpointA64:
|
||||||
case Exception_SoftwareBreakpointA32: {
|
case Exception_SoftwareBreakpointA32: {
|
||||||
n += GDB_ParseExceptionFrame(buf + n, ctx, SIGTRAP);
|
n += GDB_ParseExceptionFrame(buf + n, info, SIGTRAP);
|
||||||
strcat(buf, "swbreak:;");
|
strcat(buf, "swbreak:;");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -333,7 +334,7 @@ GDB_DECLARE_HANDLER(GetStopReason)
|
||||||
bool nonStop = (ctx->flags & GDB_FLAG_NONSTOP) != 0;
|
bool nonStop = (ctx->flags & GDB_FLAG_NONSTOP) != 0;
|
||||||
if (!nonStop) {
|
if (!nonStop) {
|
||||||
// Full-stop:
|
// Full-stop:
|
||||||
return GDB_SendStopReply(ctx, &ctx->lastDebugEvent, true);
|
return GDB_SendStopReply(ctx, ctx->lastDebugEvent, true);
|
||||||
} else {
|
} else {
|
||||||
// Non-stop, start new vStopped sequence
|
// Non-stop, start new vStopped sequence
|
||||||
ctx->sentDebugEventCoreList = 0;
|
ctx->sentDebugEventCoreList = 0;
|
||||||
|
@ -362,12 +363,12 @@ GDB_DECLARE_VERBOSE_HANDLER(CtrlC)
|
||||||
{
|
{
|
||||||
int ret = GDB_ReplyOk(ctx);
|
int ret = GDB_ReplyOk(ctx);
|
||||||
GDB_BreakAllCores(ctx);
|
GDB_BreakAllCores(ctx);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
GDB_DECLARE_HANDLER(ContinueOrStepDeprecated)
|
GDB_DECLARE_HANDLER(ContinueOrStepDeprecated)
|
||||||
{
|
{
|
||||||
char *addrStart = NULL;
|
char *addrStart = NULL;
|
||||||
uintptr_t addr = 0;
|
|
||||||
|
|
||||||
char cmd = ctx->commandData[-1];
|
char cmd = ctx->commandData[-1];
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
#include "../core_ctx.h"
|
#include "../core_ctx.h"
|
||||||
#include "../debug_manager.h"
|
#include "../debug_manager.h"
|
||||||
|
|
||||||
int GDB_SendStopReply(GDBContext *ctx, DebugEventInfo *info, bool asNotification);
|
int GDB_SendStopReply(GDBContext *ctx, const DebugEventInfo *info, bool asNotification);
|
||||||
int GDB_TrySignalDebugEvent(GDBContext *ctx, DebugEventInfo *info);
|
int GDB_TrySignalDebugEvent(GDBContext *ctx, DebugEventInfo *info);
|
||||||
|
|
||||||
void GDB_BreakAllCores(GDBContext *ctx);
|
void GDB_BreakAllCores(GDBContext *ctx);
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
#include "net.h"
|
#include "net.h"
|
||||||
#include "mem.h"
|
#include "mem.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
/*
|
||||||
bool GDB_FetchPackedHioRequest(GDBContext *ctx, u32 addr)
|
bool GDB_FetchPackedHioRequest(GDBContext *ctx, u32 addr)
|
||||||
{
|
{
|
||||||
u32 total = GDB_ReadTargetMemory(&ctx->currentHioRequest, ctx, addr, sizeof(PackedGdbHioRequest));
|
u32 total = GDB_ReadTargetMemory(&ctx->currentHioRequest, ctx, addr, sizeof(PackedGdbHioRequest));
|
||||||
|
@ -65,11 +65,12 @@ int GDB_SendCurrentHioRequest(GDBContext *ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
return GDB_SendPacket(ctx, buf, strlen(buf));
|
return GDB_SendPacket(ctx, buf, strlen(buf));
|
||||||
}
|
}*/
|
||||||
|
|
||||||
GDB_DECLARE_HANDLER(HioReply)
|
GDB_DECLARE_HANDLER(HioReply)
|
||||||
{
|
{
|
||||||
if (!GDB_IsHioInProgress(ctx))
|
return 0;
|
||||||
|
/* if (!GDB_IsHioInProgress(ctx))
|
||||||
return GDB_ReplyErrno(ctx, EPERM);
|
return GDB_ReplyErrno(ctx, EPERM);
|
||||||
|
|
||||||
// Reply in the form of Fretcode,errno,Ctrl-C flag;call-specific attachment
|
// Reply in the form of Fretcode,errno,Ctrl-C flag;call-specific attachment
|
||||||
|
@ -128,5 +129,5 @@ GDB_DECLARE_HANDLER(HioReply)
|
||||||
ctx->currentHioRequestTargetAddr = 0;
|
ctx->currentHioRequestTargetAddr = 0;
|
||||||
|
|
||||||
GDB_ContinueExecution(ctx);
|
GDB_ContinueExecution(ctx);
|
||||||
return total == sizeof(PackedGdbHioRequest) ? 0 : GDB_ReplyErrno(ctx, EFAULT);
|
return total == sizeof(PackedGdbHioRequest) ? 0 : GDB_ReplyErrno(ctx, EFAULT);*/
|
||||||
}
|
}
|
||||||
|
|
|
@ -173,7 +173,7 @@ GDB_DECLARE_QUERY_HANDLER(SearchMemory)
|
||||||
patternLen = ctx->commandEnd - patternStart;
|
patternLen = ctx->commandEnd - patternStart;
|
||||||
|
|
||||||
// Unescape pattern in place
|
// Unescape pattern in place
|
||||||
char *pattern = patternStart;
|
char *pattern = (char *)patternStart;
|
||||||
patternLen = GDB_UnescapeBinaryData(pattern, patternStart, patternLen);
|
patternLen = GDB_UnescapeBinaryData(pattern, patternStart, patternLen);
|
||||||
|
|
||||||
foundAddr = GDB_SearchMemory(&found, ctx, addr, len, patternStart, patternLen);
|
foundAddr = GDB_SearchMemory(&found, ctx, addr, len, patternStart, patternLen);
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
#include "../pattern_utils.h"
|
#include "../pattern_utils.h"
|
||||||
|
|
||||||
u8 GDB_ComputeChecksum(const char *packetData, size_t len)
|
u8 GDB_ComputeChecksum(const char *packetData, size_t len)
|
||||||
|
@ -236,7 +237,7 @@ int GDB_ReceivePacket(GDBContext *ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set helper attributes, change '#' to NUL
|
// Set helper attributes, change '#' to NUL
|
||||||
ctx->commandEnd = delimPos;
|
ctx->commandEnd = ctx->buffer + delimPos;
|
||||||
ctx->buffer[delimPos] = '\0';
|
ctx->buffer[delimPos] = '\0';
|
||||||
|
|
||||||
return (int)(delimPos + 2);
|
return (int)(delimPos + 2);
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
* SPDX-License-Identifier: (MIT OR GPL-2.0-or-later)
|
* SPDX-License-Identifier: (MIT OR GPL-2.0-or-later)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "../utils.h"
|
#include "../utils.h"
|
||||||
|
|
||||||
#include "query.h"
|
#include "query.h"
|
||||||
|
@ -36,7 +38,6 @@ static const struct {
|
||||||
GDB_QUERY_HANDLER_LIST_ITEM(sThreadInfo, READ),
|
GDB_QUERY_HANDLER_LIST_ITEM(sThreadInfo, READ),
|
||||||
GDB_QUERY_HANDLER_LIST_ITEM(ThreadEvents, WRITE),
|
GDB_QUERY_HANDLER_LIST_ITEM(ThreadEvents, WRITE),
|
||||||
GDB_QUERY_HANDLER_LIST_ITEM(ThreadExtraInfo, READ),
|
GDB_QUERY_HANDLER_LIST_ITEM(ThreadExtraInfo, READ),
|
||||||
GDB_QUERY_HANDLER_LIST_ITEM(GetTLSAddr, READ),
|
|
||||||
GDB_QUERY_HANDLER_LIST_ITEM_3("C", CurrentThreadId, READ),
|
GDB_QUERY_HANDLER_LIST_ITEM_3("C", CurrentThreadId, READ),
|
||||||
GDB_QUERY_HANDLER_LIST_ITEM_3("Search", SearchMemory, READ),
|
GDB_QUERY_HANDLER_LIST_ITEM_3("Search", SearchMemory, READ),
|
||||||
GDB_QUERY_HANDLER_LIST_ITEM(Rcmd, READ),
|
GDB_QUERY_HANDLER_LIST_ITEM(Rcmd, READ),
|
||||||
|
|
|
@ -15,4 +15,3 @@ int GDB_HandleWriteQuery(GDBContext *ctx);
|
||||||
GDB_DECLARE_QUERY_HANDLER(Supported);
|
GDB_DECLARE_QUERY_HANDLER(Supported);
|
||||||
GDB_DECLARE_QUERY_HANDLER(StartNoAckMode);
|
GDB_DECLARE_QUERY_HANDLER(StartNoAckMode);
|
||||||
GDB_DECLARE_QUERY_HANDLER(Attached);
|
GDB_DECLARE_QUERY_HANDLER(Attached);
|
||||||
GDB_DECLARE_QUERY_HANDLER(CatchSyscalls);
|
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "thread.h"
|
#include "thread.h"
|
||||||
#include "net.h"
|
#include "net.h"
|
||||||
|
@ -75,7 +76,7 @@ GDB_DECLARE_QUERY_HANDLER(fThreadInfo)
|
||||||
u32 coreMask = ctx->attachedCoreList;
|
u32 coreMask = ctx->attachedCoreList;
|
||||||
|
|
||||||
FOREACH_BIT (tmp, coreId, coreMask) {
|
FOREACH_BIT (tmp, coreId, coreMask) {
|
||||||
n += sprintf(buf + n, "%x,", 1 + coreId);
|
n += sprintf(buf + n, "%lx,", 1 + coreId);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove trailing comma
|
// Remove trailing comma
|
||||||
|
|
|
@ -18,7 +18,9 @@ static const struct {
|
||||||
} gdbVerboseCommandHandlers[] = {
|
} gdbVerboseCommandHandlers[] = {
|
||||||
{ "Cont?", '\0', GDB_VERBOSE_HANDLER(ContinueSupported) },
|
{ "Cont?", '\0', GDB_VERBOSE_HANDLER(ContinueSupported) },
|
||||||
{ "Cont", ';', GDB_VERBOSE_HANDLER(Continue) },
|
{ "Cont", ';', GDB_VERBOSE_HANDLER(Continue) },
|
||||||
|
{ "CtrlC", '\0', GDB_VERBOSE_HANDLER(CtrlC) },
|
||||||
{ "MustReplyEmpty", '\0', GDB_HANDLER(Unsupported) },
|
{ "MustReplyEmpty", '\0', GDB_HANDLER(Unsupported) },
|
||||||
|
{ "Stopped", '\0', GDB_VERBOSE_HANDLER(Stopped) },
|
||||||
};
|
};
|
||||||
|
|
||||||
GDB_DECLARE_HANDLER(VerboseCommand)
|
GDB_DECLARE_HANDLER(VerboseCommand)
|
||||||
|
|
|
@ -121,7 +121,7 @@ GDB_DECLARE_QUERY_HANDLER(Xfer)
|
||||||
bool write;
|
bool write;
|
||||||
const char *pos;
|
const char *pos;
|
||||||
if (strcmp(opStart, "read") == 0) {
|
if (strcmp(opStart, "read") == 0) {
|
||||||
unsigned int lst[2];
|
unsigned long lst[2];
|
||||||
if(GDB_ParseHexIntegerList(lst, offStart, 2, 0) == NULL) {
|
if(GDB_ParseHexIntegerList(lst, offStart, 2, 0) == NULL) {
|
||||||
return GDB_ReplyErrno(ctx, EILSEQ);
|
return GDB_ReplyErrno(ctx, EILSEQ);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue