[dsymutil] Store an optional BinaryPath in the debug map.
authorFrederic Riss <friss@apple.com>
Wed, 26 Aug 2015 05:09:59 +0000 (05:09 +0000)
committerFrederic Riss <friss@apple.com>
Wed, 26 Aug 2015 05:09:59 +0000 (05:09 +0000)
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
test/tools/dsymutil/yaml-object-address-rewrite.test
tools/dsymutil/DebugMap.cpp
tools/dsymutil/DebugMap.h
tools/dsymutil/MachODebugMapParser.cpp

index 9415c94873b70f2f457e28289e843a2cf777f45c..2b9d0917609dda02729af2a60045923d1a955c33 100644 (file)
@@ -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.
index cebda0c62c077743d2e96e86c339b1b46ee38aa2..749719fc5bd9f0bf6f2c4b8376ffc67d9bbdae39 100644 (file)
@@ -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
index 387adc7927698660fa4dddea844bd7c32fd22a0d..4717085f43227716ba26d60813fe486f3e3a4fe8 100644 (file)
@@ -179,6 +179,7 @@ SequenceTraits<std::vector<std::unique_ptr<dsymutil::DebugMapObject>>>::element(
 void MappingTraits<dsymutil::DebugMap>::mapping(IO &io,
                                                 dsymutil::DebugMap &DM) {
   io.mapRequired("triple", DM.BinaryTriple);
+  io.mapOptional("binary-path", DM.BinaryPath);
   if (void *Ctxt = io.getContext())
     reinterpret_cast<YAMLContext *>(Ctxt)->BinaryTriple = DM.BinaryTriple;
   io.mapOptional("objects", DM.Objects);
@@ -189,6 +190,7 @@ void MappingTraits<std::unique_ptr<dsymutil::DebugMap>>::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<YAMLContext *>(Ctxt)->BinaryTriple = DM->BinaryTriple;
   io.mapOptional("objects", DM->Objects);
index 9bf20c6db31abface6d8ae36ba2f65edc32ab19a..06ac5a503dcd1bf0c68c6ea5269a755c741cd20d 100644 (file)
@@ -66,6 +66,7 @@ class DebugMapObject;
 /// }
 class DebugMap {
   Triple BinaryTriple;
+  std::string BinaryPath;
   typedef std::vector<std::unique_ptr<DebugMapObject>> 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
index bd29f004b0973f2de122b53645aed7df4ff8b053..8d17d527dfcc370315ccd8e0cc972740d51a8669 100644 (file)
@@ -120,7 +120,8 @@ std::unique_ptr<DebugMap>
 MachODebugMapParser::parseOneBinary(const MachOObjectFile &MainBinary,
                                     StringRef BinaryPath) {
   loadMainBinarySymbols(MainBinary);
-  Result = make_unique<DebugMap>(BinaryHolder::getTriple(MainBinary));
+  Result =
+      make_unique<DebugMap>(BinaryHolder::getTriple(MainBinary), BinaryPath);
   MainBinaryStrings = MainBinary.getStringTableData();
   for (const SymbolRef &Symbol : MainBinary.symbols()) {
     const DataRefImpl &DRI = Symbol.getRawDataRefImpl();