mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 21:47:46 +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
|
@ -8,19 +8,19 @@
|
|||
|
||||
namespace Profiler {
|
||||
|
||||
Thread* Process::find_thread(pid_t tid, u64 timestamp)
|
||||
Thread* Process::find_thread(pid_t tid, EventSerialNumber serial)
|
||||
{
|
||||
auto it = threads.find(tid);
|
||||
if (it == threads.end())
|
||||
return nullptr;
|
||||
for (auto& thread : it->value) {
|
||||
if (thread.start_valid < timestamp && (thread.end_valid == 0 || thread.end_valid > timestamp))
|
||||
if (thread.start_valid < serial && (thread.end_valid == EventSerialNumber {} || thread.end_valid > serial))
|
||||
return &thread;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void Process::handle_thread_create(pid_t tid, u64 timestamp)
|
||||
void Process::handle_thread_create(pid_t tid, EventSerialNumber serial)
|
||||
{
|
||||
auto it = threads.find(tid);
|
||||
if (it == threads.end()) {
|
||||
|
@ -28,16 +28,16 @@ void Process::handle_thread_create(pid_t tid, u64 timestamp)
|
|||
it = threads.find(tid);
|
||||
}
|
||||
|
||||
auto thread = Thread { tid, timestamp, 0 };
|
||||
auto thread = Thread { tid, serial, {} };
|
||||
it->value.append(move(thread));
|
||||
}
|
||||
|
||||
void Process::handle_thread_exit(pid_t tid, u64 timestamp)
|
||||
void Process::handle_thread_exit(pid_t tid, EventSerialNumber serial)
|
||||
{
|
||||
auto* thread = find_thread(tid, timestamp);
|
||||
auto* thread = find_thread(tid, serial);
|
||||
if (!thread)
|
||||
return;
|
||||
thread->end_valid = timestamp;
|
||||
thread->end_valid = serial;
|
||||
}
|
||||
|
||||
HashMap<String, OwnPtr<MappedObject>> g_mapped_object_cache;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue