[ dwarfdump ] Add symbolic dump of known DWARF attribute values.

Reviewed By: dblaikie

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D5187

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217186 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Frederic Riss 2014-09-04 19:39:20 +00:00
parent 4b2e523613
commit a49caa5e3f
10 changed files with 70 additions and 25 deletions

View File

@ -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

View File

@ -86,7 +86,17 @@ void DWARFDebugInfoEntryMinimal::dumpAttribute(raw_ostream &OS,
return;
OS << "\t(";
formValue.dump(OS, u);
const char *Name = nullptr;
if (Optional<uint64_t> Val = formValue.getAsUnsignedConstant())
Name = AttributeValueString(attr, *Val);
if (Name) {
OS << Name;
} else {
formValue.dump(OS, u);
}
OS << ")\n";
}

View File

@ -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;
}

View File

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

View File

@ -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

View File

@ -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]:

View File

@ -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}

View File

@ -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

View File

@ -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}

View File

@ -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