mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 18:02:05 -05: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>();
|
||||
|
|
|
@ -178,7 +178,7 @@ public:
|
|||
bool in_kernel { false };
|
||||
|
||||
// FIXME: Put event type-specific arguments in a union to save memory.
|
||||
FlatPtr arg1 {};
|
||||
String signpost_string;
|
||||
FlatPtr arg2 {};
|
||||
|
||||
Vector<Frame> frames;
|
||||
|
|
|
@ -135,7 +135,7 @@ void TimelineTrack::mousemove_event(GUI::MouseEvent& event)
|
|||
constexpr int hoverable_padding = 2;
|
||||
Gfx::IntRect hoverable_rect { x - hoverable_padding, frame_thickness(), hoverable_padding * 2, height() - frame_thickness() * 2 };
|
||||
if (hoverable_rect.contains_horizontally(event.x())) {
|
||||
GUI::Application::the()->show_tooltip_immediately(String::formatted("Signpost {}, {}", signpost.arg1, signpost.arg2), this);
|
||||
GUI::Application::the()->show_tooltip_immediately(String::formatted("Signpost {}, {}", signpost.signpost_string, signpost.arg2), this);
|
||||
hovering_a_signpost = true;
|
||||
return IterationDecision::Break;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue