1 //===-- dsymutil.cpp - Debug info dumping utility for llvm ----------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This program is a utility that aims to be a dropin replacement for
13 //===----------------------------------------------------------------------===//
17 #include "llvm/Support/ManagedStatic.h"
18 #include "llvm/Support/Options.h"
19 #include "llvm/Support/PrettyStackTrace.h"
20 #include "llvm/Support/Signals.h"
21 #include "llvm/Support/raw_ostream.h"
24 using namespace llvm::dsymutil;
27 using namespace llvm::cl;
29 static opt<std::string> InputFile(Positional, desc("<input file>"),
32 static opt<std::string> OsoPrependPath("oso-prepend-path",
33 desc("Specify a directory to prepend "
34 "to the paths of object files."),
37 static opt<bool> Verbose("v", desc("Verbosity level"), init(false));
40 ParseOnly("parse-only",
41 desc("Only parse the debug map, do not actaully link "
46 int main(int argc, char **argv) {
47 llvm::sys::PrintStackTraceOnErrorSignal();
48 llvm::PrettyStackTraceProgram StackPrinter(argc, argv);
49 llvm::llvm_shutdown_obj Shutdown;
51 llvm::cl::ParseCommandLineOptions(argc, argv, "llvm dsymutil\n");
52 auto DebugMapPtrOrErr = parseDebugMap(InputFile, OsoPrependPath, Verbose);
54 if (auto EC = DebugMapPtrOrErr.getError()) {
55 llvm::errs() << "error: cannot parse the debug map for \"" << InputFile
56 << "\": " << EC.message() << '\n';
61 (*DebugMapPtrOrErr)->print(llvm::outs());
66 std::string OutputBasename(InputFile);
67 if (OutputBasename == "-")
68 OutputBasename = "a.out";
70 return !linkDwarf(OutputBasename + ".dwarf", **DebugMapPtrOrErr, Verbose);