Fix logging of ppu name in sys_ppu_thread_create/rename

This commit is contained in:
Eladash 2020-01-23 21:32:06 +02:00 committed by Ani
parent d481c3c7fd
commit 7ae679adbe

View file

@ -289,7 +289,7 @@ error_code sys_ppu_thread_restart(u32 thread_id)
error_code _sys_ppu_thread_create(vm::ptr<u64> thread_id, vm::ptr<ppu_thread_param_t> param, u64 arg, u64 unk, s32 prio, u32 _stacksz, u64 flags, vm::cptr<char> threadname)
{
sys_ppu_thread.warning("_sys_ppu_thread_create(thread_id=*0x%x, param=*0x%x, arg=0x%llx, unk=0x%llx, prio=%d, stacksize=0x%x, flags=0x%llx, threadname=%s)",
sys_ppu_thread.warning("_sys_ppu_thread_create(thread_id=*0x%x, param=*0x%x, arg=0x%llx, unk=0x%llx, prio=%d, stacksize=0x%x, flags=0x%llx, threadname=*0x%x)",
thread_id, param, arg, unk, prio, _stacksz, flags, threadname);
// thread_id is checked for null in stub -> CELL_ENOMEM
@ -320,11 +320,12 @@ error_code _sys_ppu_thread_create(vm::ptr<u64> thread_id, vm::ptr<ppu_thread_par
return CELL_ENOMEM;
}
std::string ppu_name;
const u32 tid = idm::import<named_thread<ppu_thread>>([&]()
{
const u32 tid = idm::last_id();
std::string ppu_name;
std::string full_name = fmt::format("PPU[0x%x] Thread", tid);
if (threadname)
@ -332,7 +333,11 @@ error_code _sys_ppu_thread_create(vm::ptr<u64> thread_id, vm::ptr<ppu_thread_par
constexpr u32 max_size = 27; // max size including null terminator
const auto pname = threadname.get_ptr();
ppu_name.assign(pname, std::find(pname, pname + max_size, '\0'));
fmt::append(full_name, " (%s)", ppu_name);
if (!ppu_name.empty())
{
fmt::append(full_name, " (%s)", ppu_name);
}
}
ppu_thread_params p;
@ -353,6 +358,7 @@ error_code _sys_ppu_thread_create(vm::ptr<u64> thread_id, vm::ptr<ppu_thread_par
}
*thread_id = tid;
sys_ppu_thread.warning(u8"_sys_ppu_thread_create(): Thread “%s” created (id=0x%x)", ppu_name, tid);
return CELL_OK;
}
@ -410,7 +416,7 @@ error_code sys_ppu_thread_start(ppu_thread& ppu, u32 thread_id)
error_code sys_ppu_thread_rename(u32 thread_id, vm::cptr<char> name)
{
sys_ppu_thread.warning("sys_ppu_thread_rename(thread_id=0x%x, name=%s)", thread_id, name);
sys_ppu_thread.warning("sys_ppu_thread_rename(thread_id=0x%x, name=*0x%x)", thread_id, name);
const auto thread = idm::get<named_thread<ppu_thread>>(thread_id);
@ -428,7 +434,8 @@ error_code sys_ppu_thread_rename(u32 thread_id, vm::cptr<char> name)
const auto pname = name.get_ptr();
// thread_ctrl name is not changed (TODO)
thread->ppu_name.assign(pname, std::find(pname, pname + max_size, '\0'));
const std::string res = thread->ppu_name.assign(pname, std::find(pname, pname + max_size, '\0'));
sys_ppu_thread.warning(u8"sys_ppu_thread_rename(): Thread renamed to “%s”", res);
return CELL_OK;
}