Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
rt.backtrace.dwarf: Optimize getDemangledSymbol() for empty symbol names
Browse files Browse the repository at this point in the history
This prevents throwing & catching a ParseException whenever trying to
demangle an empty symbol name. Empty symbols in backtrace strings are
common for executables linked with LDC (no implicit `--export-dynamic`
for ld linker).
  • Loading branch information
kinke committed Jan 9, 2020
1 parent cf69363 commit 5fddfa1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/rt/backtrace/dwarf.d
Expand Up @@ -31,7 +31,7 @@ else
import rt.backtrace.elf;

import rt.util.container.array;
import core.stdc.string : strlen, memchr, memcpy;
import core.stdc.string : strlen, memcpy;

//debug = DwarfDebugMachine;
debug(DwarfDebugMachine) import core.stdc.stdio : printf;
Expand Down Expand Up @@ -351,7 +351,8 @@ bool runStateMachine(ref const(LineNumberProgram) lp, scope RunStateMachineCallb
const(char)[] getDemangledSymbol(const(char)[] btSymbol, ref char[1024] buffer)
{
import core.demangle;
return demangle(getMangledSymbolName(btSymbol), buffer[]);
const mangledName = getMangledSymbolName(btSymbol);
return !mangledName.length ? buffer[0..0] : demangle(mangledName, buffer[]);
}

T read(T)(ref const(ubyte)[] buffer) @nogc nothrow
Expand Down

0 comments on commit 5fddfa1

Please sign in to comment.