summaryrefslogtreecommitdiff
path: root/Userland/DevTools/Profiler/SamplesModel.cpp
diff options
context:
space:
mode:
authorGunnar Beutner <gunnar@beutner.name>2021-04-25 23:42:36 +0200
committerAndreas Kling <kling@serenityos.org>2021-04-26 17:13:55 +0200
commiteb798d5538ea3c978034d8d8364ecfd7fbc6a8ee (patch)
treee023bc175ec5e7d89898f5214701e6d50154b75f /Userland/DevTools/Profiler/SamplesModel.cpp
parentf57c57966bb560a7090f4da528e5486d4c4de3f6 (diff)
downloadserenity-eb798d5538ea3c978034d8d8364ecfd7fbc6a8ee.zip
Kernel+Profiler: Improve profiling subsystem
This turns the perfcore format into more a log than it was before, which lets us properly log process, thread and region creation/destruction. This also makes it unnecessary to dump the process' regions every time it is scheduled like we did before. Incidentally this also fixes 'profile -c' because we previously ended up incorrectly dumping the parent's region map into the profile data. Log-based mmap support enables profiling shared libraries which are loaded at runtime, e.g. via dlopen(). This enables profiling both the parent and child process for programs which use execve(). Previously we'd discard the profiling data for the old process. The Profiler tool has been updated to not treat thread IDs as process IDs anymore. This enables support for processes with more than one thread. Also, there's a new widget to filter which process should be displayed.
Diffstat (limited to 'Userland/DevTools/Profiler/SamplesModel.cpp')
-rw-r--r--Userland/DevTools/Profiler/SamplesModel.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/Userland/DevTools/Profiler/SamplesModel.cpp b/Userland/DevTools/Profiler/SamplesModel.cpp
index b916061a1b..e46866e956 100644
--- a/Userland/DevTools/Profiler/SamplesModel.cpp
+++ b/Userland/DevTools/Profiler/SamplesModel.cpp
@@ -22,7 +22,7 @@ SamplesModel::~SamplesModel()
int SamplesModel::row_count(const GUI::ModelIndex&) const
{
- return m_profile.filtered_event_count();
+ return m_profile.filtered_event_indices().size();
}
int SamplesModel::column_count(const GUI::ModelIndex&) const
@@ -37,6 +37,8 @@ String SamplesModel::column_name(int column) const
return "#";
case Column::Timestamp:
return "Timestamp";
+ case Column::ProcessID:
+ return "PID";
case Column::ThreadID:
return "TID";
case Column::ExecutableName:
@@ -50,7 +52,7 @@ String SamplesModel::column_name(int column) const
GUI::Variant SamplesModel::data(const GUI::ModelIndex& index, GUI::ModelRole role) const
{
- u32 event_index = m_profile.first_filtered_event_index() + index.row();
+ u32 event_index = m_profile.filtered_event_indices()[index.row()];
auto& event = m_profile.events().at(event_index);
if (role == GUI::ModelRole::Custom) {
@@ -61,12 +63,14 @@ GUI::Variant SamplesModel::data(const GUI::ModelIndex& index, GUI::ModelRole rol
if (index.column() == Column::SampleIndex)
return event_index;
+ if (index.column() == Column::ProcessID)
+ return event.pid;
+
if (index.column() == Column::ThreadID)
return event.tid;
if (index.column() == Column::ExecutableName) {
- // FIXME: More abuse of the PID/TID relationship:
- if (auto* process = m_profile.find_process(event.tid))
+ if (auto* process = m_profile.find_process(event.pid, event.timestamp))
return process->executable;
return "";
}