[PATCH] D37334: [llvm-dwarfdump] Brief mode only dumps debug_info by default

Jonas Devlieghere via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 31 07:32:01 PDT 2017


JDevlieghere created this revision.

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.


Repository:
  rL LLVM

https://reviews.llvm.org/D37334

Files:
  test/tools/llvm-dwarfdump/X86/brief.s
  tools/llvm-dwarfdump/llvm-dwarfdump.cpp


Index: tools/llvm-dwarfdump/llvm-dwarfdump.cpp
===================================================================
--- tools/llvm-dwarfdump/llvm-dwarfdump.cpp
+++ tools/llvm-dwarfdump/llvm-dwarfdump.cpp
@@ -41,7 +41,7 @@
                cl::ZeroOrMore);
 
 static cl::opt<DIDumpType> 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<MemoryBuffer> Buff = std::move(BuffOrErr.get());
-  
+
   Expected<std::unique_ptr<Binary>> BinOrErr =
   object::createBinary(Buff->getMemBufferRef());
   if (!BinOrErr)
     error(Filename, errorToErrorCode(BinOrErr.takeError()));
-  
+
   bool Result = true;
   if (auto *Obj = dyn_cast<ObjectFile>(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");
Index: test/tools/llvm-dwarfdump/X86/brief.s
===================================================================
--- test/tools/llvm-dwarfdump/X86/brief.s
+++ test/tools/llvm-dwarfdump/X86/brief.s
@@ -2,12 +2,39 @@
 # 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: .debug_abbrev.dwo contents
+# CHECK-NOT: .debug_abbrev.dwo contents
+# CHECK-NOT: .debug_loc contents:
+# CHECK-NOT: .debug_loc.dwo contents:
+# CHECK-NOT: .debug_frame contents:
+# CHECK-NOT: .debug_macinfo contents:
+# CHECK-NOT: .debug_aranges contents:
+# CHECK-NOT: .debug_line contents:
+# CHECK-NOT: .debug_cu_index contents:
+# CHECK-NOT: .debug_tu_index contents:
+# CHECK-NOT: .debug_line.dwo contents:
+# CHECK-NOT: .debug_str contents:
+# CHECK-NOT: .debug_ranges contents:
+# CHECK-NOT: .debug_pubnames contents:
+# CHECK-NOT: .debug_pubtypes contents:
+# CHECK-NOT: .debug_gnu_pubnames contents:
+# CHECK-NOT: .debug_gnu_pubtypes contents:
+# CHECK-NOT: .apple_names contents:
+# CHECK-NOT: .apple_types contents:
+# CHECK-NOT: .apple_namespaces contents:
+# CHECK-NOT: .apple_objc 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.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37334.113402.patch
Type: text/x-patch
Size: 3190 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170831/77a33b51/attachment.bin>


More information about the llvm-commits mailing list