Bladeren bron

Kernel: Reset profiling state on exec() (but keep it going)

We now log the new executable on exec() and throw away all the samples
we've accumulated so far. But profiling keeps going.
Andreas Kling 5 jaren geleden
bovenliggende
commit
d7a13dbaa7
3 gewijzigde bestanden met toevoegingen van 10 en 0 verwijderingen
  1. 3 0
      Kernel/Process.cpp
  2. 6 0
      Kernel/Profiling.cpp
  3. 1 0
      Kernel/Profiling.h

+ 3 - 0
Kernel/Process.cpp

@@ -1015,6 +1015,9 @@ int Process::do_exec(NonnullRefPtr<FileDescription> main_program_description, Ve
     kprintf("Process %u (%s) exec'd %s @ %p\n", pid(), name().characters(), path.characters(), tss.eip);
 #endif
 
+    if (is_profiling())
+        Profiling::did_exec(path);
+
     new_main_thread->set_state(Thread::State::Skip1SchedulerPass);
     big_lock().force_unlock_if_locked();
     return 0;

+ 6 - 0
Kernel/Profiling.cpp

@@ -90,6 +90,12 @@ void stop()
     s_process = nullptr;
 }
 
+void did_exec(const String& new_executable_path)
+{
+    executable_path() = new_executable_path;
+    s_next_slot_index = 0;
+}
+
 void for_each_sample(Function<void(Sample&)> callback)
 {
     for (size_t i = 0; i < s_next_slot_index; ++i) {

+ 1 - 0
Kernel/Profiling.h

@@ -51,6 +51,7 @@ extern String& executable_path();
 Sample& next_sample_slot();
 void start(Process&);
 void stop();
+void did_exec(const String& new_executable_path);
 void for_each_sample(Function<void(Sample&)>);
 
 }