Browse Source

Kernel: Update stored registers in a thread's tracer on SIGSTOP

This is needed so we can retrieve the registers of a traced
thread that was attached to while it was running.

Attaching with ptrace to a running thread sends SIGSTOP to it.
Itamar 2 năm trước cách đây
mục cha
commit
ddec9cb1f0
1 tập tin đã thay đổi với 2 bổ sung0 xóa
  1. 2 0
      Kernel/Thread.cpp

+ 2 - 0
Kernel/Thread.cpp

@@ -958,6 +958,8 @@ DispatchSignalResult Thread::dispatch_signal(u8 signal)
     auto* tracer = process.tracer();
     auto* tracer = process.tracer();
     if (signal == SIGSTOP || (tracer && default_signal_action(signal) == DefaultSignalAction::DumpCore)) {
     if (signal == SIGSTOP || (tracer && default_signal_action(signal) == DefaultSignalAction::DumpCore)) {
         dbgln_if(SIGNAL_DEBUG, "Signal {} stopping this thread", signal);
         dbgln_if(SIGNAL_DEBUG, "Signal {} stopping this thread", signal);
+        if (tracer)
+            tracer->set_regs(get_register_dump_from_stack());
         set_state(Thread::State::Stopped, signal);
         set_state(Thread::State::Stopped, signal);
         return DispatchSignalResult::Yield;
         return DispatchSignalResult::Yield;
     }
     }