mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-20 19:45:12 +00:00
Kernel: Deduplicate backtrace printing
This commit is contained in:
parent
a721e4d507
commit
bba94804c2
Notes:
sideshowbarker
2024-07-17 03:19:14 +09:00
Author: https://github.com/HerrSpace Commit: https://github.com/SerenityOS/serenity/commit/bba94804c2 Pull-request: https://github.com/SerenityOS/serenity/pull/23911 Reviewed-by: https://github.com/ADKaster Reviewed-by: https://github.com/Hendiadyoin1 Reviewed-by: https://github.com/LucasChollet
3 changed files with 13 additions and 12 deletions
|
@ -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;
|
||||
});
|
||||
|
|
|
@ -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> {
|
||||
|
|
|
@ -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; }
|
||||
|
|
Loading…
Add table
Reference in a new issue