1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-26 12:42:41 +01:00

Log sys_spu thread group and thread names

Also safely read thread name after relevant error checks passed.
This commit is contained in:
Eladash 2020-01-23 22:24:38 +02:00 committed by Ani
parent 7ae679adbe
commit 4e0070f16d

View File

@ -272,33 +272,11 @@ error_code sys_spu_thread_initialize(ppu_thread& ppu, vm::ptr<u32> thread, u32 g
return CELL_EINVAL;
}
// Read thread name
const std::string thread_name(attr->name.get_ptr(), std::max<u32>(attr->name_len, 1) - 1);
const auto group = idm::get<lv2_spu_group>(group_id);
if (!group)
{
return CELL_ESRCH;
}
if (spu_num >= group->threads_map.size())
{
return CELL_EINVAL;
}
if (img->type != SYS_SPU_IMAGE_TYPE_KERNEL && img->type != SYS_SPU_IMAGE_TYPE_USER)
{
return CELL_EINVAL;
}
std::lock_guard lock(group->mutex);
if (group->threads_map[spu_num] != -1 || group->run_state != SPU_THREAD_GROUP_STATUS_NOT_INITIALIZED)
{
return CELL_EBUSY;
}
sys_spu_image image = *img;
if (img->type == SYS_SPU_IMAGE_TYPE_KERNEL)
@ -314,6 +292,28 @@ error_code sys_spu_thread_initialize(ppu_thread& ppu, vm::ptr<u32> thread, u32 g
image.entry_point = handle->e_entry;
}
// Read thread name
const std::string thread_name(attr->name.get_ptr(), std::max<u32>(attr->name_len, 1) - 1);
const auto group = idm::get<lv2_spu_group>(group_id);
if (!group)
{
return CELL_ESRCH;
}
if (spu_num >= group->threads_map.size())
{
return CELL_EINVAL;
}
std::lock_guard lock(group->mutex);
if (group->threads_map[spu_num] != -1 || group->run_state != SPU_THREAD_GROUP_STATUS_NOT_INITIALIZED)
{
return CELL_EBUSY;
}
if (u32 option = attr->option)
{
sys_spu.warning("Unimplemented SPU Thread options (0x%x)", option);
@ -362,6 +362,7 @@ error_code sys_spu_thread_initialize(ppu_thread& ppu, vm::ptr<u32> thread, u32 g
group->run_state = SPU_THREAD_GROUP_STATUS_INITIALIZED;
}
sys_spu.warning(u8"sys_spu_thread_initialize(): Thread “%s” created (id=0x%x)", thread_name, tid);
return CELL_OK;
}
@ -426,8 +427,15 @@ error_code sys_spu_thread_group_create(ppu_thread& ppu, vm::ptr<u32> id, u32 num
sys_spu.warning("sys_spu_thread_group_create(): SPU Thread Group type (0x%x)", attr->type);
}
*id = idm::make<lv2_spu_group>(std::string(attr->name.get_ptr(), std::max<u32>(attr->nsize, 1) - 1), num, prio, attr->type, attr->ct);
const auto group = idm::make_ptr<lv2_spu_group>(std::string(attr->name.get_ptr(), std::max<u32>(attr->nsize, 1) - 1), num, prio, attr->type, attr->ct);
if (!group)
{
return CELL_EAGAIN;
}
*id = idm::last_id();
sys_spu.warning(u8"sys_spu_thread_group_create(): Thread group “%s” created (id=0x%x)", group->name, idm::last_id());
return CELL_OK;
}