diff --git a/include/llvm/Support/Dwarf.h b/include/llvm/Support/Dwarf.h index cd9f75600cb..0a808c355bf 100644 --- a/include/llvm/Support/Dwarf.h +++ b/include/llvm/Support/Dwarf.h @@ -950,6 +950,10 @@ private: }; }; +/// Returns the symbolic string representing Val when used as a value +/// for attribute Attr. +const char *AttributeValueString(uint16_t Attr, unsigned Val); + } // End of namespace dwarf } // End of namespace llvm diff --git a/lib/DebugInfo/DWARFDebugInfoEntry.cpp b/lib/DebugInfo/DWARFDebugInfoEntry.cpp index 2e7a54aeb85..5140244dee9 100644 --- a/lib/DebugInfo/DWARFDebugInfoEntry.cpp +++ b/lib/DebugInfo/DWARFDebugInfoEntry.cpp @@ -86,7 +86,17 @@ void DWARFDebugInfoEntryMinimal::dumpAttribute(raw_ostream &OS, return; OS << "\t("; - formValue.dump(OS, u); + + const char *Name = nullptr; + if (Optional Val = formValue.getAsUnsignedConstant()) + Name = AttributeValueString(attr, *Val); + + if (Name) { + OS << Name; + } else { + formValue.dump(OS, u); + } + OS << ")\n"; } diff --git a/lib/Support/Dwarf.cpp b/lib/Support/Dwarf.cpp index c9efa61afe6..a5a05778450 100644 --- a/lib/Support/Dwarf.cpp +++ b/lib/Support/Dwarf.cpp @@ -795,3 +795,34 @@ const char *llvm::dwarf::GDBIndexEntryLinkageString(GDBIndexEntryLinkage Linkage } llvm_unreachable("Unknown GDBIndexEntryLinkage value"); } + +const char *llvm::dwarf::AttributeValueString(uint16_t Attr, unsigned Val) { + switch (Attr) { + case DW_AT_accessibility: + return AccessibilityString(Val); + case DW_AT_virtuality: + return VirtualityString(Val); + case DW_AT_language: + return LanguageString(Val); + case DW_AT_encoding: + return AttributeEncodingString(Val); + case DW_AT_decimal_sign: + return DecimalSignString(Val); + case DW_AT_endianity: + return EndianityString(Val); + case DW_AT_visibility: + return VisibilityString(Val); + case DW_AT_identifier_case: + return CaseString(Val); + case DW_AT_calling_convention: + return ConventionString(Val); + case DW_AT_inline: + return InlineCodeString(Val); + case DW_AT_ordering: + return ArrayOrderString(Val); + case DW_AT_discr_value: + return DiscriminantString(Val); + } + + return nullptr; +} diff --git a/test/DebugInfo/X86/debug-info-access.ll b/test/DebugInfo/X86/debug-info-access.ll index 1dee785a9e8..273cff0f621 100644 --- a/test/DebugInfo/X86/debug-info-access.ll +++ b/test/DebugInfo/X86/debug-info-access.ll @@ -46,22 +46,22 @@ ; ; CHECK: DW_TAG_inheritance ; CHECK-NOT: DW_TAG -; CHECK: DW_AT_accessibility {{.*}}(0x01) +; CHECK: DW_AT_accessibility {{.*}}(DW_ACCESS_public) ; ; CHECK: DW_TAG_member ; CHECK: DW_AT_name {{.*}}"public_static") ; CHECK-NOT: DW_TAG -; CHECK: DW_AT_accessibility {{.*}}(0x01) +; CHECK: DW_AT_accessibility {{.*}}(DW_ACCESS_public) ; ; CHECK: DW_TAG_subprogram ; CHECK: DW_AT_name {{.*}}"pub") ; CHECK-NOT: DW_TAG -; CHECK: DW_AT_accessibility {{.*}}(0x01) +; CHECK: DW_AT_accessibility {{.*}}(DW_ACCESS_public) ; ; CHECK: DW_TAG_subprogram ; CHECK: DW_AT_name {{.*}}"prot") ; CHECK-NOT: DW_TAG -; CHECK: DW_AT_accessibility {{.*}}(0x02) +; CHECK: DW_AT_accessibility {{.*}}(DW_ACCESS_protected) ; ; CHECK: DW_TAG_subprogram ; CHECK: DW_AT_name {{.*}}"priv_default") @@ -71,7 +71,7 @@ ; CHECK: DW_TAG_member ; CHECK: DW_AT_name {{.*}}"union_priv") ; CHECK-NOT: DW_TAG -; CHECK: DW_AT_accessibility {{.*}}(0x03) +; CHECK: DW_AT_accessibility {{.*}}(DW_ACCESS_private) ; ; CHECK: DW_TAG_subprogram ; CHECK: DW_AT_name {{.*}}"union_pub_default") diff --git a/test/DebugInfo/X86/debug-info-static-member.ll b/test/DebugInfo/X86/debug-info-static-member.ll index 1207a41ec15..cd0197f9ab8 100644 --- a/test/DebugInfo/X86/debug-info-static-member.ll +++ b/test/DebugInfo/X86/debug-info-static-member.ll @@ -101,33 +101,33 @@ declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone ; PRESENT-NEXT: DW_AT_name {{.*}} "a" ; PRESENT: DW_AT_external ; PRESENT: DW_AT_declaration -; PRESENT: DW_AT_accessibility [DW_FORM_data1] (0x03) +; PRESENT: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_private) ; PRESENT: DW_TAG_member ; PRESENT-NEXT: DW_AT_name {{.*}} "const_a" ; PRESENT: DW_AT_external ; PRESENT: DW_AT_declaration -; PRESENT: DW_AT_accessibility [DW_FORM_data1] (0x03) +; PRESENT: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_private) ; PRESENT: DW_AT_const_value {{.*}} (1) ; PRESENT: 0x[[DECL_B:[0-9a-f]+]]: DW_TAG_member ; PRESENT-NEXT: DW_AT_name {{.*}} "b" -; PRESENT: DW_AT_accessibility [DW_FORM_data1] (0x02) +; PRESENT: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_protected) ; PRESENT: DW_TAG_member ; PRESENT-NEXT: DW_AT_name {{.*}} "const_b" -; PRESENT: DW_AT_accessibility [DW_FORM_data1] (0x02) +; PRESENT: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_protected) ; PRESENT: DW_AT_const_value [DW_FORM_udata] (1078523331) ; PRESENT: 0x[[DECL_C:[0-9a-f]+]]: DW_TAG_member ; PRESENT-NEXT: DW_AT_name {{.*}} "c" -; PRESENT: DW_AT_accessibility [DW_FORM_data1] (0x01) +; PRESENT: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_public) ; PRESENT: DW_TAG_member ; PRESENT-NEXT: DW_AT_name {{.*}} "const_c" -; PRESENT: DW_AT_accessibility [DW_FORM_data1] (0x01) +; PRESENT: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_public) ; PRESENT: DW_AT_const_value {{.*}} (18) ; While we're here, a normal member has data_member_location and ; accessibility attributes. ; PRESENT: DW_TAG_member ; PRESENT-NEXT: DW_AT_name {{.*}} "d" ; PRESENT: DW_AT_data_member_location -; PRESENT: DW_AT_accessibility [DW_FORM_data1] (0x01) +; PRESENT: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_public) ; PRESENT: NULL ; Definitions point back to their declarations, and have a location. ; PRESENT: DW_TAG_variable @@ -151,33 +151,33 @@ declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone ; DARWINP-NEXT: DW_AT_name {{.*}} "a" ; DARWINP: DW_AT_external ; DARWINP: DW_AT_declaration -; DARWINP: DW_AT_accessibility [DW_FORM_data1] (0x03) +; DARWINP: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_private) ; DARWINP: DW_TAG_member ; DARWINP-NEXT: DW_AT_name {{.*}} "const_a" ; DARWINP: DW_AT_external ; DARWINP: DW_AT_declaration -; DARWINP: DW_AT_accessibility [DW_FORM_data1] (0x03) +; DARWINP: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_private) ; DARWINP: DW_AT_const_value {{.*}} (1) ; DARWINP: 0x[[DECL_B:[0-9a-f]+]]: DW_TAG_member ; DARWINP-NEXT: DW_AT_name {{.*}} "b" -; DARWINP: DW_AT_accessibility [DW_FORM_data1] (0x02) +; DARWINP: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_protected) ; DARWINP: DW_TAG_member ; DARWINP-NEXT: DW_AT_name {{.*}} "const_b" -; DARWINP: DW_AT_accessibility [DW_FORM_data1] (0x02) +; DARWINP: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_protected) ; DARWINP: DW_AT_const_value [DW_FORM_udata] (1078523331) ; DARWINP: 0x[[DECL_C:[0-9a-f]+]]: DW_TAG_member ; DARWINP-NEXT: DW_AT_name {{.*}} "c" -; DARWINP: DW_AT_accessibility [DW_FORM_data1] (0x01) +; DARWINP: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_public) ; DARWINP: DW_TAG_member ; DARWINP-NEXT: DW_AT_name {{.*}} "const_c" -; DARWINP: DW_AT_accessibility [DW_FORM_data1] (0x01) +; DARWINP: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_public) ; DARWINP: DW_AT_const_value {{.*}} (18) ; While we're here, a normal member has data_member_location and ; accessibility attributes. ; DARWINP: DW_TAG_member ; DARWINP-NEXT: DW_AT_name {{.*}} "d" ; DARWINP: DW_AT_data_member_location -; DARWINP: DW_AT_accessibility [DW_FORM_data1] (0x01) +; DARWINP: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_public) ; DARWINP: NULL ; Definitions point back to their declarations, and have a location. ; DARWINP: DW_TAG_variable diff --git a/test/DebugInfo/X86/empty-and-one-elem-array.ll b/test/DebugInfo/X86/empty-and-one-elem-array.ll index f5c37df1e5e..ba438e8156a 100644 --- a/test/DebugInfo/X86/empty-and-one-elem-array.ll +++ b/test/DebugInfo/X86/empty-and-one-elem-array.ll @@ -30,7 +30,7 @@ declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone ; CHECK: DW_TAG_base_type ; CHECK-NEXT: DW_AT_name [DW_FORM_strp] ( .debug_str[{{.*}}] = "int") -; CHECK-NEXT: DW_AT_encoding [DW_FORM_data1] (0x05) +; CHECK-NEXT: DW_AT_encoding [DW_FORM_data1] (DW_ATE_signed) ; CHECK-NEXT: DW_AT_byte_size [DW_FORM_data1] (0x04) ; int foo::b[1]: diff --git a/test/DebugInfo/X86/empty-array.ll b/test/DebugInfo/X86/empty-array.ll index 3fab313fe0e..418097382ed 100644 --- a/test/DebugInfo/X86/empty-array.ll +++ b/test/DebugInfo/X86/empty-array.ll @@ -22,7 +22,7 @@ ; CHECK: [[BASE2]]: DW_TAG_base_type ; CHECK-NEXT: DW_AT_name ; CHECK-NEXT: DW_AT_byte_size [DW_FORM_data1] (0x08) -; CHECK-NEXT: DW_AT_encoding [DW_FORM_data1] (0x07) +; CHECK-NEXT: DW_AT_encoding [DW_FORM_data1] (DW_ATE_unsigned) !llvm.dbg.cu = !{!0} !llvm.module.flags = !{!21} diff --git a/test/DebugInfo/X86/fission-cu.ll b/test/DebugInfo/X86/fission-cu.ll index 7f176986394..35db4801cfe 100644 --- a/test/DebugInfo/X86/fission-cu.ll +++ b/test/DebugInfo/X86/fission-cu.ll @@ -65,7 +65,7 @@ ; CHECK: .debug_info.dwo contents: ; CHECK: DW_TAG_compile_unit ; CHECK: DW_AT_producer [DW_FORM_GNU_str_index] ( indexed (00000000) string = "clang version 3.3 (trunk 169021) (llvm/trunk 169020)") -; CHECK: DW_AT_language [DW_FORM_data2] (0x000c) +; CHECK: DW_AT_language [DW_FORM_data2] (DW_LANG_C99) ; CHECK: DW_AT_name [DW_FORM_GNU_str_index] ( indexed (00000001) string = "baz.c") ; CHECK-NOT: DW_AT_low_pc ; CHECK-NOT: DW_AT_stmt_list diff --git a/test/DebugInfo/X86/nondefault-subrange-array.ll b/test/DebugInfo/X86/nondefault-subrange-array.ll index 4df1bd4847d..75728b5e192 100644 --- a/test/DebugInfo/X86/nondefault-subrange-array.ll +++ b/test/DebugInfo/X86/nondefault-subrange-array.ll @@ -25,7 +25,7 @@ ; CHECK: [[BASE2]]: DW_TAG_base_type ; CHECK-NEXT: DW_AT_name [DW_FORM_strp] ( .debug_str[0x{{[0-9a-f]*}}] = "sizetype") ; CHECK-NEXT: DW_AT_byte_size [DW_FORM_data1] (0x08) -; CHECK-NEXT: DW_AT_encoding [DW_FORM_data1] (0x07) +; CHECK-NEXT: DW_AT_encoding [DW_FORM_data1] (DW_ATE_unsigned) !llvm.dbg.cu = !{!0} !llvm.module.flags = !{!21} diff --git a/test/Linker/type-unique-simple2-a.ll b/test/Linker/type-unique-simple2-a.ll index 11b292ef4b9..289d613b37f 100644 --- a/test/Linker/type-unique-simple2-a.ll +++ b/test/Linker/type-unique-simple2-a.ll @@ -19,7 +19,7 @@ ; } ; ; CHECK: _ZN1A6setFooEv -; CHECK: DW_AT_accessibility [DW_FORM_data1] (0x01) +; CHECK: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_public) ; CHECK-NOT: DW_AT_accessibility ; CHECK: DW_TAG