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

Commit

Permalink
Fix Issue 18068 - No file names and line numbers in stack trace
Browse files Browse the repository at this point in the history
  • Loading branch information
wilzbach committed May 3, 2018
1 parent 243e690 commit 40438ac
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion src/rt/backtrace/dwarf.d
Expand Up @@ -67,10 +67,39 @@ int traceHandlerOpApplyImpl(const void*[] callstack, scope int delegate(ref size

if (debugLineSectionData)
{
// resolve ASLR offset
version(linux)
{
import core.sys.linux.link;
struct ElfObj
{
ElfW!"Addr" l_addr;
bool set;
}
extern(C) int dl_iterate_phdr_cb_ngc_tracehandler(dl_phdr_info* info, size_t, void* elfObj) @nogc
{
ElfObj* obj = cast(ElfObj*) elfObj;
// only take the first address
if (obj.set)
return 0;
obj.l_addr = info.dlpi_addr;
obj.set = true;
return 0;
}
ElfObj elfObj;
dl_iterate_phdr(&dl_iterate_phdr_cb_ngc_tracehandler, &elfObj);
ElfW!"Addr" offset = elfObj.l_addr;
}
else
{
// non-ASLR fallback
size_t offset;
}

// resolve addresses
locations.length = callstack.length;
foreach(size_t i; 0 .. callstack.length)
locations[i].address = cast(size_t) callstack[i];
locations[i].address = cast(size_t) callstack[i] - offset;

resolveAddresses(debugLineSectionData, locations[]);
}
Expand Down

0 comments on commit 40438ac

Please sign in to comment.