kernel explorer: Implement ability to view lwmutex owner

This commit is contained in:
Eladash 2020-03-21 23:02:36 +02:00 committed by Ivan
parent 12044bd8b0
commit f1cf62ac57

View File

@ -205,7 +205,35 @@ void kernel_explorer::Update()
case SYS_LWMUTEX_OBJECT:
{
auto& lwm = static_cast<lv2_lwmutex&>(obj);
l_addTreeChild(node, qstr(fmt::format(u8"LWMutex: ID = 0x%08x “%s”, Wq = %zu", id, lv2_obj::name64(lwm.name), lwm.sq.size())));
std::string owner_str = "unknown"; // Either invalid state or the lwmutex control data was moved from
sys_lwmutex_t lwm_data{};
if (lwm.control.try_read(lwm_data))
{
switch (const u32 owner = lwm_data.vars.owner)
{
case lwmutex_free: owner_str = "free"; break;
//case lwmutex_dead: owner_str = "dead"; break;
case lwmutex_reserved: owner_str = "reserved"; break;
default:
{
if (owner >= ppu_thread::id_base && owner <= ppu_thread::id_base + ppu_thread::id_step - 1)
{
owner_str = fmt::format("0x%x", owner);
}
break;
}
}
}
else
{
l_addTreeChild(node, qstr(fmt::format(u8"LWMutex: ID = 0x%08x “%s”, Wq = %zu (Couldn't extract control data)", id, lv2_obj::name64(lwm.name), lwm.sq.size())));
break;
}
l_addTreeChild(node, qstr(fmt::format(u8"LWMutex: ID = 0x%08x “%s”,%s Owner = %s, Locks = %u, Wq = %zu", id, lv2_obj::name64(lwm.name),
(lwm_data.attribute & SYS_SYNC_RECURSIVE) ? " Recursive," : "", owner_str, lwm_data.recursive_count, lwm.sq.size())));
break;
}
case SYS_TIMER_OBJECT: