This is the mail archive of the archer@sourceware.org mailing list for the Archer 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]

Re: Patch for pascal-dynamic arrays


On Mon, 14 Sep 2009 16:45:29 +0200, Joost van der Sluis wrote:
> Attached is the patch I have so far, including some tests.

Please fix it so that it builds with -O2 -Wall -Werror, it also does not
follow the GNU coding style (such as space after a function name).

Then also please check regressions of the testsuite - `make -C gdb check' and
comparing gdb.sum before/after the patch.

I had to do some of these fixes but it has too many regressions.


Thanks,
Jan


--- ./gdb/ada-valprint.c	2009-07-02 19:25:52.000000000 +0200
+++ ./gdb/ada-valprint.c	2009-09-15 13:51:35.000000000 +0200
@@ -90,7 +90,8 @@ print_optional_low_bound (struct ui_file
   if (options->print_array_indexes)
     return 0;
 
-  if (!get_array_bounds (type, &low_bound, &high_bound))
+gdb_assert (0);	/* type vs. val */
+  if (!get_array_bounds (NULL, &low_bound, &high_bound))
     return 0;
 
   /* If this is an empty array, then don't print the lower bound.
--- ./gdb/valprint.c	2009-09-15 13:30:39.000000000 +0200
+++ ./gdb/valprint.c	2009-09-15 13:46:25.000000000 +0200
@@ -1035,7 +1035,7 @@ print_char_chars (struct ui_file *stream
 int
 get_array_bounds (struct value *val, long *low_bound, long *high_bound)
 {
-  struct type *index = TYPE_INDEX_TYPE (value_type(val));
+  struct type *index = TYPE_INDEX_TYPE (value_type (val));
   long low = 0;
   long high = 0;
                                   
@@ -1130,16 +1130,17 @@ val_print_array_elements (struct type *t
 
   /* Always use the bounds to calculate the amount of
      elements in the array.  */
-  long low, hi;
-  if (get_array_bounds (val, &low, &hi))
-    {
+  {
+    long low, hi;
+
+    if (get_array_bounds (val, &low, &hi))
       len = hi - low + 1;
-    }
-  else
-    {
-      warning (_("unable to get bounds of array, assuming null array"));
-      len = 0;
-    }
+    else
+      {
+	warning (_("unable to get bounds of array, assuming null array"));
+	len = 0;
+      }
+  }
 
   /* Get the array low bound.  This only makes sense if the array
      has one or more element in it.  */
@@ -1182,9 +1183,14 @@ val_print_array_elements (struct type *t
       /* Set object_address to the address of the element and create a
          new, clean value to pass to common_val_print, so that all dyanic
          properties are handled correctly. */
-      struct value *element_value;
-      element_value = value_at_lazy(TYPE_TARGET_TYPE (type), data_address(val) + i * stride);
-      common_val_print(element_value,stream,recurse +1, options, current_language);
+      {
+	struct value *element_value;
+
+	element_value = value_at_lazy (TYPE_TARGET_TYPE (type),
+				       data_address (val) + i * stride);
+	common_val_print (element_value, stream, recurse + 1, options,
+			  current_language);
+      }
 
       if (reps > options->repeat_count_threshold)
 	{
--- ./gdb/value.c	2009-09-15 13:30:39.000000000 +0200
+++ ./gdb/value.c	2009-09-15 13:48:51.000000000 +0200
@@ -41,6 +41,7 @@
 #include "valprint.h"
 #include "cli/cli-decode.h"
 #include "observer.h"
+#include "dwarf2loc.h"
 
 #include "python/python.h"
 
@@ -627,7 +628,7 @@ value_length_get (struct value *value, i
   count = VALUE_UPPER_BOUND (value) - VALUE_LOWER_BOUND (value) + 1;
   /* It may happen for wrong DWARF annotations returning garbage data.  */
   if (count < 0)
-    warning (_("Range for type %s has invalid bounds %d..%d"),
+    warning (_("Range for type %s has invalid bounds %ld..%ld"),
              TYPE_NAME (type), VALUE_LOWER_BOUND (value),
              VALUE_UPPER_BOUND (value));
   /* The code below does not handle count == 0 right.  */
@@ -645,7 +646,7 @@ value_length_get (struct value *value, i
       byte_stride = TYPE_BYTE_STRIDE (range_type);
       if (byte_stride == 0)
         {
-          if (data_address(value)==NULL)
+          if (data_address (value) == 0)
             {
               if (target_type == NULL)
                 target_type = check_typedef (TYPE_TARGET_TYPE (type));
@@ -719,7 +720,6 @@ get_bound (struct type *type, int i)
             {
               case FIELD_LOC_KIND_BITPOS:
                 return TYPE_FIELD_BITPOS (index, i);
-                break;
               case FIELD_LOC_KIND_DWARF_BLOCK:
                 if (TYPE_NOT_ALLOCATED (index)
                   || TYPE_NOT_ASSOCIATED (index))
@@ -736,6 +736,8 @@ get_bound (struct type *type, int i)
             }
         }
     }
+  /* NOTREACHED */
+  return -1;
 }
 
 void
@@ -747,23 +749,24 @@ check_value_dynamics (struct value *valu
      fixed properly later */
   //if (!(&value->checked_dynamics))
     {
-      if (!(value_address (value) == NULL))
+      if (value_address (value) != 0)
         {
-          /* In allocate_value memory is allocated before value_address is set. To make this possible,
-             object_address is set. So we do not have to do this here anymore...
-           */
+	  /* In allocate_value memory is allocated before value_address is set.
+	     To make this possible, object_address is set.  So we do not have
+	     to do this here anymore...  */
+
           object_address_set (value_address (value));
         }
-      set_value_lower_bound(value,get_bound (value_type(value),0));
-      set_value_upper_bound(value,get_bound (value_type(value),1));
-      value->checked_dynamics=1;
+      set_value_lower_bound (value, get_bound (value_type (value), 0));
+      set_value_upper_bound (value, get_bound (value_type (value), 1));
+      value->checked_dynamics = 1;
     }
 }
 
 long *
 deprecated_value_lower_bound_hack (struct value *value)
 {
-  check_value_dynamics(value);
+  check_value_dynamics (value);
   return &value->lower_bound;
 }
 
@@ -776,7 +779,7 @@ set_value_lower_bound (struct value *val
 long *
 deprecated_value_upper_bound_hack (struct value *value)
 {
-  check_value_dynamics(value);
+  check_value_dynamics (value);
   return &value->upper_bound;
 }
 


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