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 //===----------------------------------------------------------------------===//
16 #include "DwarfLinker.h"
17 #include "MachODebugMapParser.h"
19 #include "llvm/Support/ManagedStatic.h"
20 #include "llvm/Support/PrettyStackTrace.h"
21 #include "llvm/Support/Options.h"
22 #include "llvm/Support/raw_ostream.h"
23 #include "llvm/Support/Signals.h"
27 static llvm::cl::opt<std::string> InputFile(llvm::cl::Positional,
28 llvm::cl::desc("<input file>"),
31 static llvm::cl::opt<std::string> OsoPrependPath("oso-prepend-path",
32 llvm::cl::desc("<path>"));
34 static llvm::cl::opt<bool> Verbose("v", llvm::cl::desc("Verbosity level"),
35 llvm::cl::init(false));
37 static llvm::cl::opt<bool> ParseOnly("parse-only",
38 llvm::cl::desc("Only parse the debug map, do "
39 "not actaully link the DWARF."),
40 llvm::cl::init(false));
42 int main(int argc, char **argv) {
43 llvm::sys::PrintStackTraceOnErrorSignal();
44 llvm::PrettyStackTraceProgram StackPrinter(argc, argv);
45 llvm::llvm_shutdown_obj Shutdown;
47 llvm::cl::ParseCommandLineOptions(argc, argv, "llvm dsymutil\n");
49 llvm::MachODebugMapParser Parser(InputFile);
50 Parser.setPreprendPath(OsoPrependPath);
51 llvm::ErrorOr<std::unique_ptr<llvm::DebugMap>> DebugMap = Parser.parse();
53 if (auto EC = DebugMap.getError()) {
54 llvm::errs() << "error: cannot parse the debug map for \"" << InputFile <<
55 "\": " << EC.message() << '\n';
60 (*DebugMap)->print(llvm::outs());
65 llvm::DwarfLinker Linker(InputFile + ".dwarf");
66 return !Linker.link(*DebugMap.get());