* valprint.h (get_array_bounds): Change low and high parameter types
authorPierre Muller <muller@sourceware.org>
Thu, 3 Jun 2010 06:50:49 +0000 (06:50 +0000)
committerPierre Muller <muller@sourceware.org>
Thu, 3 Jun 2010 06:50:49 +0000 (06:50 +0000)
to LONGEST *.
* valprint.c (get_array_bounds): Use get_discrete_bounds call to
compute bounds.
(val_print_array_elements): Adapt to change above.
* ada-valprint.c (print_optional_low_bound): Adapt to change above.
* p-valprint.c (pascal_val_print): Likewise.

gdb/ChangeLog
gdb/ada-valprint.c
gdb/p-valprint.c
gdb/valprint.c
gdb/valprint.h

index dcb8214a88cdd000e38fa5e8c5f8eef132da71b3..e226bd16a2d5baf8597e2603afc5173afb09454f 100644 (file)
@@ -1,3 +1,13 @@
+2010-06-03  Pierre Muller  <muller@ics.u-strasbg.fr>
+
+       * valprint.h (get_array_bounds): Change low and high parameter types
+       to LONGEST *.
+       * valprint.c (get_array_bounds): Use get_discrete_bounds call to 
+       compute bounds.
+       (val_print_array_elements): Adapt to change above.
+       * ada-valprint.c (print_optional_low_bound): Adapt to change above.
+       * p-valprint.c (pascal_val_print): Likewise.
+
 2010-06-02  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
        * symfile.c (init_filename_language_table): New extensions .for, .FOR,
index c56d221bc44e0842ef38738fa792b3e2fce5b58b..7e93e3aa5331a19ba753813f9e1ca03a53ee7aee 100644 (file)
@@ -85,8 +85,8 @@ print_optional_low_bound (struct ui_file *stream, struct type *type,
                          const struct value_print_options *options)
 {
   struct type *index_type;
-  long low_bound;
-  long high_bound;
+  LONGEST low_bound;
+  LONGEST high_bound;
 
   if (options->print_array_indexes)
     return 0;
@@ -131,7 +131,7 @@ print_optional_low_bound (struct ui_file *stream, struct type *type,
       break;
     }
 
-  ada_print_scalar (index_type, (LONGEST) low_bound, stream);
+  ada_print_scalar (index_type, low_bound, stream);
   fprintf_filtered (stream, " => ");
   return 1;
 }
index 1c2f36d51bb29924f5397b16c3d5ef5cdfc21de8..e58f9d2aec3c862f4a68aaff10d369da1b8bf55a 100644 (file)
@@ -60,7 +60,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   unsigned int i = 0;  /* Number of characters printed */
   unsigned len;
-  long low_bound, high_bound;
+  LONGEST low_bound, high_bound;
   struct type *elttype;
   unsigned eltlen;
   int length_pos, length_size, string_pos;
index 517e607a85d6af4f9e218786bc89356d32cf43e9..2b06579e35432a4933c7849bb67e98e7357b7fed 100644 (file)
@@ -1034,44 +1034,27 @@ print_char_chars (struct ui_file *stream, struct type *type,
 
    Return 1 if the operation was successful. Return zero otherwise,
    in which case the values of LOW_BOUND and HIGH_BOUNDS are unmodified.
-   
-   Computing the array upper and lower bounds is pretty easy, but this
-   function does some additional verifications before returning them.
-   If something incorrect is detected, it is better to return a status
-   rather than throwing an error, making it easier for the caller to
-   implement an error-recovery plan.  For instance, it may decide to
-   warn the user that the bounds were not found and then use some
-   default values instead.  */
+  
+   We now simply use get_discrete_bounds call to get the values
+   of the low and high bounds. 
+   get_discrete_bounds can return three values:
+   1, meaning that index is a range,
+   0, meaning that index is a discrete type,
+   or -1 for failure.  */
 
 int
-get_array_bounds (struct type *type, long *low_bound, long *high_bound)
+get_array_bounds (struct type *type, LONGEST *low_bound, LONGEST *high_bound)
 {
   struct type *index = TYPE_INDEX_TYPE (type);
-  long low = 0;
-  long high = 0;
-                                  
+  LONGEST low = 0;
+  LONGEST high = 0;
+  int res;
+                                
   if (index == NULL)
     return 0;
 
-  if (TYPE_CODE (index) == TYPE_CODE_RANGE)
-    {
-      low = TYPE_LOW_BOUND (index);
-      high = TYPE_HIGH_BOUND (index);
-    }
-  else if (TYPE_CODE (index) == TYPE_CODE_ENUM)
-    {
-      const int n_enums = TYPE_NFIELDS (index);
-
-      low = TYPE_FIELD_BITPOS (index, 0);
-      high = TYPE_FIELD_BITPOS (index, n_enums - 1);
-    }
-  else
-    return 0;
-
-  /* Abort if the lower bound is greater than the higher bound, except
-     when low = high + 1.  This is a very common idiom used in Ada when
-     defining empty ranges (for instance "range 1 .. 0").  */
-  if (low > high + 1)
+  res = get_discrete_bounds (index, &low, &high);
+  if (res == -1)
     return 0;
 
   if (low_bound)
@@ -1126,7 +1109,7 @@ val_print_array_elements (struct type *type, const gdb_byte *valaddr,
   unsigned int rep1;
   /* Number of repetitions we have detected so far.  */
   unsigned int reps;
-  long low_bound_index = 0;
+  LONGEST low_bound_index = 0;
 
   elttype = TYPE_TARGET_TYPE (type);
   eltlen = TYPE_LENGTH (check_typedef (elttype));
@@ -1141,7 +1124,7 @@ val_print_array_elements (struct type *type, const gdb_byte *valaddr,
     len = TYPE_LENGTH (type) / eltlen;
   else
     {
-      long low, hi;
+      LONGEST low, hi;
 
       if (get_array_bounds (type, &low, &hi))
         len = hi - low + 1;
index 9b8004eb4d0a852270f15309dd5b23672fe55dea..070d7967af1debc64aa6c084ad268308aea77a66 100644 (file)
@@ -109,8 +109,8 @@ extern void get_raw_print_options (struct value_print_options *opts);
 extern void get_formatted_print_options (struct value_print_options *opts,
                                         char format);
 
-extern int get_array_bounds (struct type *type, long *low_bound,
-                            long *high_bound);
+extern int get_array_bounds (struct type *type, LONGEST *low_bound,
+                            LONGEST *high_bound);
 
 extern void maybe_print_array_index (struct type *index_type, LONGEST index,
                                      struct ui_file *stream,
This page took 0.035158 seconds and 4 git commands to generate.