IdManager improved, added Fixed ID mechanism

Fixed UB in get_current_id()
This commit is contained in:
Nekotekina 2015-08-04 13:46:05 +03:00
parent c7ee8cadde
commit 9e5daa1737
5 changed files with 187 additions and 101 deletions

View file

@ -14,7 +14,9 @@
#include "Emu/SysCalls/lv2/sys_cond.h"
#include "Emu/SysCalls/lv2/sys_semaphore.h"
#include "Emu/SysCalls/lv2/sys_event.h"
#include "Emu/SysCalls/lv2/sys_process.h"
#include "Emu/SysCalls/lv2/sys_event_flag.h"
#include "Emu/SysCalls/lv2/sys_prx.h"
#include "Emu/SysCalls/lv2/sys_memory.h"
#include "KernelExplorer.h"
@ -78,12 +80,12 @@ void KernelExplorer::Update()
// TODO: FileSystem
// Semaphores
if (u32 count = Emu.GetIdManager().get_count(SYS_SEMAPHORE_OBJECT))
if (u32 count = Emu.GetIdManager().get_count<lv2_sema_t>())
{
sprintf(name, "Semaphores (%d)", count);
const auto& node = m_tree->AppendItem(root, name);
for (const auto id : Emu.GetIdManager().get_IDs(SYS_SEMAPHORE_OBJECT))
for (const auto id : Emu.GetIdManager().get_set<lv2_sema_t>())
{
const auto sem = Emu.GetIdManager().get<lv2_sema_t>(id);
sprintf(name, "Semaphore: ID = 0x%x '%s', Count = %d, Max Count = %d, Waiters = %#llx", id, &name64(sem->name), sem->value.load(), sem->max, sem->sq.size());
@ -92,12 +94,12 @@ void KernelExplorer::Update()
}
// Mutexes
if (u32 count = Emu.GetIdManager().get_count(SYS_MUTEX_OBJECT))
if (u32 count = Emu.GetIdManager().get_count<lv2_mutex_t>())
{
sprintf(name, "Mutexes (%d)", count);
const auto& node = m_tree->AppendItem(root, name);
for (const auto id : Emu.GetIdManager().get_IDs(SYS_MUTEX_OBJECT))
for (const auto id : Emu.GetIdManager().get_set<lv2_mutex_t>())
{
const auto mutex = Emu.GetIdManager().get<lv2_mutex_t>(id);
sprintf(name, "Mutex: ID = 0x%x '%s'", id, &name64(mutex->name));
@ -106,12 +108,12 @@ void KernelExplorer::Update()
}
// Light Weight Mutexes
if (u32 count = Emu.GetIdManager().get_count(SYS_LWMUTEX_OBJECT))
if (u32 count = Emu.GetIdManager().get_count<lv2_lwmutex_t>())
{
sprintf(name, "Lightweight Mutexes (%d)", count);
const auto& node = m_tree->AppendItem(root, name);
for (const auto id : Emu.GetIdManager().get_IDs(SYS_LWMUTEX_OBJECT))
for (const auto id : Emu.GetIdManager().get_set<lv2_lwmutex_t>())
{
const auto lwm = Emu.GetIdManager().get<lv2_lwmutex_t>(id);
sprintf(name, "Lightweight Mutex: ID = 0x%x '%s'", id, &name64(lwm->name));
@ -120,12 +122,12 @@ void KernelExplorer::Update()
}
// Condition Variables
if (u32 count = Emu.GetIdManager().get_count(SYS_COND_OBJECT))
if (u32 count = Emu.GetIdManager().get_count<lv2_cond_t>())
{
sprintf(name, "Condition Variables (%d)", count);
const auto& node = m_tree->AppendItem(root, name);
for (const auto id : Emu.GetIdManager().get_IDs(SYS_COND_OBJECT))
for (const auto id : Emu.GetIdManager().get_set<lv2_cond_t>())
{
const auto cond = Emu.GetIdManager().get<lv2_cond_t>(id);
sprintf(name, "Condition Variable: ID = 0x%x '%s'", id, &name64(cond->name));
@ -134,12 +136,12 @@ void KernelExplorer::Update()
}
// Light Weight Condition Variables
if (u32 count = Emu.GetIdManager().get_count(SYS_LWCOND_OBJECT))
if (u32 count = Emu.GetIdManager().get_count<lv2_lwcond_t>())
{
sprintf(name, "Lightweight Condition Variables (%d)", count);
const auto& node = m_tree->AppendItem(root, name);
for (const auto id : Emu.GetIdManager().get_IDs(SYS_LWCOND_OBJECT))
for (const auto id : Emu.GetIdManager().get_set<lv2_lwcond_t>())
{
const auto lwc = Emu.GetIdManager().get<lv2_lwcond_t>(id);
sprintf(name, "Lightweight Condition Variable: ID = 0x%x '%s'", id, &name64(lwc->name));
@ -148,12 +150,12 @@ void KernelExplorer::Update()
}
// Event Queues
if (u32 count = Emu.GetIdManager().get_count(SYS_EVENT_QUEUE_OBJECT))
if (u32 count = Emu.GetIdManager().get_count<lv2_event_queue_t>())
{
sprintf(name, "Event Queues (%d)", count);
const auto& node = m_tree->AppendItem(root, name);
for (const auto id : Emu.GetIdManager().get_IDs(SYS_EVENT_QUEUE_OBJECT))
for (const auto id : Emu.GetIdManager().get_set<lv2_event_queue_t>())
{
const auto queue = Emu.GetIdManager().get<lv2_event_queue_t>(id);
sprintf(name, "Event Queue: ID = 0x%x '%s', Key = %#llx", id, &name64(queue->name), queue->key);
@ -162,12 +164,12 @@ void KernelExplorer::Update()
}
// Event Ports
if (u32 count = Emu.GetIdManager().get_count(SYS_EVENT_PORT_OBJECT))
if (u32 count = Emu.GetIdManager().get_count<lv2_event_port_t>())
{
sprintf(name, "Event Ports (%d)", count);
const auto& node = m_tree->AppendItem(root, name);
for (const auto id : Emu.GetIdManager().get_IDs(SYS_EVENT_PORT_OBJECT))
for (const auto id : Emu.GetIdManager().get_set<lv2_event_port_t>())
{
const auto port = Emu.GetIdManager().get<lv2_event_port_t>(id);
sprintf(name, "Event Port: ID = 0x%x, Name = %#llx", id, port->name);
@ -176,14 +178,14 @@ void KernelExplorer::Update()
}
// Modules
if (u32 count = Emu.GetIdManager().get_count(SYS_PRX_OBJECT))
if (u32 count = Emu.GetIdManager().get_count<lv2_prx_t>())
{
sprintf(name, "Modules (%d)", count);
const auto& node = m_tree->AppendItem(root, name);
//sprintf(name, "Segment List (%l)", 2 * objects.size()); // TODO: Assuming 2 segments per PRX file is not good
//m_tree->AppendItem(node, name);
for (const auto& id : Emu.GetIdManager().get_IDs(SYS_PRX_OBJECT))
for (const auto& id : Emu.GetIdManager().get_set<lv2_prx_t>())
{
sprintf(name, "PRX: ID = 0x%x", id);
m_tree->AppendItem(node, name);
@ -191,12 +193,12 @@ void KernelExplorer::Update()
}
// Memory Containers
if (u32 count = Emu.GetIdManager().get_count(SYS_MEM_OBJECT))
if (u32 count = Emu.GetIdManager().get_count<lv2_memory_container_t>())
{
sprintf(name, "Memory Containers (%d)", count);
const auto& node = m_tree->AppendItem(root, name);
for (const auto& id : Emu.GetIdManager().get_IDs(SYS_MEM_OBJECT))
for (const auto& id : Emu.GetIdManager().get_set<lv2_memory_container_t>())
{
sprintf(name, "Memory Container: ID = 0x%x", id);
m_tree->AppendItem(node, name);
@ -204,12 +206,12 @@ void KernelExplorer::Update()
}
// Event Flags
if (u32 count = Emu.GetIdManager().get_count(SYS_EVENT_FLAG_OBJECT))
if (u32 count = Emu.GetIdManager().get_count<lv2_event_flag_t>())
{
sprintf(name, "Event Flags (%d)", count);
const auto& node = m_tree->AppendItem(root, name);
for (const auto& id : Emu.GetIdManager().get_IDs(SYS_EVENT_FLAG_OBJECT))
for (const auto& id : Emu.GetIdManager().get_set<lv2_event_flag_t>())
{
sprintf(name, "Event Flag: ID = 0x%x", id);
m_tree->AppendItem(node, name);