1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-22 14:45:08 +00:00

UserspaceEmulator: Add support for set_thread_name

It should be noted that creating threads is still not supported.
This commit is contained in:
AnotherTest 2020-10-24 11:25:58 +03:30 committed by Andreas Kling
parent 617c5ba045
commit fcc38422c6
2 changed files with 11 additions and 0 deletions

View file

@ -32,6 +32,7 @@
#include <AK/Format.h>
#include <AK/LexicalPath.h>
#include <Kernel/API/Syscall.h>
#include <LibPthread/pthread.h>
#include <LibX86/ELFSymbolProvider.h>
#include <fcntl.h>
#include <net/if.h>
@ -392,6 +393,8 @@ u32 Emulator::virt_syscall(u32 function, u32 arg1, u32 arg2, u32 arg3)
return virt$sched_getparam(arg1, arg2);
case SC_sched_setparam:
return virt$sched_setparam(arg1, arg2);
case SC_set_thread_name:
return virt$set_thread_name(arg1, arg2, arg3);
default:
reportln("\n=={}== \033[31;1mUnimplemented syscall: {}\033[0m, {:p}", getpid(), Syscall::to_string((Syscall::Function)function), function);
dump_backtrace();
@ -1450,4 +1453,11 @@ int Emulator::virt$sched_setparam(int pid, FlatPtr user_addr)
return syscall(SC_sched_setparam, pid, &user_param);
}
int Emulator::virt$set_thread_name(pid_t pid, FlatPtr name_addr, size_t name_length)
{
auto user_name = mmu().copy_buffer_from_vm(name_addr, name_length);
auto name = String::formatted("(UE) {}", StringView { user_name.data(), user_name.size() });
return syscall(SC_set_thread_name, pid, name.characters(), name.length());
}
}