Skip to content

Commit

Permalink
Profiler: Add ability to process read syscalls
Browse files Browse the repository at this point in the history
Profiler can now process and display read events.
  • Loading branch information
jakubberkop authored and awesomekling committed Feb 14, 2022
1 parent fae991f commit cdfb388
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
9 changes: 9 additions & 0 deletions Userland/DevTools/Profiler/Profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,15 @@ ErrorOr<NonnullOwnPtr<Profile>> Profile::load_from_perfcore_file(StringView path
if (it != current_processes.end())
it->value->handle_thread_exit(event.tid, event.serial);
continue;
} else if (type_string == "read"sv) {
const auto string_index = perf_event.get("filename_index"sv).to_number<FlatPtr>();
event.data = Event::ReadData {
.fd = perf_event.get("fd"sv).to_number<int>(),
.size = perf_event.get("size"sv).to_number<size_t>(),
.path = profile_strings.get(string_index).value(),
.start_timestamp = perf_event.get("start_timestamp"sv).to_number<size_t>(),
.success = perf_event.get("success"sv).to_bool()
};
} else {
dbgln("Unknown event type '{}'", type_string);
VERIFY_NOT_REACHED();
Expand Down
10 changes: 9 additions & 1 deletion Userland/DevTools/Profiler/Profile.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,15 @@ class Profile {
pid_t parent_tid {};
};

Variant<std::nullptr_t, SampleData, MallocData, FreeData, SignpostData, MmapData, MunmapData, ProcessCreateData, ProcessExecData, ThreadCreateData> data { nullptr };
struct ReadData {
int fd;
size_t size;
String path;
size_t start_timestamp;
bool success;
};

Variant<std::nullptr_t, SampleData, MallocData, FreeData, SignpostData, MmapData, MunmapData, ProcessCreateData, ProcessExecData, ThreadCreateData, ReadData> data { nullptr };
};

Vector<Event> const& events() const { return m_events; }
Expand Down
9 changes: 9 additions & 0 deletions Userland/DevTools/Profiler/SamplesModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ String SamplesModel::column_name(int column) const
return "Lost Samples";
case Column::InnermostStackFrame:
return "Innermost Frame";
case Column::Path:
return "Path";
default:
VERIFY_NOT_REACHED();
}
Expand Down Expand Up @@ -89,6 +91,13 @@ GUI::Variant SamplesModel::data(GUI::ModelIndex const& index, GUI::ModelRole rol
if (index.column() == Column::InnermostStackFrame) {
return event.frames.last().symbol;
}

if (index.column() == Column::Path) {
if (!event.data.has<Profile::Event::ReadData>())
return "";
return event.data.get<Profile::Event::ReadData>().path;
}

return {};
}
return {};
Expand Down
1 change: 1 addition & 0 deletions Userland/DevTools/Profiler/SamplesModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class SamplesModel final : public GUI::Model {
ExecutableName,
LostSamples,
InnermostStackFrame,
Path,
__Count
};

Expand Down

0 comments on commit cdfb388

Please sign in to comment.