X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=blobdiff_plain;f=tools%2Fllvm-dwarfdump%2Fllvm-dwarfdump.cpp;h=d742eb3ec342f285018e2abcb183c288d9234328;hp=018e6662facc5898437eeeb40ad22f6ad177ca91;hb=65d7d51529323933ff89df088ea20e0c33043b71;hpb=5733daa233a99a828b7b93509b3ecf5e6af46120 diff --git a/tools/llvm-dwarfdump/llvm-dwarfdump.cpp b/tools/llvm-dwarfdump/llvm-dwarfdump.cpp index 018e6662fac..d742eb3ec34 100644 --- a/tools/llvm-dwarfdump/llvm-dwarfdump.cpp +++ b/tools/llvm-dwarfdump/llvm-dwarfdump.cpp @@ -15,6 +15,7 @@ #include "llvm/ADT/Triple.h" #include "llvm/DebugInfo/DIContext.h" #include "llvm/DebugInfo/DWARF/DWARFContext.h" +#include "llvm/Object/MachOUniversal.h" #include "llvm/Object/ObjectFile.h" #include "llvm/Object/RelocVisitor.h" #include "llvm/Support/CommandLine.h" @@ -38,16 +39,16 @@ static cl::list InputFilenames(cl::Positional, cl::desc(""), cl::ZeroOrMore); -static cl::opt -DumpType("debug-dump", cl::init(DIDT_All), - cl::desc("Dump of debug sections:"), - cl::values( +static cl::opt DumpType( + "debug-dump", cl::init(DIDT_All), cl::desc("Dump of debug sections:"), + cl::values( clEnumValN(DIDT_All, "all", "Dump all debug sections"), clEnumValN(DIDT_Abbrev, "abbrev", ".debug_abbrev"), clEnumValN(DIDT_AbbrevDwo, "abbrev.dwo", ".debug_abbrev.dwo"), clEnumValN(DIDT_AppleNames, "apple_names", ".apple_names"), clEnumValN(DIDT_AppleTypes, "apple_types", ".apple_types"), - clEnumValN(DIDT_AppleNamespaces, "apple_namespaces", ".apple_namespaces"), + clEnumValN(DIDT_AppleNamespaces, "apple_namespaces", + ".apple_namespaces"), clEnumValN(DIDT_AppleObjC, "apple_objc", ".apple_objc"), clEnumValN(DIDT_Aranges, "aranges", ".debug_aranges"), clEnumValN(DIDT_Info, "info", ".debug_info"), @@ -59,6 +60,7 @@ DumpType("debug-dump", cl::init(DIDT_All), clEnumValN(DIDT_Loc, "loc", ".debug_loc"), clEnumValN(DIDT_LocDwo, "loc.dwo", ".debug_loc.dwo"), clEnumValN(DIDT_Frames, "frames", ".debug_frame"), + clEnumValN(DIDT_Macro, "macro", ".debug_macinfo"), clEnumValN(DIDT_Ranges, "ranges", ".debug_ranges"), clEnumValN(DIDT_Pubnames, "pubnames", ".debug_pubnames"), clEnumValN(DIDT_Pubtypes, "pubtypes", ".debug_pubtypes"), @@ -66,8 +68,10 @@ DumpType("debug-dump", cl::init(DIDT_All), clEnumValN(DIDT_GnuPubtypes, "gnu_pubtypes", ".debug_gnu_pubtypes"), clEnumValN(DIDT_Str, "str", ".debug_str"), clEnumValN(DIDT_StrDwo, "str.dwo", ".debug_str.dwo"), - clEnumValN(DIDT_StrOffsetsDwo, "str_offsets.dwo", ".debug_str_offsets.dwo"), - clEnumValEnd)); + clEnumValN(DIDT_StrOffsetsDwo, "str_offsets.dwo", + ".debug_str_offsets.dwo"), + clEnumValN(DIDT_CUIndex, "cu_index", ".debug_cu_index"), + clEnumValN(DIDT_TUIndex, "tu_index", ".debug_tu_index"), clEnumValEnd)); static void error(StringRef Filename, std::error_code EC) { if (!EC) @@ -76,11 +80,11 @@ static void error(StringRef Filename, std::error_code EC) { exit(1); } -static void DumpObjectFile(ObjectFile &Obj, StringRef Filename) { +static void DumpObjectFile(ObjectFile &Obj, Twine Filename) { std::unique_ptr DICtx(new DWARFContextInMemory(Obj)); - outs() << Filename - << ":\tfile format " << Obj.getFileFormatName() << "\n\n"; + outs() << Filename.str() << ":\tfile format " << Obj.getFileFormatName() + << "\n\n"; // Dump the complete DWARF structure. DICtx->dump(outs(), DumpType); } @@ -91,12 +95,19 @@ static void DumpInput(StringRef Filename) { error(Filename, BuffOrErr.getError()); std::unique_ptr Buff = std::move(BuffOrErr.get()); - ErrorOr> ObjOrErr = - ObjectFile::createObjectFile(Buff->getMemBufferRef()); - error(Filename, ObjOrErr.getError()); - ObjectFile &Obj = *ObjOrErr.get(); + ErrorOr> BinOrErr = + object::createBinary(Buff->getMemBufferRef()); + error(Filename, BinOrErr.getError()); - DumpObjectFile(Obj, Filename); + if (auto *Obj = dyn_cast(BinOrErr->get())) + DumpObjectFile(*Obj, Filename); + else if (auto *Fat = dyn_cast(BinOrErr->get())) + for (auto &ObjForArch : Fat->objects()) { + auto MachOOrErr = ObjForArch.getAsObjectFile(); + error(Filename, MachOOrErr.getError()); + DumpObjectFile(**MachOOrErr, + Filename + " (" + ObjForArch.getArchTypeName() + ")"); + } } int main(int argc, char **argv) {