This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFA] 64-bit range types in GDB


AdaCore has been using the following patch for some months now to extend
the representation of types in GDB so as to allow 64-bit values in range
types.  It required doing some violence to struct main_type, unfortunately,
but as a side effect, the representation of range types is a bit less of an
abuse of abstraction (IMHO, anyway).  I apologize to those of you who will
have to modify your type-manipulation routines in .gdbinit files.

Tested on Linux and Sparc Solaris 10 without regressions.

Paul Hilfinger
Consultant, AdaCore, Inc.

ChangeLog:

2009-12-04  Paul N. Hilfinger  <hilfinger@adacore.com>

	* dwarf2read.c (struct attribute): Increase sizes of unsnd and snd 
	fields to allow larger integer sizes.
	(read_subrange_type): Increase size of bound values.
	Add logic to determine signedness based on base-type size, signedness.
	(read_attribute_value): Change format for bad byte size in message.
	(read_8_bytes): Increase size of result type.
	(dump_die_shallow): Change format for value.
	(dwarf2_get_attr_constant_value): Increase size of return type.
	Correct comment.
	(fixup_range_type_hack): New function.
	* gdbtypes.c (create_range_type): Change API to increase size of 
	bounds. struct field -> union field.
	Always take signedness from base type.
	(check_typedef): Use new API for TYPE_LOW_BOUND, TYPE_HIGH_BOUND.
	(recursive_dump_type, copy_type_recursive): Adjust to new 
	representation of range types.
	* gdbtypes.h (fields_or_bounds): New union containing struct field and
	new struct range_bounds, used for range types.
	(TYPE_RANGE_DATA): New macro to access range_bounds member.
	(TYPE_LOW_BOUND, TYPE_HIGH_BOUND): Represent with new TYPE_RANGE_DATA.
	(TYPE_LOW_BOUND_UNDEFINED, TYPE_HIGH_BOUND_UNDEFINED): New macros,
	taking over the job of TYPE_FIELD_ARTIFICIAL for range bounds.
	(SET_TYPE_LOW_BOUND, SET_TYPE_HIGH_BOUND, SET_TYPE_LOW_BOUND_DEFINED)
	(SET_TYPE_HIGH_BOUND_DEFINED): New macros.
	(TYPE_FIELDS, TYPE_BASECLASS, TYPE_BASECLASS_NAME, TYPE_FIELD)
	(TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED)
	(TYPE_ARRAY_LOWER_BOUND_IS_UNDEFINED, TYPE_ARRAY_UPPER_BOUND_VALUE)
	(TYPE_ARRAY_LOWER_BOUND_VALUE):	Adjust to new representation.
	(create_range_type): Adjust API.
	* ada-lang.c (ada_modulus): Use new extended bound values.
	(discrete_type_low_bound): Rename to...
	(ada_discrete_type_low_bound): ... and make external.
	(discrete_type_high_bound): Rename to...
	(ada_discrete_type_high_bound): ... and make external.
	(ada_value_slice_from_ptr, ada_array_bound_from_type)
	(ada_evaluate_subexp, to_fixed_range_type): 
	Use ada_discrete_type_low_bound, ada_discrete_type_high_bound.
	* ada-typeprint.c (print_range): Use ada_discrete_type_low_bound,
	ada_discrete_type_high_bound.  Don't look at field count, which 
	is no longer meaningful.  Print bounds whenever argument is a range
	or enumeration.
	* ada-lang.h (ada_discrete_type_low_bound,ada_discrete_type_high_bound):
	Declare.
	* varobj.c (c_describe_child): Adjust to render larger values.
	* mdebugread.c (parse_type): Use proper abstractions for range types:
	TYPE_RANGE_DATA, SET_TYPE_LOW_BOUND_DEFINED,
	SET_TYPE_HIGH_BOUND_DEFINED.
	* p-typeprint.c (pascal_type_print_varspec_prefix): Use larger format
	for bounds.



diff -upr old/gdb/ada-lang.c new/gdb/ada-lang.c
--- old/gdb/ada-lang.c	2009-12-02 11:29:41.000000000 -0800
+++ new/gdb/ada-lang.c	2009-12-03 22:51:40.000000000 -0800
@@ -597,8 +597,8 @@ min_of_type (struct type *t)
 }
 
 /* The largest value in the domain of TYPE, a discrete type, as an integer.  */
-static LONGEST
-discrete_type_high_bound (struct type *type)
+LONGEST
+ada_discrete_type_high_bound (struct type *type)
 {
   switch (TYPE_CODE (type))
     {
@@ -612,13 +612,13 @@ discrete_type_high_bound (struct type *t
     case TYPE_CODE_INT:
       return max_of_type (type);
     default:
-      error (_("Unexpected type in discrete_type_high_bound."));
+      error (_("Unexpected type in ada_discrete_type_high_bound."));
     }
 }
 
 /* The largest value in the domain of TYPE, a discrete type, as an integer.  */
-static LONGEST
-discrete_type_low_bound (struct type *type)
+LONGEST
+ada_discrete_type_low_bound (struct type *type)
 {
   switch (TYPE_CODE (type))
     {
@@ -632,7 +632,7 @@ discrete_type_low_bound (struct type *ty
     case TYPE_CODE_INT:
       return min_of_type (type);
     default:
-      error (_("Unexpected type in discrete_type_low_bound."));
+      error (_("Unexpected type in ada_discrete_type_low_bound."));
     }
 }
 
@@ -2399,7 +2399,7 @@ ada_value_slice_from_ptr (struct value *
                           int low, int high)
 {
   CORE_ADDR base = value_as_address (array_ptr)
-    + ((low - TYPE_LOW_BOUND (TYPE_INDEX_TYPE (type)))
+    + ((low - ada_discrete_type_low_bound (TYPE_INDEX_TYPE (type)))
        * TYPE_LENGTH (TYPE_TARGET_TYPE (type)));
   struct type *index_type =
     create_range_type (NULL, TYPE_TARGET_TYPE (TYPE_INDEX_TYPE (type)),
@@ -2542,7 +2542,6 @@ static LONGEST
 ada_array_bound_from_type (struct type * arr_type, int n, int which)
 {
   struct type *type, *elt_type, *index_type_desc, *index_type;
-  LONGEST retval;
   int i;
 
   gdb_assert (which == 0 || which == 1);
@@ -2569,22 +2568,10 @@ ada_array_bound_from_type (struct type *
   else
     index_type = TYPE_INDEX_TYPE (elt_type);
 
-  switch (TYPE_CODE (index_type))
-    {
-    case TYPE_CODE_RANGE:
-      retval = which == 0 ? TYPE_LOW_BOUND (index_type)
-			  : TYPE_HIGH_BOUND (index_type);
-      break;
-    case TYPE_CODE_ENUM:
-      retval = which == 0 ? TYPE_FIELD_BITPOS (index_type, 0)
-			  : TYPE_FIELD_BITPOS (index_type,
-					       TYPE_NFIELDS (index_type) - 1);
-      break;
-    default:
-      internal_error (__FILE__, __LINE__, _("invalid type code of index type"));
-    }
-
-  return retval;
+  return
+    (LONGEST) (which == 0
+               ? ada_discrete_type_low_bound (index_type)
+               : ada_discrete_type_high_bound (index_type));
 }
 
 /* Given that arr is an array value, returns the lower bound of the
@@ -9262,10 +9249,10 @@ ada_evaluate_subexp (struct type *expect
                 error (_("unexpected attribute encountered"));
               case OP_ATR_FIRST:
 		return value_from_longest 
-		  (range_type, discrete_type_low_bound (range_type));
+		  (range_type, ada_discrete_type_low_bound (range_type));
               case OP_ATR_LAST:
                 return value_from_longest
-		  (range_type, discrete_type_high_bound (range_type));
+		  (range_type, ada_discrete_type_high_bound (range_type));
               case OP_ATR_LENGTH:
                 error (_("the 'length attribute applies only to array types"));
               }
@@ -9839,14 +9826,14 @@ to_fixed_range_type (char *name, struct 
   subtype_info = strstr (name, "___XD");
   if (subtype_info == NULL)
     {
-      LONGEST L = discrete_type_low_bound (raw_type);
-      LONGEST U = discrete_type_high_bound (raw_type);
+      LONGEST L = ada_discrete_type_low_bound (raw_type);
+      LONGEST U = ada_discrete_type_high_bound (raw_type);
       if (L < INT_MIN || U > INT_MAX)
 	return raw_type;
       else
 	return create_range_type (alloc_type_copy (orig_type), raw_type,
-				  discrete_type_low_bound (raw_type),
-				  discrete_type_high_bound (raw_type));
+				  ada_discrete_type_low_bound (raw_type),
+				  ada_discrete_type_high_bound (raw_type));
     }
   else
     {
@@ -9972,20 +9959,7 @@ ada_modulus_from_name (struct type *type
 ULONGEST
 ada_modulus (struct type *type)
 {
-  ULONGEST modulus;
-
-  /* Normally, the modulus of a modular type is equal to the value of
-     its upper bound + 1.  However, the upper bound is currently stored
-     as an int, which is not always big enough to hold the actual bound
-     value.  To workaround this, try to take advantage of the encoding
-     that GNAT uses with with discrete types.  To avoid some unnecessary
-     parsing, we do this only when the size of TYPE is greater than
-     the size of the field holding the bound.  */
-  if (TYPE_LENGTH (type) > sizeof (TYPE_HIGH_BOUND (type))
-      && ada_modulus_from_name (type, &modulus))
-    return modulus;
-
-  return (ULONGEST) (unsigned int) TYPE_HIGH_BOUND (type) + 1;
+  return (ULONGEST) TYPE_HIGH_BOUND (type) + 1;
 }
 
 
diff -upr old/gdb/ada-lang.h new/gdb/ada-lang.h
--- old/gdb/ada-lang.h	2009-11-19 14:42:48.000000000 -0800
+++ new/gdb/ada-lang.h	2009-12-03 22:51:40.000000000 -0800
@@ -199,6 +199,10 @@ extern int ada_is_array_descriptor_type 
 
 extern int ada_is_bogus_array_descriptor (struct type *);
 
+extern LONGEST ada_discrete_type_low_bound (struct type *);
+
+extern LONGEST ada_discrete_type_high_bound (struct type *);
+
 extern char *ada_decode_symbol (const struct general_symbol_info*);
 
 extern const char *ada_decode (const char*);
diff -upr old/gdb/ada-typeprint.c new/gdb/ada-typeprint.c
--- old/gdb/ada-typeprint.c	2009-11-19 14:42:48.000000000 -0800
+++ new/gdb/ada-typeprint.c	2009-12-03 22:51:40.000000000 -0800
@@ -114,53 +114,32 @@ decoded_type_name (struct type *type)
     }
 }
 
-/* Print range type TYPE on STREAM.  */
+/* Print TYPE on STREAM, preferably as a range.  */
 
 static void
 print_range (struct type *type, struct ui_file *stream)
 {
-  struct type *target_type;
-  target_type = TYPE_TARGET_TYPE (type);
-  if (target_type == NULL)
-    target_type = type;
-
-  switch (TYPE_CODE (target_type))
+  switch (TYPE_CODE (type))
     {
     case TYPE_CODE_RANGE:
-    case TYPE_CODE_INT:
-    case TYPE_CODE_BOOL:
-    case TYPE_CODE_CHAR:
     case TYPE_CODE_ENUM:
+      {
+	struct type *target_type;
+	target_type = TYPE_TARGET_TYPE (type);
+	if (target_type == NULL)
+	  target_type = type;
+	ada_print_scalar (target_type, ada_discrete_type_low_bound (type),
+			  stream);
+	fprintf_filtered (stream, " .. ");
+	ada_print_scalar (target_type, ada_discrete_type_high_bound (type),
+			  stream);
+      }
       break;
     default:
-      target_type = NULL;
-      break;
-    }
-
-  if (TYPE_NFIELDS (type) < 2)
-    {
-      /* A range needs at least 2 bounds to be printed.  If there are less
-         than 2, just print the type name instead of the range itself.
-         This check handles cases such as characters, for example.
-
-         If the name is not defined, then we don't print anything.
-       */
       fprintf_filtered (stream, "%.*s",
 			ada_name_prefix_len (TYPE_NAME (type)),
 			TYPE_NAME (type));
-    }
-  else
-    {
-      /* We extract the range type bounds respectively from the first element
-         and the last element of the type->fields array */
-      const LONGEST lower_bound = (LONGEST) TYPE_LOW_BOUND (type);
-      const LONGEST upper_bound = (TYPE_CODE (type) == TYPE_CODE_RANGE
-	? (LONGEST) TYPE_HIGH_BOUND (type)
-	: (LONGEST) TYPE_FIELD_BITPOS (type, TYPE_NFIELDS (type) - 1));
-
-      ada_print_scalar (target_type, lower_bound, stream);
-      fprintf_filtered (stream, " .. ");
-      ada_print_scalar (target_type, upper_bound, stream);
+      break;
     }
 }
 
diff -upr old/gdb/dwarf2read.c new/gdb/dwarf2read.c
--- old/gdb/dwarf2read.c	2009-12-02 03:44:35.000000000 -0800
+++ new/gdb/dwarf2read.c	2009-12-03 22:51:40.000000000 -0800
@@ -549,8 +549,8 @@ struct attribute
       {
 	char *str;
 	struct dwarf_block *blk;
-	unsigned long unsnd;
-	long int snd;
+	ULONGEST unsnd;
+	LONGEST snd;
 	CORE_ADDR addr;
 	struct signatured_type *signatured_type;
       }
@@ -1065,7 +1065,7 @@ static int is_ref_attr (struct attribute
 
 static unsigned int dwarf2_get_ref_die_offset (struct attribute *);
 
-static int dwarf2_get_attr_constant_value (struct attribute *, int);
+static LONGEST dwarf2_get_attr_constant_value (struct attribute *, int);
 
 static struct die_info *follow_die_ref_or_sig (struct die_info *,
 					       struct attribute *,
@@ -6032,6 +6032,42 @@ read_base_type (struct die_info *die, st
   return set_die_type (die, type, cu);
 }
 
+/* Fix the RANGE_TYPE flags if we think they are incorrect.
+   This is a temporary (?) hack to work around problems with handling 
+   of >32bit range types on older compilers. On pure 32-bit hosts, 
+   the compiler does not always emit the bounds as expected. 
+   FIXME: pnh/2009-08-05. */
+ 
+static void
+fixup_range_type_hack (struct type *range_type, struct die_info *die,
+                       struct dwarf2_cu *cu)
+{
+  struct attribute *low_attr = dwarf2_attr (die, DW_AT_lower_bound, cu);
+  struct attribute *high_attr = dwarf2_attr (die, DW_AT_upper_bound, cu);
+
+  LONGEST low = TYPE_LOW_BOUND (range_type);
+  LONGEST high = TYPE_HIGH_BOUND (range_type);
+
+  /* If no bounds are provided, then chances are that the compiler
+     failed to emit these bounds.  In this case, we can't use the
+     (default) lower bound to determine whether the range type is
+     signed or unsigned.  Use the base type instead.  */
+  if (low_attr == NULL && high_attr == NULL)
+    TYPE_UNSIGNED (range_type) =
+      TYPE_UNSIGNED (TYPE_TARGET_TYPE (range_type));
+
+  /* If the size of the low bound is 4 bytes, and it is significantly
+   * larger than the high bound, guess that bit 32 is the sign bit. */
+  else if (low_attr != NULL && low_attr->form == DW_FORM_data4
+	   && low > high + 1)
+    {
+      TYPE_UNSIGNED (range_type) = 0;
+      TYPE_LOW_BOUND (range_type) = low - ((LONGEST) 1 << 32);
+      if (high >= ((LONGEST) 1) << 31)
+	TYPE_HIGH_BOUND (range_type) = high - ((LONGEST) 1 << 32);
+    }
+}
+
 /* Read the given DW_AT_subrange DIE.  */
 
 static struct type *
@@ -6041,9 +6077,10 @@ read_subrange_type (struct die_info *die
   struct type *base_type;
   struct type *range_type;
   struct attribute *attr;
-  int low = 0;
-  int high = -1;
+  LONGEST low = 0;
+  LONGEST high = -1;
   char *name;
+  LONGEST negative_mask;
   
   base_type = die_type (die, cu);
   if (TYPE_CODE (base_type) == TYPE_CODE_VOID)
@@ -6090,6 +6127,13 @@ read_subrange_type (struct die_info *die
         high = dwarf2_get_attr_constant_value (attr, 1);
     }
 
+  negative_mask = 
+    (LONGEST) -1 << (TYPE_LENGTH (base_type) * TARGET_CHAR_BIT - 1);
+  if (!TYPE_UNSIGNED (base_type) && (low & negative_mask))
+    low |= negative_mask;
+  if (!TYPE_UNSIGNED (base_type) && (high & negative_mask))
+    high |= negative_mask;
+
   range_type = create_range_type (NULL, base_type, low, high);
 
   name = dwarf2_name (die, cu);
@@ -7127,8 +7171,8 @@ read_attribute_value (struct attribute *
     {
       complaint
         (&symfile_complaints,
-         _("Suspicious DW_AT_byte_size value treated as zero instead of 0x%lx"),
-         DW_UNSND (attr));
+         _("Suspicious DW_AT_byte_size value treated as zero instead of 0x%llx"),
+         (long long) DW_UNSND (attr));
       DW_UNSND (attr) = 0;
     }
 
@@ -10107,7 +10151,8 @@ dump_die_shallow (struct ui_file *f, int
 	case DW_FORM_data8:
 	case DW_FORM_udata:
 	case DW_FORM_sdata:
-	  fprintf_unfiltered (f, "constant: %ld", DW_UNSND (&die->attrs[i]));
+	  fprintf_unfiltered (f, "constant: %lld",
+			      (long long) DW_UNSND (&die->attrs[i]));
 	  break;
 	case DW_FORM_sig8:
 	  if (DW_SIGNATURED_TYPE (&die->attrs[i]) != NULL)
@@ -10230,10 +10275,10 @@ dwarf2_get_ref_die_offset (struct attrib
   return 0;
 }
 
-/* Return the constant value held by the given attribute.  Return -1
-   if the value held by the attribute is not constant.  */
+/* Return the constant value held by ATTR.  Return DEFAULT_VALUE if
+ * the value held by the attribute is not constant.  */
 
-static int
+static LONGEST
 dwarf2_get_attr_constant_value (struct attribute *attr, int default_value)
 {
   if (attr->form == DW_FORM_sdata)
diff -upr old/gdb/gdbtypes.c new/gdb/gdbtypes.c
--- old/gdb/gdbtypes.c	2009-11-12 11:47:25.000000000 -0800
+++ new/gdb/gdbtypes.c	2009-12-03 22:51:40.000000000 -0800
@@ -711,7 +711,7 @@ allocate_stub_method (struct type *type)
 
 struct type *
 create_range_type (struct type *result_type, struct type *index_type,
-		   int low_bound, int high_bound)
+		   LONGEST low_bound, LONGEST high_bound)
 {
   if (result_type == NULL)
     result_type = alloc_type_copy (index_type);
@@ -721,10 +721,8 @@ create_range_type (struct type *result_t
     TYPE_TARGET_STUB (result_type) = 1;
   else
     TYPE_LENGTH (result_type) = TYPE_LENGTH (check_typedef (index_type));
-  TYPE_NFIELDS (result_type) = 2;
-  TYPE_FIELDS (result_type) = TYPE_ZALLOC (result_type,
-					   TYPE_NFIELDS (result_type)
-					   * sizeof (struct field));
+  TYPE_RANGE_DATA (result_type) = (struct range_bounds *)
+    TYPE_ZALLOC (result_type, sizeof (struct range_bounds));
   TYPE_LOW_BOUND (result_type) = low_bound;
   TYPE_HIGH_BOUND (result_type) = high_bound;
 
@@ -1476,14 +1474,14 @@ check_typedef (struct type *type)
 	     number of elements and the target type's length.
 	     Watch out for Ada null Ada arrays where the high bound
 	     is smaller than the low bound.  */
-	  const int low_bound = TYPE_LOW_BOUND (range_type);
-	  const int high_bound = TYPE_HIGH_BOUND (range_type);
+	  const LONGEST low_bound = TYPE_LOW_BOUND (range_type);
+	  const LONGEST high_bound = TYPE_HIGH_BOUND (range_type);
 	  int nb_elements;
 	
 	  if (high_bound < low_bound)
 	    nb_elements = 0;
 	  else
-	    nb_elements = high_bound - low_bound + 1;
+	    nb_elements = (int) (high_bound - low_bound + 1);
 	
 	  TYPE_LENGTH (type) = nb_elements * TYPE_LENGTH (target_type);
 	  TYPE_TARGET_STUB (type) = 0;
@@ -2737,6 +2735,14 @@ recursive_dump_type (struct type *type, 
 	  recursive_dump_type (TYPE_FIELD_TYPE (type, idx), spaces + 4);
 	}
     }
+  if (TYPE_CODE (type) == TYPE_CODE_RANGE)
+    {
+      printfi_filtered (spaces, "low %lld%s  high %lld%s\n",
+			(long long) TYPE_LOW_BOUND (type), 
+			TYPE_LOW_BOUND_UNDEFINED (type) ? " (undefined)" : "",
+			(long long) TYPE_HIGH_BOUND (type),
+			TYPE_HIGH_BOUND_UNDEFINED (type) ? " (undefined)" : "");
+    }
   printfi_filtered (spaces, "vptr_basetype ");
   gdb_print_host_address (TYPE_VPTR_BASETYPE (type), gdb_stdout);
   puts_filtered ("\n");
@@ -2925,6 +2931,13 @@ copy_type_recursive (struct objfile *obj
 	}
     }
 
+  /* For range types, copy the bounds information. */
+  if (TYPE_CODE (type) == TYPE_CODE_RANGE)
+    {
+      TYPE_RANGE_DATA (new_type) = xmalloc (sizeof (struct range_bounds));
+      *TYPE_RANGE_DATA (new_type) = *TYPE_RANGE_DATA (type);
+    }
+
   /* Copy pointers to other types.  */
   if (TYPE_TARGET_TYPE (type))
     TYPE_TARGET_TYPE (new_type) = 
diff -upr old/gdb/gdbtypes.h new/gdb/gdbtypes.h
--- old/gdb/gdbtypes.h	2009-11-12 11:47:25.000000000 -0800
+++ new/gdb/gdbtypes.h	2009-12-03 22:51:40.000000000 -0800
@@ -447,61 +447,87 @@ struct main_type
      because we can allocate the space for a type before
      we know what to put in it.  */
 
-  struct field
+  union 
   {
-    union field_location
+    struct field
     {
-      /* Position of this field, counting in bits from start of
-	 containing structure.
-	 For gdbarch_bits_big_endian=1 targets, it is the bit offset to the MSB.
-	 For gdbarch_bits_big_endian=0 targets, it is the bit offset to the LSB.
-	 For a range bound or enum value, this is the value itself. */
+      union field_location
+      {
+	/* Position of this field, counting in bits from start of
+	   containing structure.
+	   For gdbarch_bits_big_endian=1 targets, it is the bit offset to the MSB.
+	   For gdbarch_bits_big_endian=0 targets, it is the bit offset to the LSB.
+	   For a range bound or enum value, this is the value itself. */
+
+	int bitpos;
+
+	/* For a static field, if TYPE_FIELD_STATIC_HAS_ADDR then physaddr
+	   is the location (in the target) of the static field.
+	   Otherwise, physname is the mangled label of the static field. */
+
+	CORE_ADDR physaddr;
+	char *physname;
+
+	/* The field location can be computed by evaluating the following DWARF
+	   block.  This can be used in Fortran variable-length arrays, for
+	   instance.  */
+
+	struct dwarf2_locexpr_baton *dwarf_block;
+      }
+      loc;
+
+      /* For a function or member type, this is 1 if the argument is marked
+	 artificial.  Artificial arguments should not be shown to the
+	 user.  For TYPE_CODE_RANGE it is set if the specific bound is not
+	 defined.  */
+      unsigned int artificial : 1;
+
+      /* Discriminant for union field_location.  */
+      ENUM_BITFIELD(field_loc_kind) loc_kind : 2;
+
+      /* Size of this field, in bits, or zero if not packed.
+	 If non-zero in an array type, indicates the element size in
+	 bits (used only in Ada at the moment).
+	 For an unpacked field, the field's type's length
+	 says how many bytes the field occupies.  */
 
-      int bitpos;
+      unsigned int bitsize : 29;
 
-      /* For a static field, if TYPE_FIELD_STATIC_HAS_ADDR then physaddr
-	 is the location (in the target) of the static field.
-	 Otherwise, physname is the mangled label of the static field. */
+      /* In a struct or union type, type of this field.
+	 In a function or member type, type of this argument.
+	 In an array type, the domain-type of the array.  */
 
-      CORE_ADDR physaddr;
-      char *physname;
+      struct type *type;
 
-      /* The field location can be computed by evaluating the following DWARF
-	 block.  This can be used in Fortran variable-length arrays, for
-	 instance.  */
+      /* Name of field, value or argument.
+	 NULL for range bounds, array domains, and member function
+	 arguments.  */
 
-      struct dwarf2_locexpr_baton *dwarf_block;
-    }
-    loc;
+      char *name;
+    } *fields;
 
-    /* For a function or member type, this is 1 if the argument is marked
-       artificial.  Artificial arguments should not be shown to the
-       user.  For TYPE_CODE_RANGE it is set if the specific bound is not
-       defined.  */
-    unsigned int artificial : 1;
+    /* Union member used for range types. */
 
-    /* Discriminant for union field_location.  */
-    ENUM_BITFIELD(field_loc_kind) loc_kind : 2;
+    struct range_bounds {
 
-    /* Size of this field, in bits, or zero if not packed.
-       For an unpacked field, the field's type's length
-       says how many bytes the field occupies.  */
+      /* Low bound of range. */
 
-    unsigned int bitsize : 29;
+      LONGEST low;
 
-    /* In a struct or union type, type of this field.
-       In a function or member type, type of this argument.
-       In an array type, the domain-type of the array.  */
+      /* High bound of range. */
 
-    struct type *type;
+      LONGEST high;
 
-    /* Name of field, value or argument.
-       NULL for range bounds, array domains, and member function
-       arguments.  */
+      /* Flags indicating whether the values of low and high are
+         valid.  When true, the respective range value is
+         undefined.  Currently used only for FORTRAN arrays.  */
+           
+      char low_undefined;
+      char high_undefined;
 
-    char *name;
+    } *bounds;
 
-  } *fields;
+  } flds_bnds;
 
   /* For types with virtual functions (TYPE_CODE_STRUCT), VPTR_BASETYPE
      is the base class which defined the virtual function table pointer.  
@@ -828,19 +854,24 @@ extern void allocate_cplus_struct_type (
    type, you need to do TYPE_CODE (check_type (this_type)). */
 #define TYPE_CODE(thistype) TYPE_MAIN_TYPE(thistype)->code
 #define TYPE_NFIELDS(thistype) TYPE_MAIN_TYPE(thistype)->nfields
-#define TYPE_FIELDS(thistype) TYPE_MAIN_TYPE(thistype)->fields
+#define TYPE_FIELDS(thistype) TYPE_MAIN_TYPE(thistype)->flds_bnds.fields
 #define TYPE_TEMPLATE_ARGS(thistype) TYPE_CPLUS_SPECIFIC(thistype)->template_args
 
 #define TYPE_INDEX_TYPE(type) TYPE_FIELD_TYPE (type, 0)
-#define TYPE_LOW_BOUND(range_type) TYPE_FIELD_BITPOS (range_type, 0)
-#define TYPE_HIGH_BOUND(range_type) TYPE_FIELD_BITPOS (range_type, 1)
+#define TYPE_RANGE_DATA(thistype) TYPE_MAIN_TYPE(thistype)->flds_bnds.bounds
+#define TYPE_LOW_BOUND(range_type) TYPE_RANGE_DATA(range_type)->low
+#define TYPE_HIGH_BOUND(range_type) TYPE_RANGE_DATA(range_type)->high
+#define TYPE_LOW_BOUND_UNDEFINED(range_type) \
+   TYPE_RANGE_DATA(range_type)->low_undefined
+#define TYPE_HIGH_BOUND_UNDEFINED(range_type) \
+   TYPE_RANGE_DATA(range_type)->high_undefined
 
 /* Moto-specific stuff for FORTRAN arrays */
 
 #define TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED(arraytype) \
-   (TYPE_FIELD_ARTIFICIAL(TYPE_INDEX_TYPE((arraytype)),1))
+   TYPE_HIGH_BOUND_UNDEFINED(TYPE_INDEX_TYPE(arraytype))
 #define TYPE_ARRAY_LOWER_BOUND_IS_UNDEFINED(arraytype) \
-   (TYPE_FIELD_ARTIFICIAL(TYPE_INDEX_TYPE((arraytype)),0))
+   TYPE_LOW_BOUND_UNDEFINED(TYPE_INDEX_TYPE(arraytype))
 
 #define TYPE_ARRAY_UPPER_BOUND_VALUE(arraytype) \
    (TYPE_HIGH_BOUND(TYPE_INDEX_TYPE((arraytype))))
@@ -862,9 +893,9 @@ extern void allocate_cplus_struct_type (
 #define TYPE_CPLUS_SPECIFIC(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.cplus_stuff
 #define TYPE_FLOATFORMAT(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.floatformat
 #define TYPE_CALLING_CONVENTION(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.calling_convention
-#define TYPE_BASECLASS(thistype,index) TYPE_MAIN_TYPE(thistype)->fields[index].type
+#define TYPE_BASECLASS(thistype,index) TYPE_FIELD_TYPE(thistype, index)
 #define TYPE_N_BASECLASSES(thistype) TYPE_CPLUS_SPECIFIC(thistype)->n_baseclasses
-#define TYPE_BASECLASS_NAME(thistype,index) TYPE_MAIN_TYPE(thistype)->fields[index].name
+#define TYPE_BASECLASS_NAME(thistype,index) TYPE_FIELD_NAME(thistype, index)
 #define TYPE_BASECLASS_BITPOS(thistype,index) TYPE_FIELD_BITPOS(thistype,index)
 #define BASETYPE_VIA_PUBLIC(thistype, index) \
   ((!TYPE_FIELD_PRIVATE(thistype, index)) && (!TYPE_FIELD_PROTECTED(thistype, index)))
@@ -896,7 +927,7 @@ extern void allocate_cplus_struct_type (
 #define FIELD_ARTIFICIAL(thisfld) ((thisfld).artificial)
 #define FIELD_BITSIZE(thisfld) ((thisfld).bitsize)
 
-#define TYPE_FIELD(thistype, n) TYPE_MAIN_TYPE(thistype)->fields[n]
+#define TYPE_FIELD(thistype, n) TYPE_MAIN_TYPE(thistype)->flds_bnds.fields[n]
 #define TYPE_FIELD_TYPE(thistype, n) FIELD_TYPE(TYPE_FIELD(thistype, n))
 #define TYPE_FIELD_NAME(thistype, n) FIELD_NAME(TYPE_FIELD(thistype, n))
 #define TYPE_FIELD_LOC_KIND(thistype, n) FIELD_LOC_KIND (TYPE_FIELD (thistype, n))
@@ -1227,8 +1258,8 @@ extern struct type *make_function_type (
 
 extern struct type *lookup_function_type (struct type *);
 
-extern struct type *create_range_type (struct type *, struct type *, int,
-				       int);
+extern struct type *create_range_type (struct type *, struct type *, LONGEST,
+				       LONGEST);
 
 extern struct type *create_array_type (struct type *, struct type *,
 				       struct type *);
diff -upr old/gdb/mdebugread.c new/gdb/mdebugread.c
--- old/gdb/mdebugread.c	2009-11-16 10:40:22.000000000 -0800
+++ new/gdb/mdebugread.c	2009-12-03 22:51:40.000000000 -0800
@@ -1743,13 +1743,12 @@ parse_type (int fd, union aux_ext *ax, u
   /* Deal with range types */
   if (t->bt == btRange)
     {
-      TYPE_NFIELDS (tp) = 2;
-      TYPE_FIELDS (tp) = ((struct field *)
-			  TYPE_ALLOC (tp, 2 * sizeof (struct field)));
-      TYPE_FIELD_NAME (tp, 0) = "Low";
+      TYPE_NFIELDS (tp) = 0;
+      TYPE_RANGE_DATA (tp) = ((struct range_bounds *)
+			  TYPE_ALLOC (tp, sizeof (struct range_bounds)));
+      memset (TYPE_RANGE_DATA (tp), 0, sizeof (struct range_bounds));
       TYPE_LOW_BOUND (tp) = AUX_GET_DNLOW (bigend, ax);
       ax++;
-      TYPE_FIELD_NAME (tp, 1) = "High";
       TYPE_HIGH_BOUND (tp) = AUX_GET_DNHIGH (bigend, ax);
       ax++;
     }
diff -upr old/gdb/p-typeprint.c new/gdb/p-typeprint.c
--- old/gdb/p-typeprint.c	2009-07-02 05:16:56.000000000 -0700
+++ new/gdb/p-typeprint.c	2009-12-03 22:51:40.000000000 -0800
@@ -267,10 +267,9 @@ pascal_type_print_varspec_prefix (struct
       fprintf_filtered (stream, "array ");
       if (TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0
 	&& !TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (type))
-	fprintf_filtered (stream, "[%d..%d] ",
-			  TYPE_ARRAY_LOWER_BOUND_VALUE (type),
-			  TYPE_ARRAY_UPPER_BOUND_VALUE (type)
-	  );
+	fprintf_filtered (stream, "[%lld..%lld] ",
+			  (long long) TYPE_ARRAY_LOWER_BOUND_VALUE (type),
+			  (long long) TYPE_ARRAY_UPPER_BOUND_VALUE (type));
       fprintf_filtered (stream, "of ");
       break;
 
diff -upr old/gdb/varobj.c new/gdb/varobj.c
--- old/gdb/varobj.c	2009-11-12 11:47:25.000000000 -0800
+++ new/gdb/varobj.c	2009-12-03 22:51:40.000000000 -0800
@@ -2793,8 +2793,9 @@ c_describe_child (struct varobj *parent,
     {
     case TYPE_CODE_ARRAY:
       if (cname)
-	*cname = xstrprintf ("%d", index
-			     + TYPE_LOW_BOUND (TYPE_INDEX_TYPE (type)));
+	*cname = xstrdup (int_string (index 
+				      + TYPE_LOW_BOUND (TYPE_INDEX_TYPE (type)),
+				      10, 1, 0, 0));
 
       if (cvalue && value)
 	{
@@ -2806,9 +2807,11 @@ c_describe_child (struct varobj *parent,
 	*ctype = get_target_type (type);
 
       if (cfull_expression)
-	*cfull_expression = xstrprintf ("(%s)[%d]", parent_expression, 
-					index
-					+ TYPE_LOW_BOUND (TYPE_INDEX_TYPE (type)));
+	*cfull_expression = 
+	  xstrprintf ("(%s)[%s]", parent_expression, 
+		      int_string (index
+				  + TYPE_LOW_BOUND (TYPE_INDEX_TYPE (type)),
+				  10, 1, 0, 0));
 
 
       break;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]