From 65ce0b1a58500376a94491ff99ba38db39a79707 Mon Sep 17 00:00:00 2001 From: Frederic Riss Date: Wed, 26 Aug 2015 05:09:59 +0000 Subject: [PATCH] [dsymutil] Store an optional BinaryPath in the debug map. llvm-dsymutil needs to emit dSYM companion bundles. These are binary files that replicate some of the orignal binary file properties (sections and symbols). To get acces to these properties, pass the binary path in the debug map. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@246011 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/tools/dsymutil/debug-map-parsing.test | 4 ++++ test/tools/dsymutil/yaml-object-address-rewrite.test | 1 + tools/dsymutil/DebugMap.cpp | 2 ++ tools/dsymutil/DebugMap.h | 6 +++++- tools/dsymutil/MachODebugMapParser.cpp | 3 ++- 5 files changed, 14 insertions(+), 2 deletions(-) diff --git a/test/tools/dsymutil/debug-map-parsing.test b/test/tools/dsymutil/debug-map-parsing.test index 9415c94873b..2b9d0917609 100644 --- a/test/tools/dsymutil/debug-map-parsing.test +++ b/test/tools/dsymutil/debug-map-parsing.test @@ -10,6 +10,7 @@ Check that We can parse the debug map of the basic executable. CHECK-NOT: error CHECK: --- CHECK: triple: 'x86_64-apple-darwin' +CHECK: binary-path:{{.*}}/Inputs/basic.macho.x86_64 CHECK: filename:{{.*}}/Inputs/basic1.macho.x86_64.o CHECK-DAG: sym: _main, objAddr: 0x0000000000000000, binAddr: 0x0000000100000EA0, size: 0x00000024 CHECK: filename{{.*}}/Inputs/basic2.macho.x86_64.o @@ -29,6 +30,7 @@ Check that we can parse the debug-map of the basic-lto executable CHECK-LTO-NOT: error CHECK-LTO: --- CHECK-LTO: triple: 'x86_64-apple-darwin' +CHECK-LTO: binary-path:{{.*}}/Inputs/basic-lto.macho.x86_64 CHECK-LTO: /Inputs/basic-lto.macho.x86_64.o CHECK-LTO-DAG: sym: _bar, objAddr: 0x0000000000000050, binAddr: 0x0000000100000F90, size: 0x00000024 CHECK-LTO-DAG: sym: _baz, objAddr: 0x0000000000000658, binAddr: 0x0000000100001000, size: 0x00000000 @@ -52,6 +54,7 @@ CHECK-ARCHIVE-NEXT: trying to open {{.*}}/libbasic.a(basic3.macho.x86_64.o)' CHECK-ARCHIVE-NEXT: found member in current archive. CHECK-ARCHIVE: --- CHECK-ARCHIVE: triple: 'x86_64-apple-darwin' +CHECK-ARCHIVE: binary-path:{{.*}}/Inputs/basic-archive.macho.x86_64 CHECK-ARCHIVE: /Inputs/basic1.macho.x86_64.o CHECK-ARCHIVE-DAG: sym: _main, objAddr: 0x0000000000000000, binAddr: 0x0000000100000EA0, size: 0x00000024 CHECK-ARCHIVE: /Inputs/./libbasic.a(basic2.macho.x86_64.o) @@ -73,6 +76,7 @@ NOT-FOUND: cannot open{{.*}}"/Inputs/basic2.macho.x86_64.o": {{[Nn]o}} such file NOT-FOUND: cannot open{{.*}}"/Inputs/basic3.macho.x86_64.o": {{[Nn]o}} such file NOT-FOUND: --- NOT-FOUND-NEXT: triple: 'x86_64-apple-darwin' +NOT-FOUND-NEXT: binary-path:{{.*}}/Inputs/basic.macho.x86_64 NOT-FOUND-NEXT: ... Check that we correctly error out on invalid executatble. diff --git a/test/tools/dsymutil/yaml-object-address-rewrite.test b/test/tools/dsymutil/yaml-object-address-rewrite.test index cebda0c62c0..749719fc5bd 100644 --- a/test/tools/dsymutil/yaml-object-address-rewrite.test +++ b/test/tools/dsymutil/yaml-object-address-rewrite.test @@ -6,6 +6,7 @@ # # CHECK: --- # CHECK-NEXT: triple:{{.*}}'x86_64-apple-darwin' +# CHECK-NEXT: binary-path:{{.*}}'' # CHECK-NEXT: objects: # CHECK-NEXT: filename:{{.*}}/Inputs/basic1.macho.x86_64.o # CHECK-NEXT: timestamp: 0 diff --git a/tools/dsymutil/DebugMap.cpp b/tools/dsymutil/DebugMap.cpp index 387adc79276..4717085f432 100644 --- a/tools/dsymutil/DebugMap.cpp +++ b/tools/dsymutil/DebugMap.cpp @@ -179,6 +179,7 @@ SequenceTraits>>::element( void MappingTraits::mapping(IO &io, dsymutil::DebugMap &DM) { io.mapRequired("triple", DM.BinaryTriple); + io.mapOptional("binary-path", DM.BinaryPath); if (void *Ctxt = io.getContext()) reinterpret_cast(Ctxt)->BinaryTriple = DM.BinaryTriple; io.mapOptional("objects", DM.Objects); @@ -189,6 +190,7 @@ void MappingTraits>::mapping( if (!DM) DM.reset(new DebugMap()); io.mapRequired("triple", DM->BinaryTriple); + io.mapOptional("binary-path", DM->BinaryPath); if (void *Ctxt = io.getContext()) reinterpret_cast(Ctxt)->BinaryTriple = DM->BinaryTriple; io.mapOptional("objects", DM->Objects); diff --git a/tools/dsymutil/DebugMap.h b/tools/dsymutil/DebugMap.h index 9bf20c6db31..06ac5a503dc 100644 --- a/tools/dsymutil/DebugMap.h +++ b/tools/dsymutil/DebugMap.h @@ -66,6 +66,7 @@ class DebugMapObject; /// } class DebugMap { Triple BinaryTriple; + std::string BinaryPath; typedef std::vector> ObjectContainer; ObjectContainer Objects; @@ -76,7 +77,8 @@ class DebugMap { DebugMap() = default; ///@} public: - DebugMap(const Triple &BinaryTriple) : BinaryTriple(BinaryTriple) {} + DebugMap(const Triple &BinaryTriple, StringRef BinaryPath) + : BinaryTriple(BinaryTriple), BinaryPath(BinaryPath) {} typedef ObjectContainer::const_iterator const_iterator; @@ -95,6 +97,8 @@ public: const Triple &getTriple() const { return BinaryTriple; } + StringRef getBinaryPath() const { return BinaryPath; } + void print(raw_ostream &OS) const; #ifndef NDEBUG diff --git a/tools/dsymutil/MachODebugMapParser.cpp b/tools/dsymutil/MachODebugMapParser.cpp index bd29f004b09..8d17d527dfc 100644 --- a/tools/dsymutil/MachODebugMapParser.cpp +++ b/tools/dsymutil/MachODebugMapParser.cpp @@ -120,7 +120,8 @@ std::unique_ptr MachODebugMapParser::parseOneBinary(const MachOObjectFile &MainBinary, StringRef BinaryPath) { loadMainBinarySymbols(MainBinary); - Result = make_unique(BinaryHolder::getTriple(MainBinary)); + Result = + make_unique(BinaryHolder::getTriple(MainBinary), BinaryPath); MainBinaryStrings = MainBinary.getStringTableData(); for (const SymbolRef &Symbol : MainBinary.symbols()) { const DataRefImpl &DRI = Symbol.getRawDataRefImpl(); -- 2.34.1