1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 04:28:13 +00:00

Kernel: Make sys$perf_register_string() generate the string ID's

Making userspace provide a global string ID was silly, and made the API
extremely difficult to use correctly in a global profiling context.

Instead, simply make the kernel do the string ID allocation for us.
This also allows us to convert the string storage to a Vector in the
kernel (and an array in the JSON profile data.)
This commit is contained in:
Andreas Kling 2021-08-11 20:41:29 +02:00
parent 56e84a63ca
commit 1e90a3a542
8 changed files with 24 additions and 24 deletions

View file

@ -167,9 +167,9 @@ template<typename Serializer>
bool PerformanceEventBuffer::to_json_impl(Serializer& object) const
{
{
auto strings = object.add_object("strings");
auto strings = object.add_array("strings");
for (auto& it : m_strings) {
strings.add(String::number(it.key), it.value->view());
strings.add(it.view());
}
}
@ -305,13 +305,14 @@ void PerformanceEventBuffer::add_process(const Process& process, ProcessEventTyp
}
}
KResult PerformanceEventBuffer::register_string(FlatPtr string_id, NonnullOwnPtr<KString> string)
KResultOr<FlatPtr> PerformanceEventBuffer::register_string(NonnullOwnPtr<KString> string)
{
m_strings.set(string_id, move(string));
FlatPtr string_id = m_strings.size();
// FIXME: Switch m_strings to something that can signal allocation failure,
// and then propagate such failures here.
return KSuccess;
if (!m_strings.try_append(move(string)))
return ENOBUFS;
return string_id;
}
}