diff options
author | Idan Horowitz <idan.horowitz@gmail.com> | 2022-01-15 21:19:41 +0200 |
---|---|---|
committer | Idan Horowitz <idan.horowitz@gmail.com> | 2022-01-16 01:01:08 +0200 |
commit | 309d71a66b63fe1390c0d0a2225a43813c40b73d (patch) | |
tree | 74a92580f8db0a9c144aa0fdea35c8d67ea168d1 | |
parent | 0142f33ddc12eed586fa961b0f22c49370dc3b59 (diff) | |
download | serenity-309d71a66b63fe1390c0d0a2225a43813c40b73d.zip |
Kernel: Use kernelputstr instead of dbgln when printing backtraces
This will allow us to eventually switch dbgln in the kernel to an
allocation-free (although length-bounded) formatter.
-rw-r--r-- | Kernel/Scheduler.cpp | 11 | ||||
-rw-r--r-- | Kernel/Thread.cpp | 11 |
2 files changed, 18 insertions, 4 deletions
diff --git a/Kernel/Scheduler.cpp b/Kernel/Scheduler.cpp index 4b537f20a8..b6c3a7df19 100644 --- a/Kernel/Scheduler.cpp +++ b/Kernel/Scheduler.cpp @@ -18,6 +18,7 @@ #include <Kernel/Scheduler.h> #include <Kernel/Sections.h> #include <Kernel/Time/TimeManagement.h> +#include <Kernel/kstdio.h> // Remove this once SMP is stable and can be enabled by default #define SCHEDULE_ON_ALL_PROCESSORS 0 @@ -595,8 +596,14 @@ void dump_thread_list(bool with_stack_traces) thread.times_scheduled()); break; } - if (with_stack_traces) - dbgln("{}", thread.backtrace()); + 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()); + } + } return IterationDecision::Continue; }); } diff --git a/Kernel/Thread.cpp b/Kernel/Thread.cpp index d218c6b697..220b7bf966 100644 --- a/Kernel/Thread.cpp +++ b/Kernel/Thread.cpp @@ -27,6 +27,7 @@ #include <Kernel/Thread.h> #include <Kernel/ThreadTracer.h> #include <Kernel/TimerQueue.h> +#include <Kernel/kstdio.h> #include <LibC/signal_numbers.h> namespace Kernel { @@ -501,8 +502,14 @@ void Thread::finalize() m_join_blocker_set.thread_finalizing(); } - if (m_dump_backtrace_on_finalization) - dbgln("{}", backtrace()); + 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()); + } + } drop_thread_count(false); } |