[llvm] r314685 - [dwarfdump] Add -show-form
Jonas Devlieghere via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 2 09:02:05 PDT 2017
Author: jdevlieghere
Date: Mon Oct 2 09:02:04 2017
New Revision: 314685
URL: http://llvm.org/viewvc/llvm-project?rev=314685&view=rev
Log:
[dwarfdump] Add -show-form
This enables printing of DWARF form types after the DWARF attribute
types.
Differential revision: https://reviews.llvm.org/D38459
Added:
llvm/trunk/test/tools/llvm-dwarfdump/X86/form.test
Modified:
llvm/trunk/include/llvm/DebugInfo/DIContext.h
llvm/trunk/lib/DebugInfo/DWARF/DWARFDie.cpp
llvm/trunk/test/tools/llvm-dwarfdump/cmdline.test
llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
Modified: llvm/trunk/include/llvm/DebugInfo/DIContext.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DIContext.h?rev=314685&r1=314684&r2=314685&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/DIContext.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/DIContext.h Mon Oct 2 09:02:04 2017
@@ -141,6 +141,7 @@ struct DIDumpOptions {
unsigned RecurseDepth = -1U;
bool ShowChildren = false;
bool ShowParents = false;
+ bool ShowForm = false;
bool SummarizeTypes = false;
bool Verbose = false;
Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFDie.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFDie.cpp?rev=314685&r1=314684&r2=314685&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFDie.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFDie.cpp Mon Oct 2 09:02:04 2017
@@ -139,7 +139,7 @@ static void dumpAttribute(raw_ostream &O
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 << ']';
Added: llvm/trunk/test/tools/llvm-dwarfdump/X86/form.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-dwarfdump/X86/form.test?rev=314685&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-dwarfdump/X86/form.test (added)
+++ llvm/trunk/test/tools/llvm-dwarfdump/X86/form.test Mon Oct 2 09:02:04 2017
@@ -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_
Modified: llvm/trunk/test/tools/llvm-dwarfdump/cmdline.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-dwarfdump/cmdline.test?rev=314685&r1=314684&r2=314685&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-dwarfdump/cmdline.test (original)
+++ llvm/trunk/test/tools/llvm-dwarfdump/cmdline.test Mon Oct 2 09:02:04 2017
@@ -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
Modified: llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp?rev=314685&r1=314684&r2=314685&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp (original)
+++ llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp Mon Oct 2 09:02:04 2017
@@ -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 &O
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 &O
if (!DumpOffsets[DIDT_ID_DebugInfo])
return true;
}
-
+
// Dump the complete DWARF structure.
DICtx.dump(OS, getDumpOpts(), DumpOffsets);
return true;
More information about the llvm-commits
mailing list