summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-02-24 14:51:48 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-02-24 14:51:48 +0100
commit9fd4f4862baa52d7aa5d4b842224a8293251c13f (patch)
treeb85ee02df6f8af262fb96c5fdf327ae0e49b86d2 /Kernel
parentd218686c0adde4454e4006a91a9a9b1cf18ccbd5 (diff)
downloadserenity-9fd4f4862baa52d7aa5d4b842224a8293251c13f.zip
Kernel: Make dump_backtrace() kinda sorta work.
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/KSyms.cpp15
-rw-r--r--Kernel/KSyms.h2
2 files changed, 13 insertions, 4 deletions
diff --git a/Kernel/KSyms.cpp b/Kernel/KSyms.cpp
index b5913b582c..56321eb62e 100644
--- a/Kernel/KSyms.cpp
+++ b/Kernel/KSyms.cpp
@@ -71,7 +71,7 @@ static void load_ksyms_from_data(const ByteBuffer& buffer)
ksyms_ready = true;
}
-void dump_backtrace(bool use_ksyms)
+[[gnu::noinline]] void dump_backtrace_impl(dword ebp, bool use_ksyms)
{
if (!current) {
hang();
@@ -87,13 +87,13 @@ void dump_backtrace(bool use_ksyms)
};
Vector<RecognizedSymbol> recognized_symbols;
if (use_ksyms) {
- for (dword* stack_ptr = (dword*)&use_ksyms; current->validate_read_from_kernel(LinearAddress((dword)stack_ptr)); stack_ptr = (dword*)*stack_ptr) {
+ for (dword* stack_ptr = (dword*)ebp; current->validate_read_from_kernel(LinearAddress((dword)stack_ptr)); stack_ptr = (dword*)*stack_ptr) {
dword retaddr = stack_ptr[1];
if (auto* ksym = ksymbolicate(retaddr))
recognized_symbols.append({ retaddr, ksym });
}
} else{
- for (dword* stack_ptr = (dword*)&use_ksyms; current->validate_read_from_kernel(LinearAddress((dword)stack_ptr)); stack_ptr = (dword*)*stack_ptr) {
+ for (dword* stack_ptr = (dword*)ebp; current->validate_read_from_kernel(LinearAddress((dword)stack_ptr)); stack_ptr = (dword*)*stack_ptr) {
dword retaddr = stack_ptr[1];
kprintf("%x (next: %x)\n", retaddr, stack_ptr ? (dword*)*stack_ptr : 0);
}
@@ -105,10 +105,17 @@ void dump_backtrace(bool use_ksyms)
}
for (auto& symbol : recognized_symbols) {
unsigned offset = symbol.address - symbol.ksym->address;
- dbgprintf("%p %s +%u\n", symbol.address, symbol.ksym->name, offset);
+ kprintf("%p %s +%u\n", symbol.address, symbol.ksym->name, offset);
}
}
+void dump_backtrace(bool use_ksyms)
+{
+ dword ebp;
+ asm volatile("movl %%ebp, %%eax":"=a"(ebp));
+ dump_backtrace_impl(ebp, use_ksyms);
+}
+
void init_ksyms()
{
ksyms_ready = false;
diff --git a/Kernel/KSyms.h b/Kernel/KSyms.h
index a7f8c33fa3..567f9e273e 100644
--- a/Kernel/KSyms.h
+++ b/Kernel/KSyms.h
@@ -15,3 +15,5 @@ void init_ksyms();
extern bool ksyms_ready;
extern dword ksym_lowest_address;
extern dword ksym_highest_address;
+
+void dump_backtrace(bool use_ksyms);