Fix debug bug

This commit is contained in:
TuxSH 2019-03-30 15:05:49 +01:00
parent 5955ca6957
commit 127101a683

View File

@ -10,7 +10,7 @@
#include "luma.h" #include "luma.h"
// Note: official PM has two distinct functions for sysmodule vs. regular app. We refactor that into a single function. // Note: official PM has two distinct functions for sysmodule vs. regular app. We refactor that into a single function.
static Result launchTitleImpl(Handle *debug, ProcessData **outProcessData, const FS_ProgramInfo *programInfo, static Result launchTitleImpl(Handle *outDebug, ProcessData **outProcessData, const FS_ProgramInfo *programInfo,
const FS_ProgramInfo *programInfoUpdate, u32 launchFlags, ExHeader_Info *exheaderInfo); const FS_ProgramInfo *programInfoUpdate, u32 launchFlags, ExHeader_Info *exheaderInfo);
// Note: official PM doesn't include svcDebugActiveProcess in this function, but rather in the caller handling dependencies // Note: official PM doesn't include svcDebugActiveProcess in this function, but rather in the caller handling dependencies
@ -23,6 +23,10 @@ static Result loadWithoutDependencies(Handle *outDebug, ProcessData **outProcess
ProcessData *process; ProcessData *process;
const ExHeader_Arm11SystemLocalCapabilities *localcaps = &exheaderInfo->aci.local_caps; const ExHeader_Arm11SystemLocalCapabilities *localcaps = &exheaderInfo->aci.local_caps;
if (outDebug != NULL) {
*outDebug = 0;
}
if (outProcessData != NULL) { if (outProcessData != NULL) {
*outProcessData = NULL; *outProcessData = NULL;
} }
@ -83,7 +87,7 @@ static Result loadWithoutDependencies(Handle *outDebug, ProcessData **outProcess
(*outProcessData)->flags |= PROCESSFLAG_NORMAL_APPLICATION; // not in official PM (*outProcessData)->flags |= PROCESSFLAG_NORMAL_APPLICATION; // not in official PM
} }
if (launchFlags & PMLAUNCHFLAG_QUEUE_DEBUG_APPLICATION) { if (outDebug != NULL) {
TRY(svcDebugActiveProcess(outDebug, pid)); TRY(svcDebugActiveProcess(outDebug, pid));
} }
@ -106,6 +110,11 @@ static Result loadWithDependencies(Handle *outDebug, ProcessData **outProcessDat
ProcessData *process = *outProcessData; ProcessData *process = *outProcessData;
if (R_FAILED(res)) { if (R_FAILED(res)) {
if (outDebug != NULL) {
svcCloseHandle(*outDebug);
*outDebug = 0;
}
if (process != NULL) { if (process != NULL) {
svcTerminateProcess(process->handle); svcTerminateProcess(process->handle);
} }
@ -150,6 +159,11 @@ static Result loadWithDependencies(Handle *outDebug, ProcessData **outProcessDat
remrefcounts[i] = 0; remrefcounts[i] = 0;
listMergeUniqueDependencies(depProcs, dependencies, remrefcounts, &numUnique, depExheaderInfo); // does some incref too listMergeUniqueDependencies(depProcs, dependencies, remrefcounts, &numUnique, depExheaderInfo); // does some incref too
} else if (process != NULL) { } else if (process != NULL) {
if (outDebug != NULL) {
svcCloseHandle(*outDebug);
*outDebug = 0;
}
svcTerminateProcess(process->handle); svcTerminateProcess(process->handle);
ExHeaderInfoHeap_Delete(depExheaderInfo); ExHeaderInfoHeap_Delete(depExheaderInfo);
return res; return res;