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

Commit

Permalink
Merge pull request #2236 from wilzbach/merge_stable
Browse files Browse the repository at this point in the history
Merge remote-tracking branch 'upstream/stable' into merge_stable
  • Loading branch information
wilzbach committed Jun 28, 2018
2 parents 8fd5201 + da0c5fa commit 9a8edfb
Show file tree
Hide file tree
Showing 36 changed files with 101 additions and 38 deletions.
2 changes: 1 addition & 1 deletion src/core/internal/string.d
Expand Up @@ -4,7 +4,7 @@
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
* Authors: Sean Kelly, Walter Bright
* Source: $(DRUNTIMESRC src/rt/util/_string.d)
* Source: $(DRUNTIMESRC rt/util/_string.d)
*/

module core.internal.string;
Expand Down
2 changes: 1 addition & 1 deletion src/rt/aApply.d
Expand Up @@ -6,7 +6,7 @@
* Copyright: Copyright Digital Mars 2004 - 2010.
* License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
* Authors: Walter Bright
* Source: $(DRUNTIMESRC src/rt/_aApply.d)
* Source: $(DRUNTIMESRC rt/_aApply.d)
*/
module rt.aApply;

Expand Down
2 changes: 1 addition & 1 deletion src/rt/adi.d
Expand Up @@ -6,7 +6,7 @@
* $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
* (See accompanying file LICENSE)
* Authors: Walter Bright
* Source: $(DRUNTIMESRC src/rt/_adi.d)
* Source: $(DRUNTIMESRC rt/_adi.d)
*/

module rt.adi;
Expand Down
2 changes: 1 addition & 1 deletion src/rt/alloca.d
Expand Up @@ -6,7 +6,7 @@
* $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
* (See accompanying file LICENSE)
* Authors: Walter Bright
* Source: $(DRUNTIMESRC src/rt/_alloca.d)
* Source: $(DRUNTIMESRC rt/_alloca.d)
*/

module rt.alloca;
Expand Down
2 changes: 1 addition & 1 deletion src/rt/arrayassign.d
Expand Up @@ -6,7 +6,7 @@
* License: Distributed under the
* $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
* Authors: Walter Bright, Kenji Hara
* Source: $(DRUNTIMESRC src/rt/_arrayassign.d)
* Source: $(DRUNTIMESRC rt/_arrayassign.d)
*/

module rt.arrayassign;
Expand Down
2 changes: 1 addition & 1 deletion src/rt/arraycast.d
Expand Up @@ -5,7 +5,7 @@
* License: Distributed under the
* $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
* Authors: Walter Bright, Sean Kelly
* Source: $(DRUNTIMESRC src/rt/_arraycast.d)
* Source: $(DRUNTIMESRC rt/_arraycast.d)
*/

module rt.arraycast;
Expand Down
2 changes: 1 addition & 1 deletion src/rt/arraycat.d
Expand Up @@ -5,7 +5,7 @@
* License: Distributed under the
* $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
* Authors: Walter Bright, Sean Kelly
* Source: $(DRUNTIMESRC src/rt/_arraycat.d)
* Source: $(DRUNTIMESRC rt/_arraycat.d)
*/

module rt.arraycat;
Expand Down
9 changes: 6 additions & 3 deletions src/rt/backtrace/dwarf.d
Expand Up @@ -7,7 +7,7 @@
* Copyright: Copyright Digital Mars 2015 - 2015.
* License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
* Authors: Yazan Dabain, Sean Kelly
* Source: $(DRUNTIMESRC src/rt/backtrace/dwarf.d)
* Source: $(DRUNTIMESRC rt/backtrace/dwarf.d)
*/

module rt.backtrace.dwarf;
Expand Down Expand Up @@ -72,7 +72,7 @@ int traceHandlerOpApplyImpl(const void*[] callstack, scope int delegate(ref size
foreach(size_t i; 0 .. callstack.length)
locations[i].address = cast(size_t) callstack[i];

resolveAddresses(debugLineSectionData, locations[]);
resolveAddresses(debugLineSectionData, locations[], image.baseAddress);
}
}

Expand Down Expand Up @@ -108,7 +108,7 @@ int traceHandlerOpApplyImpl(const void*[] callstack, scope int delegate(ref size
private:

// the lifetime of the Location data is the lifetime of the mmapped ElfSection
void resolveAddresses(const(ubyte)[] debugLineSectionData, Location[] locations) @nogc nothrow
void resolveAddresses(const(ubyte)[] debugLineSectionData, Location[] locations, size_t baseAddress) @nogc nothrow
{
debug(DwarfDebugMachine) import core.stdc.stdio;

Expand Down Expand Up @@ -202,6 +202,9 @@ void resolveAddresses(const(ubyte)[] debugLineSectionData, Location[] locations)
runStateMachine(lph, program, standardOpcodeLengths,
(size_t address, LocationInfo locInfo, bool isEndSequence)
{
// adjust to ASLR offset
address += baseAddress;
debug(DwarfDebugMachine) printf("-- offsetting 0x%x to 0x%x\n", address - baseAddress, address);
// If loc.line != -1, then it has been set previously.
// Some implementations (eg. dmd) write an address to
// the debug data multiple times, but so far I have found
Expand Down
57 changes: 56 additions & 1 deletion src/rt/backtrace/elf.d
Expand Up @@ -6,7 +6,7 @@
* Copyright: Copyright Digital Mars 2015 - 2015.
* License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
* Authors: Yazan Dabain
* Source: $(DRUNTIMESRC src/rt/backtrace/elf.d)
* Source: $(DRUNTIMESRC rt/backtrace/elf.d)
*/

module rt.backtrace.elf;
Expand Down Expand Up @@ -61,6 +61,61 @@ struct Image

return null;
}

@property size_t baseAddress()
{
version(linux)
{
import core.sys.linux.link;
import core.sys.linux.elf;
}
else version(FreeBSD)
{
import core.sys.freebsd.sys.link_elf;
import core.sys.freebsd.sys.elf;
}
else version(DragonFlyBSD)
{
import core.sys.dragonflybsd.sys.link_elf;
import core.sys.dragonflybsd.sys.elf;
}

static struct ElfAddress
{
size_t begin;
bool set;
}
ElfAddress elfAddress;

// the DWARF addresses for DSOs are relative
const isDynamicSharedObject = (file.ehdr.e_type == ET_DYN);
if (!isDynamicSharedObject)
return 0;

extern(C) int dl_iterate_phdr_cb_ngc_tracehandler(dl_phdr_info* info, size_t, void* elfObj) @nogc
{
auto obj = cast(ElfAddress*) elfObj;
// only take the first address as this will be the main binary
if (obj.set)
return 0;

obj.set = true;
// search for the executable code segment
foreach (const ref phdr; info.dlpi_phdr[0 .. info.dlpi_phnum])
{
if (phdr.p_type == PT_LOAD && phdr.p_flags & PF_X)
{
obj.begin = info.dlpi_addr + phdr.p_vaddr;
return 0;
}
}
// fall back to the base address of the object file
obj.begin = info.dlpi_addr;
return 0;
}
dl_iterate_phdr(&dl_iterate_phdr_cb_ngc_tracehandler, &elfAddress);
return elfAddress.begin;
}
}

private:
Expand Down
7 changes: 6 additions & 1 deletion src/rt/backtrace/macho.d
Expand Up @@ -4,7 +4,7 @@
* Copyright: Copyright Jacob Carlborg 2018.
* License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Authors: Jacob Carlborg
* Source: $(DRUNTIMESRC src/rt/backtrace/macho.d)
* Source: $(DRUNTIMESRC rt/backtrace/macho.d)
*/
module rt.backtrace.macho;

Expand Down Expand Up @@ -67,4 +67,9 @@ struct Image
auto data = getsectiondata(self, "__DWARF", "__debug_line", &size);
return data[0 .. size];
}

@property size_t baseAddress()
{
return 0;
}
}
2 changes: 1 addition & 1 deletion src/rt/config.d
Expand Up @@ -6,7 +6,7 @@
* $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
* (See accompanying file LICENSE)
* Authors: Rainer Schuetze
* Source: $(DRUNTIMESRC src/rt/_config.d)
* Source: $(DRUNTIMESRC rt/_config.d)
*/

module rt.config;
Expand Down
2 changes: 1 addition & 1 deletion src/rt/cover.d
Expand Up @@ -6,7 +6,7 @@
* $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
* (See accompanying file LICENSE)
* Authors: Walter Bright, Sean Kelly
* Source: $(DRUNTIMESRC src/rt/_cover.d)
* Source: $(DRUNTIMESRC rt/_cover.d)
*/

module rt.cover;
Expand Down
2 changes: 1 addition & 1 deletion src/rt/deh.d
Expand Up @@ -6,7 +6,7 @@
* $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
* (See accompanying file LICENSE)
* Authors: Walter Bright
* Source: $(DRUNTIMESRC src/rt/deh.d)
* Source: $(DRUNTIMESRC rt/deh.d)
*/

module rt.deh;
Expand Down
2 changes: 1 addition & 1 deletion src/rt/deh_win32.d
Expand Up @@ -6,7 +6,7 @@
* $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
* (See accompanying file LICENSE)
* Authors: Walter Bright
* Source: $(DRUNTIMESRC src/rt/deh_win32.d)
* Source: $(DRUNTIMESRC rt/deh_win32.d)
*/

module rt.deh_win32;
Expand Down
2 changes: 1 addition & 1 deletion src/rt/deh_win64_posix.d
Expand Up @@ -7,7 +7,7 @@
* $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
* (See accompanying file LICENSE)
* Authors: Walter Bright, Sean Kelly
* Source: $(DRUNTIMESRC src/rt/deh_win64_posix.d)
* Source: $(DRUNTIMESRC rt/deh_win64_posix.d)
*/

module rt.deh_win64_posix;
Expand Down
2 changes: 1 addition & 1 deletion src/rt/dwarfeh.d
Expand Up @@ -6,7 +6,7 @@
* $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
* (See accompanying file LICENSE)
* Authors: Walter Bright
* Source: $(DRUNTIMESRC src/rt/_dwarfeh.d)
* Source: $(DRUNTIMESRC rt/_dwarfeh.d)
*/

module rt.dwarfeh;
Expand Down
2 changes: 1 addition & 1 deletion src/rt/ehalloc.d
Expand Up @@ -6,7 +6,7 @@
* $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
* (See accompanying file LICENSE)
* Authors: Walter Bright
* Source: $(DRUNTIMESRC src/rt/_dwarfeh.d)
* Source: $(DRUNTIMESRC rt/_dwarfeh.d)
*/

module rt.ehalloc;
Expand Down
2 changes: 1 addition & 1 deletion src/rt/lifetime.d
Expand Up @@ -7,7 +7,7 @@
* $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
* (See accompanying file LICENSE)
* Authors: Walter Bright, Sean Kelly, Steven Schveighoffer
* Source: $(DRUNTIMESRC src/rt/_lifetime.d)
* Source: $(DRUNTIMESRC rt/_lifetime.d)
*/

module rt.lifetime;
Expand Down
2 changes: 1 addition & 1 deletion src/rt/llmath.d
Expand Up @@ -6,7 +6,7 @@
* $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
* (See accompanying file LICENSE)
* Authors: Walter Bright, Sean Kelly
* Source: $(DRUNTIMESRC src/rt/_llmath.d)
* Source: $(DRUNTIMESRC rt/_llmath.d)
*/

module rt.llmath;
Expand Down
2 changes: 1 addition & 1 deletion src/rt/memory.d
Expand Up @@ -7,7 +7,7 @@
* $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
* (See accompanying file LICENSE)
* Authors: Walter Bright, Sean Kelly
* Source: $(DRUNTIMESRC src/rt/_memory.d)
* Source: $(DRUNTIMESRC rt/_memory.d)
*/

module rt.memory;
Expand Down
2 changes: 1 addition & 1 deletion src/rt/minfo.d
Expand Up @@ -7,7 +7,7 @@
* $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
* (See accompanying file LICENSE)
* Authors: Walter Bright, Sean Kelly
* Source: $(DRUNTIMESRC src/rt/_minfo.d)
* Source: $(DRUNTIMESRC rt/_minfo.d)
*/

module rt.minfo;
Expand Down
2 changes: 1 addition & 1 deletion src/rt/profilegc.d
Expand Up @@ -8,7 +8,7 @@
* $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
* (See accompanying file LICENSE)
* Authors: Andrei Alexandrescu and Walter Bright
* Source: $(DRUNTIMESRC src/rt/_profilegc.d)
* Source: $(DRUNTIMESRC rt/_profilegc.d)
*/

module rt.profilegc;
Expand Down
2 changes: 1 addition & 1 deletion src/rt/sections.d
Expand Up @@ -5,7 +5,7 @@
* $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
* (See accompanying file LICENSE)
* Authors: Walter Bright, Sean Kelly, Martin Nowak
* Source: $(DRUNTIMESRC src/rt/_sections.d)
* Source: $(DRUNTIMESRC rt/_sections.d)
*/

module rt.sections;
Expand Down
2 changes: 1 addition & 1 deletion src/rt/sections_android.d
Expand Up @@ -5,7 +5,7 @@
* Copyright: Copyright Martin Nowak 2012-2013.
* License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
* Authors: Martin Nowak
* Source: $(DRUNTIMESRC src/rt/_sections_android.d)
* Source: $(DRUNTIMESRC rt/_sections_android.d)
*/

module rt.sections_android;
Expand Down
2 changes: 1 addition & 1 deletion src/rt/sections_elf_shared.d
Expand Up @@ -5,7 +5,7 @@
* Copyright: Copyright Martin Nowak 2012-2013.
* License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
* Authors: Martin Nowak
* Source: $(DRUNTIMESRC src/rt/_sections_linux.d)
* Source: $(DRUNTIMESRC rt/_sections_linux.d)
*/

module rt.sections_elf_shared;
Expand Down
2 changes: 1 addition & 1 deletion src/rt/sections_osx_x86.d
Expand Up @@ -7,7 +7,7 @@
* $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
* (See accompanying file LICENSE)
* Authors: Walter Bright, Sean Kelly, Martin Nowak, Jacob Carlborg
* Source: $(DRUNTIMESRC src/rt/_sections_osx_x86.d)
* Source: $(DRUNTIMESRC rt/_sections_osx_x86.d)
*/
module rt.sections_osx_x86;

Expand Down
2 changes: 1 addition & 1 deletion src/rt/sections_osx_x86_64.d
Expand Up @@ -7,7 +7,7 @@
* $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
* (See accompanying file LICENSE)
* Authors: Walter Bright, Sean Kelly, Martin Nowak, Jacob Carlborg
* Source: $(DRUNTIMESRC src/rt/_sections_osx_x86_64.d)
* Source: $(DRUNTIMESRC rt/_sections_osx_x86_64.d)
*/
module rt.sections_osx_x86_64;

Expand Down
2 changes: 1 addition & 1 deletion src/rt/sections_solaris.d
Expand Up @@ -5,7 +5,7 @@
* Copyright: Copyright Martin Nowak 2012-2013.
* License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
* Authors: Martin Nowak
* Source: $(DRUNTIMESRC src/rt/_sections_solaris.d)
* Source: $(DRUNTIMESRC rt/_sections_solaris.d)
*/

module rt.sections_solaris;
Expand Down
2 changes: 1 addition & 1 deletion src/rt/sections_win32.d
Expand Up @@ -7,7 +7,7 @@
* $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
* (See accompanying file LICENSE)
* Authors: Walter Bright, Sean Kelly, Martin Nowak
* Source: $(DRUNTIMESRC src/rt/_sections_win32.d)
* Source: $(DRUNTIMESRC rt/_sections_win32.d)
*/

module rt.sections_win32;
Expand Down
2 changes: 1 addition & 1 deletion src/rt/sections_win64.d
Expand Up @@ -7,7 +7,7 @@
* $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
* (See accompanying file LICENSE)
* Authors: Walter Bright, Sean Kelly, Martin Nowak
* Source: $(DRUNTIMESRC src/rt/_sections_win64.d)
* Source: $(DRUNTIMESRC rt/_sections_win64.d)
*/

module rt.sections_win64;
Expand Down
2 changes: 1 addition & 1 deletion src/rt/trace.d
Expand Up @@ -6,7 +6,7 @@
* $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
* (See accompanying file LICENSE)
* Authors: Walter Bright, Sean Kelly, the LDC team
* Source: $(DRUNTIMESRC src/rt/_trace.d)
* Source: $(DRUNTIMESRC rt/_trace.d)
*/

module rt.trace;
Expand Down
2 changes: 1 addition & 1 deletion src/rt/tracegc.d
Expand Up @@ -8,7 +8,7 @@
* $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
* (See accompanying file LICENSE)
* Authors: Walter Bright
* Source: $(DRUNTIMESRC src/rt/_tracegc.d)
* Source: $(DRUNTIMESRC rt/_tracegc.d)
*/

module rt.tracegc;
Expand Down
2 changes: 1 addition & 1 deletion src/rt/unwind.d
Expand Up @@ -4,7 +4,7 @@
*
* See_Also:
* Itanium C++ ABI: Exception Handling ($Revision: 1.22 $)
* Source: $(DRUNTIMESRC src/rt/_unwind.d)
* Source: $(DRUNTIMESRC rt/_unwind.d)
*/

module rt.unwind;
Expand Down

0 comments on commit 9a8edfb

Please sign in to comment.