diff options
author | Gunnar Beutner <gbeutner@serenityos.org> | 2021-06-01 17:22:23 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-06-02 09:24:58 +0200 |
commit | 15b69eef66fac3410ebd3c987688d06e034d83b1 (patch) | |
tree | c9367eb1660734c71b49918d381ba3c2654af2d8 /Userland/DevTools/Profiler | |
parent | 21a62fe8362982b206445fe64c7afa3a4ab842f1 (diff) | |
download | serenity-15b69eef66fac3410ebd3c987688d06e034d83b1.zip |
Profiler: Fix loading profiles which previously would crash the profiler
The profiler tried to be clever when handling process_exit events by
subtracting one from the timestamp. This was supposed to ensure that
events after a process' death would be attributed to the new process
in case the old process used execve(). However, if there was another
event (e.g. a CPU sample) at the exact same time the process_exit
event was recorded the profile would fail to load because we
didn't find the process anymore.
This changes introduces a new problem where samples would be attributed
to the incorrect process if a CPU sample for the old process, a
process_exit as well as a process_create event plus another CPU sample
event for the new process happened at the exact same time. I think
it's a reasonable compromise though.
Diffstat (limited to 'Userland/DevTools/Profiler')
-rw-r--r-- | Userland/DevTools/Profiler/Profile.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Userland/DevTools/Profiler/Profile.cpp b/Userland/DevTools/Profiler/Profile.cpp index 2c5a9b65a3..fb46b33862 100644 --- a/Userland/DevTools/Profiler/Profile.cpp +++ b/Userland/DevTools/Profiler/Profile.cpp @@ -267,7 +267,7 @@ Result<NonnullOwnPtr<Profile>, String> Profile::load_from_perfcore_file(const St event.executable = perf_event.get("executable").to_string(); auto old_process = current_processes.get(event.pid).value(); - old_process->end_valid = event.timestamp - 1; + old_process->end_valid = event.timestamp; current_processes.remove(event.pid); @@ -282,7 +282,7 @@ Result<NonnullOwnPtr<Profile>, String> Profile::load_from_perfcore_file(const St continue; } else if (event.type == "process_exit"sv) { auto old_process = current_processes.get(event.pid).value(); - old_process->end_valid = event.timestamp - 1; + old_process->end_valid = event.timestamp; current_processes.remove(event.pid); continue; |