llvm-dwarf-dump: include type name for AT_containing_type
authorFelipe de Azevedo Piovezan <piovezan.fpi@gmail.com>
Sat, 18 Jun 2022 00:48:40 +0000 (00:48 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Sat, 18 Jun 2022 00:52:34 +0000 (00:52 +0000)
Type attributes are currently printed as:
  DW_AT_type    (<address> "<name>")
For example:
  DW_AT_type    (0x00000086 "double")

However, containing_type attributes omit the name, for example:
  DW_AT_containing_type    (0x00000086)

In order to make the dwarf dumps easier to read, and to have consistency
between the type-like attributes, this commit changes the way
DW_AT_containing_type is printed so that it includes the name of the
type it refers to:
  DW_AT_containing_type    (0x00000086 "double")

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D127078

llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
llvm/test/DebugInfo/Generic/containing-type-extension.ll
llvm/test/DebugInfo/Generic/tu-composite.ll
llvm/test/DebugInfo/X86/containing-type-extension-rust.ll

index 9bbe09fccfe69fba9548ba58a9a9524ce4c16ec2..fb982804c7b125ca94387737a393873ac20c9714 100644 (file)
@@ -194,7 +194,7 @@ static void dumpAttribute(raw_ostream &OS, const DWARFDie &Die,
             Die.getAttributeValueAsReferencedDie(FormValue).getName(
                 DINameKind::LinkageName))
       OS << Space << "\"" << Name << '\"';
-  } else if (Attr == DW_AT_type) {
+  } else if (Attr == DW_AT_type || Attr == DW_AT_containing_type) {
     DWARFDie D = resolveReferencedType(Die, FormValue);
     if (D && !D.isNULL()) {
       OS << Space << "\"";
index 2eab36c423a83d24084c08c0f4380bb31b4d9fae..ada407929374ccd9e5df70330e0848fc7aff18f5 100644 (file)
@@ -4,7 +4,7 @@
 ; Check that any type can have a vtable holder.
 ; CHECK: [[SP:.*]]: DW_TAG_structure_type
 ; CHECK-NOT: TAG
-; CHECK: DW_AT_containing_type [DW_FORM_ref4]
+; CHECK: DW_AT_containing_type [DW_FORM_ref4] ({{.*}} "int")
 ; CHECK: DW_AT_name {{.*}}"vtable"
 
 ; The code doesn't actually matter.
index a95b9460d67de238846ea9a1569ff1604b18e37e..1700507b1b3bc62c9abfff41cc980cdb926e2647 100644 (file)
@@ -2,14 +2,14 @@
 ; RUN: llvm-dwarfdump -v -debug-info %t | FileCheck %s
 ; CHECK: [[TYPE:.*]]: DW_TAG_structure_type
 ; Make sure we correctly handle containing type of a struct being a type identifier.
-; CHECK-NEXT: DW_AT_containing_type [DW_FORM_ref4]       (cu + {{.*}} => {[[TYPE]]})
+; CHECK-NEXT: DW_AT_containing_type [DW_FORM_ref4]       (cu + {{.*}} => {[[TYPE]]} "C")
 ; CHECK-NEXT: DW_AT_name {{.*}}"C"
 
 ; Make sure we correctly handle context of a subprogram being a type identifier.
 ; CHECK: [[SP:.*]]: DW_TAG_subprogram
 ; CHECK: DW_AT_name {{.*}}"foo"
 ; Make sure we correctly handle containing type of a subprogram being a type identifier.
-; CHECK: DW_AT_containing_type [DW_FORM_ref4]       (cu + {{.*}} => {[[TYPE]]})
+; CHECK: DW_AT_containing_type [DW_FORM_ref4]       (cu + {{.*}} => {[[TYPE]]} "C")
 ; CHECK: DW_TAG_formal_parameter
 ; CHECK: NULL
 ; CHECK: NULL
index 3e6c6d26908241c6c2e372e4ee355b67ffbc0dd0..0ec8397769198be840f85420b6e4742cee0529cd 100644 (file)
@@ -4,7 +4,7 @@
 ; Check that any type can have a vtable holder.
 ; CHECK: [[SP:.*]]: DW_TAG_structure_type
 ; CHECK-NOT: TAG
-; CHECK: DW_AT_containing_type [DW_FORM_ref4]
+; CHECK: DW_AT_containing_type [DW_FORM_ref4] ({{.*}} "f64")
 ; CHECK: DW_AT_name [DW_FORM_strp] {{.*}}= "vtable")
 
 ; This was compiled using