mirror of
https://github.com/jpd002/Play-.git
synced 2025-04-28 13:47:57 +03:00
More WIP.
- Remove thread specific object list. - Use a map instead of vector for object schema.
This commit is contained in:
parent
ac13a43a99
commit
02d5b9ce98
10 changed files with 121 additions and 106 deletions
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <variant>
|
||||
#include "Types.h"
|
||||
|
||||
|
@ -16,18 +17,6 @@ struct BIOS_DEBUG_MODULE_INFO
|
|||
typedef std::vector<BIOS_DEBUG_MODULE_INFO> BiosDebugModuleInfoArray;
|
||||
typedef BiosDebugModuleInfoArray::iterator BiosDebugModuleInfoIterator;
|
||||
|
||||
struct BIOS_DEBUG_THREAD_INFO
|
||||
{
|
||||
uint32 id;
|
||||
uint32 priority;
|
||||
uint32 pc;
|
||||
uint32 ra;
|
||||
uint32 sp;
|
||||
std::string stateDescription;
|
||||
};
|
||||
|
||||
typedef std::vector<BIOS_DEBUG_THREAD_INFO> BiosDebugThreadInfoArray;
|
||||
|
||||
typedef std::variant<uint32, std::string> BIOS_DEBUG_OBJECT_FIELD;
|
||||
|
||||
struct BIOS_DEBUG_OBJECT
|
||||
|
@ -83,7 +72,6 @@ typedef std::vector<BIOS_DEBUG_OBJECT_FIELD_INFO> BiosDebugObjectFieldInfoArray;
|
|||
|
||||
struct BIOS_DEBUG_OBJECT_INFO
|
||||
{
|
||||
uint32 typeId = 0;
|
||||
std::string name;
|
||||
BiosDebugObjectFieldInfoArray fields;
|
||||
BIOS_DEBUG_OBJECT_ACTION selectionAction = BIOS_DEBUG_OBJECT_ACTION::NONE;
|
||||
|
@ -101,7 +89,7 @@ struct BIOS_DEBUG_OBJECT_INFO
|
|||
return -1;
|
||||
}
|
||||
};
|
||||
typedef std::vector<BIOS_DEBUG_OBJECT_INFO> BiosDebugObjectInfoArray;
|
||||
typedef std::map<uint32, BIOS_DEBUG_OBJECT_INFO> BiosDebugObjectInfoMap;
|
||||
|
||||
class CBiosDebugInfoProvider
|
||||
{
|
||||
|
@ -109,10 +97,9 @@ public:
|
|||
~CBiosDebugInfoProvider() = default;
|
||||
#ifdef DEBUGGER_INCLUDED
|
||||
virtual BiosDebugModuleInfoArray GetModulesDebugInfo() const = 0;
|
||||
virtual BiosDebugThreadInfoArray GetThreadsDebugInfo() const = 0;
|
||||
virtual BiosDebugObjectInfoArray GetBiosObjectsDebugInfo() const
|
||||
virtual BiosDebugObjectInfoMap GetBiosObjectsDebugInfo() const
|
||||
{
|
||||
return BiosDebugObjectInfoArray();
|
||||
return BiosDebugObjectInfoMap();
|
||||
}
|
||||
virtual BiosDebugObjectArray GetBiosObjects(uint32 typeId) const
|
||||
{
|
||||
|
|
|
@ -121,6 +121,7 @@ set(COMMON_SRC_FILES
|
|||
AppConfig.h
|
||||
BasicBlock.cpp
|
||||
BasicBlock.h
|
||||
BiosDebugInfoProvider.h
|
||||
BlockLookupOneWay.h
|
||||
BlockLookupTwoWay.h
|
||||
ControllerInfo.cpp
|
||||
|
|
|
@ -3695,26 +3695,19 @@ BiosDebugModuleInfoArray CPS2OS::GetModulesDebugInfo() const
|
|||
return result;
|
||||
}
|
||||
|
||||
BiosDebugThreadInfoArray CPS2OS::GetThreadsDebugInfo() const
|
||||
{
|
||||
BiosDebugThreadInfoArray threadInfos;
|
||||
return threadInfos;
|
||||
}
|
||||
|
||||
#define BIOS_OBJECT_TYPE_SEMAPHORES 0
|
||||
#define BIOS_OBJECT_TYPE_INTCHANDLERS 1
|
||||
#define BIOS_OBJECT_TYPE_DMACHANDLERS 2
|
||||
#define BIOS_OBJECT_TYPE_THREADS 3
|
||||
|
||||
BiosDebugObjectInfoArray CPS2OS::GetBiosObjectsDebugInfo() const
|
||||
BiosDebugObjectInfoMap CPS2OS::GetBiosObjectsDebugInfo() const
|
||||
{
|
||||
static BiosDebugObjectInfoArray objectDebugInfo = []
|
||||
static BiosDebugObjectInfoMap objectDebugInfo = []
|
||||
{
|
||||
BiosDebugObjectInfoArray result;
|
||||
BiosDebugObjectInfoMap result;
|
||||
{
|
||||
BIOS_DEBUG_OBJECT_INFO info;
|
||||
info.name = "Semaphores";
|
||||
info.typeId = BIOS_OBJECT_TYPE_SEMAPHORES;
|
||||
info.fields =
|
||||
{
|
||||
{ "Id" },
|
||||
|
@ -3722,12 +3715,11 @@ BiosDebugObjectInfoArray CPS2OS::GetBiosObjectsDebugInfo() const
|
|||
{ "Max Count" },
|
||||
{ "Wait Count" },
|
||||
};
|
||||
result.push_back(info);
|
||||
result.emplace(std::make_pair(BIOS_OBJECT_TYPE_SEMAPHORES, std::move(info)));
|
||||
}
|
||||
{
|
||||
BIOS_DEBUG_OBJECT_INFO info;
|
||||
info.name = "INTC Handlers";
|
||||
info.typeId = BIOS_OBJECT_TYPE_INTCHANDLERS;
|
||||
info.fields =
|
||||
{
|
||||
{ "Id", BIOS_DEBUG_OBJECT_FIELD_TYPE::UINT32 },
|
||||
|
@ -3737,12 +3729,11 @@ BiosDebugObjectInfoArray CPS2OS::GetBiosObjectsDebugInfo() const
|
|||
{ "GP", BIOS_DEBUG_OBJECT_FIELD_TYPE::UINT32, BIOS_DEBUG_OBJECT_FIELD_ATTRIBUTE::DATA_ADDRESS },
|
||||
{ "Next Id", BIOS_DEBUG_OBJECT_FIELD_TYPE::UINT32 },
|
||||
};
|
||||
result.push_back(info);
|
||||
result.emplace(std::make_pair(BIOS_OBJECT_TYPE_INTCHANDLERS, std::move(info)));
|
||||
}
|
||||
{
|
||||
BIOS_DEBUG_OBJECT_INFO info;
|
||||
info.name = "DMAC Handlers";
|
||||
info.typeId = BIOS_OBJECT_TYPE_DMACHANDLERS;
|
||||
info.fields =
|
||||
{
|
||||
{ "Id", BIOS_DEBUG_OBJECT_FIELD_TYPE::UINT32 },
|
||||
|
@ -3752,12 +3743,11 @@ BiosDebugObjectInfoArray CPS2OS::GetBiosObjectsDebugInfo() const
|
|||
{ "GP", BIOS_DEBUG_OBJECT_FIELD_TYPE::UINT32, BIOS_DEBUG_OBJECT_FIELD_ATTRIBUTE::DATA_ADDRESS },
|
||||
{ "Next Id", BIOS_DEBUG_OBJECT_FIELD_TYPE::UINT32 },
|
||||
};
|
||||
result.push_back(info);
|
||||
result.emplace(std::make_pair(BIOS_OBJECT_TYPE_DMACHANDLERS, std::move(info)));
|
||||
}
|
||||
{
|
||||
BIOS_DEBUG_OBJECT_INFO info;
|
||||
info.name = "Threads";
|
||||
info.typeId = BIOS_OBJECT_TYPE_THREADS;
|
||||
info.selectionAction = BIOS_DEBUG_OBJECT_ACTION::SHOW_STACK_OR_LOCATION;
|
||||
info.fields =
|
||||
{
|
||||
|
@ -3768,7 +3758,7 @@ BiosDebugObjectInfoArray CPS2OS::GetBiosObjectsDebugInfo() const
|
|||
{ "SP", BIOS_DEBUG_OBJECT_FIELD_TYPE::UINT32, BIOS_DEBUG_OBJECT_FIELD_ATTRIBUTE::STACK_POINTER | BIOS_DEBUG_OBJECT_FIELD_ATTRIBUTE::HIDDEN },
|
||||
{ "State", BIOS_DEBUG_OBJECT_FIELD_TYPE::STRING },
|
||||
};
|
||||
result.push_back(info);
|
||||
result.emplace(std::make_pair(BIOS_OBJECT_TYPE_THREADS, std::move(info)));
|
||||
}
|
||||
return result;
|
||||
}();
|
||||
|
|
|
@ -63,8 +63,7 @@ public:
|
|||
|
||||
#ifdef DEBUGGER_INCLUDED
|
||||
BiosDebugModuleInfoArray GetModulesDebugInfo() const override;
|
||||
BiosDebugThreadInfoArray GetThreadsDebugInfo() const override;
|
||||
BiosDebugObjectInfoArray GetBiosObjectsDebugInfo() const override;
|
||||
BiosDebugObjectInfoMap GetBiosObjectsDebugInfo() const override;
|
||||
BiosDebugObjectArray GetBiosObjects(uint32) const override;
|
||||
#endif
|
||||
|
||||
|
|
|
@ -3598,74 +3598,116 @@ BiosDebugModuleInfoArray CIopBios::GetModulesDebugInfo() const
|
|||
return m_moduleTags;
|
||||
}
|
||||
|
||||
BiosDebugThreadInfoArray CIopBios::GetThreadsDebugInfo() const
|
||||
#define BIOS_OBJECT_TYPE_THREADS 3
|
||||
|
||||
BiosDebugObjectInfoMap CIopBios::GetBiosObjectsDebugInfo() const
|
||||
{
|
||||
BiosDebugThreadInfoArray threadInfos;
|
||||
|
||||
for(auto thread : m_threads)
|
||||
static BiosDebugObjectInfoMap objectDebugInfo = []
|
||||
{
|
||||
if(!thread) continue;
|
||||
|
||||
BIOS_DEBUG_THREAD_INFO threadInfo;
|
||||
threadInfo.id = thread->id;
|
||||
threadInfo.priority = thread->priority;
|
||||
if(m_currentThreadId == threadInfo.id)
|
||||
BiosDebugObjectInfoMap result;
|
||||
{
|
||||
threadInfo.pc = m_cpu.m_State.nPC;
|
||||
threadInfo.ra = m_cpu.m_State.nGPR[CMIPS::RA].nV0;
|
||||
threadInfo.sp = m_cpu.m_State.nGPR[CMIPS::SP].nV0;
|
||||
}
|
||||
else
|
||||
{
|
||||
threadInfo.pc = thread->context.epc;
|
||||
threadInfo.ra = thread->context.gpr[CMIPS::RA];
|
||||
threadInfo.sp = thread->context.gpr[CMIPS::SP];
|
||||
}
|
||||
|
||||
int64 deltaTime = thread->nextActivateTime - GetCurrentTime();
|
||||
|
||||
switch(thread->status)
|
||||
{
|
||||
case THREAD_STATUS_DORMANT:
|
||||
threadInfo.stateDescription = "Dormant";
|
||||
break;
|
||||
case THREAD_STATUS_RUNNING:
|
||||
if(deltaTime <= 0)
|
||||
BIOS_DEBUG_OBJECT_INFO info;
|
||||
info.name = "Threads";
|
||||
info.selectionAction = BIOS_DEBUG_OBJECT_ACTION::SHOW_STACK_OR_LOCATION;
|
||||
info.fields =
|
||||
{
|
||||
threadInfo.stateDescription = "Running";
|
||||
{ "Id", BIOS_DEBUG_OBJECT_FIELD_TYPE::UINT32, BIOS_DEBUG_OBJECT_FIELD_ATTRIBUTE::IDENTIFIER },
|
||||
{ "Priority", BIOS_DEBUG_OBJECT_FIELD_TYPE::UINT32 },
|
||||
{ "Location", BIOS_DEBUG_OBJECT_FIELD_TYPE::UINT32, BIOS_DEBUG_OBJECT_FIELD_ATTRIBUTE::LOCATION | BIOS_DEBUG_OBJECT_FIELD_ATTRIBUTE::TEXT_ADDRESS },
|
||||
{ "RA", BIOS_DEBUG_OBJECT_FIELD_TYPE::UINT32, BIOS_DEBUG_OBJECT_FIELD_ATTRIBUTE::RETURN_ADDRESS | BIOS_DEBUG_OBJECT_FIELD_ATTRIBUTE::HIDDEN },
|
||||
{ "SP", BIOS_DEBUG_OBJECT_FIELD_TYPE::UINT32, BIOS_DEBUG_OBJECT_FIELD_ATTRIBUTE::STACK_POINTER | BIOS_DEBUG_OBJECT_FIELD_ATTRIBUTE::HIDDEN },
|
||||
{ "State", BIOS_DEBUG_OBJECT_FIELD_TYPE::STRING },
|
||||
};
|
||||
result.emplace(std::make_pair(BIOS_OBJECT_TYPE_THREADS, std::move(info)));
|
||||
}
|
||||
return result;
|
||||
}();
|
||||
return objectDebugInfo;
|
||||
}
|
||||
|
||||
BiosDebugObjectArray CIopBios::GetBiosObjects(uint32 typeId) const
|
||||
{
|
||||
BiosDebugObjectArray result;
|
||||
switch(typeId)
|
||||
{
|
||||
case BIOS_OBJECT_TYPE_THREADS:
|
||||
for(auto it = std::begin(m_threads); it != std::end(m_threads); it++)
|
||||
{
|
||||
auto thread = *it;
|
||||
if(!thread) continue;
|
||||
|
||||
uint32 pc = 0;
|
||||
uint32 ra = 0;
|
||||
uint32 sp = 0;
|
||||
|
||||
if(m_currentThreadId == it)
|
||||
{
|
||||
pc = m_cpu.m_State.nPC;
|
||||
ra = m_cpu.m_State.nGPR[CMIPS::RA].nV0;
|
||||
sp = m_cpu.m_State.nGPR[CMIPS::SP].nV0;
|
||||
}
|
||||
else
|
||||
{
|
||||
threadInfo.stateDescription = string_format("Delayed (%ld ticks)", deltaTime);
|
||||
pc = thread->context.epc;
|
||||
ra = thread->context.gpr[CMIPS::RA];
|
||||
sp = thread->context.gpr[CMIPS::SP];
|
||||
}
|
||||
break;
|
||||
case THREAD_STATUS_SLEEPING:
|
||||
threadInfo.stateDescription = "Sleeping";
|
||||
break;
|
||||
case THREAD_STATUS_WAITING_SEMAPHORE:
|
||||
threadInfo.stateDescription = string_format("Waiting (Semaphore: %d)", thread->waitSemaphore);
|
||||
break;
|
||||
case THREAD_STATUS_WAITING_EVENTFLAG:
|
||||
threadInfo.stateDescription = string_format("Waiting (Event Flag: %d)", thread->waitEventFlag);
|
||||
break;
|
||||
case THREAD_STATUS_WAITING_MESSAGEBOX:
|
||||
threadInfo.stateDescription = string_format("Waiting (Message Box: %d)", thread->waitMessageBox);
|
||||
break;
|
||||
case THREAD_STATUS_WAIT_VBLANK_START:
|
||||
threadInfo.stateDescription = "Waiting (Vblank Start)";
|
||||
break;
|
||||
case THREAD_STATUS_WAIT_VBLANK_END:
|
||||
threadInfo.stateDescription = "Waiting (Vblank End)";
|
||||
break;
|
||||
default:
|
||||
threadInfo.stateDescription = "Unknown";
|
||||
break;
|
||||
|
||||
std::string stateDescription;
|
||||
int64 deltaTime = thread->nextActivateTime - GetCurrentTime();
|
||||
|
||||
switch(thread->status)
|
||||
{
|
||||
case THREAD_STATUS_DORMANT:
|
||||
stateDescription = "Dormant";
|
||||
break;
|
||||
case THREAD_STATUS_RUNNING:
|
||||
if(deltaTime <= 0)
|
||||
{
|
||||
stateDescription = "Running";
|
||||
}
|
||||
else
|
||||
{
|
||||
stateDescription = string_format("Delayed (%ld ticks)", deltaTime);
|
||||
}
|
||||
break;
|
||||
case THREAD_STATUS_SLEEPING:
|
||||
stateDescription = "Sleeping";
|
||||
break;
|
||||
case THREAD_STATUS_WAITING_SEMAPHORE:
|
||||
stateDescription = string_format("Waiting (Semaphore: %d)", thread->waitSemaphore);
|
||||
break;
|
||||
case THREAD_STATUS_WAITING_EVENTFLAG:
|
||||
stateDescription = string_format("Waiting (Event Flag: %d)", thread->waitEventFlag);
|
||||
break;
|
||||
case THREAD_STATUS_WAITING_MESSAGEBOX:
|
||||
stateDescription = string_format("Waiting (Message Box: %d)", thread->waitMessageBox);
|
||||
break;
|
||||
case THREAD_STATUS_WAIT_VBLANK_START:
|
||||
stateDescription = "Waiting (Vblank Start)";
|
||||
break;
|
||||
case THREAD_STATUS_WAIT_VBLANK_END:
|
||||
stateDescription = "Waiting (Vblank End)";
|
||||
break;
|
||||
default:
|
||||
stateDescription = "Unknown";
|
||||
break;
|
||||
}
|
||||
|
||||
BIOS_DEBUG_OBJECT obj;
|
||||
obj.fields = {
|
||||
BIOS_DEBUG_OBJECT_FIELD(std::in_place_type<uint32>, it),
|
||||
BIOS_DEBUG_OBJECT_FIELD(std::in_place_type<uint32>, thread->priority),
|
||||
BIOS_DEBUG_OBJECT_FIELD(std::in_place_type<uint32>, pc),
|
||||
BIOS_DEBUG_OBJECT_FIELD(std::in_place_type<uint32>, ra),
|
||||
BIOS_DEBUG_OBJECT_FIELD(std::in_place_type<uint32>, sp),
|
||||
BIOS_DEBUG_OBJECT_FIELD(std::in_place_type<std::string>, stateDescription),
|
||||
};
|
||||
result.push_back(obj);
|
||||
}
|
||||
|
||||
threadInfos.push_back(threadInfo);
|
||||
break;
|
||||
}
|
||||
|
||||
return threadInfos;
|
||||
return result;
|
||||
}
|
||||
|
||||
void CIopBios::PrepareModuleDebugInfo(CELF32& elf, const ExecutableRange& moduleRange, const std::string& moduleName, const std::string& modulePath)
|
||||
|
|
|
@ -291,7 +291,8 @@ public:
|
|||
void SaveDebugTags(Framework::Xml::CNode*) override;
|
||||
|
||||
BiosDebugModuleInfoArray GetModulesDebugInfo() const override;
|
||||
BiosDebugThreadInfoArray GetThreadsDebugInfo() const override;
|
||||
BiosDebugObjectInfoMap GetBiosObjectsDebugInfo() const override;
|
||||
BiosDebugObjectArray GetBiosObjects(uint32) const override;
|
||||
#endif
|
||||
|
||||
typedef Framework::CSignal<void(const char*)> ModuleLoadedEvent;
|
||||
|
|
|
@ -189,11 +189,6 @@ BiosDebugModuleInfoArray CPsxBios::GetModulesDebugInfo() const
|
|||
return BiosDebugModuleInfoArray();
|
||||
}
|
||||
|
||||
BiosDebugThreadInfoArray CPsxBios::GetThreadsDebugInfo() const
|
||||
{
|
||||
return BiosDebugThreadInfoArray();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void CPsxBios::CountTicks(uint32 ticks)
|
||||
|
|
|
@ -53,7 +53,6 @@ public:
|
|||
void SaveDebugTags(Framework::Xml::CNode*) override;
|
||||
|
||||
BiosDebugModuleInfoArray GetModulesDebugInfo() const override;
|
||||
BiosDebugThreadInfoArray GetThreadsDebugInfo() const override;
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
|
|
@ -31,7 +31,7 @@ private:
|
|||
|
||||
CMIPS* m_context = nullptr;
|
||||
CBiosDebugInfoProvider* m_biosDebugInfoProvider = nullptr;
|
||||
BiosDebugObjectInfoArray m_schema;
|
||||
BiosDebugObjectInfoMap m_schema;
|
||||
QTableView* m_tableView = nullptr;
|
||||
CQtGenericTableModel* m_model = nullptr;
|
||||
uint32 m_objectType = 0;
|
||||
|
|
|
@ -495,12 +495,13 @@ void QtDebugger::ActivateView(unsigned int nView)
|
|||
ui->menuKernelObjects->clear();
|
||||
if(biosDebugInfoProvider)
|
||||
{
|
||||
auto objects = biosDebugInfoProvider->GetBiosObjectsDebugInfo();
|
||||
for(const auto& object : objects)
|
||||
auto objectTypes = biosDebugInfoProvider->GetBiosObjectsDebugInfo();
|
||||
for(const auto& objectTypePair : objectTypes)
|
||||
{
|
||||
const auto& objectType = objectTypePair.second;
|
||||
QAction* objectAction = new QAction(this);
|
||||
objectAction->setText(QString::fromStdString(object.name));
|
||||
objectAction->setData(object.typeId);
|
||||
objectAction->setText(QString::fromStdString(objectType.name));
|
||||
objectAction->setData(objectTypePair.first);
|
||||
//objectAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_O));
|
||||
connect(objectAction, SIGNAL(triggered()), this, SLOT(on_actionViewKernelObject_triggered()));
|
||||
ui->menuKernelObjects->addAction(objectAction);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue