From ddec9cb1f03a4f1e3752db7b8bb5aca2733430ab Mon Sep 17 00:00:00 2001 From: Itamar Date: Sat, 4 Feb 2023 16:57:45 +0200 Subject: [PATCH] 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. --- Kernel/Thread.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Kernel/Thread.cpp b/Kernel/Thread.cpp index 28f8a0d6ea..b6f53cad58 100644 --- a/Kernel/Thread.cpp +++ b/Kernel/Thread.cpp @@ -958,6 +958,8 @@ DispatchSignalResult Thread::dispatch_signal(u8 signal) auto* tracer = process.tracer(); if (signal == SIGSTOP || (tracer && default_signal_action(signal) == DefaultSignalAction::DumpCore)) { 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); return DispatchSignalResult::Yield; }