From 8ac8df03c10c98b1f782b4e0df201361ee4ee067 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Thu, 31 Aug 2017 16:44:47 +0000 Subject: [llvm-dwarfdump] Brief mode only dumps debug_info by default This patch changes the default behavior in brief mode to only show the debug_info section. This is undoubtedly the most popular and likely the one you'd want in brief mode. Non-brief mode behavior is not affected and still defaults to all. Differential revision: https://reviews.llvm.org/D37334 llvm-svn: 312252 --- llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp') diff --git a/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp b/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp index 2eb433ab3ce..39a035d8129 100644 --- a/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp +++ b/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp @@ -41,7 +41,7 @@ InputFilenames(cl::Positional, cl::desc("") cl::ZeroOrMore); static cl::opt DumpType( - "debug-dump", cl::init(DIDT_All), cl::desc("Dump of debug sections:"), + "debug-dump", cl::init(DIDT_Null), cl::desc("Dump of debug sections:"), cl::values( clEnumValN(DIDT_All, "all", "Dump all debug sections"), clEnumValN(DIDT_Abbrev, "abbrev", ".debug_abbrev"), @@ -154,12 +154,12 @@ static bool VerifyInput(StringRef Filename) { MemoryBuffer::getFileOrSTDIN(Filename); error(Filename, BuffOrErr.getError()); std::unique_ptr Buff = std::move(BuffOrErr.get()); - + Expected> BinOrErr = object::createBinary(Buff->getMemBufferRef()); if (!BinOrErr) error(Filename, errorToErrorCode(BinOrErr.takeError())); - + bool Result = true; if (auto *Obj = dyn_cast(BinOrErr->get())) Result = VerifyObjectFile(*Obj, Filename); @@ -217,6 +217,15 @@ int main(int argc, char **argv) { cl::ParseCommandLineOptions(argc, argv, "llvm dwarf dumper\n"); + // Defaults to dumping all sections, unless brief mode is specified in which + // case only the .debug_info section in dumped. + if (DumpType == DIDT_Null) { + if (Brief) + DumpType = DIDT_Info; + else + DumpType = DIDT_All; + } + // Defaults to a.out if no filenames specified. if (InputFilenames.size() == 0) InputFilenames.push_back("a.out"); -- cgit v1.2.3