1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 06:48:12 +00:00

Kernel: Simplify dump_backtrace() API for clients.

It makes no sense that clients had to worry about whether or not KSyms
were loaded.
This commit is contained in:
Andreas Kling 2019-05-16 13:41:16 +02:00
parent 7a2da54c07
commit 2f4e7edee5
6 changed files with 10 additions and 11 deletions

View file

@ -125,11 +125,11 @@ static void load_ksyms_from_data(const ByteBuffer& buffer)
} }
} }
void dump_backtrace(bool use_ksyms) void dump_backtrace()
{ {
dword ebp; dword ebp;
asm volatile("movl %%ebp, %%eax":"=a"(ebp)); asm volatile("movl %%ebp, %%eax":"=a"(ebp));
dump_backtrace_impl(ebp, use_ksyms); dump_backtrace_impl(ebp, ksyms_ready);
} }
void init_ksyms() void init_ksyms()

View file

@ -16,4 +16,4 @@ extern bool ksyms_ready;
extern dword ksym_lowest_address; extern dword ksym_lowest_address;
extern dword ksym_highest_address; extern dword ksym_highest_address;
void dump_backtrace(bool use_ksyms); void dump_backtrace();

View file

@ -53,7 +53,7 @@ private:
{ {
if (!are_interrupts_enabled()) { if (!are_interrupts_enabled()) {
kprintf("Interrupts disabled when trying to take Lock{%s}\n", m_name); kprintf("Interrupts disabled when trying to take Lock{%s}\n", m_name);
dump_backtrace(ksyms_ready); dump_backtrace();
hang(); hang();
} }
ASSERT(!Scheduler::is_active()); ASSERT(!Scheduler::is_active());

View file

@ -642,7 +642,7 @@ void Process::sys$exit(int status)
kprintf("sys$exit: %s(%u) exit with status %d\n", name().characters(), pid(), status); kprintf("sys$exit: %s(%u) exit with status %d\n", name().characters(), pid(), status);
#endif #endif
dump_backtrace(ksyms_ready); dump_backtrace();
m_termination_status = status; m_termination_status = status;
m_termination_signal = 0; m_termination_signal = 0;

View file

@ -281,7 +281,7 @@ void exception_14_handler(RegisterDumpWithExceptionCode& regs)
regs.exception_code & 2 ? "write" : "read", regs.exception_code & 2 ? "write" : "read",
faultAddress); faultAddress);
dump(regs); dump(regs);
dump_backtrace(ksyms_ready); dump_backtrace();
current->process().crash(); current->process().crash();
} else if (response == PageFaultResponse::Continue) { } else if (response == PageFaultResponse::Continue) {
#ifdef PAGE_FAULT_DEBUG #ifdef PAGE_FAULT_DEBUG
@ -491,8 +491,7 @@ void __assertion_failed(const char* msg, const char* file, unsigned line, const
{ {
asm volatile("cli"); asm volatile("cli");
kprintf("ASSERTION FAILED: %s\n%s:%u in %s\n", msg, file, line, func); kprintf("ASSERTION FAILED: %s\n%s:%u in %s\n", msg, file, line, func);
extern void dump_backtrace(bool); dump_backtrace();
dump_backtrace(true);
asm volatile("hlt"); asm volatile("hlt");
for (;;); for (;;);
} }

View file

@ -99,14 +99,14 @@ void* kmalloc_impl(size_t size)
if (g_dump_kmalloc_stacks && ksyms_ready) { if (g_dump_kmalloc_stacks && ksyms_ready) {
dbgprintf("kmalloc(%u)\n", size); dbgprintf("kmalloc(%u)\n", size);
dump_backtrace(true); dump_backtrace();
} }
// We need space for the allocation_t structure at the head of the block. // We need space for the allocation_t structure at the head of the block.
size_t real_size = size + sizeof(allocation_t); size_t real_size = size + sizeof(allocation_t);
if (sum_free < real_size) { if (sum_free < real_size) {
dump_backtrace(ksyms_ready); dump_backtrace();
kprintf("%s(%u) kmalloc(): PANIC! Out of memory (sucks, dude)\nsum_free=%u, real_size=%u\n", current->process().name().characters(), current->pid(), sum_free, real_size); kprintf("%s(%u) kmalloc(): PANIC! Out of memory (sucks, dude)\nsum_free=%u, real_size=%u\n", current->process().name().characters(), current->pid(), sum_free, real_size);
hang(); hang();
} }
@ -160,7 +160,7 @@ void* kmalloc_impl(size_t size)
} }
kprintf("%s(%u) kmalloc(): PANIC! Out of memory (no suitable block for size %u)\n", current->process().name().characters(), current->pid(), size); kprintf("%s(%u) kmalloc(): PANIC! Out of memory (no suitable block for size %u)\n", current->process().name().characters(), current->pid(), size);
dump_backtrace(ksyms_ready); dump_backtrace();
hang(); hang();
} }