diff options
author | Tom <tomut@yahoo.com> | 2021-07-15 14:54:19 -0600 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-07-15 23:46:37 +0200 |
commit | 82e9fe8d6726564475c5620099efc737de5e44f5 (patch) | |
tree | b0655b3580853e4c50a0dd333ecc6d09744e33f5 /Kernel | |
parent | 0150ae4bbdb328f9d2b447e51995bded5f66cd07 (diff) | |
download | serenity-82e9fe8d6726564475c5620099efc737de5e44f5.zip |
Kernel: Optionally dump scheduler state with stack traces
This will dump stack traces of all threads when pressing
Ctrl+Shift+Alt+F12
Diffstat (limited to 'Kernel')
-rw-r--r-- | Kernel/Devices/HID/PS2KeyboardDevice.cpp | 4 | ||||
-rw-r--r-- | Kernel/Scheduler.cpp | 10 | ||||
-rw-r--r-- | Kernel/Scheduler.h | 2 | ||||
-rw-r--r-- | Kernel/Thread.h | 3 |
4 files changed, 11 insertions, 8 deletions
diff --git a/Kernel/Devices/HID/PS2KeyboardDevice.cpp b/Kernel/Devices/HID/PS2KeyboardDevice.cpp index 85a152c94a..19db54ddc6 100644 --- a/Kernel/Devices/HID/PS2KeyboardDevice.cpp +++ b/Kernel/Devices/HID/PS2KeyboardDevice.cpp @@ -32,10 +32,10 @@ void PS2KeyboardDevice::irq_handle_byte_read(u8 byte) return; } - if (m_modifiers == (Mod_Alt | Mod_Shift) && byte == 0x58) { + if ((m_modifiers == (Mod_Alt | Mod_Shift) || m_modifiers == (Mod_Ctrl | Mod_Alt | Mod_Shift)) && byte == 0x58) { // Alt+Shift+F12 pressed, dump some kernel state to the debug console. ConsoleManagement::the().switch_to_debug(); - Scheduler::dump_scheduler_state(); + Scheduler::dump_scheduler_state(m_modifiers == (Mod_Ctrl | Mod_Alt | Mod_Shift)); } dbgln_if(KEYBOARD_DEBUG, "Keyboard::irq_handle_byte_read: {:#02x} {}", ch, (pressed ? "down" : "up")); diff --git a/Kernel/Scheduler.cpp b/Kernel/Scheduler.cpp index ef3e702aca..21f1762467 100644 --- a/Kernel/Scheduler.cpp +++ b/Kernel/Scheduler.cpp @@ -53,7 +53,7 @@ static SpinLock<u8> g_ready_queues_lock; static u32 g_ready_queues_mask; static constexpr u32 g_ready_queue_buckets = sizeof(g_ready_queues_mask) * 8; READONLY_AFTER_INIT static ThreadReadyQueue* g_ready_queues; // g_ready_queue_buckets entries -static void dump_thread_list(); +static void dump_thread_list(bool = false); static inline u32 thread_priority_to_priority_index(u32 thread_priority) { @@ -526,9 +526,9 @@ void Scheduler::idle_loop(void*) } } -void Scheduler::dump_scheduler_state() +void Scheduler::dump_scheduler_state(bool with_stack_traces) { - dump_thread_list(); + dump_thread_list(with_stack_traces); } bool Scheduler::is_initialized() @@ -537,7 +537,7 @@ bool Scheduler::is_initialized() return Processor::idle_thread() != nullptr; } -void dump_thread_list() +void dump_thread_list(bool with_stack_traces) { dbgln("Scheduler thread list for processor {}:", Processor::id()); @@ -580,6 +580,8 @@ void dump_thread_list() thread.times_scheduled()); break; } + if (with_stack_traces) + dbgln("{}", thread.backtrace()); }); } diff --git a/Kernel/Scheduler.h b/Kernel/Scheduler.h index ec48055e4b..c703df83a6 100644 --- a/Kernel/Scheduler.h +++ b/Kernel/Scheduler.h @@ -47,7 +47,7 @@ public: static Thread* peek_next_runnable_thread(); static bool dequeue_runnable_thread(Thread&, bool = false); static void queue_runnable_thread(Thread&); - static void dump_scheduler_state(); + static void dump_scheduler_state(bool = false); static bool is_initialized(); }; diff --git a/Kernel/Thread.h b/Kernel/Thread.h index bb6f5914ee..64916838d5 100644 --- a/Kernel/Thread.h +++ b/Kernel/Thread.h @@ -1189,6 +1189,8 @@ public: InodeIndex global_procfs_inode_index() const { return m_global_procfs_inode_index; } + String backtrace(); + private: Thread(NonnullRefPtr<Process>, NonnullOwnPtr<Region>, NonnullRefPtr<Timer>, FPUState*); @@ -1255,7 +1257,6 @@ private: LockMode unlock_process_if_locked(u32&); void relock_process(LockMode, u32); - String backtrace(); void reset_fpu_state(); mutable RecursiveSpinLock m_lock; |