/// first step when we start processing a DebugMapObject.
class DwarfLinker {
public:
- DwarfLinker(StringRef OutputFilename, bool Verbose)
- : OutputFilename(OutputFilename), Verbose(Verbose), BinHolder(Verbose) {}
+ DwarfLinker(StringRef OutputFilename, const LinkOptions &Options)
+ : OutputFilename(OutputFilename), Options(Options),
+ BinHolder(Options.Verbose) {}
/// \brief Link the contents of the DebugMap.
bool link(const DebugMap &);
private:
std::string OutputFilename;
- bool Verbose;
+ LinkOptions Options;
BinaryHolder BinHolder;
/// The units of the current debug map object.
Context = CurrentDebugObject->getObjectFilename();
warn(Warning, Context);
- if (!Verbose || !DIE)
+ if (!Options.Verbose || !DIE)
return;
errs() << " in DIE:\n";
return false;
const auto &ValidReloc = ValidRelocs[NextValidReloc++];
- if (Verbose)
+ if (Options.Verbose)
outs() << "Found valid debug map entry: " << ValidReloc.Mapping->getKey()
<< " " << format("\t%016" PRIx64 " => %016" PRIx64,
ValidReloc.Mapping->getValue().ObjectAddress,
(Flags & TF_InFunctionScope))
return Flags;
- if (Verbose)
+ if (Options.Verbose)
DIE.dump(outs(), const_cast<DWARFUnit *>(&OrigUnit), 0, 8 /* Indent */);
return Flags | TF_Keep;
!hasValidRelocation(LowPcOffset, LowPcEndOffset, MyInfo))
return Flags;
- if (Verbose)
+ if (Options.Verbose)
DIE.dump(outs(), const_cast<DWARFUnit *>(&OrigUnit), 0, 8 /* Indent */);
return Flags | TF_Keep;
for (const auto &Obj : Map.objects()) {
CurrentDebugObject = Obj.get();
- if (Verbose)
+ if (Options.Verbose)
outs() << "DEBUG MAP OBJECT: " << Obj->getObjectFilename() << "\n";
auto ErrOrObj = BinHolder.GetObjectFile(Obj->getObjectFilename());
if (std::error_code EC = ErrOrObj.getError()) {
// Look for relocations that correspond to debug map entries.
if (!findValidRelocsInDebugInfo(*ErrOrObj, *Obj)) {
- if (Verbose)
+ if (Options.Verbose)
outs() << "No valid relocations found. Skipping.\n";
continue;
}
// parent links that we will use during the next phase.
for (const auto &CU : DwarfContext.compile_units()) {
auto *CUDie = CU->getCompileUnitDIE(false);
- if (Verbose) {
+ if (Options.Verbose) {
outs() << "Input compilation unit:";
CUDie->dump(outs(), CU.get(), 0);
}
}
}
-bool linkDwarf(StringRef OutputFilename, const DebugMap &DM, bool Verbose) {
- DwarfLinker Linker(OutputFilename, Verbose);
+bool linkDwarf(StringRef OutputFilename, const DebugMap &DM,
+ const LinkOptions &Options) {
+ DwarfLinker Linker(OutputFilename, Options);
return Linker.link(DM);
}
}
llvm::sys::PrintStackTraceOnErrorSignal();
llvm::PrettyStackTraceProgram StackPrinter(argc, argv);
llvm::llvm_shutdown_obj Shutdown;
+ LinkOptions Options;
llvm::cl::ParseCommandLineOptions(argc, argv, "llvm dsymutil\n");
auto DebugMapPtrOrErr = parseDebugMap(InputFile, OsoPrependPath, Verbose);
+ Options.Verbose = Verbose;
+
if (auto EC = DebugMapPtrOrErr.getError()) {
llvm::errs() << "error: cannot parse the debug map for \"" << InputFile
<< "\": " << EC.message() << '\n';
OutputFile = OutputFileOpt;
}
- return !linkDwarf(OutputFile, **DebugMapPtrOrErr, Verbose);
+ return !linkDwarf(OutputFile, **DebugMapPtrOrErr, Options);
}
namespace llvm {
namespace dsymutil {
+
+struct LinkOptions {
+ bool Verbose;
+
+ LinkOptions() : Verbose(false) {}
+};
+
/// \brief Extract the DebugMap from the given file.
/// The file has to be a MachO object file.
llvm::ErrorOr<std::unique_ptr<DebugMap>>
/// \p DM into a DwarfFile named \p OutputFilename.
/// \returns false if the link failed.
bool linkDwarf(StringRef OutputFilename, const DebugMap &DM,
- bool Verbose = false);
+ const LinkOptions &Options);
}
}
#endif // LLVM_TOOLS_DSYMUTIL_DSYMUTIL_H