[llvm] r226525 - [dsymutil] Add the detected target triple to the debug map.

Frederic Riss friss at apple.com
Mon Jan 19 15:33:15 PST 2015


Author: friss
Date: Mon Jan 19 17:33:14 2015
New Revision: 226525

URL: http://llvm.org/viewvc/llvm-project?rev=226525&view=rev
Log:
[dsymutil] Add the detected target triple to the debug map.

It will be needed to instantiate the Target object that we will
use to create all the MC objects for the dwarf emission.

Modified:
    llvm/trunk/test/tools/dsymutil/debug-map-parsing.test
    llvm/trunk/tools/dsymutil/DebugMap.cpp
    llvm/trunk/tools/dsymutil/DebugMap.h
    llvm/trunk/tools/dsymutil/MachODebugMapParser.cpp

Modified: llvm/trunk/test/tools/dsymutil/debug-map-parsing.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/dsymutil/debug-map-parsing.test?rev=226525&r1=226524&r2=226525&view=diff
==============================================================================
--- llvm/trunk/test/tools/dsymutil/debug-map-parsing.test (original)
+++ llvm/trunk/test/tools/dsymutil/debug-map-parsing.test Mon Jan 19 17:33:14 2015
@@ -8,7 +8,7 @@ RUN: not llvm-dsymutil -v -parse-only %p
 Check that We can parse the debug map of the basic executable.
 
 CHECK-NOT: error
-CHECK: DEBUG MAP:
+CHECK: DEBUG MAP: x86_64-unknown-unknown-macho
 CHECK: /Inputs/basic1.macho.x86_64.o:
 CHECK: 	0000000000000000 => 0000000100000ea0	_main
 CHECK: /Inputs/basic2.macho.x86_64.o:
@@ -26,7 +26,7 @@ CHECK: END DEBUG MAP
 Check that we can parse the debug-map of the basic-lto executable
 
 CHECK-LTO-NOT: error
-CHECK-LTO: DEBUG MAP:
+CHECK-LTO: DEBUG MAP: x86_64-unknown-unknown-macho
 CHECK-LTO: /Inputs/basic-lto.macho.x86_64.o:
 CHECK-LTO: 	0000000000000050 => 0000000100000f90	_bar
 CHECK-LTO: 	0000000000000658 => 0000000100001000	_baz
@@ -48,7 +48,8 @@ CHECK-ARCHIVE-NEXT: 	opened new archive
 CHECK-ARCHIVE-NEXT: 	found member in current archive.
 CHECK-ARCHIVE-NEXT: trying to open {{.*}}/libbasic.a(basic3.macho.x86_64.o)'
 CHECK-ARCHIVE-NEXT: 	found member in current archive.
-CHECK-ARCHIVE: DEBUG MAP:   object addr =>  executable addr	symbol name
+CHECK-ARCHIVE: DEBUG MAP: x86_64-unknown-unknown-macho
+CHECK-ARCHIVE:       object addr =>  executable addr	symbol name
 CHECK-ARCHIVE: /Inputs/basic1.macho.x86_64.o:
 CHECK-ARCHIVE: 	0000000000000000 => 0000000100000ea0	_main
 CHECK-ARCHIVE: /Inputs/./libbasic.a(basic2.macho.x86_64.o):
@@ -69,6 +70,7 @@ NOT-FOUND: cannot open{{.*}}"/Inputs/bas
 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: DEBUG MAP:
+NOT-FOUND-NEXT:  object addr =>  executable addr	symbol name
 NOT-FOUND-NEXT: END DEBUG MAP
 
 Check that we correctly error out on invalid executatble.

Modified: llvm/trunk/tools/dsymutil/DebugMap.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/dsymutil/DebugMap.cpp?rev=226525&r1=226524&r2=226525&view=diff
==============================================================================
--- llvm/trunk/tools/dsymutil/DebugMap.cpp (original)
+++ llvm/trunk/tools/dsymutil/DebugMap.cpp Mon Jan 19 17:33:14 2015
@@ -67,7 +67,8 @@ DebugMapObject::lookupSymbol(StringRef S
 }
 
 void DebugMap::print(raw_ostream &OS) const {
-  OS << "DEBUG MAP:   object addr =>  executable addr\tsymbol name\n";
+  OS << "DEBUG MAP: " << BinaryTriple.getTriple()
+     << "\n\tobject addr =>  executable addr\tsymbol name\n";
   for (const auto &Obj : objects())
     Obj->print(OS);
   OS << "END DEBUG MAP\n";

Modified: llvm/trunk/tools/dsymutil/DebugMap.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/dsymutil/DebugMap.h?rev=226525&r1=226524&r2=226525&view=diff
==============================================================================
--- llvm/trunk/tools/dsymutil/DebugMap.h (original)
+++ llvm/trunk/tools/dsymutil/DebugMap.h Mon Jan 19 17:33:14 2015
@@ -22,6 +22,7 @@
 #define LLVM_TOOLS_DSYMUTIL_DEBUGMAP_H
 
 #include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/Triple.h"
 #include "llvm/ADT/iterator_range.h"
 #include "llvm/Object/ObjectFile.h"
 #include "llvm/Support/ErrorOr.h"
@@ -60,10 +61,13 @@ class DebugMapObject;
 ///     }
 /// }
 class DebugMap {
+  Triple BinaryTriple;
   typedef std::vector<std::unique_ptr<DebugMapObject>> ObjectContainer;
   ObjectContainer Objects;
 
 public:
+  DebugMap(const Triple &BinaryTriple) : BinaryTriple(BinaryTriple) {}
+
   typedef ObjectContainer::const_iterator const_iterator;
 
   iterator_range<const_iterator> objects() const {
@@ -78,6 +82,8 @@ public:
   /// debug map.
   DebugMapObject &addDebugMapObject(StringRef ObjectFilePath);
 
+  const Triple &getTriple() { return BinaryTriple; }
+
   void print(raw_ostream &OS) const;
 
 #ifndef NDEBUG

Modified: llvm/trunk/tools/dsymutil/MachODebugMapParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/dsymutil/MachODebugMapParser.cpp?rev=226525&r1=226524&r2=226525&view=diff
==============================================================================
--- llvm/trunk/tools/dsymutil/MachODebugMapParser.cpp (original)
+++ llvm/trunk/tools/dsymutil/MachODebugMapParser.cpp Mon Jan 19 17:33:14 2015
@@ -97,6 +97,13 @@ void MachODebugMapParser::switchToNewDeb
   CurrentDebugMapObject = &Result->addDebugMapObject(Path);
 }
 
+static Triple getTriple(const object::MachOObjectFile &Obj) {
+  Triple TheTriple("unknown-unknown-unknown");
+  TheTriple.setArch(Triple::ArchType(Obj.getArch()));
+  TheTriple.setObjectFormat(Triple::MachO);
+  return TheTriple;
+}
+
 /// This main parsing routine tries to open the main binary and if
 /// successful iterates over the STAB entries. The real parsing is
 /// done in handleStabSymbolTableEntry.
@@ -107,7 +114,7 @@ ErrorOr<std::unique_ptr<DebugMap>> MachO
 
   const MachOObjectFile &MainBinary = *MainBinOrError;
   loadMainBinarySymbols();
-  Result = make_unique<DebugMap>();
+  Result = make_unique<DebugMap>(getTriple(MainBinary));
   MainBinaryStrings = MainBinary.getStringTableData();
   for (const SymbolRef &Symbol : MainBinary.symbols()) {
     const DataRefImpl &DRI = Symbol.getRawDataRefImpl();





More information about the llvm-commits mailing list