Просмотр исходного кода

[dsymutil] Print architecture in warning

Make the architecture part of the warning in the DebugMapParser. This
makes things consistent with the Apple's internal version of dsymutil.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327485 91177308-0d34-0410-b5e6-96231b3b80d8
Jonas Devlieghere 7 лет назад
Родитель
Сommit
21cda30c18
2 измененных файлов с 21 добавлено и 14 удалено
  1. 4 3
      test/tools/dsymutil/debug-map-parsing.test
  2. 17 11
      tools/dsymutil/MachODebugMapParser.cpp

+ 4 - 3
test/tools/dsymutil/debug-map-parsing.test

@@ -71,9 +71,10 @@ CHECK-ARCHIVE: ...
 Check that we warn about missing object files (this presumes that the files aren't
 present in the machine's /Inputs/ folder, which should be a pretty safe bet).
 
-NOT-FOUND: cannot open{{.*}}'/Inputs/basic1.macho.x86_64.o': {{[Nn]o}} such file
-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
+warning: (x86_64) /Inputs/basic1.macho.x86_64.o unable to open object file:
+NOT-FOUND: warning: (x86_64) {{.*}}/Inputs/basic1.macho.x86_64.o unable to open object file: {{[Nn]o}} such file
+NOT-FOUND: warning: (x86_64) {{.*}}/Inputs/basic2.macho.x86_64.o unable to open object file: {{[Nn]o}} such file
+NOT-FOUND: warning: (x86_64) {{.*}}/Inputs/basic3.macho.x86_64.o unable to open object file: {{[Nn]o}} such file
 NOT-FOUND: ---
 NOT-FOUND-NEXT: triple: 'x86_64-apple-darwin'
 NOT-FOUND-NEXT: binary-path:{{.*}}/Inputs/basic.macho.x86_64

+ 17 - 11
tools/dsymutil/MachODebugMapParser.cpp

@@ -10,6 +10,7 @@
 #include "BinaryHolder.h"
 #include "DebugMap.h"
 #include "ErrorReporting.h"
+#include "MachOUtils.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/Object/MachO.h"
 #include "llvm/Support/Path.h"
@@ -96,9 +97,14 @@ private:
   }
   void dumpOneBinaryStab(const MachOObjectFile &MainBinary,
                          StringRef BinaryPath);
+
+  void Warning(const Twine &Msg, StringRef File = StringRef()) {
+    warn_ostream() << "("
+                   << MachOUtils::getArchName(Result->getTriple().getArchName())
+                   << ") " << File << " " << Msg << "\n";
+  }
 };
 
-static void Warning(const Twine &Msg) { warn_ostream() << Msg << '\n'; }
 } // anonymous namespace
 
 /// Reset the parser state corresponding to the current object
@@ -122,16 +128,14 @@ void MachODebugMapParser::switchToNewDebugMapObject(
   auto MachOOrError =
       CurrentObjectHolder.GetFilesAs<MachOObjectFile>(Path, Timestamp);
   if (auto Error = MachOOrError.getError()) {
-    Warning(Twine("cannot open debug object '") + Path.str() +
-            "': " + Error.message());
+    Warning("unable to open object file: " + Error.message(), Path.str());
     return;
   }
 
   auto ErrOrAchObj =
       CurrentObjectHolder.GetAs<MachOObjectFile>(Result->getTriple());
   if (auto Error = ErrOrAchObj.getError()) {
-    Warning(Twine("cannot open debug object '") + Path.str() +
-            "': " + Error.message());
+    Warning("unable to open object file: " + Error.message(), Path.str());
     return;
   }
 
@@ -405,14 +409,16 @@ void MachODebugMapParser::handleStabSymbolTableEntry(uint32_t StringIndex,
     }
   }
 
-  if (ObjectSymIt == CurrentObjectAddresses.end())
-    return Warning("could not find object file symbol for symbol " +
-                   Twine(Name));
+  if (ObjectSymIt == CurrentObjectAddresses.end()) {
+    Warning("could not find object file symbol for symbol " + Twine(Name));
+    return;
+  }
 
   if (!CurrentDebugMapObject->addSymbol(Name, ObjectSymIt->getValue(), Value,
-                                        Size))
-    return Warning(Twine("failed to insert symbol '") + Name +
-                   "' in the debug map.");
+                                        Size)) {
+    Warning(Twine("failed to insert symbol '") + Name + "' in the debug map.");
+    return;
+  }
 }
 
 /// Load the current object file symbols into CurrentObjectAddresses.