Fix GSYM tests to run the yaml files and fix test failures on some machines.
authorGreg Clayton <gclayton@fb.com>
Thu, 5 Mar 2020 03:12:08 +0000 (19:12 -0800)
committerGreg Clayton <gclayton@fb.com>
Thu, 5 Mar 2020 03:14:08 +0000 (19:14 -0800)
YAML files were not being run during lit testing as there was no lit.local.cfg file. Once this was fixed, some buildbots would fail due to a StringRef that pointed to a std::string inside of a temporary llvm::Triple object. These issues are fixed here by making a local triple object that stays around long enough so the StringRef points to valid data. Fixed memory sanitizer bot bugs as well.

Differential Revision: https://reviews.llvm.org/D75390

llvm/lib/DebugInfo/GSYM/GsymCreator.cpp
llvm/test/tools/llvm-gsymutil/ARM_AArch64/fat-macho-dwarf.yaml [moved from llvm/test/tools/llvm-gsymutil/fat-macho-dwarf.yaml with 100% similarity]
llvm/test/tools/llvm-gsymutil/ARM_AArch64/lit.local.cfg [new file with mode: 0644]
llvm/test/tools/llvm-gsymutil/X86/elf-dwarf.yaml [moved from llvm/test/tools/llvm-gsymutil/elf-dwarf.yaml with 100% similarity]
llvm/test/tools/llvm-gsymutil/X86/lit.local.cfg [new file with mode: 0644]
llvm/test/tools/llvm-gsymutil/X86/mach-dwarf.yaml [moved from llvm/test/tools/llvm-gsymutil/mach-dwarf.yaml with 100% similarity]
llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp

index 3a84ac4..f7d7afe 100644 (file)
@@ -74,7 +74,7 @@ llvm::Error GsymCreator::encode(FileWriter &O) const {
   Hdr.BaseAddress = MinAddr;
   Hdr.NumAddresses = static_cast<uint32_t>(Funcs.size());
   Hdr.StrtabOffset = 0; // We will fix this up later.
-  Hdr.StrtabOffset = 0; // We will fix this up later.
+  Hdr.StrtabSize = 0; // We will fix this up later.
   memset(Hdr.UUID, 0, sizeof(Hdr.UUID));
   if (UUID.size() > sizeof(Hdr.UUID))
     return createStringError(std::errc::invalid_argument,
diff --git a/llvm/test/tools/llvm-gsymutil/ARM_AArch64/lit.local.cfg b/llvm/test/tools/llvm-gsymutil/ARM_AArch64/lit.local.cfg
new file mode 100644 (file)
index 0000000..e06c15e
--- /dev/null
@@ -0,0 +1,4 @@
+if not ('ARM' in config.root.targets and 'AArch64' in config.root.targets):
+    config.unsupported = True
+
+config.suffixes = ['.test', '.yaml']
diff --git a/llvm/test/tools/llvm-gsymutil/X86/lit.local.cfg b/llvm/test/tools/llvm-gsymutil/X86/lit.local.cfg
new file mode 100644 (file)
index 0000000..52c762f
--- /dev/null
@@ -0,0 +1,4 @@
+if not 'X86' in config.root.targets:
+    config.unsupported = True
+
+config.suffixes = ['.test', '.yaml']
index 6ad2009..2d75473 100644 (file)
@@ -179,7 +179,8 @@ static bool filterArch(MachOObjectFile &Obj) {
   if (ArchFilters.empty())
     return true;
 
-  StringRef ObjArch = Obj.getArchTriple().getArchName();
+  Triple ObjTriple(Obj.getArchTriple());
+  StringRef ObjArch = ObjTriple.getArchName();
 
   for (auto Arch : ArchFilters) {
     // Match name.
@@ -350,7 +351,8 @@ static llvm::Error handleBuffer(StringRef Filename, MemoryBufferRef Buffer,
   error(Filename, errorToErrorCode(BinOrErr.takeError()));
 
   if (auto *Obj = dyn_cast<ObjectFile>(BinOrErr->get())) {
-    auto ArchName = Obj->makeTriple().getArchName();
+    Triple ObjTriple(Obj->makeTriple());
+    auto ArchName = ObjTriple.getArchName();
     outs() << "Output file (" << ArchName << "): " << OutFile << "\n";
     if (auto Err = handleObjectFile(*Obj, OutFile.c_str()))
       return Err;
@@ -374,7 +376,8 @@ static llvm::Error handleBuffer(StringRef Filename, MemoryBufferRef Buffer,
 
     // Now handle each architecture we need to convert.
     for (auto &Obj: FilterObjs) {
-      auto ArchName = Obj->getArchTriple().getArchName();
+      Triple ObjTriple(Obj->getArchTriple());
+      auto ArchName = ObjTriple.getArchName();
       std::string ArchOutFile(OutFile);
       // If we are only handling a single architecture, then we will use the
       // normal output file. If we are handling multiple architectures append