gdb: add support to run new processes
Only titleId [mediaType [launchFlags]] is supported, and the launched title shouldn't rely on APT and all 3 parameters should be hex-encoded. usage example, with titleId+mediaType: (gdb) set remote file-exec 0004013000003702 (gdb) r 0
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
#include <3ds/svc.h>
|
||||
#include <3ds/synchronization.h>
|
||||
#include <3ds/result.h>
|
||||
#include "pmdbgext.h"
|
||||
#include "sock_util.h"
|
||||
#include "memory.h"
|
||||
|
||||
@@ -64,17 +65,19 @@ enum
|
||||
GDB_FLAG_ALLOCATED_MASK = GDB_FLAG_SELECTED | GDB_FLAG_USED,
|
||||
GDB_FLAG_EXTENDED_REMOTE = 4,
|
||||
GDB_FLAG_NOACK = 8,
|
||||
GDB_FLAG_PROC_RESTART_MASK = GDB_FLAG_NOACK | GDB_FLAG_EXTENDED_REMOTE | GDB_FLAG_USED,
|
||||
GDB_FLAG_PROCESS_CONTINUING = 16,
|
||||
GDB_FLAG_TERMINATE_PROCESS = 32,
|
||||
GDB_FLAG_ATTACHED_AT_START = 64,
|
||||
GDB_FLAG_CREATED = 128,
|
||||
};
|
||||
|
||||
typedef enum GDBState
|
||||
{
|
||||
GDB_STATE_DISCONNECTED,
|
||||
GDB_STATE_CONNECTED,
|
||||
GDB_STATE_NOACK_SENT,
|
||||
GDB_STATE_DETACHING
|
||||
GDB_STATE_ATTACHED,
|
||||
GDB_STATE_DETACHING,
|
||||
} GDBState;
|
||||
|
||||
typedef struct ThreadInfo
|
||||
@@ -95,9 +98,15 @@ typedef struct GDBContext
|
||||
|
||||
u32 flags;
|
||||
GDBState state;
|
||||
bool noAckSent;
|
||||
|
||||
u32 pid;
|
||||
Handle debug;
|
||||
|
||||
// vRun and R (restart) info:
|
||||
FS_ProgramInfo launchedProgramInfo;
|
||||
u32 launchedProgramLaunchFlags;
|
||||
|
||||
ThreadInfo threadInfos[MAX_DEBUG_THREAD];
|
||||
u32 nbThreads;
|
||||
u32 currentThreadId, selectedThreadId, selectedThreadIdForContinuing;
|
||||
@@ -138,6 +147,7 @@ void GDB_FinalizeContext(GDBContext *ctx);
|
||||
|
||||
Result GDB_AttachToProcess(GDBContext *ctx);
|
||||
void GDB_DetachFromProcess(GDBContext *ctx);
|
||||
Result GDB_CreateProcess(GDBContext *ctx, const FS_ProgramInfo *progInfo, u32 launchFlags);
|
||||
|
||||
GDB_DECLARE_HANDLER(Unsupported);
|
||||
GDB_DECLARE_HANDLER(EnableExtendedMode);
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
|
||||
#include "gdb.h"
|
||||
|
||||
GDB_DECLARE_VERBOSE_HANDLER(Run);
|
||||
GDB_DECLARE_HANDLER(Restart);
|
||||
GDB_DECLARE_VERBOSE_HANDLER(Attach);
|
||||
GDB_DECLARE_HANDLER(Detach);
|
||||
GDB_DECLARE_HANDLER(Kill);
|
||||
|
||||
@@ -36,6 +36,8 @@ u32 GDB_DecodeHex(void *dst, const char *src, u32 len);
|
||||
u32 GDB_UnescapeBinaryData(void *dst, const void *src, u32 len);
|
||||
const char *GDB_ParseIntegerList(u32 *dst, const char *src, u32 nb, char sep, char lastSep, u32 base, bool allowPrefix);
|
||||
const char *GDB_ParseHexIntegerList(u32 *dst, const char *src, u32 nb, char lastSep);
|
||||
const char *GDB_ParseIntegerList64(u64 *dst, const char *src, u32 nb, char sep, char lastSep, u32 base, bool allowPrefix);
|
||||
const char *GDB_ParseHexIntegerList64(u64 *dst, const char *src, u32 nb, char lastSep);
|
||||
int GDB_ReceivePacket(GDBContext *ctx);
|
||||
int GDB_SendPacket(GDBContext *ctx, const char *packetData, u32 len);
|
||||
int GDB_SendFormattedPacket(GDBContext *ctx, const char *packetDataFmt, ...);
|
||||
|
||||
@@ -32,3 +32,4 @@
|
||||
u8 *memsearch(u8 *startPos, const void *pattern, u32 size, u32 patternSize);
|
||||
void hexItoa(u64 number, char *out, u32 digits, bool uppercase);
|
||||
unsigned long int xstrtoul(const char *nptr, char **endptr, int base, bool allowPrefix, bool *ok);
|
||||
unsigned long long int xstrtoull(const char *nptr, char **endptr, int base, bool allowPrefix, bool *ok);
|
||||
|
||||
Reference in New Issue
Block a user