kernel: Add keyboard combinations for debug information dumps
Ctrl+Alt+E: Dump threads Ctrl+Alt+M: Dump memory usage Ctrl+Alt+H: Dump heap state
This commit is contained in:
parent
3ed9e578c7
commit
3a1c22bb93
@ -1,10 +1,13 @@
|
|||||||
#include "fs/devices/ConsoleDevice.h"
|
#include "fs/devices/ConsoleDevice.h"
|
||||||
|
#include "Log.h"
|
||||||
#include "arch/Keyboard.h"
|
#include "arch/Keyboard.h"
|
||||||
#include "memory/MemoryManager.h"
|
#include "memory/MemoryManager.h"
|
||||||
|
#include "thread/Scheduler.h"
|
||||||
#include "video/TextConsole.h"
|
#include "video/TextConsole.h"
|
||||||
#include <bits/termios.h>
|
#include <bits/termios.h>
|
||||||
#include <luna/Buffer.h>
|
#include <luna/Buffer.h>
|
||||||
#include <luna/CString.h>
|
#include <luna/CString.h>
|
||||||
|
#include <luna/Units.h>
|
||||||
#include <luna/Vector.h>
|
#include <luna/Vector.h>
|
||||||
|
|
||||||
static Buffer g_console_input;
|
static Buffer g_console_input;
|
||||||
@ -63,6 +66,27 @@ void ConsoleDevice::did_press_key(char key)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (key == 'e' && (Keyboard::modifiers() & (Keyboard::LeftAlt | Keyboard::LeftControl)))
|
||||||
|
{
|
||||||
|
Scheduler::dump_state();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (key == 'm' && (Keyboard::modifiers() & (Keyboard::LeftAlt | Keyboard::LeftControl)))
|
||||||
|
{
|
||||||
|
kinfoln("Total memory: %s", to_dynamic_unit(MemoryManager::total()).release_value().chars());
|
||||||
|
kinfoln("Free memory: %s", to_dynamic_unit(MemoryManager::free()).release_value().chars());
|
||||||
|
kinfoln("Used memory: %s", to_dynamic_unit(MemoryManager::used()).release_value().chars());
|
||||||
|
kinfoln("Reserved memory: %s", to_dynamic_unit(MemoryManager::reserved()).release_value().chars());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (key == 'h' && (Keyboard::modifiers() & (Keyboard::LeftAlt | Keyboard::LeftControl)))
|
||||||
|
{
|
||||||
|
dump_heap_usage();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
g_temp_input.try_append((u8)key).value();
|
g_temp_input.try_append((u8)key).value();
|
||||||
|
|
||||||
if (key == '\n')
|
if (key == '\n')
|
||||||
|
@ -327,6 +327,28 @@ namespace Scheduler
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void dump_state()
|
||||||
|
{
|
||||||
|
CPU::disable_interrupts();
|
||||||
|
|
||||||
|
kdbgln("--- BEGIN SCHEDULER DUMP ---");
|
||||||
|
kdbgln("current at %p, id = %zu", g_current, g_current->id);
|
||||||
|
|
||||||
|
for (const auto* thread : g_threads)
|
||||||
|
{
|
||||||
|
kdbgln("%p %c [%-20s] %4zu, parent = (%-18p,%zu), state = %d, ticks: (t:%04zu,k:%04zu,u:%04zu), status = "
|
||||||
|
"%d, cwd = %s",
|
||||||
|
thread, thread->is_kernel ? 'k' : 'u', thread->name.chars(), thread->id, thread->parent,
|
||||||
|
thread->parent ? thread->parent->id : 0, (int)thread->state, thread->ticks, thread->ticks_in_kernel,
|
||||||
|
thread->ticks_in_user, thread->status,
|
||||||
|
thread->current_directory_path.is_empty() ? "/" : thread->current_directory_path.chars());
|
||||||
|
}
|
||||||
|
|
||||||
|
kdbgln("--- END SCHEDULER DUMP ---");
|
||||||
|
|
||||||
|
CPU::enable_interrupts();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void kernel_sleep(u64 ms)
|
void kernel_sleep(u64 ms)
|
||||||
|
@ -45,6 +45,8 @@ namespace Scheduler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void dump_state();
|
||||||
|
|
||||||
bool has_children(Thread* thread);
|
bool has_children(Thread* thread);
|
||||||
|
|
||||||
Option<Thread*> find_exited_child(Thread* thread);
|
Option<Thread*> find_exited_child(Thread* thread);
|
||||||
|
Loading…
Reference in New Issue
Block a user