mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-02-15 12:15:59 +00:00
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! :^)
This commit is contained in:
@@ -448,10 +448,13 @@ bool Process::dump_perfcore()
|
||||
if (description_or_error.is_error())
|
||||
return false;
|
||||
auto& description = description_or_error.value();
|
||||
auto json = m_perf_event_buffer->to_json(m_pid, m_executable ? m_executable->absolute_path() : "");
|
||||
if (!json)
|
||||
KBufferBuilder builder;
|
||||
if (!m_perf_event_buffer->to_json(builder))
|
||||
return false;
|
||||
|
||||
auto json = builder.build();
|
||||
if (!json)
|
||||
return false;
|
||||
auto json_buffer = UserOrKernelBuffer::for_kernel_buffer(json->data());
|
||||
return !description->write(json_buffer, json->size()).is_error();
|
||||
}
|
||||
@@ -671,6 +674,7 @@ bool Process::create_perf_events_buffer_if_needed()
|
||||
{
|
||||
if (!m_perf_event_buffer) {
|
||||
m_perf_event_buffer = PerformanceEventBuffer::try_create_with_size(4 * MiB);
|
||||
m_perf_event_buffer->add_process(*this);
|
||||
}
|
||||
return !!m_perf_event_buffer;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user