1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 19:38:12 +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

@ -209,15 +209,14 @@ Result<NonnullOwnPtr<Profile>, String> Profile::load_from_perfcore_file(const St
kernel_elf = make<ELF::Image>(file_or_error.value()->bytes());
auto strings_value = object.get_ptr("strings"sv);
if (!strings_value || !strings_value->is_object())
return String { "Malformed profile (strings is not an object)" };
if (!strings_value || !strings_value->is_array())
return String { "Malformed profile (strings is not an array)" };
HashMap<FlatPtr, String> profile_strings;
strings_value->as_object().for_each_member([&](String const& key, JsonValue const& value) {
auto string_id = key.to_uint();
VERIFY(string_id.has_value());
profile_strings.set(string_id.value(), value.to_string());
});
for (FlatPtr string_id = 0; string_id < strings_value->as_array().size(); ++string_id) {
auto& value = strings_value->as_array().at(string_id);
profile_strings.set(string_id, value.to_string());
}
auto events_value = object.get_ptr("events");
if (!events_value || !events_value->is_array())