[llvm] r327485 - [dsymutil] Print architecture in warning

Jonas Devlieghere via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 14 02:34:54 PDT 2018


Author: jdevlieghere
Date: Wed Mar 14 02:34:54 2018
New Revision: 327485

URL: http://llvm.org/viewvc/llvm-project?rev=327485&view=rev
Log:
[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.

Modified:
    llvm/trunk/test/tools/dsymutil/debug-map-parsing.test
    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=327485&r1=327484&r2=327485&view=diff
==============================================================================
--- llvm/trunk/test/tools/dsymutil/debug-map-parsing.test (original)
+++ llvm/trunk/test/tools/dsymutil/debug-map-parsing.test Wed Mar 14 02:34:54 2018
@@ -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

Modified: llvm/trunk/tools/dsymutil/MachODebugMapParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/dsymutil/MachODebugMapParser.cpp?rev=327485&r1=327484&r2=327485&view=diff
==============================================================================
--- llvm/trunk/tools/dsymutil/MachODebugMapParser.cpp (original)
+++ llvm/trunk/tools/dsymutil/MachODebugMapParser.cpp Wed Mar 14 02:34:54 2018
@@ -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::switchToNewDeb
   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::handleStabSymb
     }
   }
 
-  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.




More information about the llvm-commits mailing list