Skip to content

Commit

Permalink
Fix GSYM tests to run the yaml files and fix test failures on some ma…
Browse files Browse the repository at this point in the history
…chines.

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. Also fixed an issue where strings for files in the file table could be added in opposite order due to parameters to function calls not having a strong ordering, which caused tests to fail.

Differential Revision: https://reviews.llvm.org/D75390
  • Loading branch information
clayborg committed Mar 2, 2020
1 parent 4d6f3ee commit 5768835
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
8 changes: 7 additions & 1 deletion llvm/lib/DebugInfo/GSYM/GsymCreator.cpp
Expand Up @@ -29,7 +29,13 @@ uint32_t GsymCreator::insertFile(StringRef Path,
llvm::sys::path::Style Style) {
llvm::StringRef directory = llvm::sys::path::parent_path(Path, Style);
llvm::StringRef filename = llvm::sys::path::filename(Path, Style);
FileEntry FE(insertString(directory), insertString(filename));
// We must insert the strings first, then call the FileEntry constructor.
// If we inline the insertString() function call into the constructor, the
// call order is undefined due to parameter lists not having any ordering
// requirements.
const uint32_t Dir = insertString(directory);
const uint32_t Base = insertString(filename);
FileEntry FE(Dir, Base);

std::lock_guard<std::recursive_mutex> Guard(Mutex);
const auto NextIndex = Files.size();
Expand Down
1 change: 1 addition & 0 deletions llvm/test/tools/llvm-gsymutil/lit.local.cfg
@@ -0,0 +1 @@
config.suffixes = ['.test', '.yaml']
9 changes: 6 additions & 3 deletions llvm/tools/llvm-gsym/llvm-gsymutil.cpp
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
Expand All @@ -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
Expand Down

0 comments on commit 5768835

Please sign in to comment.