1
0
mirror of https://github.com/SerenityOS/serenity synced 2024-07-09 10:57:26 +00:00

Kernel: Deduplicate backtrace printing

This commit is contained in:
Space Meyer 2024-04-08 02:19:23 +02:00 committed by Andrew Kaster
parent a721e4d507
commit bba94804c2
3 changed files with 13 additions and 12 deletions

View File

@ -552,12 +552,7 @@ void dump_thread_list(bool with_stack_traces)
});
#endif
if (with_stack_traces) {
auto trace_or_error = thread.backtrace();
if (!trace_or_error.is_error()) {
auto trace = trace_or_error.release_value();
dbgln("Backtrace:");
kernelputstr(trace->characters(), trace->length());
}
thread.print_backtrace();
}
return IterationDecision::Continue;
});

View File

@ -561,12 +561,7 @@ void Thread::finalize()
}
if (m_dump_backtrace_on_finalization) {
auto trace_or_error = backtrace();
if (!trace_or_error.is_error()) {
auto trace = trace_or_error.release_value();
dbgln("Backtrace:");
kernelputstr(trace->characters(), trace->length());
}
print_backtrace();
}
drop_thread_count();
@ -1350,6 +1345,16 @@ ErrorOr<NonnullOwnPtr<KString>> Thread::backtrace()
return KString::try_create(builder.string_view());
}
void Thread::print_backtrace()
{
auto trace_or_error = this->backtrace();
if (!trace_or_error.is_error()) {
auto trace = trace_or_error.release_value();
dbgln("Backtrace:");
kernelputstr(trace->characters(), trace->length());
}
}
ErrorOr<void> Thread::make_thread_specific_region(Badge<Process>)
{
return process().m_master_tls.with([&](auto& master_tls) -> ErrorOr<void> {

View File

@ -1069,6 +1069,7 @@ public:
void set_allocation_enabled(bool value) { m_allocation_enabled = value; }
ErrorOr<NonnullOwnPtr<KString>> backtrace();
void print_backtrace();
Blocker const* blocker() const { return m_blocker; }
Kernel::Mutex const* blocking_mutex() const { return m_blocking_mutex; }