Index: llvm/trunk/test/tools/llvm-dwarfdump/X86/brief.s =================================================================== --- llvm/trunk/test/tools/llvm-dwarfdump/X86/brief.s +++ llvm/trunk/test/tools/llvm-dwarfdump/X86/brief.s @@ -2,12 +2,19 @@ # RUN: | llvm-dwarfdump -debug-dump=info -brief - \ # RUN: | FileCheck %s +# CHECK-NOT: .debug_abbrev contents: +# +# CHECK: .debug_info contents: # CHECK: DW_TAG_compile_unit # CHECK-NOT: DW_FORM -# CHECK: DW_AT +# CHECK: DW_AT_name ("brief.c") +# CHECK: DW_AT_name ("main") +# CHECK: DW_AT_name ("int") # CHECK-NOT: debug_str # CHECK-NOT: DW_AT_type {{.*}} => - +# +# CHECK-NOT: {{.*}} contents: +# # This test is meant to verify that -brief hides DW_FORMs and abbreviation # codes from .debug_info section. Furthermore it verifies that it also hides # .debug_str and die reference offsets into the CU. Index: llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp =================================================================== --- llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp +++ llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp @@ -41,7 +41,7 @@ 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 @@ 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 @@ 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");