Exemplo n.º 1
0
struct value *
value_subscripted_rvalue (struct value *array, LONGEST index, int lowerbound)
{
  struct type *array_type = check_typedef (value_type (array));
  struct type *elt_type = check_typedef (TYPE_TARGET_TYPE (array_type));
  ULONGEST elt_size = type_length_units (elt_type);
  ULONGEST elt_offs = elt_size * (index - lowerbound);

  if (index < lowerbound
      || (!TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (array_type)
          && elt_offs >= type_length_units (array_type))
      || (VALUE_LVAL (array) != lval_memory
          && TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (array_type)))
    {
      if (type_not_associated (array_type))
        error (_("no such vector element (vector not associated)"));
      else if (type_not_allocated (array_type))
        error (_("no such vector element (vector not allocated)"));
      else
        error (_("no such vector element"));
    }

  if (is_dynamic_type (elt_type))
    {
      CORE_ADDR address;

      address = value_address (array) + elt_offs;
      elt_type = resolve_dynamic_type (elt_type, NULL, address);
    }

  return value_from_component (array, elt_type, elt_offs);
}
Exemplo n.º 2
0
static void
ada_val_print_1 (struct type *type,
		 int offset, CORE_ADDR address,
		 struct ui_file *stream, int recurse,
		 struct value *original_value,
		 const struct value_print_options *options,
		 const struct language_defn *language)
{
  int offset_aligned;
  const gdb_byte *valaddr = value_contents_for_printing (original_value);

  type = ada_check_typedef (type);

  if (ada_is_array_descriptor_type (type)
      || (ada_is_constrained_packed_array_type (type)
	  && TYPE_CODE (type) != TYPE_CODE_PTR))
    {
      ada_val_print_gnat_array (type, valaddr, offset, address,
				stream, recurse, original_value,
				options, language);
      return;
    }

  offset_aligned = offset + ada_aligned_value_addr (type, valaddr) - valaddr;
  type = printable_val_type (type, valaddr + offset_aligned);
  type = resolve_dynamic_type (type, valaddr + offset_aligned,
			       address + offset_aligned);

  switch (TYPE_CODE (type))
    {
    default:
      val_print (type, offset, address, stream, recurse,
		 original_value, options, language_def (language_c));
      break;

    case TYPE_CODE_PTR:
      ada_val_print_ptr (type, valaddr, offset, offset_aligned,
			 address, stream, recurse, original_value,
			 options, language);
      break;

    case TYPE_CODE_INT:
    case TYPE_CODE_RANGE:
      ada_val_print_num (type, valaddr, offset, offset_aligned,
			 address, stream, recurse, original_value,
			 options, language);
      break;

    case TYPE_CODE_ENUM:
      ada_val_print_enum (type, valaddr, offset, offset_aligned,
			  address, stream, recurse, original_value,
			  options, language);
      break;

    case TYPE_CODE_FLT:
      ada_val_print_flt (type, valaddr, offset, offset_aligned,
			 address, stream, recurse, original_value,
			 options, language);
      break;

    case TYPE_CODE_UNION:
    case TYPE_CODE_STRUCT:
      ada_val_print_struct_union (type, valaddr, offset, offset_aligned,
				  address, stream, recurse,
				  original_value, options, language);
      break;

    case TYPE_CODE_ARRAY:
      ada_val_print_array (type, valaddr, offset, offset_aligned,
			   address, stream, recurse, original_value,
			   options);
      return;

    case TYPE_CODE_REF:
      ada_val_print_ref (type, valaddr, offset, offset_aligned,
			 address, stream, recurse, original_value,
			 options, language);
      break;
    }
}