1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 04:17:35 +00:00

Kernel+LibC: Add sys$perf_register_string()

This syscall allows userspace to register a keyed string that appears in
a new "strings" JSON object in profile output.

This will be used to add custom strings to profile signposts. :^)
This commit is contained in:
Andreas Kling 2021-08-11 20:28:29 +02:00
parent 00b11d7577
commit 4657c79143
7 changed files with 43 additions and 0 deletions

View file

@ -21,4 +21,18 @@ KResultOr<FlatPtr> Process::sys$perf_event(int type, FlatPtr arg1, FlatPtr arg2)
return events_buffer->append(type, arg1, arg2, nullptr);
}
KResultOr<FlatPtr> Process::sys$perf_register_string(FlatPtr string_id, Userspace<char const*> user_string, size_t user_string_length)
{
VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this)
auto* events_buffer = current_perf_events_buffer();
if (!events_buffer)
return KSuccess;
auto string_or_error = try_copy_kstring_from_user(user_string, user_string_length);
if (string_or_error.is_error())
return string_or_error.error();
return events_buffer->register_string(string_id, string_or_error.release_value());
}
}