Merge pull request #796 from O1L/master

PPU / SPU / RawSPU threads in KernelExplorer.
This commit is contained in:
Alexandro Sánchez Bach 2014-09-08 23:16:10 +02:00
commit a99c8e3c7c
3 changed files with 125 additions and 21 deletions

View File

@ -93,6 +93,22 @@ public:
return "Unknown";
}
std::string ThreadStatusToString()
{
switch (ThreadStatus())
{
case CPUThread_Ready: return "Ready";
case CPUThread_Running: return "Running";
case CPUThread_Paused: return "Paused";
case CPUThread_Stopped: return "Stopped";
case CPUThread_Sleeping: return "Sleeping";
case CPUThread_Break: return "Break";
case CPUThread_Step: return "Step";
default: return "Unknown status";
}
}
std::string GetTypeString() const { return CPUThreadTypeToString(m_type); }
virtual std::string GetThreadName() const

View File

@ -709,9 +709,12 @@ int cellHddGameCheck(u32 version, vm::ptr<const char> dirName, u32 errDialog, vm
// TODO ?
funcStat(result, get, set);
if (result->result != CELL_HDDGAME_CBRESULT_OK &&
/*
if (result->result != CELL_HDDGAME_CBRESULT_OK && // error on compiling in MVS. Needs to use LE byte order?
result->result != CELL_HDDGAME_CBRESULT_OK_CANCEL)
return CELL_HDDGAME_ERROR_CBRESULT;
*/
// TODO ?

View File

@ -5,6 +5,8 @@
#include "Emu/IdManager.h"
#include "KernelExplorer.h"
#include "Emu/CPU/CPUThreadManager.h"
#include "Emu/CPU/CPUThread.h"
KernelExplorer::KernelExplorer(wxWindow* parent)
: wxFrame(parent, wxID_ANY, "Kernel Explorer", wxDefaultPosition, wxSize(700, 450))
@ -46,17 +48,17 @@ void KernelExplorer::Update()
m_tree->DeleteAllItems();
const auto& root = m_tree->AddRoot("Process, ID = 0x00000001, Total Memory Usage = 0x???????? (???.? MB)");
// TODO: PPU Threads
// TODO: SPU/RawSPU Threads
// TODO: FileSystem
// Semaphores
count = Emu.GetIdManager().GetTypeCount(TYPE_SEMAPHORE);
if (count) {
if (count)
{
sprintf(name, "Semaphores (%d)", count);
const auto& node = m_tree->AppendItem(root, name);
const auto& objects = Emu.GetIdManager().GetTypeIDs(TYPE_SEMAPHORE);
for (const auto& id : objects) {
for (const auto& id : objects)
{
sprintf(name, "Semaphore: ID = 0x%08x", id);
m_tree->AppendItem(node, name);
}
@ -64,11 +66,13 @@ void KernelExplorer::Update()
// Mutexes
count = Emu.GetIdManager().GetTypeCount(TYPE_MUTEX);
if (count) {
if (count)
{
sprintf(name, "Mutexes (%d)", count);
const auto& node = m_tree->AppendItem(root, name);
const auto& objects = Emu.GetIdManager().GetTypeIDs(TYPE_MUTEX);
for (const auto& id : objects) {
for (const auto& id : objects)
{
sprintf(name, "Mutex: ID = 0x%08x", id);
m_tree->AppendItem(node, name);
}
@ -76,11 +80,13 @@ void KernelExplorer::Update()
// Light Weight Mutexes
count = Emu.GetIdManager().GetTypeCount(TYPE_LWMUTEX);
if (count) {
if (count)
{
sprintf(name, "Light Weight Mutexes (%d)", count);
const auto& node = m_tree->AppendItem(root, name);
const auto& objects = Emu.GetIdManager().GetTypeIDs(TYPE_LWMUTEX);
for (const auto& id : objects) {
for (const auto& id : objects)
{
sprintf(name, "LW Mutex: ID = 0x%08x", id);
m_tree->AppendItem(node, name);
}
@ -88,11 +94,13 @@ void KernelExplorer::Update()
// Condition Variables
count = Emu.GetIdManager().GetTypeCount(TYPE_COND);
if (count) {
if (count)
{
sprintf(name, "Condition Variables (%d)", count);
const auto& node = m_tree->AppendItem(root, name);
const auto& objects = Emu.GetIdManager().GetTypeIDs(TYPE_COND);
for (const auto& id : objects) {
for (const auto& id : objects)
{
sprintf(name, "Condition Variable: ID = 0x%08x", id);
m_tree->AppendItem(node, name);
}
@ -100,11 +108,13 @@ void KernelExplorer::Update()
// Light Weight Condition Variables
count = Emu.GetIdManager().GetTypeCount(TYPE_LWCOND);
if (count) {
if (count)
{
sprintf(name, "Light Weight Condition Variables (%d)", count);
const auto& node = m_tree->AppendItem(root, name);
const auto& objects = Emu.GetIdManager().GetTypeIDs(TYPE_LWCOND);
for (const auto& id : objects) {
for (const auto& id : objects)
{
sprintf(name, "LW Condition Variable: ID = 0x%08x", id);
m_tree->AppendItem(node, name);
}
@ -112,11 +122,13 @@ void KernelExplorer::Update()
// Event Queues
count = Emu.GetIdManager().GetTypeCount(TYPE_EVENT_QUEUE);
if (count) {
if (count)
{
sprintf(name, "Event Queues (%d)", count);
const auto& node = m_tree->AppendItem(root, name);
const auto& objects = Emu.GetIdManager().GetTypeIDs(TYPE_EVENT_QUEUE);
for (const auto& id : objects) {
for (const auto& id : objects)
{
sprintf(name, "Event Queue: ID = 0x%08x", id);
m_tree->AppendItem(node, name);
}
@ -124,13 +136,15 @@ void KernelExplorer::Update()
// Modules
count = Emu.GetIdManager().GetTypeCount(TYPE_PRX);
if (count) {
if (count)
{
sprintf(name, "Modules (%d)", count);
const auto& node = m_tree->AppendItem(root, name);
const auto& objects = Emu.GetIdManager().GetTypeIDs(TYPE_PRX);
sprintf(name, "Segment List (%d)", 2 * objects.size()); // TODO: Assuming 2 segments per PRX file is not good
m_tree->AppendItem(node, name);
for (const auto& id : objects) {
for (const auto& id : objects)
{
sprintf(name, "PRX: ID = 0x%08x", id);
m_tree->AppendItem(node, name);
}
@ -138,27 +152,98 @@ void KernelExplorer::Update()
// Memory Containers
count = Emu.GetIdManager().GetTypeCount(TYPE_MEM);
if (count) {
if (count)
{
sprintf(name, "Memory Containers (%d)", count);
const auto& node = m_tree->AppendItem(root, name);
const auto& objects = Emu.GetIdManager().GetTypeIDs(TYPE_MEM);
for (const auto& id : objects) {
for (const auto& id : objects)
{
sprintf(name, "Memory Container: ID = 0x%08x", id);
m_tree->AppendItem(node, name);
}
}
// Event Flags
count = Emu.GetIdManager().GetTypeCount(TYPE_EVENT_FLAG);
if (count) {
if (count)
{
sprintf(name, "Event Flags (%d)", count);
const auto& node = m_tree->AppendItem(root, name);
const auto& objects = Emu.GetIdManager().GetTypeIDs(TYPE_EVENT_FLAG);
for (const auto& id : objects) {
for (const auto& id : objects)
{
sprintf(name, "Event Flag: ID = 0x%08x", id);
m_tree->AppendItem(node, name);
}
}
// PPU / SPU / RawSPU threads
{
// TODO: add mutexes owners
const auto& objects = Emu.GetCPU().GetThreads();
u32 ppu_threads_count = 0;
u32 spu_threads_count = 0;
u32 raw_spu_threads_count = 0;
for (const auto& thread : objects)
{
if (thread->GetType() == CPU_THREAD_PPU)
ppu_threads_count++;
if (thread->GetType() == CPU_THREAD_SPU)
spu_threads_count++;
if (thread->GetType() == CPU_THREAD_RAW_SPU)
raw_spu_threads_count++;
}
if (ppu_threads_count)
{
sprintf(name, "PPU Threads (%d)", ppu_threads_count);
const auto& node = m_tree->AppendItem(root, name);
for (const auto& thread : objects)
{
if (thread->GetType() == CPU_THREAD_PPU)
{
sprintf(name, "Thread: ID = 0x%08x ''%s'', - %s", thread->GetId(), thread->GetName().c_str(), thread->ThreadStatusToString().c_str());
m_tree->AppendItem(node, name);
}
}
}
if (spu_threads_count)
{
sprintf(name, "SPU Threads (%d)", spu_threads_count);
const auto& node = m_tree->AppendItem(root, name);
for (const auto& thread : objects)
{
if (thread->GetType() == CPU_THREAD_SPU)
{
sprintf(name, "Thread: ID = 0x%08x ''%s'', - %s", thread->GetId(), thread->GetName().c_str(), thread->ThreadStatusToString().c_str());
m_tree->AppendItem(node, name);
}
}
}
if (raw_spu_threads_count)
{
sprintf(name, "RawSPU Threads (%d)", raw_spu_threads_count);
const auto& node = m_tree->AppendItem(root, name);
for (const auto& thread : objects)
{
if (thread->GetType() == CPU_THREAD_RAW_SPU)
{
sprintf(name, "Thread: ID = 0x%08x ''%s'', - %s", thread->GetId(), thread->GetName().c_str(), thread->ThreadStatusToString().c_str());
m_tree->AppendItem(node, name);
}
}
}
}
m_tree->Expand(root);
}