X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=gdb%2Fada-lang.c;h=656e771e9b54c59e9311f8b800609b5153531025;hb=457395c3504d0f35f0365e9176597c1aec091f94;hp=cce7da9f0a84464db6bee26174e5ebec18e94f9b;hpb=4af8819895fd82c3bfad1163e988f9e9fdc689d6;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index cce7da9f0a..656e771e9b 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -353,9 +353,9 @@ ada_get_gdb_completer_word_break_characters (void) static void ada_print_array_index (struct value *index_value, struct ui_file *stream, - int format, enum val_prettyprint pretty) + const struct value_print_options *options) { - LA_VALUE_PRINT (index_value, stream, format, pretty); + LA_VALUE_PRINT (index_value, stream, options); fprintf_filtered (stream, " => "); } @@ -465,26 +465,6 @@ is_suffix (const char *str, const char *suffix) return (len1 >= len2 && strcmp (str + len1 - len2, suffix) == 0); } -/* Create a value of type TYPE whose contents come from VALADDR, if it - is non-null, and whose memory address (in the inferior) is - ADDRESS. */ - -struct value * -value_from_contents_and_address (struct type *type, - const gdb_byte *valaddr, - CORE_ADDR address) -{ - struct value *v = allocate_value (type); - if (valaddr == NULL) - set_value_lazy (v, 1); - else - memcpy (value_contents_raw (v), valaddr, TYPE_LENGTH (type)); - VALUE_ADDRESS (v) = address; - if (address != 0) - VALUE_LVAL (v) = lval_memory; - return v; -} - /* The contents of value VAL, treated as a value of type TYPE. The result is an lval in memory if VAL is. */ @@ -503,10 +483,10 @@ coerce_unspec_val_to_type (struct value *val, struct type *type) check_size (type); result = allocate_value (type); - VALUE_LVAL (result) = VALUE_LVAL (val); + set_value_component_location (result, val); set_value_bitsize (result, value_bitsize (val)); set_value_bitpos (result, value_bitpos (val)); - VALUE_ADDRESS (result) = VALUE_ADDRESS (val) + value_offset (val); + VALUE_ADDRESS (result) += value_offset (val); if (value_lazy (val) || TYPE_LENGTH (type) > TYPE_LENGTH (value_type (val))) set_value_lazy (result, 1); @@ -1797,11 +1777,11 @@ packed_array_type (struct type *type, long *elt_bits) new_type = alloc_type (TYPE_OBJFILE (type)); new_elt_type = packed_array_type (ada_check_typedef (TYPE_TARGET_TYPE (type)), elt_bits); - create_array_type (new_type, new_elt_type, TYPE_FIELD_TYPE (type, 0)); + create_array_type (new_type, new_elt_type, TYPE_INDEX_TYPE (type)); TYPE_FIELD_BITSIZE (new_type, 0) = *elt_bits; TYPE_NAME (new_type) = ada_type_name (type); - if (get_discrete_bounds (TYPE_FIELD_TYPE (type, 0), + if (get_discrete_bounds (TYPE_INDEX_TYPE (type), &low_bound, &high_bound) < 0) low_bound = high_bound = 0; if (high_bound < low_bound) @@ -2038,10 +2018,8 @@ ada_value_primitive_packed_val (struct value *obj, const gdb_byte *valaddr, if (obj != NULL) { - VALUE_LVAL (v) = VALUE_LVAL (obj); - if (VALUE_LVAL (obj) == lval_internalvar) - VALUE_LVAL (v) = lval_internalvar_component; - VALUE_ADDRESS (v) = VALUE_ADDRESS (obj) + value_offset (obj) + offset; + set_value_component_location (v, obj); + VALUE_ADDRESS (v) += value_offset (obj) + offset; set_value_bitpos (v, bit_offset + value_bitpos (obj)); set_value_bitsize (v, bit_size); if (value_bitpos (v) >= HOST_CHAR_BIT) @@ -2366,12 +2344,12 @@ ada_value_ptr_subscript (struct value *arr, struct type *type, int arity, } /* Given that ARRAY_PTR is a pointer or reference to an array of type TYPE (the - actual type of ARRAY_PTR is ignored), returns a reference to - the Ada slice of HIGH-LOW+1 elements starting at index LOW. The lower - bound of this array is LOW, as per Ada rules. */ + actual type of ARRAY_PTR is ignored), returns the Ada slice of HIGH-LOW+1 + elements starting at index LOW. The lower bound of this array is LOW, as + per Ada rules. */ static struct value * -ada_value_slice_ptr (struct value *array_ptr, struct type *type, - int low, int high) +ada_value_slice_from_ptr (struct value *array_ptr, struct type *type, + int low, int high) { CORE_ADDR base = value_as_address (array_ptr) + ((low - TYPE_LOW_BOUND (TYPE_INDEX_TYPE (type))) @@ -2381,7 +2359,7 @@ ada_value_slice_ptr (struct value *array_ptr, struct type *type, low, high); struct type *slice_type = create_array_type (NULL, TYPE_TARGET_TYPE (type), index_type); - return value_from_pointer (lookup_reference_type (slice_type), base); + return value_at_lazy (slice_type, base); } @@ -2488,7 +2466,7 @@ ada_index_type (struct type *type, int n) for (i = 1; i < n; i += 1) type = TYPE_TARGET_TYPE (type); - result_type = TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (type, 0)); + result_type = TYPE_TARGET_TYPE (TYPE_INDEX_TYPE (type)); /* FIXME: The stabs type r(0,0);bound;bound in an array type has a target type of TYPE_CODE_UNDEF. We compensate here, but perhaps stabsread.c would make more sense. */ @@ -2512,8 +2490,10 @@ static LONGEST ada_array_bound_from_type (struct type * arr_type, int n, int which, struct type ** typep) { - struct type *type; - struct type *index_type_desc; + struct type *type, *index_type_desc, *index_type; + LONGEST retval; + + gdb_assert (which == 0 || which == 1); if (ada_is_packed_array_type (arr_type)) arr_type = decode_packed_array_type (arr_type); @@ -2531,10 +2511,11 @@ ada_array_bound_from_type (struct type * arr_type, int n, int which, type = arr_type; index_type_desc = ada_find_parallel_type (type, "___XA"); - if (index_type_desc == NULL) + if (index_type_desc != NULL) + index_type = to_fixed_range_type (TYPE_FIELD_NAME (index_type_desc, n - 1), + NULL, TYPE_OBJFILE (arr_type)); + else { - struct type *index_type; - while (n > 1) { type = TYPE_TARGET_TYPE (type); @@ -2542,34 +2523,27 @@ ada_array_bound_from_type (struct type * arr_type, int n, int which, } index_type = TYPE_INDEX_TYPE (type); - if (typep != NULL) - *typep = index_type; - - /* The index type is either a range type or an enumerated type. - For the range type, we have some macros that allow us to - extract the value of the low and high bounds. But they - do now work for enumerated types. The expressions used - below work for both range and enum types. */ - return - (LONGEST) (which == 0 - ? TYPE_FIELD_BITPOS (index_type, 0) - : TYPE_FIELD_BITPOS (index_type, - TYPE_NFIELDS (index_type) - 1)); } - else + + switch (TYPE_CODE (index_type)) { - struct type *index_type = - to_fixed_range_type (TYPE_FIELD_NAME (index_type_desc, n - 1), - NULL, TYPE_OBJFILE (arr_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")); + } - if (typep != NULL) - *typep = index_type; + if (typep != NULL) + *typep = index_type; - return - (LONGEST) (which == 0 - ? TYPE_LOW_BOUND (index_type) - : TYPE_HIGH_BOUND (index_type)); - } + return retval; } /* Given that arr is an array value, returns the lower bound of the @@ -6198,9 +6172,7 @@ ada_index_struct_field_1 (int *index_p, struct value *arg, int offset, /* Given ARG, a value of type (pointer or reference to a)* structure/union, extract the component named NAME from the ultimate target structure/union and return it as a value with its - appropriate type. If ARG is a pointer or reference and the field - is not packed, returns a reference to the field, otherwise the - value of the field (an lvalue if ARG is an lvalue). + appropriate type. The routine searches for NAME among all members of the structure itself and (recursively) among all members of any wrapper members @@ -6277,8 +6249,7 @@ ada_value_struct_elt (struct value *arg, char *name, int no_err) field_type); } else - v = value_from_pointer (lookup_reference_type (field_type), - address + byte_offset); + v = value_at_lazy (field_type, address + byte_offset); } } @@ -8828,9 +8799,9 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp, struct type *arr_type0 = to_fixed_array_type (TYPE_TARGET_TYPE (value_type (array)), NULL, 1); - return ada_value_slice_ptr (array, arr_type0, - longest_to_int (low_bound), - longest_to_int (high_bound)); + return ada_value_slice_from_ptr (array, arr_type0, + longest_to_int (low_bound), + longest_to_int (high_bound)); } } else if (noside == EVAL_AVOID_SIDE_EFFECTS) @@ -9204,12 +9175,18 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp, arg1 = ada_coerce_ref (arg1); /* FIXME: What is this for?? */ type = ada_check_typedef (value_type (arg1)); - if (TYPE_CODE (type) == TYPE_CODE_INT && expect_type != NULL) - /* GDB allows dereferencing an int. We give it the expected - type (which will be set in the case of a coercion or - qualification). */ - return ada_value_ind (value_cast (lookup_pointer_type (expect_type), - arg1)); + if (TYPE_CODE (type) == TYPE_CODE_INT) + /* GDB allows dereferencing an int. If we were given + the expect_type, then use that as the target type. + Otherwise, assume that the target type is an int. */ + { + if (expect_type != NULL) + return ada_value_ind (value_cast (lookup_pointer_type (expect_type), + arg1)); + else + return value_at_lazy (builtin_type (exp->gdbarch)->builtin_int, + (CORE_ADDR) value_as_address (arg1)); + } if (ada_is_array_descriptor_type (type)) /* GDB allows dereferencing GNAT array descriptors. */ @@ -10100,7 +10077,10 @@ static void print_one_exception (enum exception_catchpoint_kind ex, struct breakpoint *b, CORE_ADDR *last_addr) { - if (addressprint) + struct value_print_options opts; + + get_user_print_options (&opts); + if (opts.addressprint) { annotate_field (4); ui_out_field_core_addr (uiout, "addr", b->loc->address);