blob: 5c9fe2421bec034ad2e5a71fc3de333e023c5437 [file] [log] [blame]
Eric Christopher3680f882012-10-16 23:46:21 +00001//===-- llvm-dwarfdump.cpp - Debug info dumping utility for llvm ----------===//
Benjamin Krameraa2f78f2011-09-13 19:42:23 +00002//
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
Benjamin Krameraa2f78f2011-09-13 19:42:23 +000014#include "llvm/ADT/STLExtras.h"
Chandler Carruth4d88a1c2012-12-04 10:44:52 +000015#include "llvm/ADT/Triple.h"
Zachary Turner6489d7b2015-04-23 17:37:47 +000016#include "llvm/DebugInfo/DIContext.h"
17#include "llvm/DebugInfo/DWARF/DWARFContext.h"
Adrian Prantl5fd3d492017-09-14 17:01:53 +000018#include "llvm/Object/Archive.h"
Frederic Riss4c5d3572015-08-03 00:10:31 +000019#include "llvm/Object/MachOUniversal.h"
Benjamin Krameraa2f78f2011-09-13 19:42:23 +000020#include "llvm/Object/ObjectFile.h"
Eric Christopher7c678de2012-11-07 23:22:07 +000021#include "llvm/Object/RelocVisitor.h"
Benjamin Krameraa2f78f2011-09-13 19:42:23 +000022#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"
Adrian Prantl8e7d3b92015-12-23 21:51:13 +000027#include "llvm/Support/Path.h"
Benjamin Krameraa2f78f2011-09-13 19:42:23 +000028#include "llvm/Support/PrettyStackTrace.h"
29#include "llvm/Support/Signals.h"
Reid Klecknera0587362017-08-29 21:41:21 +000030#include "llvm/Support/TargetSelect.h"
Benjamin Krameraa2f78f2011-09-13 19:42:23 +000031#include "llvm/Support/raw_ostream.h"
Benjamin Krameraa2f78f2011-09-13 19:42:23 +000032#include <algorithm>
33#include <cstring>
Eric Christopher7c678de2012-11-07 23:22:07 +000034#include <string>
Rafael Espindolaa6e9c3e2014-06-12 17:38:55 +000035#include <system_error>
Eric Christopher7c678de2012-11-07 23:22:07 +000036
Benjamin Krameraa2f78f2011-09-13 19:42:23 +000037using namespace llvm;
38using namespace object;
39
Adrian Prantl057d3362017-09-15 23:04:04 +000040/// Parser for options that take an optional offest argument.
41/// @{
42struct OffsetOption {
43 uint64_t Val = 0;
44 bool HasValue = false;
45 bool IsRequested = false;
46};
47
48namespace llvm {
49namespace cl {
50template <>
51class parser<OffsetOption> final : public basic_parser<OffsetOption> {
52public:
53 parser(Option &O) : basic_parser(O) {}
54
55 /// Return true on error.
56 bool parse(Option &O, StringRef ArgName, StringRef Arg, OffsetOption &Val) {
57 if (Arg == "") {
58 Val.Val = 0;
59 Val.HasValue = false;
60 Val.IsRequested = true;
61 return false;
62 }
63 if (Arg.getAsInteger(0, Val.Val))
64 return O.error("'" + Arg + "' value invalid for integer argument!");
65 Val.HasValue = true;
66 Val.IsRequested = true;
67 return false;
68 }
69
70 enum ValueExpected getValueExpectedFlagDefault() const {
71 return ValueOptional;
72 }
73
74 void printOptionInfo(const Option &O, size_t GlobalWidth) const {
75 outs() << " -" << O.ArgStr;
76 Option::printHelpStr(O.HelpStr, GlobalWidth, getOptionWidth(O));
77 }
78
79 void printOptionDiff(const Option &O, OffsetOption V, OptVal Default,
80 size_t GlobalWidth) const {
81 printOptionName(O, GlobalWidth);
82 outs() << "[=offset]";
83 }
84
85 // An out-of-line virtual method to provide a 'home' for this class.
86 void anchor() override {};
87};
88} // cl
89} // llvm
90
91/// @}
92/// Command line options.
93/// @{
94
Adrian Prantl7c5b45d2017-09-12 22:32:53 +000095namespace {
Adrian Prantl057d3362017-09-15 23:04:04 +000096using namespace cl;
Benjamin Krameraa2f78f2011-09-13 19:42:23 +000097
Adrian Prantl7c5b45d2017-09-12 22:32:53 +000098OptionCategory DwarfDumpCategory("Specific Options");
99static opt<bool> Help("h", desc("Alias for -help"), Hidden,
100 cat(DwarfDumpCategory));
101static list<std::string>
102 InputFilenames(Positional, desc("<input object files or .dSYM bundles>"),
103 ZeroOrMore, cat(DwarfDumpCategory));
104
Adrian Prantl057d3362017-09-15 23:04:04 +0000105cl::OptionCategory SectionCategory("Section-specific Dump Options",
106 "These control which sections are dumped. "
107 "Where applicable these parameters take an "
108 "optional =<offset> argument to dump only "
109 "the entry at the specified offset.");
110
Adrian Prantl7c5b45d2017-09-12 22:32:53 +0000111static opt<bool> DumpAll("all", desc("Dump all debug info sections"),
112 cat(SectionCategory));
113static alias DumpAllAlias("a", desc("Alias for -all"), aliasopt(DumpAll));
Adrian Prantl7bc1b282017-09-11 22:59:45 +0000114
Adrian Prantl057d3362017-09-15 23:04:04 +0000115// Options for dumping specific sections.
Adrian Prantl3ae35eb2017-09-13 22:09:01 +0000116static unsigned DumpType = DIDT_Null;
Adrian Prantlccc21c42017-09-19 20:58:57 +0000117static std::array<llvm::Optional<uint64_t>, (unsigned)DIDT_ID_Count>
118 DumpOffsets;
Adrian Prantl7bc1b282017-09-11 22:59:45 +0000119#define HANDLE_DWARF_SECTION(ENUM_NAME, ELF_NAME, CMDLINE_NAME) \
Adrian Prantl057d3362017-09-15 23:04:04 +0000120 static opt<OffsetOption> Dump##ENUM_NAME( \
121 CMDLINE_NAME, desc("Dump the " ELF_NAME " section"), \
122 cat(SectionCategory));
Adrian Prantl7bc1b282017-09-11 22:59:45 +0000123#include "llvm/BinaryFormat/Dwarf.def"
124#undef HANDLE_DWARF_SECTION
Adrian Prantl057d3362017-09-15 23:04:04 +0000125
Jonas Devliegherec0a758d2017-09-18 14:15:57 +0000126static alias DumpDebugFrameAlias("eh-frame", desc("Alias for -debug-frame"),
Adrian Prantl31819b32017-09-20 23:29:31 +0000127 NotHidden, cat(SectionCategory),
Jonas Devliegherec0a758d2017-09-18 14:15:57 +0000128 aliasopt(DumpDebugFrame));
Adrian Prantl5a919cb2017-09-21 16:26:18 +0000129static list<std::string>
130 ArchFilters("arch",
131 desc("Dump debug information for the specified CPU "
132 "architecture only. Architectures may be specified by "
133 "name or by number. This option can be specified "
134 "multiple times, once for each desired architecture."),
135 cat(DwarfDumpCategory));
Adrian Prantl3dcd1222017-09-13 18:22:59 +0000136static opt<bool> DumpUUID("uuid", desc("Show the UUID for each architecture"),
137 cat(DwarfDumpCategory));
138static alias DumpUUIDAlias("u", desc("Alias for -uuid"), aliasopt(DumpUUID));
Eli Bendersky7a94daa2013-01-25 20:26:43 +0000139
Adrian Prantl7c5b45d2017-09-12 22:32:53 +0000140static opt<bool>
Adrian Prantl597aa482017-09-16 17:28:00 +0000141 ShowChildren("show-children",
142 desc("Show a debug info entry's children when selectively "
Adrian Prantlccc21c42017-09-19 20:58:57 +0000143 "printing with the =<offset> option"),
144 cat(DwarfDumpCategory));
Adrian Prantl597aa482017-09-16 17:28:00 +0000145static alias ShowChildrenAlias("c", desc("Alias for -show-children"),
146 aliasopt(ShowChildren));
147static opt<bool>
Adrian Prantlc2bc7172017-09-18 21:27:44 +0000148 ShowParents("show-parents",
149 desc("Show a debug info entry's parents when selectively "
Adrian Prantlccc21c42017-09-19 20:58:57 +0000150 "printing with the =<offset> option"),
151 cat(DwarfDumpCategory));
Adrian Prantlc2bc7172017-09-18 21:27:44 +0000152static alias ShowParentsAlias("p", desc("Alias for -show-parents"),
153 aliasopt(ShowParents));
Adrian Prantld3f9f212017-09-20 17:44:00 +0000154static opt<unsigned> RecurseDepth(
155 "recurse-depth",
156 desc("Only recurse to a depth of N when displaying debug info entries."),
157 cat(DwarfDumpCategory), init(-1U), value_desc("N"));
158static alias RecurseDepthAlias("r", desc("Alias for -recurse-depth"),
159 aliasopt(RecurseDepth));
160
Adrian Prantlc2bc7172017-09-18 21:27:44 +0000161static opt<bool>
David Blaikie50cc27e2016-10-18 21:09:48 +0000162 SummarizeTypes("summarize-types",
Adrian Prantlccc21c42017-09-19 20:58:57 +0000163 desc("Abbreviate the description of type unit entries"),
164 cat(DwarfDumpCategory));
Adrian Prantl7c5b45d2017-09-12 22:32:53 +0000165static opt<bool> Verify("verify", desc("Verify the DWARF debug info"),
166 cat(DwarfDumpCategory));
167static opt<bool> Quiet("quiet", desc("Use with -verify to not emit to STDOUT."),
168 cat(DwarfDumpCategory));
169static opt<bool> Verbose("verbose",
170 desc("Print more low-level encoding details"),
171 cat(DwarfDumpCategory));
172static alias VerboseAlias("v", desc("Alias for -verbose"), aliasopt(Verbose),
173 cat(DwarfDumpCategory));
174} // namespace
Adrian Prantl057d3362017-09-15 23:04:04 +0000175/// @}
176//===----------------------------------------------------------------------===//
177
Adrian Prantl318d1192017-06-06 23:28:45 +0000178
Davide Italiano4376ddb2015-07-26 05:35:59 +0000179static void error(StringRef Filename, std::error_code EC) {
Alexey Samsonov85c7d662015-06-25 23:40:15 +0000180 if (!EC)
Davide Italiano4376ddb2015-07-26 05:35:59 +0000181 return;
Alexey Samsonov85c7d662015-06-25 23:40:15 +0000182 errs() << Filename << ": " << EC.message() << "\n";
Davide Italiano4376ddb2015-07-26 05:35:59 +0000183 exit(1);
Alexey Samsonov85c7d662015-06-25 23:40:15 +0000184}
185
Adrian Prantl2611ffe2017-09-13 23:07:24 +0000186static DIDumpOptions getDumpOpts() {
Jonas Devlieghere27476ce2017-09-13 09:43:05 +0000187 DIDumpOptions DumpOpts;
188 DumpOpts.DumpType = DumpType;
Adrian Prantld3f9f212017-09-20 17:44:00 +0000189 DumpOpts.RecurseDepth = RecurseDepth;
Adrian Prantl597aa482017-09-16 17:28:00 +0000190 DumpOpts.ShowChildren = ShowChildren;
Adrian Prantlc2bc7172017-09-18 21:27:44 +0000191 DumpOpts.ShowParents = ShowParents;
Jonas Devlieghere27476ce2017-09-13 09:43:05 +0000192 DumpOpts.SummarizeTypes = SummarizeTypes;
193 DumpOpts.Verbose = Verbose;
Adrian Prantld3f9f212017-09-20 17:44:00 +0000194 // In -verify mode, print DIEs without children in error messages.
195 if (Verify)
196 return DumpOpts.noImplicitRecursion();
Jonas Devlieghere27476ce2017-09-13 09:43:05 +0000197 return DumpOpts;
198}
199
Adrian Prantl5a919cb2017-09-21 16:26:18 +0000200static uint32_t getCPUType(MachOObjectFile &MachO) {
201 if (MachO.is64Bit())
202 return MachO.getHeader64().cputype;
203 else
204 return MachO.getHeader().cputype;
205}
206
207/// Return true if the object file has not been filtered by an --arch option.
208static bool filterArch(ObjectFile &Obj) {
209 if (ArchFilters.empty())
210 return true;
211 if (auto *MachO = dyn_cast<MachOObjectFile>(&Obj)) {
212 std::string ObjArch =
213 Triple::getArchTypeName(MachO->getArchTriple().getArch());
214 for (auto Arch : ArchFilters) {
215 if (Arch == ObjArch)
216 return true;
217 unsigned Value;
218 if (!StringRef(Arch).getAsInteger(0, Value))
219 if (Value == getCPUType(*MachO))
220 return true;
221 }
222 }
223 return false;
224}
225
226using HandlerFn = std::function<bool(ObjectFile &, DWARFContext &DICtx, Twine)>;
227
228static bool dumpObjectFile(ObjectFile &Obj, DWARFContext &DICtx,
229 Twine Filename) {
230 logAllUnhandledErrors(DICtx.loadRegisterInfo(Obj), errs(),
Reid Klecknera0587362017-08-29 21:41:21 +0000231 Filename.str() + ": ");
Adrian Prantl3dcd1222017-09-13 18:22:59 +0000232 // The UUID dump already contains all the same information.
233 if (!(DumpType & DIDT_UUID) || DumpType == DIDT_All)
Adrian Prantl3ae35eb2017-09-13 22:09:01 +0000234 outs() << Filename << ":\tfile format " << Obj.getFileFormatName() << '\n';
Spyridoula Gravanicc0d13a2017-06-12 19:04:28 +0000235
Frederic Riss40c017932015-08-03 00:10:25 +0000236 // Dump the complete DWARF structure.
Adrian Prantl5a919cb2017-09-21 16:26:18 +0000237 DICtx.dump(outs(), getDumpOpts(), DumpOffsets);
Adrian Prantl2611ffe2017-09-13 23:07:24 +0000238 return true;
Frederic Riss40c017932015-08-03 00:10:25 +0000239}
240
Adrian Prantl5a919cb2017-09-21 16:26:18 +0000241static bool verifyObjectFile(ObjectFile &Obj, DWARFContext &DICtx,
242 Twine Filename) {
Greg Clayton48432cf2017-05-01 22:07:02 +0000243 // Verify the DWARF and exit with non-zero exit status if verification
244 // fails.
245 raw_ostream &stream = Quiet ? nulls() : outs();
246 stream << "Verifying " << Filename.str() << ":\tfile format "
247 << Obj.getFileFormatName() << "\n";
Adrian Prantl5a919cb2017-09-21 16:26:18 +0000248 bool Result = DICtx.verify(stream, getDumpOpts());
Greg Clayton48432cf2017-05-01 22:07:02 +0000249 if (Result)
250 stream << "No errors.\n";
251 else
252 stream << "Errors detected.\n";
253 return Result;
254}
255
Adrian Prantld866b472017-09-13 23:16:13 +0000256static bool handleBuffer(StringRef Filename, MemoryBufferRef Buffer,
Adrian Prantl5a919cb2017-09-21 16:26:18 +0000257 HandlerFn HandleObj);
Adrian Prantl5fd3d492017-09-14 17:01:53 +0000258
259static bool handleArchive(StringRef Filename, Archive &Arch,
Adrian Prantl5a919cb2017-09-21 16:26:18 +0000260 HandlerFn HandleObj) {
Adrian Prantl5fd3d492017-09-14 17:01:53 +0000261 bool Result = true;
262 Error Err = Error::success();
263 for (auto Child : Arch.children(Err)) {
264 auto BuffOrErr = Child.getMemoryBufferRef();
265 error(Filename, errorToErrorCode(BuffOrErr.takeError()));
266 auto NameOrErr = Child.getName();
267 error(Filename, errorToErrorCode(NameOrErr.takeError()));
268 std::string Name = (Filename + "(" + NameOrErr.get() + ")").str();
269 Result &= handleBuffer(Name, BuffOrErr.get(), HandleObj);
270 }
271 error(Filename, errorToErrorCode(std::move(Err)));
272
273 return Result;
274}
275
276static bool handleBuffer(StringRef Filename, MemoryBufferRef Buffer,
Adrian Prantl5a919cb2017-09-21 16:26:18 +0000277 HandlerFn HandleObj) {
Adrian Prantld866b472017-09-13 23:16:13 +0000278 Expected<std::unique_ptr<Binary>> BinOrErr = object::createBinary(Buffer);
Adrian Prantl5fd3d492017-09-14 17:01:53 +0000279 error(Filename, errorToErrorCode(BinOrErr.takeError()));
Jonas Devlieghere8ac8df02017-08-31 16:44:47 +0000280
Greg Clayton48432cf2017-05-01 22:07:02 +0000281 bool Result = true;
Adrian Prantl5a919cb2017-09-21 16:26:18 +0000282 if (auto *Obj = dyn_cast<ObjectFile>(BinOrErr->get())) {
283 if (filterArch(*Obj)) {
284 std::unique_ptr<DWARFContext> DICtx = DWARFContext::create(*Obj);
285 Result = HandleObj(*Obj, *DICtx, Filename);
286 }
287 }
Greg Clayton48432cf2017-05-01 22:07:02 +0000288 else if (auto *Fat = dyn_cast<MachOUniversalBinary>(BinOrErr->get()))
289 for (auto &ObjForArch : Fat->objects()) {
Adrian Prantl5fd3d492017-09-14 17:01:53 +0000290 std::string ObjName =
291 (Filename + "(" + ObjForArch.getArchFlagName() + ")").str();
292 if (auto MachOOrErr = ObjForArch.getAsObjectFile()) {
Adrian Prantl5a919cb2017-09-21 16:26:18 +0000293 auto &Obj = **MachOOrErr;
294 if (filterArch(Obj)) {
295 std::unique_ptr<DWARFContext> DICtx = DWARFContext::create(Obj);
296 Result &= HandleObj(Obj, *DICtx, ObjName);
297 }
Adrian Prantl5fd3d492017-09-14 17:01:53 +0000298 continue;
299 } else
300 consumeError(MachOOrErr.takeError());
301 if (auto ArchiveOrErr = ObjForArch.getAsArchive()) {
302 error(ObjName, errorToErrorCode(ArchiveOrErr.takeError()));
303 Result &= handleArchive(ObjName, *ArchiveOrErr.get(), HandleObj);
304 continue;
305 } else
306 consumeError(ArchiveOrErr.takeError());
Greg Clayton48432cf2017-05-01 22:07:02 +0000307 }
Adrian Prantl5fd3d492017-09-14 17:01:53 +0000308 else if (auto *Arch = dyn_cast<Archive>(BinOrErr->get()))
309 Result = handleArchive(Filename, *Arch, HandleObj);
Greg Clayton48432cf2017-05-01 22:07:02 +0000310 return Result;
311}
312
Adrian Prantl5a919cb2017-09-21 16:26:18 +0000313static bool handleFile(StringRef Filename, HandlerFn HandleObj) {
Adrian Prantl2611ffe2017-09-13 23:07:24 +0000314 ErrorOr<std::unique_ptr<MemoryBuffer>> BuffOrErr =
315 MemoryBuffer::getFileOrSTDIN(Filename);
316 error(Filename, BuffOrErr.getError());
317 std::unique_ptr<MemoryBuffer> Buffer = std::move(BuffOrErr.get());
318 return handleBuffer(Filename, *Buffer, HandleObj);
319}
320
Adrian Prantl8e7d3b92015-12-23 21:51:13 +0000321/// If the input path is a .dSYM bundle (as created by the dsymutil tool),
322/// replace it with individual entries for each of the object files inside the
323/// bundle otherwise return the input path.
Benjamin Kramerc321e532016-06-08 19:09:22 +0000324static std::vector<std::string> expandBundle(const std::string &InputPath) {
Adrian Prantl8e7d3b92015-12-23 21:51:13 +0000325 std::vector<std::string> BundlePaths;
326 SmallString<256> BundlePath(InputPath);
327 // Manually open up the bundle to avoid introducing additional dependencies.
328 if (sys::fs::is_directory(BundlePath) &&
329 sys::path::extension(BundlePath) == ".dSYM") {
330 std::error_code EC;
331 sys::path::append(BundlePath, "Contents", "Resources", "DWARF");
332 for (sys::fs::directory_iterator Dir(BundlePath, EC), DirEnd;
333 Dir != DirEnd && !EC; Dir.increment(EC)) {
334 const std::string &Path = Dir->path();
335 sys::fs::file_status Status;
336 EC = sys::fs::status(Path, Status);
337 error(Path, EC);
338 switch (Status.type()) {
339 case sys::fs::file_type::regular_file:
340 case sys::fs::file_type::symlink_file:
341 case sys::fs::file_type::type_unknown:
342 BundlePaths.push_back(Path);
343 break;
344 default: /*ignore*/;
345 }
346 }
347 error(BundlePath, EC);
348 }
349 if (!BundlePaths.size())
350 BundlePaths.push_back(InputPath);
351 return BundlePaths;
352}
353
Benjamin Krameraa2f78f2011-09-13 19:42:23 +0000354int main(int argc, char **argv) {
355 // Print a stack trace if we signal out.
Richard Smith2ad6d482016-06-09 00:53:21 +0000356 sys::PrintStackTraceOnErrorSignal(argv[0]);
Benjamin Krameraa2f78f2011-09-13 19:42:23 +0000357 PrettyStackTraceProgram X(argc, argv);
358 llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
359
Reid Klecknera0587362017-08-29 21:41:21 +0000360 llvm::InitializeAllTargetInfos();
361 llvm::InitializeAllTargetMCs();
362
Adrian Prantl7c5b45d2017-09-12 22:32:53 +0000363 HideUnrelatedOptions({&DwarfDumpCategory, &SectionCategory});
364 cl::ParseCommandLineOptions(
365 argc, argv,
366 "pretty-print DWARF debug information in object files"
367 " and debug info archives.\n");
368
369 if (Help) {
370 PrintHelpMessage(/*Hidden =*/false, /*Categorized =*/true);
371 return 0;
372 }
Benjamin Krameraa2f78f2011-09-13 19:42:23 +0000373
Jonas Devlieghere8ac8df02017-08-31 16:44:47 +0000374 // Defaults to dumping all sections, unless brief mode is specified in which
375 // case only the .debug_info section in dumped.
Adrian Prantl7bc1b282017-09-11 22:59:45 +0000376#define HANDLE_DWARF_SECTION(ENUM_NAME, ELF_NAME, CMDLINE_NAME) \
Adrian Prantl057d3362017-09-15 23:04:04 +0000377 if (Dump##ENUM_NAME.IsRequested) { \
378 DumpType |= DIDT_##ENUM_NAME; \
379 if (Dump##ENUM_NAME.HasValue) \
380 DumpOffsets[DIDT_ID_##ENUM_NAME] = Dump##ENUM_NAME.Val; \
381 }
Adrian Prantl7bc1b282017-09-11 22:59:45 +0000382#include "llvm/BinaryFormat/Dwarf.def"
383#undef HANDLE_DWARF_SECTION
Adrian Prantl3dcd1222017-09-13 18:22:59 +0000384 if (DumpUUID)
385 DumpType |= DIDT_UUID;
Adrian Prantl7bc1b282017-09-11 22:59:45 +0000386 if (DumpAll)
387 DumpType = DIDT_All;
Jonas Devlieghere8ac8df02017-08-31 16:44:47 +0000388 if (DumpType == DIDT_Null) {
Adrian Prantl16aa4cf2017-09-11 23:05:20 +0000389 if (Verbose)
Jonas Devlieghere8ac8df02017-08-31 16:44:47 +0000390 DumpType = DIDT_All;
Adrian Prantl16aa4cf2017-09-11 23:05:20 +0000391 else
392 DumpType = DIDT_DebugInfo;
Jonas Devlieghere8ac8df02017-08-31 16:44:47 +0000393 }
394
Benjamin Krameraa2f78f2011-09-13 19:42:23 +0000395 // Defaults to a.out if no filenames specified.
396 if (InputFilenames.size() == 0)
397 InputFilenames.push_back("a.out");
398
Adrian Prantl8e7d3b92015-12-23 21:51:13 +0000399 // Expand any .dSYM bundles to the individual object files contained therein.
400 std::vector<std::string> Objects;
Benjamin Kramer4fed9282016-05-27 12:30:51 +0000401 for (const auto &F : InputFilenames) {
Adrian Prantl8e7d3b92015-12-23 21:51:13 +0000402 auto Objs = expandBundle(F);
403 Objects.insert(Objects.end(), Objs.begin(), Objs.end());
404 }
405
Greg Clayton48432cf2017-05-01 22:07:02 +0000406 if (Verify) {
407 // If we encountered errors during verify, exit with a non-zero exit status.
Adrian Prantl2611ffe2017-09-13 23:07:24 +0000408 if (!std::all_of(Objects.begin(), Objects.end(), [](std::string Object) {
409 return handleFile(Object, verifyObjectFile);
410 }))
Greg Clayton48432cf2017-05-01 22:07:02 +0000411 exit(1);
Adrian Prantlb8f08422017-09-18 22:11:33 +0000412 } else
413 for (auto Object : Objects)
Adrian Prantl2611ffe2017-09-13 23:07:24 +0000414 handleFile(Object, dumpObjectFile);
Benjamin Krameraa2f78f2011-09-13 19:42:23 +0000415
Davide Italiano4376ddb2015-07-26 05:35:59 +0000416 return EXIT_SUCCESS;
Benjamin Krameraa2f78f2011-09-13 19:42:23 +0000417}