mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 20:07:36 +00:00
Kernel: Make dump_backtrace() kinda sorta work.
This commit is contained in:
parent
d218686c0a
commit
9fd4f4862b
2 changed files with 13 additions and 4 deletions
|
@ -71,7 +71,7 @@ static void load_ksyms_from_data(const ByteBuffer& buffer)
|
||||||
ksyms_ready = true;
|
ksyms_ready = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dump_backtrace(bool use_ksyms)
|
[[gnu::noinline]] void dump_backtrace_impl(dword ebp, bool use_ksyms)
|
||||||
{
|
{
|
||||||
if (!current) {
|
if (!current) {
|
||||||
hang();
|
hang();
|
||||||
|
@ -87,13 +87,13 @@ void dump_backtrace(bool use_ksyms)
|
||||||
};
|
};
|
||||||
Vector<RecognizedSymbol> recognized_symbols;
|
Vector<RecognizedSymbol> recognized_symbols;
|
||||||
if (use_ksyms) {
|
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];
|
dword retaddr = stack_ptr[1];
|
||||||
if (auto* ksym = ksymbolicate(retaddr))
|
if (auto* ksym = ksymbolicate(retaddr))
|
||||||
recognized_symbols.append({ retaddr, ksym });
|
recognized_symbols.append({ retaddr, ksym });
|
||||||
}
|
}
|
||||||
} else{
|
} 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];
|
dword retaddr = stack_ptr[1];
|
||||||
kprintf("%x (next: %x)\n", retaddr, stack_ptr ? (dword*)*stack_ptr : 0);
|
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) {
|
for (auto& symbol : recognized_symbols) {
|
||||||
unsigned offset = symbol.address - symbol.ksym->address;
|
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()
|
void init_ksyms()
|
||||||
{
|
{
|
||||||
ksyms_ready = false;
|
ksyms_ready = false;
|
||||||
|
|
|
@ -15,3 +15,5 @@ void init_ksyms();
|
||||||
extern bool ksyms_ready;
|
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);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue