Merge pull request #2654 from Kingcom/Debugger

Add thread list columns
This commit is contained in:
Henrik Rydgård 2013-07-06 12:51:28 -07:00
commit a28cfe6327
3 changed files with 60 additions and 3 deletions

View File

@ -38,6 +38,50 @@
#include "sceKernelModule.h"
#include "sceKernelInterrupt.h"
typedef struct
{
WaitType type;
char* name;
} WaitTypeNames;
const WaitTypeNames waitTypeNames[] = {
{ WAITTYPE_NONE, "None" },
{ WAITTYPE_SLEEP, "Sleep" },
{ WAITTYPE_DELAY, "Delay" },
{ WAITTYPE_SEMA, "Semaphore" },
{ WAITTYPE_EVENTFLAG, "Event flag", },
{ WAITTYPE_MBX, "MBX" },
{ WAITTYPE_VPL, "VPL" },
{ WAITTYPE_FPL, "FPL" },
{ WAITTYPE_MSGPIPE, "Message pipe" },
{ WAITTYPE_THREADEND, "Thread end" },
{ WAITTYPE_AUDIOCHANNEL, "Audio channel" },
{ WAITTYPE_UMD, "UMD" },
{ WAITTYPE_VBLANK, "VBlank" },
{ WAITTYPE_MUTEX, "Mutex" },
{ WAITTYPE_LWMUTEX, "LwMutex" },
{ WAITTYPE_CTRL, "Control" },
{ WAITTYPE_IO, "IO" },
{ WAITTYPE_GEDRAWSYNC, "GeDrawSync" },
{ WAITTYPE_GELISTSYNC, "GeListSync" },
{ WAITTYPE_MODULE, "Module" },
{ WAITTYPE_HLEDELAY, "HleDelay" }
};
char* getWaitTypeName(WaitType type)
{
int waitTypeNamesAmount = sizeof(waitTypeNames)/sizeof(WaitTypeNames);
for (int i = 0; i < waitTypeNamesAmount; i++)
{
if (waitTypeNames[i].type == type)
{
return waitTypeNames[i].name;
}
}
return "Unknown";
}
enum {
PSP_THREAD_ATTR_KERNEL = 0x00001000,
@ -3480,6 +3524,8 @@ std::vector<DebugThreadInfo> GetThreadsInfo()
info.name[KERNELOBJECT_MAX_NAME_LENGTH] = 0;
info.status = t->nt.status;
info.entrypoint = t->nt.entrypoint;
info.priority = t->nt.currentPriority;
info.waitType = t->nt.waitType;
if(*iter == currentThread)
info.curPC = currentMIPS->pc;
else

View File

@ -68,6 +68,7 @@ struct SceKernelSysClock {
// TODO: Map these to PSP wait types.
// remember to update the waitTypeNames array in sceKernelThread.cpp when changing these
enum WaitType
{
WAITTYPE_NONE = 0,
@ -95,6 +96,8 @@ enum WaitType
NUM_WAITTYPES
};
char* getWaitTypeName(WaitType type);
// Suspend wait and timeout while a thread enters a callback.
typedef void (* WaitBeginCallbackFunc)(SceUID threadID, SceUID prevCallbackId);
// Resume wait and timeout as a thread exits a callback.
@ -311,6 +314,8 @@ struct DebugThreadInfo
u32 status;
int curPC;
int entrypoint;
int priority;
WaitType waitType;
bool isCurrent;
};

View File

@ -4,14 +4,14 @@
#include <commctrl.h>
#include "DebuggerShared.h"
enum { TL_NAME, TL_PROGRAMCOUNTER, TL_ENTRYPOINT, TL_STATE, TL_COLUMNCOUNT };
enum { TL_NAME, TL_PROGRAMCOUNTER, TL_ENTRYPOINT, TL_PRIORITY, TL_STATE, TL_WAITTYPE, TL_COLUMNCOUNT };
char* threadColumns[] = {
"Name", "PC", "Entry Point", "State"
"Name", "PC", "Entry Point", "Priority","State", "Wait type"
};
const float threadColumnSizes[] = {
0.25f, 0.25f, 0.25f, 0.25f
0.20f, 0.15f, 0.15f, 0.15f, 0.15f, 0.20f
};
void CtrlThreadList::setDialogItem(HWND hwnd)
@ -126,6 +126,9 @@ void CtrlThreadList::handleNotify(LPARAM lParam)
case TL_ENTRYPOINT:
sprintf(stringBuffer,"0x%08X",threads[index].entrypoint);
break;
case TL_PRIORITY:
sprintf(stringBuffer,"%d",threads[index].priority);
break;
case TL_STATE:
switch (threads[index].status)
{
@ -155,6 +158,9 @@ void CtrlThreadList::handleNotify(LPARAM lParam)
break;
}
break;
case TL_WAITTYPE:
strcpy(stringBuffer,getWaitTypeName(threads[index].waitType));
break;
}
if (stringBuffer[0] == 0) strcat(stringBuffer,"Invalid");