Fix log-stack problem in kernel

This commit is contained in:
Henrik Rydgård 2025-03-08 01:14:54 +01:00
parent 3564333582
commit 881e88268f
3 changed files with 11 additions and 8 deletions

View file

@ -2442,8 +2442,7 @@ static u32 sceKernelStopUnloadSelfModuleWithStatus(u32 exitCode, u32 argSize, u3
return __KernelStopUnloadSelfModuleWithOrWithoutStatus(exitCode, argSize, argp, statusAddr, optionAddr, true);
}
void __KernelReturnFromModuleFunc()
{
void __KernelReturnFromModuleFunc() {
// Return from the thread as normal.
hleSkipDeadbeef();
__KernelReturnFromThread();
@ -2451,6 +2450,10 @@ void __KernelReturnFromModuleFunc()
SceUID leftModuleID = __KernelGetCurThreadModuleId();
SceUID leftThreadID = __KernelGetCurThread();
int exitStatus = __KernelGetThreadExitStatus(leftThreadID);
if (exitStatus < 0) {
ERROR_LOG(Log::sceModule, "%s=GetThreadExitStatus(%d)", KernelErrorToString(exitStatus), leftThreadID);
}
// What else should happen with the exit status?
// Reschedule immediately (to leave the thread) and delete it and its stack.
__KernelReSchedule("returned from module");

View file

@ -1333,21 +1333,21 @@ int __KernelGetThreadExitStatus(SceUID threadID) {
u32 error;
PSPThread *t = kernelObjects.Get<PSPThread>(threadID, error);
if (!t) {
return hleLogError(Log::sceKernel, error);
return error;
}
// __KernelResetThread and __KernelCreateThread set exitStatus in case it's DORMANT.
if (t->nt.status == THREADSTATUS_DORMANT) {
return hleLogDebug(Log::sceKernel, t->nt.exitStatus);
return t->nt.exitStatus;
}
return hleLogVerbose(Log::sceKernel, SCE_KERNEL_ERROR_NOT_DORMANT, "not dormant");
return SCE_KERNEL_ERROR_NOT_DORMANT;
}
int sceKernelGetThreadExitStatus(SceUID threadID) {
u32 status = __KernelGetThreadExitStatus(threadID);
int status = __KernelGetThreadExitStatus(threadID);
// Seems this is called in a tight-ish loop, maybe awaiting an interrupt - issue #13698
hleEatCycles(330);
return hleNoLog(status);
return hleLogDebugOrError(Log::sceKernel, status);
}
u32 sceKernelGetThreadmanIdType(u32 uid) {

View file

@ -996,7 +996,7 @@ void DrawAudioDecodersView(ImConfig &cfg, ImControl &control) {
if (cfg.selectedAtracCtx >= 0 && cfg.selectedAtracCtx < PSP_NUM_ATRAC_IDS) {
u32 type = 0;
const AtracBase *ctx = __AtracGetCtx(cfg.selectedAtracCtx, &type);
const AtracCtx *ctx = __AtracGetCtx(cfg.selectedAtracCtx, &type);
// Show details about the selected atrac context here.
char header[32];
snprintf(header, sizeof(header), "Atrac context %d", cfg.selectedAtracCtx);