[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 09:45:59 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL312252: [llvm-dwarfdump] Brief mode only dumps debug_info by default (authored by JDevlieghere).

Changed prior to commit:
  https://reviews.llvm.org/D37334?vs=113419&id=113421#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D37334

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


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<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");


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


More information about the llvm-commits mailing list