mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-26 22:38:30 +00:00
Add C++ demangling to privileged runtime
Cosmo will now print C++ symbols correctly in --ftrace logs and backtraces. Doing this required reducing the memory requirement of the __demangle() function by 3x. This was accomplished using 16-bit indices and 16-bit malloc granularity. That puts a limit on the longest symbol we can successfully decode, which I think would be around 6553 characters long, given a 65536-byte buffer
This commit is contained in:
parent
dcd626edf8
commit
165c6b37e2
13 changed files with 727 additions and 284 deletions
|
@ -51,10 +51,9 @@ dontinstrument dontasan int PrintBacktraceUsingSymbols(
|
|||
size_t gi;
|
||||
intptr_t addr;
|
||||
const char *name;
|
||||
char cxxbuf[3000];
|
||||
int i, symbol, addend;
|
||||
static char cxxbuf[8192];
|
||||
struct Garbages *garbage;
|
||||
static pthread_spinlock_t lock;
|
||||
const struct StackFrame *frame;
|
||||
(void)gi;
|
||||
if (!bp)
|
||||
|
@ -92,10 +91,8 @@ dontinstrument dontasan int PrintBacktraceUsingSymbols(
|
|||
addend = 0;
|
||||
}
|
||||
if ((name = __get_symbol_name(st, symbol)) && __is_mangled(name)) {
|
||||
pthread_spin_lock(&lock);
|
||||
__demangle(cxxbuf, name, sizeof(cxxbuf));
|
||||
kprintf("%012lx %lx %s%+d\n", frame, addr, cxxbuf, addend);
|
||||
pthread_spin_unlock(&lock);
|
||||
name = cxxbuf;
|
||||
} else {
|
||||
kprintf("%012lx %lx %s%+d\n", frame, addr, name, addend);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue