Change regcache list to be an hash map
[deliverable/binutils-gdb.git] / gdb / valprint.c
index 17d091d613117857afa36923eedc2d73854e92f2..db98ca2abc986a84d6bc5ac3468a9f18fbdfe5d6 100644 (file)
@@ -298,7 +298,7 @@ val_print_scalar_or_string_type_p (struct type *type,
                                   const struct language_defn *language)
 {
   return (val_print_scalar_type_p (type)
-         || language->la_is_string_type_p (type));
+         || language->is_string_type_p (type));
 }
 
 /* See its definition in value.h.  */
@@ -781,19 +781,15 @@ generic_value_print_char (struct value *value, struct ui_file *stream,
 /* generic_val_print helper for TYPE_CODE_FLT and TYPE_CODE_DECFLOAT.  */
 
 static void
-generic_val_print_float (struct type *type,
-                        int embedded_offset, struct ui_file *stream,
+generic_val_print_float (struct type *type, struct ui_file *stream,
                         struct value *original_value,
                         const struct value_print_options *options)
 {
-  struct gdbarch *gdbarch = get_type_arch (type);
-  int unit_size = gdbarch_addressable_memory_unit_size (gdbarch);
-
   gdb_assert (!options->format);
 
   const gdb_byte *valaddr = value_contents_for_printing (original_value);
 
-  print_floating (valaddr + embedded_offset * unit_size, type, stream);
+  print_floating (valaddr, type, stream);
 }
 
 /* generic_value_print helper for TYPE_CODE_COMPLEX.  */
@@ -896,8 +892,7 @@ generic_value_print (struct value *val, struct ui_file *stream, int recurse,
       if (options->format)
        value_print_scalar_formatted (val, options, 0, stream);
       else
-       generic_val_print_float (type, 0, stream,
-                                val, options);
+       generic_val_print_float (type, stream, val, options);
       break;
 
     case TYPE_CODE_VOID:
@@ -984,7 +979,7 @@ do_val_print (struct value *value, struct ui_file *stream, int recurse,
 
   try
     {
-      language->la_value_print_inner (value, stream, recurse, &local_opts);
+      language->value_print_inner (value, stream, recurse, &local_opts);
     }
   catch (const gdb_exception_error &except)
     {
@@ -1144,7 +1139,7 @@ val_print_type_code_flags (struct type *type, struct value *original_value,
     {
       if (TYPE_FIELD_NAME (type, field)[0] != '\0')
        {
-         struct type *field_type = TYPE_FIELD_TYPE (type, field);
+         struct type *field_type = type->field (field).type ();
 
          if (field_type == bool_type
              /* We require boolean types here to be one bit wide.  This is a
@@ -1851,14 +1846,10 @@ maybe_print_array_index (struct type *index_type, LONGEST index,
                          struct ui_file *stream,
                         const struct value_print_options *options)
 {
-  struct value *index_value;
-
   if (!options->print_array_indexes)
     return; 
     
-  index_value = value_from_longest (index_type, index);
-
-  LA_PRINT_ARRAY_INDEX (index_value, stream, options);
+  LA_PRINT_ARRAY_INDEX (index_type, index, stream, options);
 }
 
 /* See valprint.h.  */
@@ -1871,7 +1862,7 @@ value_print_array_elements (struct value *val, struct ui_file *stream,
 {
   unsigned int things_printed = 0;
   unsigned len;
-  struct type *elttype, *index_type, *base_index_type;
+  struct type *elttype, *index_type;
   unsigned eltlen;
   /* Position of the array element we are examining to see
      whether it is repeated.  */
@@ -1879,43 +1870,26 @@ value_print_array_elements (struct value *val, struct ui_file *stream,
   /* Number of repetitions we have detected so far.  */
   unsigned int reps;
   LONGEST low_bound, high_bound;
-  LONGEST low_pos, high_pos;
 
   struct type *type = check_typedef (value_type (val));
 
   elttype = TYPE_TARGET_TYPE (type);
   eltlen = type_length_units (check_typedef (elttype));
-  index_type = TYPE_INDEX_TYPE (type);
+  index_type = type->index_type ();
+  if (index_type->code () == TYPE_CODE_RANGE)
+    index_type = TYPE_TARGET_TYPE (index_type);
 
   if (get_array_bounds (type, &low_bound, &high_bound))
     {
-      if (index_type->code () == TYPE_CODE_RANGE)
-       base_index_type = TYPE_TARGET_TYPE (index_type);
-      else
-       base_index_type = index_type;
-
-      /* Non-contiguous enumerations types can by used as index types
-        in some languages (e.g. Ada).  In this case, the array length
-        shall be computed from the positions of the first and last
-        literal in the enumeration type, and not from the values
-        of these literals.  */
-      if (!discrete_position (base_index_type, low_bound, &low_pos)
-         || !discrete_position (base_index_type, high_bound, &high_pos))
-       {
-         warning (_("unable to get positions in array, use bounds instead"));
-         low_pos = low_bound;
-         high_pos = high_bound;
-       }
-
-      /* The array length should normally be HIGH_POS - LOW_POS + 1.
-         But we have to be a little extra careful, because some languages
-        such as Ada allow LOW_POS to be greater than HIGH_POS for
-        empty arrays.  In that situation, the array length is just zero,
-        not negative!  */
-      if (low_pos > high_pos)
+      /* The array length should normally be HIGH_BOUND - LOW_BOUND +
+         1.  But we have to be a little extra careful, because some
+         languages such as Ada allow LOW_BOUND to be greater than
+         HIGH_BOUND for empty arrays.  In that situation, the array
+         length is just zero, not negative!  */
+      if (low_bound > high_bound)
        len = 0;
       else
-       len = high_pos - low_pos + 1;
+       len = high_bound - low_bound + 1;
     }
   else
     {
@@ -2053,13 +2027,7 @@ partial_memory_read (CORE_ADDR memaddr, gdb_byte *myaddr,
 
    Unless an exception is thrown, BUFFER will always be allocated, even on
    failure.  In this case, some characters might have been read before the
-   failure happened.  Check BYTES_READ to recognize this situation.
-
-   Note: There was a FIXME asking to make this code use target_read_string,
-   but this function is more general (can read past null characters, up to
-   given LEN).  Besides, it is used much more often than target_read_string
-   so it is more tested.  Perhaps callers of target_read_string should use
-   this function instead?  */
+   failure happened.  Check BYTES_READ to recognize this situation.  */
 
 int
 read_string (CORE_ADDR addr, int len, int width, unsigned int fetchlimit,
This page took 0.024254 seconds and 4 git commands to generate.