From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22925 invoked by alias); 16 Sep 2009 15:45:12 -0000 Mailing-List: contact archer-help@sourceware.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Subscribe: List-Id: Received: (qmail 22912 invoked by uid 22791); 16 Sep 2009 15:45:10 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_33,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Date: Wed, 16 Sep 2009 15:45:00 -0000 From: Jan Kratochvil To: Joost van der Sluis Cc: Project Archer Subject: Re: Patch for pascal-dynamic arrays Message-ID: <20090916154453.GA23913@host0.dyn.jankratochvil.net> References: <1252939529.28930.33.camel@wsjoost.cnoc.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1252939529.28930.33.camel@wsjoost.cnoc.lan> User-Agent: Mutt/1.5.19 (2009-01-05) X-SW-Source: 2009-q3/txt/msg00221.txt.bz2 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; }