mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 07:58:11 +00:00
Kernel: Demangle userspace ELF symbols in backtraces
Turns out we can use abi::__cxa_demangle() for this, and all we need to provide is sprintf(), realloc() and free(), so this patch exposes them. We now have fully demangled C++ backtraces :^)
This commit is contained in:
parent
2d1bcce34a
commit
0adbacf59e
10 changed files with 44 additions and 9 deletions
|
@ -1,6 +1,7 @@
|
|||
#include "ELFLoader.h"
|
||||
#include <AK/QuickSort.h>
|
||||
#include <AK/kstdio.h>
|
||||
#include <cxxabi.h>
|
||||
|
||||
#ifdef KERNEL
|
||||
#include <Kernel/VM/MemoryManager.h>
|
||||
|
@ -138,7 +139,12 @@ String ELFLoader::symbolicate(u32 address) const
|
|||
if (i == 0)
|
||||
return "!!";
|
||||
auto& symbol = sorted_symbols[i - 1];
|
||||
return String::format("%s +%u", symbol.name, address - symbol.address);
|
||||
int status = 0;
|
||||
auto* demangled_name = abi::__cxa_demangle(symbol.name, nullptr, nullptr, &status);
|
||||
auto string = String::format("%s +%u", status == 0 ? demangled_name : symbol.name, address - symbol.address);
|
||||
if (status == 0)
|
||||
kfree(demangled_name);
|
||||
return string;
|
||||
}
|
||||
}
|
||||
return "??";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue