mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-11-14 16:06:56 +00:00
thermosphere: add src/gdb to build list, fix subsequent warnings and errors
This commit is contained in:
parent
175f16627b
commit
0509fa57ca
6 changed files with 17 additions and 22 deletions
|
@ -49,7 +49,7 @@ endif
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
TARGET := $(notdir $(CURDIR))
|
TARGET := $(notdir $(CURDIR))
|
||||||
BUILD := build
|
BUILD := build
|
||||||
SOURCES := src src/platform $(PLATFORM_SOURCES)
|
SOURCES := src src/platform src/gdb $(PLATFORM_SOURCES)
|
||||||
DATA := data
|
DATA := data
|
||||||
INCLUDES := include ../common/include
|
INCLUDES := include ../common/include
|
||||||
|
|
||||||
|
|
|
@ -93,7 +93,7 @@ typedef struct GDBContext {
|
||||||
|
|
||||||
char *commandData, *commandEnd;
|
char *commandData, *commandEnd;
|
||||||
size_t lastSentPacketSize;
|
size_t lastSentPacketSize;
|
||||||
char *buffer[GDB_BUF_LEN + 4];
|
char buffer[GDB_BUF_LEN + 4];
|
||||||
char *workBuffer;
|
char *workBuffer;
|
||||||
} GDBContext;
|
} GDBContext;
|
||||||
|
|
||||||
|
|
|
@ -7,11 +7,10 @@
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "gdb/hio.h"
|
#include "hio.h"
|
||||||
#include "gdb/net.h"
|
#include "net.h"
|
||||||
#include "gdb/mem.h"
|
#include "mem.h"
|
||||||
#include "gdb/debug.h"
|
#include "debug.h"
|
||||||
#include "fmt.h"
|
|
||||||
|
|
||||||
bool GDB_FetchPackedHioRequest(GDBContext *ctx, u32 addr)
|
bool GDB_FetchPackedHioRequest(GDBContext *ctx, u32 addr)
|
||||||
{
|
{
|
||||||
|
|
|
@ -48,7 +48,7 @@ u32 GDB_SearchMemory(bool *found, GDBContext *ctx, uintptr_t addr, size_t len, c
|
||||||
{
|
{
|
||||||
// Note: need to ensure GDB_WORK_BUF_LEN is at least 0x1000 bytes in size
|
// Note: need to ensure GDB_WORK_BUF_LEN is at least 0x1000 bytes in size
|
||||||
|
|
||||||
char *buf = ctx->workBuffer;
|
u8 *buf = (u8 *)ctx->workBuffer;
|
||||||
size_t maxNbPages = GDB_WORK_BUF_LEN / 0x1000;
|
size_t maxNbPages = GDB_WORK_BUF_LEN / 0x1000;
|
||||||
uintptr_t curAddr = addr;
|
uintptr_t curAddr = addr;
|
||||||
|
|
||||||
|
|
|
@ -20,13 +20,13 @@ GDB_DECLARE_HANDLER(ReadRegisters)
|
||||||
{
|
{
|
||||||
ENSURE(ctx->selectedThreadId == currentCoreCtx->coreId);
|
ENSURE(ctx->selectedThreadId == currentCoreCtx->coreId);
|
||||||
|
|
||||||
const ExceptionStackFrame *frame = currentCoreCtx->guestFrame;
|
ExceptionStackFrame *frame = currentCoreCtx->guestFrame;
|
||||||
const FpuRegisterCache *fpuRegCache = fpuReadRegisters();
|
FpuRegisterCache *fpuRegCache = fpuReadRegisters();
|
||||||
|
|
||||||
char *buf = ctx->buffer + 1;
|
char *buf = ctx->buffer + 1;
|
||||||
size_t n = 0;
|
size_t n = 0;
|
||||||
|
|
||||||
struct PACKED ALIGN(4) {
|
struct {
|
||||||
u64 sp;
|
u64 sp;
|
||||||
u64 pc;
|
u64 pc;
|
||||||
u32 cpsr;
|
u32 cpsr;
|
||||||
|
@ -35,7 +35,6 @@ GDB_DECLARE_HANDLER(ReadRegisters)
|
||||||
.pc = frame->elr_el2,
|
.pc = frame->elr_el2,
|
||||||
.cpsr = (u32)frame->spsr_el2,
|
.cpsr = (u32)frame->spsr_el2,
|
||||||
};
|
};
|
||||||
static_assert(sizeof(cpuSprs) == 12, "sizeof(cpuSprs) != 12");
|
|
||||||
|
|
||||||
u32 fpuSprs[2] = {
|
u32 fpuSprs[2] = {
|
||||||
(u32)fpuRegCache->fpsr,
|
(u32)fpuRegCache->fpsr,
|
||||||
|
@ -44,7 +43,7 @@ GDB_DECLARE_HANDLER(ReadRegisters)
|
||||||
|
|
||||||
|
|
||||||
n += GDB_EncodeHex(buf + n, frame->x, sizeof(frame->x));
|
n += GDB_EncodeHex(buf + n, frame->x, sizeof(frame->x));
|
||||||
n += GDB_EncodeHex(buf + n, &cpuSprs, sizeof(cpuSprs));
|
n += GDB_EncodeHex(buf + n, &cpuSprs, 8+8+4);
|
||||||
n += GDB_EncodeHex(buf + n, fpuRegCache->q, sizeof(fpuRegCache->q));
|
n += GDB_EncodeHex(buf + n, fpuRegCache->q, sizeof(fpuRegCache->q));
|
||||||
n += GDB_EncodeHex(buf + n, fpuSprs, sizeof(fpuSprs));
|
n += GDB_EncodeHex(buf + n, fpuSprs, sizeof(fpuSprs));
|
||||||
|
|
||||||
|
@ -64,12 +63,11 @@ GDB_DECLARE_HANDLER(WriteRegisters)
|
||||||
size_t n = 0;
|
size_t n = 0;
|
||||||
size_t m = 0;
|
size_t m = 0;
|
||||||
|
|
||||||
struct PACKED ALIGN(4) {
|
struct {
|
||||||
u64 sp;
|
u64 sp;
|
||||||
u64 pc;
|
u64 pc;
|
||||||
u32 cpsr;
|
u32 cpsr;
|
||||||
} cpuSprs;
|
} cpuSprs;
|
||||||
static_assert(sizeof(cpuSprs) == 12, "sizeof(cpuSprs) != 12");
|
|
||||||
|
|
||||||
u32 fpuSprs[2];
|
u32 fpuSprs[2];
|
||||||
|
|
||||||
|
@ -78,7 +76,7 @@ GDB_DECLARE_HANDLER(WriteRegisters)
|
||||||
size_t sz;
|
size_t sz;
|
||||||
} info[4] = {
|
} info[4] = {
|
||||||
{ frame->x, sizeof(frame->x) },
|
{ frame->x, sizeof(frame->x) },
|
||||||
{ &cpuSprs, sizeof(cpuSprs) },
|
{ &cpuSprs, 8+8+4 },
|
||||||
{ fpuRegCache->q, sizeof(fpuRegCache->q) },
|
{ fpuRegCache->q, sizeof(fpuRegCache->q) },
|
||||||
{ fpuSprs, sizeof(fpuSprs) },
|
{ fpuSprs, sizeof(fpuSprs) },
|
||||||
};
|
};
|
||||||
|
@ -142,10 +140,9 @@ GDB_DECLARE_HANDLER(ReadRegister)
|
||||||
{
|
{
|
||||||
ENSURE(ctx->selectedThreadId == currentCoreCtx->coreId);
|
ENSURE(ctx->selectedThreadId == currentCoreCtx->coreId);
|
||||||
|
|
||||||
const ExceptionStackFrame *frame = currentCoreCtx->guestFrame;
|
ExceptionStackFrame *frame = currentCoreCtx->guestFrame;
|
||||||
const FpuRegisterCache *fpuRegCache = NULL;
|
FpuRegisterCache *fpuRegCache = NULL;
|
||||||
|
|
||||||
char *buf = ctx->buffer + 1;
|
|
||||||
unsigned long gdbRegNum;
|
unsigned long gdbRegNum;
|
||||||
|
|
||||||
if (GDB_ParseHexIntegerList(&gdbRegNum, ctx->commandData, 1, 0) == NULL) {
|
if (GDB_ParseHexIntegerList(&gdbRegNum, ctx->commandData, 1, 0) == NULL) {
|
||||||
|
@ -211,6 +208,5 @@ GDB_DECLARE_HANDLER(WriteRegister)
|
||||||
fpuCommitRegisters();
|
fpuCommitRegisters();
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
return GDB_ReplyOk(ctx);
|
||||||
return GDB_ReplyOk(ctx);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ static inline size_t guestReadMemory(uintptr_t addr, size_t size, void *buf)
|
||||||
return guestReadWriteMemory(addr, size, buf, NULL);
|
return guestReadWriteMemory(addr, size, buf, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline size_t guestWriteMemory(uintptr_t addr, size_t size, void *buf)
|
static inline size_t guestWriteMemory(uintptr_t addr, size_t size, const void *buf)
|
||||||
{
|
{
|
||||||
return guestReadWriteMemory(addr, size, NULL, buf);
|
return guestReadWriteMemory(addr, size, NULL, buf);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue