Index: include/llvm/DebugInfo/DIContext.h =================================================================== --- include/llvm/DebugInfo/DIContext.h +++ include/llvm/DebugInfo/DIContext.h @@ -141,6 +141,7 @@ unsigned RecurseDepth = -1U; bool ShowChildren = false; bool ShowParents = false; + bool ShowForm = false; bool SummarizeTypes = false; bool Verbose = false; Index: lib/DebugInfo/DWARF/DWARFDie.cpp =================================================================== --- lib/DebugInfo/DWARF/DWARFDie.cpp +++ lib/DebugInfo/DWARF/DWARFDie.cpp @@ -139,7 +139,7 @@ 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 << ']'; Index: test/tools/llvm-dwarfdump/X86/form.test =================================================================== --- /dev/null +++ test/tools/llvm-dwarfdump/X86/form.test @@ -0,0 +1,62 @@ +# 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 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] + +# FORM: DW_TAG_compile_unit +# FORM-NOT: [DW_FORM_strp] +# FORM-NOT: [DW_FORM_data2] +# FORM-NOT: [DW_FORM_strp] +# FORM-NOT: [DW_FORM_sec_offset] +# FORM-NOT: [DW_FORM_strp] +# FORM-NOT: [DW_FORM_addr] +# FORM-NOT: [DW_FORM_data4] + +# FORM: DW_TAG_subprogram +# FORM-NOT: [DW_FORM_addr] +# FORM-NOT: [DW_FORM_data4] +# FORM-NOT: [DW_FORM_exprloc] +# FORM-NOT: [DW_FORM_strp] +# FORM-NOT: [DW_FORM_data1] +# FORM-NOT: [DW_FORM_data1] +# FORM-NOT: [DW_FORM_ref4] +# FORM-NOT: [DW_FORM_flag_present] + +# FORM: DW_TAG_base_type +# FORM-NOT: [DW_FORM_strp] +# FORM-NOT: [DW_FORM_data1] +# FORM-NOT: [DW_FORM_data1] Index: tools/llvm-dwarfdump/llvm-dwarfdump.cpp =================================================================== --- tools/llvm-dwarfdump/llvm-dwarfdump.cpp +++ tools/llvm-dwarfdump/llvm-dwarfdump.cpp @@ -170,13 +170,19 @@ cat(DwarfDumpCategory)); static alias ShowParentsAlias("p", desc("Alias for -show-parents"), aliasopt(ShowParents)); +static opt + 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 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 SummarizeTypes("summarize-types", desc("Abbreviate the description of type unit entries"), @@ -210,6 +216,7 @@ 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 @@ 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 @@ if (!DumpOffsets[DIDT_ID_DebugInfo]) return true; } - + // Dump the complete DWARF structure. DICtx.dump(OS, getDumpOpts(), DumpOffsets); return true;