mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 03:17:35 +00:00
Profiler: Parse and render signpost strings
The first perf_event argument to a PERF_EVENT_SIGNPOST is now interpreted as a string ID (in the profile strings set.) This allows us to generate signposts with custom strings. :^)
This commit is contained in:
parent
4657c79143
commit
3ed6c137df
3 changed files with 15 additions and 3 deletions
|
@ -208,6 +208,17 @@ Result<NonnullOwnPtr<Profile>, String> Profile::load_from_perfcore_file(const St
|
|||
if (!file_or_error.is_error())
|
||||
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)" };
|
||||
|
||||
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());
|
||||
});
|
||||
|
||||
auto events_value = object.get_ptr("events");
|
||||
if (!events_value || !events_value->is_array())
|
||||
return String { "Malformed profile (events is not an array)" };
|
||||
|
@ -242,7 +253,8 @@ Result<NonnullOwnPtr<Profile>, String> Profile::load_from_perfcore_file(const St
|
|||
event.ptr = perf_event.get("ptr").to_number<FlatPtr>();
|
||||
} else if (event.type == "signpost"sv) {
|
||||
is_signpost = true;
|
||||
event.arg1 = perf_event.get("arg1").to_number<FlatPtr>();
|
||||
auto string_id = perf_event.get("arg1").to_number<FlatPtr>();
|
||||
event.signpost_string = profile_strings.get(string_id).value_or(String::formatted("Signpost #{}", string_id));
|
||||
event.arg2 = perf_event.get("arg2").to_number<FlatPtr>();
|
||||
} else if (event.type == "mmap"sv) {
|
||||
event.ptr = perf_event.get("ptr").to_number<FlatPtr>();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue