mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 01:17:35 +00:00
Profiler: Use sequential serial numbers for profiling events
Previously Profiler was using timestamps to distinguish processes. However it is possible that separate processes with the same PID exist at the exact same timestamp (e.g. for execve). This changes Profiler to use unique serial numbers for each event instead.
This commit is contained in:
parent
af72b5ec82
commit
a607f13fc7
8 changed files with 125 additions and 47 deletions
|
@ -6,6 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "EventSerialNumber.h"
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/MappedFile.h>
|
||||
#include <AK/OwnPtr.h>
|
||||
|
@ -42,12 +43,12 @@ private:
|
|||
|
||||
struct Thread {
|
||||
pid_t tid;
|
||||
u64 start_valid;
|
||||
u64 end_valid { 0 };
|
||||
EventSerialNumber start_valid;
|
||||
EventSerialNumber end_valid;
|
||||
|
||||
bool valid_at(u64 timestamp) const
|
||||
bool valid_at(EventSerialNumber serial) const
|
||||
{
|
||||
return timestamp >= start_valid && (end_valid == 0 || timestamp <= end_valid);
|
||||
return serial >= start_valid && (end_valid == EventSerialNumber {} || serial <= end_valid);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -57,16 +58,16 @@ struct Process {
|
|||
String basename;
|
||||
HashMap<int, Vector<Thread>> threads {};
|
||||
LibraryMetadata library_metadata {};
|
||||
u64 start_valid;
|
||||
u64 end_valid { 0 };
|
||||
EventSerialNumber start_valid;
|
||||
EventSerialNumber end_valid;
|
||||
|
||||
Thread* find_thread(pid_t tid, u64 timestamp);
|
||||
void handle_thread_create(pid_t tid, u64 timestamp);
|
||||
void handle_thread_exit(pid_t tid, u64 timestamp);
|
||||
Thread* find_thread(pid_t tid, EventSerialNumber serial);
|
||||
void handle_thread_create(pid_t tid, EventSerialNumber serial);
|
||||
void handle_thread_exit(pid_t tid, EventSerialNumber serial);
|
||||
|
||||
bool valid_at(u64 timestamp) const
|
||||
bool valid_at(EventSerialNumber serial) const
|
||||
{
|
||||
return timestamp >= start_valid && (end_valid == 0 || timestamp <= end_valid);
|
||||
return serial >= start_valid && (end_valid == EventSerialNumber {} || serial <= end_valid);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue