1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-10 18:10:56 +09: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
Notes: sideshowbarker 2024-07-18 07:06:20 +09:00
7 changed files with 43 additions and 0 deletions

View file

@ -166,6 +166,13 @@ PerformanceEvent& PerformanceEventBuffer::at(size_t index)
template<typename Serializer>
bool PerformanceEventBuffer::to_json_impl(Serializer& object) const
{
{
auto strings = object.add_object("strings");
for (auto& it : m_strings) {
strings.add(String::number(it.key), it.value->view());
}
}
auto array = object.add_array("events");
bool seen_first_sample = false;
for (size_t i = 0; i < m_count; ++i) {
@ -298,4 +305,13 @@ void PerformanceEventBuffer::add_process(const Process& process, ProcessEventTyp
}
}
KResult PerformanceEventBuffer::register_string(FlatPtr string_id, NonnullOwnPtr<KString> string)
{
m_strings.set(string_id, move(string));
// FIXME: Switch m_strings to something that can signal allocation failure,
// and then propagate such failures here.
return KSuccess;
}
}