This is an archive of the discontinued LLVM Phabricator instance.

Switch over to using the LLVM archive parser for BSD archives.
ClosedPublic

Authored by clayborg on Sep 2 2023, 9:14 PM.

Details

Summary

Our LLDB parser didn't correctly handle archives of all flavors on different systems, it currently only correctly handled BSD archives, normal and thin, on macOS, but I noticed that it was getting incorrect information when decoding a variety of archives on linux. There were subtle changes to how names were encoded that we didn't handle correctly and we also didn't set the result of GetObjectSize() correctly as there was some bad math. This didn't matter when exracting .o files from .a files for LLDB because the size was always way too big, but it was big enough to at least read enough bytes for each object within the archive.

This patch does the following:

  • switch over to use LLVM's archive parser and avoids previous code duplication
  • remove values from ObjectContainerBSDArchive::Object that we don't use like:
    • uid
    • gid
    • mode
  • fix ths ObjectContainerBSDArchive::Object::file_size value to be correct
  • adds tests to test that we get the correct module specifications

Diff Detail

Event Timeline

clayborg created this revision.Sep 2 2023, 9:14 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 2 2023, 9:14 PM
clayborg requested review of this revision.Sep 2 2023, 9:14 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 2 2023, 9:14 PM

Overall this looks good, but instead of consuming all the errors, let's log them with LLDB_LOG_ERROR. Note that the API is a bit tricky and still requires you to provide a format string:

LLDB_LOG_ERROR(GetLog(LLDBLog::Object), something.takeError(), "context before printing the actual error: {0}");
clayborg updated this revision to Diff 555933.Sep 5 2023, 2:14 PM

Log any errors we encounter during archive object parsing.

This revision is now accepted and ready to land.Sep 5 2023, 2:58 PM