tweak
authorJason Merrill <merrill@gnu.org>
Fri, 18 Oct 1996 06:23:23 +0000 (06:23 +0000)
committerJason Merrill <merrill@gnu.org>
Fri, 18 Oct 1996 06:23:23 +0000 (06:23 +0000)
From-SVN: r12976

gcc/dwarf2out.c
gcc/dwarfout.c

index 582e20989df081e8c015db60cb0b0921de57f61a..9d8b6c6b1151dc036e474feb523a48d30386e0c9 100644 (file)
@@ -637,6 +637,7 @@ static void decls_for_scope ();
 static void gen_decl_die ();
 static unsigned lookup_filename ();
 static int constant_size PROTO((long unsigned));
+static enum dwarf_form value_format PROTO((dw_val_ref));
 
 /* Definitions of defaults for assembler-dependent names of various
    pseudo-ops and section names.
@@ -2775,14 +2776,8 @@ build_abbrev_table (die)
              while (a_attr != NULL && d_attr != NULL)
                {
                  if ((a_attr->dw_attr != d_attr->dw_attr)
-                     || (a_attr->dw_attr_val.val_class
-                         != d_attr->dw_attr_val.val_class)
-                     || (a_attr->dw_attr_val.val_class
-                         == dw_val_class_unsigned_const
-                         && (constant_size (a_attr->dw_attr_val
-                                            .v.val_unsigned)
-                             != constant_size (d_attr->dw_attr_val
-                                               .v.val_unsigned))))
+                     || (value_format (&a_attr->dw_attr_val)
+                         != value_format (&d_attr->dw_attr_val)))
                    {
                      break;
                    }
@@ -2979,6 +2974,17 @@ size_of_loc_descr (loc)
   return size;
 }
 
+/* Return the size of a series of location descriptors.  */
+static unsigned long
+size_of_locs (loc)
+     register dw_loc_descr_ref loc;
+{
+  register unsigned long size = 0;
+  for (; loc != NULL; loc = loc->dw_loc_next)
+    size += size_of_loc_descr (loc);
+  return size;
+}
+
 /* Return the power-of-two number of bytes necessary to represent VALUE.  */
 static int
 constant_size (value)
@@ -3015,13 +3021,14 @@ size_of_die (die)
          size += PTR_SIZE;
          break;
        case dw_val_class_loc:
-         /* Block length.  */
-         size += 2;
-         for (loc = a->dw_attr_val.v.val_loc; loc != NULL;
-              loc = loc->dw_loc_next)
-           {
-             size += size_of_loc_descr (loc);
-           }
+         {
+           register unsigned long lsize
+             = size_of_locs (a->dw_attr_val.v.val_loc);
+
+           /* Block length.  */
+           size += constant_size (lsize);
+           size += lsize;
+         }
          break;
        case dw_val_class_const:
          size += 4;
@@ -3321,63 +3328,64 @@ output_sleb128 (value)
   while (more);
 }
 
-/* Output the encoding of an attribute value.  */
-static void
-output_value_format (v)
+/* Select the encoding of an attribute value.  */
+static enum dwarf_form
+value_format (v)
      dw_val_ref v;
 {
-  enum dwarf_form form;
   switch (v->val_class)
     {
     case dw_val_class_addr:
-      form = DW_FORM_addr;
-      break;
+      return DW_FORM_addr;
     case dw_val_class_loc:
-      form = DW_FORM_block2;
-      break;
+      switch (constant_size (size_of_locs (v->v.val_loc)))
+       {
+       case 1:
+         return DW_FORM_block1;
+       case 2:
+         return DW_FORM_block2;
+       default:
+         abort ();
+       }
     case dw_val_class_const:
-      form = DW_FORM_data4;
-      break;
+      return DW_FORM_data4;
     case dw_val_class_unsigned_const:
       switch (constant_size (v->v.val_unsigned))
        {
        case 1:
-         form = DW_FORM_data1;
-         break;
+         return DW_FORM_data1;
        case 2:
-         form = DW_FORM_data2;
-         break;
+         return DW_FORM_data2;
        case 4:
-         form = DW_FORM_data4;
-         break;
+         return DW_FORM_data4;
        default:
          abort ();
        }
-      break;
     case dw_val_class_double_const:
-      form = DW_FORM_data8;
-      break;
+      return DW_FORM_data8;
     case dw_val_class_flag:
-      form = DW_FORM_flag;
-      break;
+      return DW_FORM_flag;
     case dw_val_class_die_ref:
-      form = DW_FORM_ref;
-      break;
+      return DW_FORM_ref;
     case dw_val_class_fde_ref:
-      form = DW_FORM_data;
-      break;
+      return DW_FORM_data;
     case dw_val_class_lbl_id:
-      form = DW_FORM_addr;
-      break;
+      return DW_FORM_addr;
     case dw_val_class_section_offset:
-      form = DW_FORM_data;
-      break;
+      return DW_FORM_data;
     case dw_val_class_str:
-      form = DW_FORM_string;
-      break;
+      return DW_FORM_string;
     default:
       abort ();
     }
+}
+
+/* Output the encoding of an attribute value.  */
+static void
+output_value_format (v)
+     dw_val_ref v;
+{
+  enum dwarf_form form = value_format (v);
   output_uleb128 (form);
   if (flag_verbose_asm)
     {
@@ -3604,14 +3612,19 @@ output_die (die)
                                       a->dw_attr_val.v.val_addr);
          break;
        case dw_val_class_loc:
-         size = 0;
-         for (loc = a->dw_attr_val.v.val_loc; loc != NULL;
-              loc = loc->dw_loc_next)
+         size = size_of_locs (a->dw_attr_val.v.val_loc);
+         /* Output the block length for this list of location operations.  */
+         switch (constant_size (size))
            {
-             size += size_of_loc_descr (loc);
+           case 1:
+             ASM_OUTPUT_DWARF_DATA1 (asm_out_file, size);
+             break;
+           case 2:
+             ASM_OUTPUT_DWARF_DATA2 (asm_out_file, size);
+             break;
+           default:
+             abort ();
            }
-         /* Output the block length for this list of location operations.  */
-         ASM_OUTPUT_DWARF_DATA2 (asm_out_file, size);
          if (flag_verbose_asm)
            {
              fprintf (asm_out_file, "\t%s %s",
index 87b67d01af3b1e5840a2bc4c36ed0d8720a5ab98..c1ea559665aabb8d06e6a12d7690d16b053a7d1c 100644 (file)
@@ -2077,13 +2077,18 @@ location_attribute (rtl)
    (See the `bit_offset_attribute' function below.)  */
 
 static void
-data_member_location_attribute (decl)
-     register tree decl;
+data_member_location_attribute (t)
+     register tree t;
 {
-  register unsigned object_offset_in_bytes = field_byte_offset (decl);
+  register unsigned object_offset_in_bytes;
   char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
   char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
 
+  if (TREE_CODE (t) == TREE_VEC)
+    object_offset_in_bytes = TREE_INT_CST_LOW (BINFO_OFFSET (t));
+  else
+    object_offset_in_bytes = field_byte_offset (t);
+
   ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_location);
   sprintf (begin_label, LOC_BEGIN_LABEL_FMT, current_dienum);
   sprintf (end_label, LOC_END_LABEL_FMT, current_dienum);
@@ -3579,6 +3584,33 @@ output_string_type_die (arg)
   string_length_attribute (TYPE_MAX_VALUE (TYPE_DOMAIN (type)));
 }
 
+static void
+output_inheritance_die (arg)
+     register void *arg;
+{
+  register tree binfo = arg;
+
+  ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_inheritance);
+  sibling_attribute ();
+  type_attribute (BINFO_TYPE (binfo), 0, 0);
+  data_member_location_attribute (binfo);
+  if (TREE_VIA_VIRTUAL (binfo))
+    {
+      ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_virtual);
+      ASM_OUTPUT_DWARF_STRING (asm_out_file, "");
+    }
+  if (TREE_VIA_PUBLIC (binfo))
+    {
+      ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_public);
+      ASM_OUTPUT_DWARF_STRING (asm_out_file, "");
+    }
+  else if (TREE_VIA_PROTECTED (binfo))
+    {
+      ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_protected);
+      ASM_OUTPUT_DWARF_STRING (asm_out_file, "");
+    }
+}  
+
 static void
 output_structure_type_die (arg)
      register void *arg;
@@ -4184,10 +4216,21 @@ output_type (type, containing_scope)
 
        if (TYPE_SIZE (type))
          {
+           /* First output info about the base classes.  */
+           if (TYPE_BINFO (type) && TYPE_BINFO_BASETYPES (type))
+             {
+               register tree bases = TYPE_BINFO_BASETYPES (type);
+               register int n_bases = TREE_VEC_LENGTH (bases);
+               register int i;
+
+               for (i = 0; i < n_bases; i++)
+                 output_die (output_inheritance_die, TREE_VEC_ELT (bases, i));
+             }
+
            {
              register tree normal_member;
 
-             /* First output info about the data members and type members.  */
+             /* Now output info about the data members and type members.  */
 
              for (normal_member = TYPE_FIELDS (type);
                   normal_member;