mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:37:37 +00:00
Kernel: For signal-killed threads, dump backtrace from finalizer thread
Instead of dumping the dying thread's backtrace in the signal handling code, wait until we're finalizing the thread. Since signalling happens during scheduling, the less work we do there the better. Basically the less that happens during a scheduler pass the better. :^)
This commit is contained in:
parent
73c998dbfc
commit
83fdad25ed
2 changed files with 17 additions and 5 deletions
|
@ -171,6 +171,9 @@ void Thread::finalize()
|
||||||
dbgprintf("Finalizing Thread %u in %s(%u)\n", tid(), m_process.name().characters(), pid());
|
dbgprintf("Finalizing Thread %u in %s(%u)\n", tid(), m_process.name().characters(), pid());
|
||||||
set_state(Thread::State::Dead);
|
set_state(Thread::State::Dead);
|
||||||
|
|
||||||
|
if (m_dump_backtrace_on_finalization)
|
||||||
|
dbg() << backtrace_impl();
|
||||||
|
|
||||||
if (this == &m_process.main_thread()) {
|
if (this == &m_process.main_thread()) {
|
||||||
m_process.finalize();
|
m_process.finalize();
|
||||||
return;
|
return;
|
||||||
|
@ -337,11 +340,11 @@ ShouldUnblockThread Thread::dispatch_signal(u8 signal)
|
||||||
case DefaultSignalAction::Stop:
|
case DefaultSignalAction::Stop:
|
||||||
set_state(Stopped);
|
set_state(Stopped);
|
||||||
return ShouldUnblockThread::No;
|
return ShouldUnblockThread::No;
|
||||||
case DefaultSignalAction::DumpCore: {
|
case DefaultSignalAction::DumpCore:
|
||||||
ProcessInspectionHandle handle(process());
|
process().for_each_thread([](auto& thread) {
|
||||||
dbg() << "Dumping \"Core\" for " << process();
|
thread.set_dump_backtrace_on_finalization();
|
||||||
dbg() << process().backtrace(handle);
|
return IterationDecision::Continue;
|
||||||
}
|
});
|
||||||
[[fallthrough]];
|
[[fallthrough]];
|
||||||
case DefaultSignalAction::Terminate:
|
case DefaultSignalAction::Terminate:
|
||||||
m_process.terminate_due_to_signal(signal);
|
m_process.terminate_due_to_signal(signal);
|
||||||
|
@ -568,6 +571,11 @@ void Thread::set_state(State new_state)
|
||||||
}
|
}
|
||||||
|
|
||||||
String Thread::backtrace(ProcessInspectionHandle&) const
|
String Thread::backtrace(ProcessInspectionHandle&) const
|
||||||
|
{
|
||||||
|
return backtrace_impl();
|
||||||
|
}
|
||||||
|
|
||||||
|
String Thread::backtrace_impl() const
|
||||||
{
|
{
|
||||||
auto& process = const_cast<Process&>(this->process());
|
auto& process = const_cast<Process&>(this->process());
|
||||||
ProcessPagingScope paging_scope(process);
|
ProcessPagingScope paging_scope(process);
|
||||||
|
|
|
@ -281,6 +281,8 @@ public:
|
||||||
void send_signal(u8 signal, Process* sender);
|
void send_signal(u8 signal, Process* sender);
|
||||||
void consider_unblock(time_t now_sec, long now_usec);
|
void consider_unblock(time_t now_sec, long now_usec);
|
||||||
|
|
||||||
|
void set_dump_backtrace_on_finalization() { m_dump_backtrace_on_finalization = true; }
|
||||||
|
|
||||||
ShouldUnblockThread dispatch_one_pending_signal();
|
ShouldUnblockThread dispatch_one_pending_signal();
|
||||||
ShouldUnblockThread dispatch_signal(u8 signal);
|
ShouldUnblockThread dispatch_signal(u8 signal);
|
||||||
bool has_unmasked_pending_signals() const;
|
bool has_unmasked_pending_signals() const;
|
||||||
|
@ -315,6 +317,7 @@ private:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class SchedulerData;
|
friend class SchedulerData;
|
||||||
|
String backtrace_impl() const;
|
||||||
Process& m_process;
|
Process& m_process;
|
||||||
int m_tid { -1 };
|
int m_tid { -1 };
|
||||||
TSS32 m_tss;
|
TSS32 m_tss;
|
||||||
|
@ -335,6 +338,7 @@ private:
|
||||||
FPUState* m_fpu_state { nullptr };
|
FPUState* m_fpu_state { nullptr };
|
||||||
State m_state { Invalid };
|
State m_state { Invalid };
|
||||||
bool m_has_used_fpu { false };
|
bool m_has_used_fpu { false };
|
||||||
|
bool m_dump_backtrace_on_finalization { false };
|
||||||
|
|
||||||
void block_helper();
|
void block_helper();
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue