thermosphere: gdb: add missing command list entries, fix warnings again

This commit is contained in:
TuxSH 2020-01-31 02:28:51 +00:00
parent 0509fa57ca
commit cf0b052590
11 changed files with 31 additions and 23 deletions

View file

@ -42,14 +42,14 @@
#include "../software_breakpoints.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{
char command;
GDBCommandHandler handler;
} gdbCommandHandlers[] = {
{ '?', GDB_HANDLER(GetStopReason) },
{ '!', GDB_HANDLER(EnableExtendedMode) },
{ '!', GDB_HANDLER(EnableExtendedMode) }, // note: stubbed
{ 'c', GDB_HANDLER(ContinueOrStepDeprecated) },
{ 'C', GDB_HANDLER(ContinueOrStepDeprecated) },
{ 'D', GDB_HANDLER(Detach) },
@ -64,6 +64,8 @@ static const struct{
{ 'P', GDB_HANDLER(WriteRegister) },
{ 'q', GDB_HANDLER(ReadQuery) },
{ 'Q', GDB_HANDLER(WriteQuery) },
{ 's', GDB_HANDLER(ContinueOrStepDeprecated) },
{ 'S', GDB_HANDLER(ContinueOrStepDeprecated) },
{ 'T', GDB_HANDLER(IsThreadAlive) },
{ 'v', GDB_HANDLER(VerboseCommand) },
{ 'X', GDB_HANDLER(WriteMemoryRaw) },
@ -91,7 +93,7 @@ static int GDB_ProcessPacket(GDBContext *ctx, size_t len)
// Handle the packet...
if (ctx->buffer[0] == '\x03') {
GDB_HandleBreak(ctx);
GDB_BreakAllCores(ctx);
ret = 0;
} else {
GDBCommandHandler handler = GDB_GetCommandHandler(ctx->buffer[1]);
@ -226,7 +228,7 @@ void GDB_DetachFromContext(GDBContext *ctx)
ctx->currentHioRequestTargetAddr = 0;
memset(&ctx->currentHioRequest, 0, sizeof(PackedGdbHioRequest));
debugManagerSetReportingFalse(true);
debugManagerSetReportingEnabled(false);
debugManagerContinueCores(getActiveCoreMask());
}

View file

@ -71,7 +71,7 @@ static int GDB_ParseExceptionFrame(char *out, const DebugEventInfo *info, int si
u32 coreId = info->coreId;
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)
// 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,
"1f:%016lx;20:%016lx;21:%08x",
__builtin_bswap64(*exceptionGetSpPtr(frame)),
__builitin_bswap32((u32)frame->spsr_el2)
__builtin_bswap64(frame->elr_el2),
__builtin_bswap32((u32)frame->spsr_el2)
);
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;
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)
switch(ec) {
case Exception_BreakpointLowerEl: {
n += GDB_ParseExceptionFrame(buf + n, ctx, SIGTRAP);
n += GDB_ParseExceptionFrame(buf + n, info, SIGTRAP);
strcat(buf, "hwbreak:;");
}
@ -162,7 +163,7 @@ int GDB_SendStopReply(GDBContext *ctx, DebugEventInfo *info, bool asNotification
if (!cr.enabled) {
DEBUG("GDB: oops, unhandled watchpoint for core id %u, far=%016lx\n", info->coreId, info->frame->far_el2);
} 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);
}
}
@ -171,7 +172,7 @@ int GDB_SendStopReply(GDBContext *ctx, DebugEventInfo *info, bool asNotification
// if the guest has inserted some of them manually...
case Exception_SoftwareBreakpointA64:
case Exception_SoftwareBreakpointA32: {
n += GDB_ParseExceptionFrame(buf + n, ctx, SIGTRAP);
n += GDB_ParseExceptionFrame(buf + n, info, SIGTRAP);
strcat(buf, "swbreak:;");
}
@ -333,7 +334,7 @@ GDB_DECLARE_HANDLER(GetStopReason)
bool nonStop = (ctx->flags & GDB_FLAG_NONSTOP) != 0;
if (!nonStop) {
// Full-stop:
return GDB_SendStopReply(ctx, &ctx->lastDebugEvent, true);
return GDB_SendStopReply(ctx, ctx->lastDebugEvent, true);
} else {
// Non-stop, start new vStopped sequence
ctx->sentDebugEventCoreList = 0;
@ -362,12 +363,12 @@ GDB_DECLARE_VERBOSE_HANDLER(CtrlC)
{
int ret = GDB_ReplyOk(ctx);
GDB_BreakAllCores(ctx);
return ret;
}
GDB_DECLARE_HANDLER(ContinueOrStepDeprecated)
{
char *addrStart = NULL;
uintptr_t addr = 0;
char cmd = ctx->commandData[-1];

View file

@ -11,7 +11,7 @@
#include "../core_ctx.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);
void GDB_BreakAllCores(GDBContext *ctx);

View file

@ -11,7 +11,7 @@
#include "net.h"
#include "mem.h"
#include "debug.h"
/*
bool GDB_FetchPackedHioRequest(GDBContext *ctx, u32 addr)
{
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));
}
}*/
GDB_DECLARE_HANDLER(HioReply)
{
if (!GDB_IsHioInProgress(ctx))
return 0;
/* if (!GDB_IsHioInProgress(ctx))
return GDB_ReplyErrno(ctx, EPERM);
// Reply in the form of Fretcode,errno,Ctrl-C flag;call-specific attachment
@ -128,5 +129,5 @@ GDB_DECLARE_HANDLER(HioReply)
ctx->currentHioRequestTargetAddr = 0;
GDB_ContinueExecution(ctx);
return total == sizeof(PackedGdbHioRequest) ? 0 : GDB_ReplyErrno(ctx, EFAULT);
return total == sizeof(PackedGdbHioRequest) ? 0 : GDB_ReplyErrno(ctx, EFAULT);*/
}

View file

@ -173,7 +173,7 @@ GDB_DECLARE_QUERY_HANDLER(SearchMemory)
patternLen = ctx->commandEnd - patternStart;
// Unescape pattern in place
char *pattern = patternStart;
char *pattern = (char *)patternStart;
patternLen = GDB_UnescapeBinaryData(pattern, patternStart, patternLen);
foundAddr = GDB_SearchMemory(&found, ctx, addr, len, patternStart, patternLen);

View file

@ -10,6 +10,7 @@
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "../pattern_utils.h"
u8 GDB_ComputeChecksum(const char *packetData, size_t len)
@ -236,7 +237,7 @@ int GDB_ReceivePacket(GDBContext *ctx)
}
// Set helper attributes, change '#' to NUL
ctx->commandEnd = delimPos;
ctx->commandEnd = ctx->buffer + delimPos;
ctx->buffer[delimPos] = '\0';
return (int)(delimPos + 2);

View file

@ -5,6 +5,8 @@
* SPDX-License-Identifier: (MIT OR GPL-2.0-or-later)
*/
#include <string.h>
#include "../utils.h"
#include "query.h"
@ -36,7 +38,6 @@ static const struct {
GDB_QUERY_HANDLER_LIST_ITEM(sThreadInfo, READ),
GDB_QUERY_HANDLER_LIST_ITEM(ThreadEvents, WRITE),
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("Search", SearchMemory, READ),
GDB_QUERY_HANDLER_LIST_ITEM(Rcmd, READ),

View file

@ -15,4 +15,3 @@ int GDB_HandleWriteQuery(GDBContext *ctx);
GDB_DECLARE_QUERY_HANDLER(Supported);
GDB_DECLARE_QUERY_HANDLER(StartNoAckMode);
GDB_DECLARE_QUERY_HANDLER(Attached);
GDB_DECLARE_QUERY_HANDLER(CatchSyscalls);

View file

@ -6,6 +6,7 @@
*/
#include <stdio.h>
#include <string.h>
#include "thread.h"
#include "net.h"
@ -75,7 +76,7 @@ GDB_DECLARE_QUERY_HANDLER(fThreadInfo)
u32 coreMask = ctx->attachedCoreList;
FOREACH_BIT (tmp, coreId, coreMask) {
n += sprintf(buf + n, "%x,", 1 + coreId);
n += sprintf(buf + n, "%lx,", 1 + coreId);
}
// Remove trailing comma

View file

@ -18,7 +18,9 @@ static const struct {
} gdbVerboseCommandHandlers[] = {
{ "Cont?", '\0', GDB_VERBOSE_HANDLER(ContinueSupported) },
{ "Cont", ';', GDB_VERBOSE_HANDLER(Continue) },
{ "CtrlC", '\0', GDB_VERBOSE_HANDLER(CtrlC) },
{ "MustReplyEmpty", '\0', GDB_HANDLER(Unsupported) },
{ "Stopped", '\0', GDB_VERBOSE_HANDLER(Stopped) },
};
GDB_DECLARE_HANDLER(VerboseCommand)

View file

@ -121,7 +121,7 @@ GDB_DECLARE_QUERY_HANDLER(Xfer)
bool write;
const char *pos;
if (strcmp(opStart, "read") == 0) {
unsigned int lst[2];
unsigned long lst[2];
if(GDB_ParseHexIntegerList(lst, offStart, 2, 0) == NULL) {
return GDB_ReplyErrno(ctx, EILSEQ);
}