mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
ImDebugger thread window: Visualize the wait ID when possible
This commit is contained in:
parent
93baf22369
commit
e0a1d658ea
1 changed files with 58 additions and 13 deletions
|
@ -160,6 +160,50 @@ static const char *ThreadStatusToString(u32 status) {
|
|||
return "(unk)";
|
||||
}
|
||||
|
||||
void WaitIDToString(WaitType waitType, SceUID waitID, char *buffer, size_t bufSize) {
|
||||
switch (waitType) {
|
||||
case WAITTYPE_AUDIOCHANNEL:
|
||||
snprintf(buffer, bufSize, "chan %d", (int)waitID);
|
||||
return;
|
||||
case WAITTYPE_IO:
|
||||
// TODO: More detail
|
||||
snprintf(buffer, bufSize, "fd: %d", (int)waitID);
|
||||
return;
|
||||
case WAITTYPE_ASYNCIO:
|
||||
snprintf(buffer, bufSize, "id: %d", (int)waitID);
|
||||
return;
|
||||
case WAITTYPE_THREADEND:
|
||||
case WAITTYPE_MUTEX:
|
||||
case WAITTYPE_LWMUTEX:
|
||||
case WAITTYPE_MODULE:
|
||||
case WAITTYPE_MSGPIPE:
|
||||
case WAITTYPE_FPL:
|
||||
case WAITTYPE_VPL:
|
||||
case WAITTYPE_MBX:
|
||||
case WAITTYPE_EVENTFLAG:
|
||||
case WAITTYPE_SEMA:
|
||||
// Get the name of the thread
|
||||
if (kernelObjects.IsValid(waitID)) {
|
||||
auto obj = kernelObjects.GetFast<KernelObject>(waitID);
|
||||
if (obj && obj->GetName()) {
|
||||
truncate_cpy(buffer, bufSize, obj->GetName());
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case WAITTYPE_DELAY:
|
||||
case WAITTYPE_SLEEP:
|
||||
case WAITTYPE_HLEDELAY:
|
||||
case WAITTYPE_UMD:
|
||||
truncate_cpy(buffer, bufSize, "-");
|
||||
return;
|
||||
default:
|
||||
truncate_cpy(buffer, bufSize, "(unimpl)");
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void DrawThreadView(ImConfig &cfg) {
|
||||
ImGui::SetNextWindowSize(ImVec2(420, 300), ImGuiCond_FirstUseEver);
|
||||
if (!ImGui::Begin("Threads", &cfg.threadsOpen)) {
|
||||
|
@ -168,7 +212,8 @@ void DrawThreadView(ImConfig &cfg) {
|
|||
}
|
||||
|
||||
std::vector<DebugThreadInfo> info = GetThreadsInfo();
|
||||
if (ImGui::BeginTable("threads", 7, ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersH)) {
|
||||
if (ImGui::BeginTable("threads", 8, ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersH)) {
|
||||
ImGui::TableSetupColumn("Id", ImGuiTableColumnFlags_WidthFixed);
|
||||
ImGui::TableSetupColumn("Name", ImGuiTableColumnFlags_WidthFixed);
|
||||
ImGui::TableSetupColumn("PC", ImGuiTableColumnFlags_WidthFixed);
|
||||
ImGui::TableSetupColumn("Entry", ImGuiTableColumnFlags_WidthFixed);
|
||||
|
@ -183,6 +228,8 @@ void DrawThreadView(ImConfig &cfg) {
|
|||
const DebugThreadInfo &thread = info[i];
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("%d", thread.id);
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::PushID(i);
|
||||
if (ImGui::Selectable(thread.name, cfg.selectedThread == i, ImGuiSelectableFlags_AllowDoubleClick | ImGuiSelectableFlags_SpanAllColumns)) {
|
||||
cfg.selectedThread = i;
|
||||
|
@ -200,16 +247,11 @@ void DrawThreadView(ImConfig &cfg) {
|
|||
ImGui::TableNextColumn();
|
||||
ImGui::TextUnformatted(ThreadStatusToString(thread.status));
|
||||
ImGui::TableNextColumn();
|
||||
if (thread.waitType != WAITTYPE_NONE) {
|
||||
ImGui::TextUnformatted(getWaitTypeName(thread.waitType));
|
||||
} else {
|
||||
ImGui::TextUnformatted("N/A");
|
||||
}
|
||||
ImGui::TextUnformatted(getWaitTypeName(thread.waitType));
|
||||
ImGui::TableNextColumn();
|
||||
switch (thread.waitType) {
|
||||
default:
|
||||
ImGui::TextUnformatted("N/A");
|
||||
}
|
||||
char temp[64];
|
||||
WaitIDToString(thread.waitType, thread.waitID, temp, sizeof(temp));
|
||||
ImGui::TextUnformatted(temp);
|
||||
if (ImGui::BeginPopup("threadPopup")) {
|
||||
DebugThreadInfo &thread = info[i];
|
||||
ImGui::Text("Thread: %s", thread.name);
|
||||
|
@ -218,16 +260,19 @@ void DrawThreadView(ImConfig &cfg) {
|
|||
snprintf(temp, sizeof(temp), "%08x", thread.entrypoint);
|
||||
System_CopyStringToClipboard(temp);
|
||||
}
|
||||
if (ImGui::MenuItem("Copy PC to clipboard")) {
|
||||
if (ImGui::MenuItem("Copy thread PC to clipboard")) {
|
||||
char temp[64];
|
||||
snprintf(temp, sizeof(temp), "%08x", thread.curPC);
|
||||
System_CopyStringToClipboard(temp);
|
||||
}
|
||||
if (ImGui::MenuItem("Kill thread")) {
|
||||
// Dangerous!
|
||||
sceKernelTerminateThread(thread.id);
|
||||
}
|
||||
if (ImGui::MenuItem("Force run")) {
|
||||
__KernelResumeThreadFromWait(thread.id, 0);
|
||||
if (thread.status == THREADSTATUS_WAIT) {
|
||||
if (ImGui::MenuItem("Force run now")) {
|
||||
__KernelResumeThreadFromWait(thread.id, 0);
|
||||
}
|
||||
}
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue