]> granicus.if.org Git - llvm/commitdiff
[dwarfdump] Add -show-form
authorJonas Devlieghere <jonas@devlieghere.com>
Mon, 2 Oct 2017 16:02:04 +0000 (16:02 +0000)
committerJonas Devlieghere <jonas@devlieghere.com>
Mon, 2 Oct 2017 16:02:04 +0000 (16:02 +0000)
This enables printing of DWARF form types after the DWARF attribute
types.

Differential revision: https://reviews.llvm.org/D38459

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314685 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/DebugInfo/DIContext.h
lib/DebugInfo/DWARF/DWARFDie.cpp
test/tools/llvm-dwarfdump/X86/form.test [new file with mode: 0644]
test/tools/llvm-dwarfdump/cmdline.test
tools/llvm-dwarfdump/llvm-dwarfdump.cpp

index d5ff7cb35bf7e403259f0ba3d82e677eac170666..ce0a156e9f7483eac1dd0cf7371a38ad41a5bed7 100644 (file)
@@ -141,6 +141,7 @@ struct DIDumpOptions {
   unsigned RecurseDepth = -1U;
   bool ShowChildren = false;
   bool ShowParents = false;
+  bool ShowForm = false;
   bool SummarizeTypes = false;
   bool Verbose = false;
 
index 31074a81a989b9d7e63572c0a108ccf83afb39a1..a2371038b96f12e0b3962f0669a26821cbf3d7f9 100644 (file)
@@ -139,7 +139,7 @@ static void dumpAttribute(raw_ostream &OS, const DWARFDie &Die,
   else
     WithColor(OS, syntax::Attribute).get() << format("DW_AT_Unknown_%x", Attr);
 
-  if (DumpOpts.Verbose) {
+  if (DumpOpts.Verbose || DumpOpts.ShowForm) {
     auto formString = FormEncodingString(Form);
     if (!formString.empty())
       OS << " [" << formString << ']';
diff --git a/test/tools/llvm-dwarfdump/X86/form.test b/test/tools/llvm-dwarfdump/X86/form.test
new file mode 100644 (file)
index 0000000..92b7996
--- /dev/null
@@ -0,0 +1,40 @@
+# This test verifies that DWARF form types are printed in verbose mode and when
+# passing -F but not in brief mode.
+
+# RUN: llvm-mc %S/brief.s -filetype obj -triple x86_64-apple-darwin -o - \
+# RUN: | llvm-dwarfdump -v --debug-info - \
+# RUN: | FileCheck %s
+
+# RUN: llvm-mc %S/brief.s -filetype obj -triple x86_64-apple-darwin -o - \
+# RUN: | llvm-dwarfdump -F --debug-info - \
+# RUN: | FileCheck %s
+
+# RUN: llvm-mc %S/brief.s -filetype obj -triple x86_64-apple-darwin -o - \
+# RUN: | llvm-dwarfdump --debug-info - \
+# RUN: | FileCheck %s --check-prefix NO-FORM
+
+# CHECK: DW_TAG_compile_unit
+# CHECK: DW_AT_producer [DW_FORM_strp]
+# CHECK: DW_AT_language [DW_FORM_data2]
+# CHECK: DW_AT_name [DW_FORM_strp]
+# CHECK: DW_AT_stmt_list [DW_FORM_sec_offset]
+# CHECK: DW_AT_comp_dir [DW_FORM_strp]
+# CHECK: DW_AT_low_pc [DW_FORM_addr]
+# CHECK: DW_AT_high_pc [DW_FORM_data4]
+
+# CHECK: DW_TAG_subprogram
+# CHECK: DW_AT_low_pc [DW_FORM_addr]
+# CHECK: DW_AT_high_pc [DW_FORM_data4]
+# CHECK: DW_AT_frame_base [DW_FORM_exprloc]
+# CHECK: DW_AT_name [DW_FORM_strp]
+# CHECK: DW_AT_decl_file [DW_FORM_data1]
+# CHECK: DW_AT_decl_line [DW_FORM_data1]
+# CHECK: DW_AT_type [DW_FORM_ref4]
+# CHECK: DW_AT_external [DW_FORM_flag_present]
+
+# CHECK: DW_TAG_base_type
+# CHECK: DW_AT_name [DW_FORM_strp]
+# CHECK: DW_AT_encoding [DW_FORM_data1]
+# CHECK: DW_AT_byte_size [DW_FORM_data1]
+
+# NO-FORM-NOT: DW_FORM_
index fd06f77dda3e4310305f10ff0cf9f30f6ee59666..16b422a960b0874269e1e2542dc8af645df03252 100644 (file)
@@ -8,8 +8,9 @@ HELP: -eh-frame
 HELP: Specific Options
 HELP: -find
 HELP: -name
-HELP: -recurse-depth=<N> 
+HELP: -recurse-depth=<N>
 HELP: -show-children
+HELP: -show-form
 HELP: -show-parents
 HELP: -summarize-types
 HELP-NOT: -reverse-iterate
index f8909800852a7a5e5d84c5ddc38e14b83aef5144..28b4a136fb16d7f3c1d5d34eb64a7712d0d0044c 100644 (file)
@@ -170,13 +170,19 @@ static opt<bool>
                 cat(DwarfDumpCategory));
 static alias ShowParentsAlias("p", desc("Alias for -show-parents"),
                               aliasopt(ShowParents));
+static opt<bool>
+    ShowForm("show-form",
+             desc("Show DWARF form types after the DWARF attribute types."),
+             cat(DwarfDumpCategory));
+static alias ShowFormAlias("F", desc("Alias for -show-form"),
+                           aliasopt(ShowForm), cat(DwarfDumpCategory));
 static opt<unsigned> RecurseDepth(
     "recurse-depth",
     desc("Only recurse to a depth of N when displaying debug info entries."),
     cat(DwarfDumpCategory), init(-1U), value_desc("N"));
 static alias RecurseDepthAlias("r", desc("Alias for -recurse-depth"),
                                aliasopt(RecurseDepth));
-  
+
 static opt<bool>
     SummarizeTypes("summarize-types",
                    desc("Abbreviate the description of type unit entries"),
@@ -210,6 +216,7 @@ static DIDumpOptions getDumpOpts() {
   DumpOpts.RecurseDepth = RecurseDepth;
   DumpOpts.ShowChildren = ShowChildren;
   DumpOpts.ShowParents = ShowParents;
+  DumpOpts.ShowForm = ShowForm;
   DumpOpts.SummarizeTypes = SummarizeTypes;
   DumpOpts.Verbose = Verbose;
   // In -verify mode, print DIEs without children in error messages.
@@ -277,7 +284,7 @@ static bool dumpObjectFile(ObjectFile &Obj, DWARFContext &DICtx, Twine Filename,
     StringSet<> Names;
     for (auto name : Name)
       Names.insert(name);
-      
+
     filterByName(Names, DICtx.compile_units(), OS);
     filterByName(Names, DICtx.dwo_compile_units(), OS);
     return true;
@@ -308,7 +315,7 @@ static bool dumpObjectFile(ObjectFile &Obj, DWARFContext &DICtx, Twine Filename,
     if (!DumpOffsets[DIDT_ID_DebugInfo])
       return true;
   }
-  
+
   // Dump the complete DWARF structure.
   DICtx.dump(OS, getDumpOpts(), DumpOffsets);
   return true;