Implement HBLDR_DebugNextApplicationByForce

also prevent port 4003 (next application) from being extended-remote
This commit is contained in:
TuxSH
2019-04-18 22:28:23 +02:00
parent 0b33134f6c
commit 9e1a9f2842
4 changed files with 67 additions and 21 deletions

View File

@@ -52,7 +52,7 @@ static u8 ALIGN(8) debuggerDebugThreadStack[0x2000];
GDBServer gdbServer = { 0 };
static GDBContext *nextApplicationGdbCtx = NULL;
GDBContext *nextApplicationGdbCtx = NULL;
void debuggerSocketThreadMain(void);
MyThread *debuggerCreateSocketThread(void)
@@ -170,29 +170,34 @@ void DebuggerMenu_DebugNextApplicationByForce(void)
Result res = 0;
char buf[256];
if(initialized)
GDB_LockAllContexts(&gdbServer);
if (nextApplicationGdbCtx != NULL)
strcpy(buf, "Operation already performed.");
else if(initialized)
{
res = PMDBG_DebugNextApplicationByForce();
if(R_SUCCEEDED(res))
nextApplicationGdbCtx = GDB_SelectAvailableContext(&gdbServer, GDB_PORT_BASE + 3, GDB_PORT_BASE + 4);
if (nextApplicationGdbCtx != NULL)
{
GDB_LockAllContexts(&gdbServer);
if (nextApplicationGdbCtx == NULL)
nextApplicationGdbCtx = GDB_SelectAvailableContext(&gdbServer, GDB_PORT_BASE + 3, GDB_PORT_BASE + 4);
if (nextApplicationGdbCtx != NULL)
{
nextApplicationGdbCtx->debug = 0;
nextApplicationGdbCtx->pid = 0xFFFFFFFF;
nextApplicationGdbCtx->debug = 0;
nextApplicationGdbCtx->pid = 0xFFFFFFFF;
res = PMDBG_DebugNextApplicationByForce();
if(R_SUCCEEDED(res))
sprintf(buf, "Operation succeeded.\nUse port %d to connect to the next launched\napplication.", nextApplicationGdbCtx->localPort);
}
else
strcpy(buf, "Failed to allocate a slot.\nPlease unselect a process in the process list first");
GDB_UnlockAllContexts(&gdbServer);
{
nextApplicationGdbCtx->flags = 0;
nextApplicationGdbCtx->localPort = 0;
nextApplicationGdbCtx = NULL;
sprintf(buf, "Operation failed (0x%08lx).", (u32)res);
}
}
else
sprintf(buf, "Operation failed (0x%08lx).", (u32)res);
strcpy(buf, "Failed to allocate a slot.\nPlease unselect a process in the process list first");
}
else
strcpy(buf, "Debugger not enabled.");
GDB_UnlockAllContexts(&gdbServer);
do
{