]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / llvm-dwarfdump / llvm-dwarfdump.cpp
1 //===-- llvm-dwarfdump.cpp - Debug info dumping utility for llvm ----------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This program is a utility that works like "dwarfdump".
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "llvm/ADT/STLExtras.h"
15 #include "llvm/ADT/StringSet.h"
16 #include "llvm/ADT/Triple.h"
17 #include "llvm/DebugInfo/DIContext.h"
18 #include "llvm/DebugInfo/DWARF/DWARFContext.h"
19 #include "llvm/Object/Archive.h"
20 #include "llvm/Object/MachOUniversal.h"
21 #include "llvm/Object/ObjectFile.h"
22 #include "llvm/Support/CommandLine.h"
23 #include "llvm/Support/Debug.h"
24 #include "llvm/Support/Format.h"
25 #include "llvm/Support/ManagedStatic.h"
26 #include "llvm/Support/MemoryBuffer.h"
27 #include "llvm/Support/Path.h"
28 #include "llvm/Support/PrettyStackTrace.h"
29 #include "llvm/Support/Regex.h"
30 #include "llvm/Support/Signals.h"
31 #include "llvm/Support/TargetSelect.h"
32 #include "llvm/Support/ToolOutputFile.h"
33 #include "llvm/Support/raw_ostream.h"
34
35 using namespace llvm;
36 using namespace object;
37
38 /// Parser for options that take an optional offest argument.
39 /// @{
40 struct OffsetOption {
41   uint64_t Val = 0;
42   bool HasValue = false;
43   bool IsRequested = false;
44 };
45
46 namespace llvm {
47 namespace cl {
48 template <>
49 class parser<OffsetOption> final : public basic_parser<OffsetOption> {
50 public:
51   parser(Option &O) : basic_parser(O) {}
52
53   /// Return true on error.
54   bool parse(Option &O, StringRef ArgName, StringRef Arg, OffsetOption &Val) {
55     if (Arg == "") {
56       Val.Val = 0;
57       Val.HasValue = false;
58       Val.IsRequested = true;
59       return false;
60     }
61     if (Arg.getAsInteger(0, Val.Val))
62       return O.error("'" + Arg + "' value invalid for integer argument!");
63     Val.HasValue = true;
64     Val.IsRequested = true;
65     return false;
66   }
67
68   enum ValueExpected getValueExpectedFlagDefault() const {
69     return ValueOptional;
70   }
71
72   void printOptionInfo(const Option &O, size_t GlobalWidth) const {
73     outs() << "  -" << O.ArgStr;
74     Option::printHelpStr(O.HelpStr, GlobalWidth, getOptionWidth(O));
75   }
76
77   void printOptionDiff(const Option &O, OffsetOption V, OptVal Default,
78                        size_t GlobalWidth) const {
79     printOptionName(O, GlobalWidth);
80     outs() << "[=offset]";
81   }
82
83   // An out-of-line virtual method to provide a 'home' for this class.
84   void anchor() override {};
85 };
86 } // cl
87 } // llvm
88
89 /// @}
90 /// Command line options.
91 /// @{
92
93 namespace {
94 using namespace cl;
95
96 OptionCategory DwarfDumpCategory("Specific Options");
97 static opt<bool> Help("h", desc("Alias for -help"), Hidden,
98                       cat(DwarfDumpCategory));
99 static list<std::string>
100     InputFilenames(Positional, desc("<input object files or .dSYM bundles>"),
101                    ZeroOrMore, cat(DwarfDumpCategory));
102
103 cl::OptionCategory SectionCategory("Section-specific Dump Options",
104                                    "These control which sections are dumped. "
105                                    "Where applicable these parameters take an "
106                                    "optional =<offset> argument to dump only "
107                                    "the entry at the specified offset.");
108
109 static opt<bool> DumpAll("all", desc("Dump all debug info sections"),
110                          cat(SectionCategory));
111 static alias DumpAllAlias("a", desc("Alias for -all"), aliasopt(DumpAll));
112
113 // Options for dumping specific sections.
114 static unsigned DumpType = DIDT_Null;
115 static std::array<llvm::Optional<uint64_t>, (unsigned)DIDT_ID_Count>
116     DumpOffsets;
117 #define HANDLE_DWARF_SECTION(ENUM_NAME, ELF_NAME, CMDLINE_NAME)                \
118   static opt<OffsetOption> Dump##ENUM_NAME(                                    \
119       CMDLINE_NAME, desc("Dump the " ELF_NAME " section"),                     \
120       cat(SectionCategory));
121 #include "llvm/BinaryFormat/Dwarf.def"
122 #undef HANDLE_DWARF_SECTION
123
124 static alias DumpDebugFrameAlias("eh-frame", desc("Alias for -debug-frame"),
125                                  NotHidden, cat(SectionCategory),
126                                  aliasopt(DumpDebugFrame));
127 static list<std::string>
128     ArchFilters("arch",
129                 desc("Dump debug information for the specified CPU "
130                      "architecture only. Architectures may be specified by "
131                      "name or by number. This option can be specified "
132                      "multiple times, once for each desired architecture."),
133                 cat(DwarfDumpCategory));
134 static opt<bool>
135     Diff("diff",
136          desc("Emit diff-friendly output by omitting offsets and addresses."),
137          cat(DwarfDumpCategory));
138 static list<std::string>
139     Find("find",
140          desc("Search for the exact match for <name> in the accelerator tables "
141               "and print the matching debug information entries. When no "
142               "accelerator tables are available, the slower but more complete "
143               "-name option can be used instead."),
144          value_desc("name"), cat(DwarfDumpCategory));
145 static alias FindAlias("f", desc("Alias for -find."), aliasopt(Find));
146 static opt<bool>
147     IgnoreCase("ignore-case",
148                desc("Ignore case distinctions in when searching by name."),
149                value_desc("i"), cat(DwarfDumpCategory));
150 static alias IgnoreCaseAlias("i", desc("Alias for -ignore-case."),
151                              aliasopt(IgnoreCase));
152 static list<std::string> Name(
153     "name",
154     desc("Find and print all debug info entries whose name (DW_AT_name "
155          "attribute) matches the exact text in <pattern>.  When used with the "
156          "the -regex option <pattern> is interpreted as a regular expression."),
157     value_desc("pattern"), cat(DwarfDumpCategory));
158 static alias NameAlias("n", desc("Alias for -name"), aliasopt(Name));
159 static opt<unsigned long long> Lookup("lookup",
160            desc("Lookup <address> in the debug information and print out any"
161                 "available file, function, block and line table details."),
162            value_desc("address"), cat(DwarfDumpCategory));
163 static opt<std::string>
164     OutputFilename("out-file", cl::init(""),
165                    cl::desc("Redirect output to the specified file."),
166                    cl::value_desc("filename"));
167 static alias OutputFilenameAlias("o", desc("Alias for -out-file."),
168                                  aliasopt(OutputFilename),
169                                  cat(DwarfDumpCategory));
170 static opt<bool>
171     UseRegex("regex",
172              desc("Treat any <pattern> strings as regular expressions when "
173                   "searching instead of just as an exact string match."),
174              cat(DwarfDumpCategory));
175 static alias RegexAlias("x", desc("Alias for -regex"), aliasopt(UseRegex));
176 static opt<bool>
177     ShowChildren("show-children",
178                  desc("Show a debug info entry's children when selectively "
179                       "printing with the =<offset> option."),
180                  cat(DwarfDumpCategory));
181 static alias ShowChildrenAlias("c", desc("Alias for -show-children."),
182                                aliasopt(ShowChildren));
183 static opt<bool>
184     ShowParents("show-parents",
185                 desc("Show a debug info entry's parents when selectively "
186                      "printing with the =<offset> option."),
187                 cat(DwarfDumpCategory));
188 static alias ShowParentsAlias("p", desc("Alias for -show-parents."),
189                               aliasopt(ShowParents));
190 static opt<bool>
191     ShowForm("show-form",
192              desc("Show DWARF form types after the DWARF attribute types."),
193              cat(DwarfDumpCategory));
194 static alias ShowFormAlias("F", desc("Alias for -show-form."),
195                            aliasopt(ShowForm), cat(DwarfDumpCategory));
196 static opt<unsigned> RecurseDepth(
197     "recurse-depth",
198     desc("Only recurse to a depth of N when displaying debug info entries."),
199     cat(DwarfDumpCategory), init(-1U), value_desc("N"));
200 static alias RecurseDepthAlias("r", desc("Alias for -recurse-depth."),
201                                aliasopt(RecurseDepth));
202
203 static opt<bool>
204     SummarizeTypes("summarize-types",
205                    desc("Abbreviate the description of type unit entries."),
206                    cat(DwarfDumpCategory));
207 static cl::opt<bool>
208     Statistics("statistics",
209                cl::desc("Emit JSON-formatted debug info quality metrics."),
210                cat(DwarfDumpCategory));
211 static opt<bool> Verify("verify", desc("Verify the DWARF debug info."),
212                         cat(DwarfDumpCategory));
213 static opt<bool> Quiet("quiet", desc("Use with -verify to not emit to STDOUT."),
214                        cat(DwarfDumpCategory));
215 static opt<bool> DumpUUID("uuid", desc("Show the UUID for each architecture."),
216                           cat(DwarfDumpCategory));
217 static alias DumpUUIDAlias("u", desc("Alias for -uuid."), aliasopt(DumpUUID));
218 static opt<bool> Verbose("verbose",
219                          desc("Print more low-level encoding details."),
220                          cat(DwarfDumpCategory));
221 static alias VerboseAlias("v", desc("Alias for -verbose."), aliasopt(Verbose),
222                           cat(DwarfDumpCategory));
223 } // namespace
224 /// @}
225 //===----------------------------------------------------------------------===//
226
227 static void error(StringRef Prefix, std::error_code EC) {
228   if (!EC)
229     return;
230   errs() << Prefix << ": " << EC.message() << "\n";
231   exit(1);
232 }
233
234 static DIDumpOptions getDumpOpts() {
235   DIDumpOptions DumpOpts;
236   DumpOpts.DumpType = DumpType;
237   DumpOpts.RecurseDepth = RecurseDepth;
238   DumpOpts.ShowAddresses = !Diff;
239   DumpOpts.ShowChildren = ShowChildren;
240   DumpOpts.ShowParents = ShowParents;
241   DumpOpts.ShowForm = ShowForm;
242   DumpOpts.SummarizeTypes = SummarizeTypes;
243   DumpOpts.Verbose = Verbose;
244   // In -verify mode, print DIEs without children in error messages.
245   if (Verify)
246     return DumpOpts.noImplicitRecursion();
247   return DumpOpts;
248 }
249
250 static uint32_t getCPUType(MachOObjectFile &MachO) {
251   if (MachO.is64Bit())
252     return MachO.getHeader64().cputype;
253   else
254     return MachO.getHeader().cputype;
255 }
256
257 /// Return true if the object file has not been filtered by an --arch option.
258 static bool filterArch(ObjectFile &Obj) {
259   if (ArchFilters.empty())
260     return true;
261
262   if (auto *MachO = dyn_cast<MachOObjectFile>(&Obj)) {
263     std::string ObjArch =
264         Triple::getArchTypeName(MachO->getArchTriple().getArch());
265
266     for (auto Arch : ArchFilters) {
267       // Match name.
268       if (Arch == ObjArch)
269         return true;
270
271       // Match architecture number.
272       unsigned Value;
273       if (!StringRef(Arch).getAsInteger(0, Value))
274         if (Value == getCPUType(*MachO))
275           return true;
276     }
277   }
278   return false;
279 }
280
281 using HandlerFn = std::function<bool(ObjectFile &, DWARFContext &DICtx, Twine,
282                                      raw_ostream &)>;
283
284 /// Print only DIEs that have a certain name.
285 static void filterByName(const StringSet<> &Names,
286                          DWARFContext::cu_iterator_range CUs, raw_ostream &OS) {
287   for (const auto &CU : CUs)
288     for (const auto &Entry : CU->dies()) {
289       DWARFDie Die = {CU.get(), &Entry};
290       if (const char *NamePtr = Die.getName(DINameKind::ShortName)) {
291         std::string Name =
292             (IgnoreCase && !UseRegex) ? StringRef(NamePtr).lower() : NamePtr;
293         // Match regular expression.
294         if (UseRegex)
295           for (auto Pattern : Names.keys()) {
296             Regex RE(Pattern, IgnoreCase ? Regex::IgnoreCase : Regex::NoFlags);
297             std::string Error;
298             if (!RE.isValid(Error)) {
299               errs() << "error in regular expression: " << Error << "\n";
300               exit(1);
301             }
302             if (RE.match(Name))
303               Die.dump(OS, 0, getDumpOpts());
304           }
305         // Match full text.
306         else if (Names.count(Name))
307           Die.dump(OS, 0, getDumpOpts());
308       }
309     }
310
311 }
312
313 /// Handle the --lookup option and dump the DIEs and line info for the given
314 /// address.
315 static bool lookup(DWARFContext &DICtx, uint64_t Address, raw_ostream &OS) {
316   auto DIEsForAddr = DICtx.getDIEsForAddress(Lookup);
317
318   if (!DIEsForAddr)
319     return false;
320
321   DIDumpOptions DumpOpts = getDumpOpts();
322   DumpOpts.RecurseDepth = 0;
323   DIEsForAddr.CompileUnit->dump(OS, DumpOpts);
324   if (DIEsForAddr.FunctionDIE) {
325     DIEsForAddr.FunctionDIE.dump(OS, 2, DumpOpts);
326     if (DIEsForAddr.BlockDIE)
327       DIEsForAddr.BlockDIE.dump(OS, 4, DumpOpts);
328   }
329
330   if (DILineInfo LineInfo = DICtx.getLineInfoForAddress(Lookup))
331     LineInfo.dump(OS);
332
333   return true;
334 }
335
336 bool collectStatsForObjectFile(ObjectFile &Obj, DWARFContext &DICtx,
337                                Twine Filename, raw_ostream &OS);
338
339 static bool dumpObjectFile(ObjectFile &Obj, DWARFContext &DICtx, Twine Filename,
340                            raw_ostream &OS) {
341   logAllUnhandledErrors(DICtx.loadRegisterInfo(Obj), errs(),
342                         Filename.str() + ": ");
343   // The UUID dump already contains all the same information.
344   if (!(DumpType & DIDT_UUID) || DumpType == DIDT_All)
345     OS << Filename << ":\tfile format " << Obj.getFileFormatName() << '\n';
346
347   // Handle the --lookup option.
348   if (Lookup)
349     return lookup(DICtx, Lookup, OS);
350
351   // Handle the --name option.
352   if (!Name.empty()) {
353     StringSet<> Names;
354     for (auto name : Name)
355       Names.insert((IgnoreCase && !UseRegex) ? StringRef(name).lower() : name);
356
357     filterByName(Names, DICtx.compile_units(), OS);
358     filterByName(Names, DICtx.dwo_compile_units(), OS);
359     return true;
360   }
361
362   // Handle the --find option and lower it to --debug-info=<offset>.
363   if (!Find.empty()) {
364     DumpOffsets[DIDT_ID_DebugInfo] = [&]() -> llvm::Optional<uint64_t> {
365       for (auto Name : Find) {
366         auto find = [&](const DWARFAcceleratorTable &Accel)
367             -> llvm::Optional<uint64_t> {
368           for (auto Entry : Accel.equal_range(Name))
369             for (auto Atom : Entry)
370               if (auto Offset = Atom.getAsSectionOffset())
371                 return Offset;
372           return None;
373         };
374         if (auto Offset = find(DICtx.getAppleNames()))
375           return DumpOffsets[DIDT_ID_DebugInfo] = *Offset;
376         if (auto Offset = find(DICtx.getAppleTypes()))
377           return DumpOffsets[DIDT_ID_DebugInfo] = *Offset;
378         if (auto Offset = find(DICtx.getAppleNamespaces()))
379           return DumpOffsets[DIDT_ID_DebugInfo] = *Offset;
380       }
381       return None;
382     }();
383     // Early exit if --find was specified but the current file doesn't have it.
384     if (!DumpOffsets[DIDT_ID_DebugInfo])
385       return true;
386   }
387
388   // Dump the complete DWARF structure.
389   DICtx.dump(OS, getDumpOpts(), DumpOffsets);
390   return true;
391 }
392
393 static bool verifyObjectFile(ObjectFile &Obj, DWARFContext &DICtx,
394                              Twine Filename, raw_ostream &OS) {
395   // Verify the DWARF and exit with non-zero exit status if verification
396   // fails.
397   raw_ostream &stream = Quiet ? nulls() : OS;
398   stream << "Verifying " << Filename.str() << ":\tfile format "
399   << Obj.getFileFormatName() << "\n";
400   bool Result = DICtx.verify(stream, getDumpOpts());
401   if (Result)
402     stream << "No errors.\n";
403   else
404     stream << "Errors detected.\n";
405   return Result;
406 }
407
408 static bool handleBuffer(StringRef Filename, MemoryBufferRef Buffer,
409                          HandlerFn HandleObj, raw_ostream &OS);
410
411 static bool handleArchive(StringRef Filename, Archive &Arch,
412                           HandlerFn HandleObj, raw_ostream &OS) {
413   bool Result = true;
414   Error Err = Error::success();
415   for (auto Child : Arch.children(Err)) {
416     auto BuffOrErr = Child.getMemoryBufferRef();
417     error(Filename, errorToErrorCode(BuffOrErr.takeError()));
418     auto NameOrErr = Child.getName();
419     error(Filename, errorToErrorCode(NameOrErr.takeError()));
420     std::string Name = (Filename + "(" + NameOrErr.get() + ")").str();
421     Result &= handleBuffer(Name, BuffOrErr.get(), HandleObj, OS);
422   }
423   error(Filename, errorToErrorCode(std::move(Err)));
424
425   return Result;
426 }
427
428 static bool handleBuffer(StringRef Filename, MemoryBufferRef Buffer,
429                          HandlerFn HandleObj, raw_ostream &OS) {
430   Expected<std::unique_ptr<Binary>> BinOrErr = object::createBinary(Buffer);
431   error(Filename, errorToErrorCode(BinOrErr.takeError()));
432
433   bool Result = true;
434   if (auto *Obj = dyn_cast<ObjectFile>(BinOrErr->get())) {
435     if (filterArch(*Obj)) {
436       std::unique_ptr<DWARFContext> DICtx = DWARFContext::create(*Obj);
437       Result = HandleObj(*Obj, *DICtx, Filename, OS);
438     }
439   }
440   else if (auto *Fat = dyn_cast<MachOUniversalBinary>(BinOrErr->get()))
441     for (auto &ObjForArch : Fat->objects()) {
442       std::string ObjName =
443           (Filename + "(" + ObjForArch.getArchFlagName() + ")").str();
444       if (auto MachOOrErr = ObjForArch.getAsObjectFile()) {
445         auto &Obj = **MachOOrErr;
446         if (filterArch(Obj)) {
447           std::unique_ptr<DWARFContext> DICtx = DWARFContext::create(Obj);
448           Result &= HandleObj(Obj, *DICtx, ObjName, OS);
449         }
450         continue;
451       } else
452         consumeError(MachOOrErr.takeError());
453       if (auto ArchiveOrErr = ObjForArch.getAsArchive()) {
454         error(ObjName, errorToErrorCode(ArchiveOrErr.takeError()));
455         Result &= handleArchive(ObjName, *ArchiveOrErr.get(), HandleObj, OS);
456         continue;
457       } else
458         consumeError(ArchiveOrErr.takeError());
459     }
460   else if (auto *Arch = dyn_cast<Archive>(BinOrErr->get()))
461     Result = handleArchive(Filename, *Arch, HandleObj, OS);
462   return Result;
463 }
464
465 static bool handleFile(StringRef Filename, HandlerFn HandleObj,
466                        raw_ostream &OS) {
467   ErrorOr<std::unique_ptr<MemoryBuffer>> BuffOrErr =
468   MemoryBuffer::getFileOrSTDIN(Filename);
469   error(Filename, BuffOrErr.getError());
470   std::unique_ptr<MemoryBuffer> Buffer = std::move(BuffOrErr.get());
471   return handleBuffer(Filename, *Buffer, HandleObj, OS);
472 }
473
474 /// If the input path is a .dSYM bundle (as created by the dsymutil tool),
475 /// replace it with individual entries for each of the object files inside the
476 /// bundle otherwise return the input path.
477 static std::vector<std::string> expandBundle(const std::string &InputPath) {
478   std::vector<std::string> BundlePaths;
479   SmallString<256> BundlePath(InputPath);
480   // Manually open up the bundle to avoid introducing additional dependencies.
481   if (sys::fs::is_directory(BundlePath) &&
482       sys::path::extension(BundlePath) == ".dSYM") {
483     std::error_code EC;
484     sys::path::append(BundlePath, "Contents", "Resources", "DWARF");
485     for (sys::fs::directory_iterator Dir(BundlePath, EC), DirEnd;
486          Dir != DirEnd && !EC; Dir.increment(EC)) {
487       const std::string &Path = Dir->path();
488       sys::fs::file_status Status;
489       EC = sys::fs::status(Path, Status);
490       error(Path, EC);
491       switch (Status.type()) {
492       case sys::fs::file_type::regular_file:
493       case sys::fs::file_type::symlink_file:
494       case sys::fs::file_type::type_unknown:
495         BundlePaths.push_back(Path);
496         break;
497       default: /*ignore*/;
498       }
499     }
500     error(BundlePath, EC);
501   }
502   if (!BundlePaths.size())
503     BundlePaths.push_back(InputPath);
504   return BundlePaths;
505 }
506
507 int main(int argc, char **argv) {
508   // Print a stack trace if we signal out.
509   sys::PrintStackTraceOnErrorSignal(argv[0]);
510   PrettyStackTraceProgram X(argc, argv);
511   llvm_shutdown_obj Y;  // Call llvm_shutdown() on exit.
512
513   llvm::InitializeAllTargetInfos();
514   llvm::InitializeAllTargetMCs();
515
516   HideUnrelatedOptions({&DwarfDumpCategory, &SectionCategory});
517   cl::ParseCommandLineOptions(
518       argc, argv,
519       "pretty-print DWARF debug information in object files"
520       " and debug info archives.\n");
521
522   if (Help) {
523     PrintHelpMessage(/*Hidden =*/false, /*Categorized =*/true);
524     return 0;
525   }
526
527   std::unique_ptr<ToolOutputFile> OutputFile;
528   if (!OutputFilename.empty()) {
529     std::error_code EC;
530     OutputFile = llvm::make_unique<ToolOutputFile>(OutputFilename, EC,
531                                                      sys::fs::F_None);
532     error("Unable to open output file" + OutputFilename, EC);
533     // Don't remove output file if we exit with an error.
534     OutputFile->keep();
535   }
536
537   raw_ostream &OS = OutputFile ? OutputFile->os() : outs();
538   bool OffsetRequested = false;
539
540   // Defaults to dumping all sections, unless brief mode is specified in which
541   // case only the .debug_info section in dumped.
542 #define HANDLE_DWARF_SECTION(ENUM_NAME, ELF_NAME, CMDLINE_NAME)                \
543   if (Dump##ENUM_NAME.IsRequested) {                                           \
544     DumpType |= DIDT_##ENUM_NAME;                                              \
545     if (Dump##ENUM_NAME.HasValue) {                                            \
546       DumpOffsets[DIDT_ID_##ENUM_NAME] = Dump##ENUM_NAME.Val;                  \
547       OffsetRequested = true;                                                  \
548     }                                                                          \
549   }
550 #include "llvm/BinaryFormat/Dwarf.def"
551 #undef HANDLE_DWARF_SECTION
552   if (DumpUUID)
553     DumpType |= DIDT_UUID;
554   if (DumpAll)
555     DumpType = DIDT_All;
556   if (DumpType == DIDT_Null) {
557     if (Verbose)
558       DumpType = DIDT_All;
559     else
560       DumpType = DIDT_DebugInfo;
561   }
562
563   // Unless dumping a specific DIE, default to --show-children.
564   if (!ShowChildren && !Verify && !OffsetRequested && Name.empty() && Find.empty())
565     ShowChildren = true;
566
567   // Defaults to a.out if no filenames specified.
568   if (InputFilenames.size() == 0)
569     InputFilenames.push_back("a.out");
570
571   // Expand any .dSYM bundles to the individual object files contained therein.
572   std::vector<std::string> Objects;
573   for (const auto &F : InputFilenames) {
574     auto Objs = expandBundle(F);
575     Objects.insert(Objects.end(), Objs.begin(), Objs.end());
576   }
577
578   if (Verify) {
579     // If we encountered errors during verify, exit with a non-zero exit status.
580     if (!std::all_of(Objects.begin(), Objects.end(), [&](std::string Object) {
581           return handleFile(Object, verifyObjectFile, OS);
582         }))
583       exit(1);
584   } else if (Statistics)
585     for (auto Object : Objects)
586       handleFile(Object, collectStatsForObjectFile, OS);
587   else
588     for (auto Object : Objects)
589       handleFile(Object, dumpObjectFile, OS);
590
591   return EXIT_SUCCESS;
592 }