summaryrefslogtreecommitdiff
path: root/Kernel/PerformanceEventBuffer.h
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-03-02 19:01:02 +0100
committerAndreas Kling <kling@serenityos.org>2021-03-02 22:38:06 +0100
commit5e7abea31e447f234e18d933e3421fc204009fcc (patch)
tree93d2662dfffd7ed9b338af1d145899f20fa1201d /Kernel/PerformanceEventBuffer.h
parentea500dd3e31f531212af2e9a33ff40f26de48594 (diff)
downloadserenity-5e7abea31e447f234e18d933e3421fc204009fcc.zip
Kernel+Profiler: Capture metadata about all profiled processes
The perfcore file format was previously limited to a single process since the pid/executable/regions data was top-level in the JSON. This patch moves the process-specific data into a top-level array named "processes" and we now add entries for each process that has been sampled during the profile run. This makes it possible to see samples from multiple threads when viewing a perfcore file with Profiler. This is extremely cool! :^)
Diffstat (limited to 'Kernel/PerformanceEventBuffer.h')
-rw-r--r--Kernel/PerformanceEventBuffer.h20
1 files changed, 16 insertions, 4 deletions
diff --git a/Kernel/PerformanceEventBuffer.h b/Kernel/PerformanceEventBuffer.h
index b85b60f7c8..18c1a1d087 100644
--- a/Kernel/PerformanceEventBuffer.h
+++ b/Kernel/PerformanceEventBuffer.h
@@ -75,15 +75,25 @@ public:
return const_cast<PerformanceEventBuffer&>(*this).at(index);
}
- OwnPtr<KBuffer> to_json(ProcessID, const String& executable_path) const;
- bool to_json(KBufferBuilder&, ProcessID, const String& executable_path) const;
+ bool to_json(KBufferBuilder&) const;
- // Used by full-system profile (/proc/profile)
- bool to_json(KBufferBuilder&);
+ void add_process(const Process&);
private:
explicit PerformanceEventBuffer(NonnullOwnPtr<KBuffer>);
+ struct SampledProcess {
+ ProcessID pid;
+ String executable;
+ HashTable<ThreadID> threads;
+
+ struct Region {
+ String name;
+ Range range;
+ };
+ Vector<Region> regions;
+ };
+
template<typename Serializer>
bool to_json_impl(Serializer&) const;
@@ -91,6 +101,8 @@ private:
size_t m_count { 0 };
NonnullOwnPtr<KBuffer> m_buffer;
+
+ HashMap<ProcessID, NonnullOwnPtr<SampledProcess>> m_processes;
};
}