1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-04 21:07:35 +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:
Andreas Kling 2021-03-02 19:01:02 +01:00
parent ea500dd3e3
commit 5e7abea31e
11 changed files with 223 additions and 102 deletions

View file

@ -552,8 +552,15 @@ void Scheduler::timer_tick(const RegisterState& regs)
VERIFY(g_global_perf_events);
// FIXME: We currently don't collect samples while idle.
// That will be an interesting mode to add in the future. :^)
if (current_thread != Processor::current().idle_thread())
if (current_thread != Processor::current().idle_thread()) {
perf_events = g_global_perf_events;
if (current_thread->process().space().enforces_syscall_regions()) {
// FIXME: This is very nasty! We dump the current process's address
// space layout *every time* it's sampled. We should figure out
// a way to do this less often.
perf_events->add_process(current_thread->process());
}
}
} else if (current_thread->process().is_profiling()) {
VERIFY(current_thread->process().perf_events());
perf_events = current_thread->process().perf_events();