Example #1
0
static void
ada_varobj_adjust_for_child_access (struct value **value,
				    struct type **type)
{
   /* Pointers to struct/union types are special: Instead of having
      one child (the struct), their children are the components of
      the struct/union type.  We handle this situation by dereferencing
      the (value, type) couple.  */
  if (TYPE_CODE (*type) == TYPE_CODE_PTR
      && (TYPE_CODE (TYPE_TARGET_TYPE (*type)) == TYPE_CODE_STRUCT
          || TYPE_CODE (TYPE_TARGET_TYPE (*type)) == TYPE_CODE_UNION)
      && !ada_is_array_descriptor_type (TYPE_TARGET_TYPE (*type))
      && !ada_is_constrained_packed_array_type (TYPE_TARGET_TYPE (*type)))
    ada_varobj_ind (*value, *type, value, type);

  /* If this is a tagged type, we need to transform it a bit in order
     to be able to fetch its full view.  As always with tagged types,
     we can only do that if we have a value.  */
  if (*value != NULL && ada_is_tagged_type (*type, 1))
    {
      *value = ada_tag_value_at_base_address (*value);
      *type = value_type (*value);
    }
}
Example #2
0
void
ada_print_type (struct type *type0, const char *varstring,
                struct ui_file *stream, int show, int level,
                const struct type_print_options *flags)
{
    struct type *type = ada_check_typedef (ada_get_base_type (type0));
    char *type_name = decoded_type_name (type0);
    int is_var_decl = (varstring != NULL && varstring[0] != '\0');

    if (type == NULL)
    {
        if (is_var_decl)
            fprintf_filtered (stream, "%.*s: ",
                              ada_name_prefix_len (varstring), varstring);
        fprintf_filtered (stream, "<null type?>");
        return;
    }

    if (show > 0)
        type = ada_check_typedef (type);

    if (is_var_decl && TYPE_CODE (type) != TYPE_CODE_FUNC)
        fprintf_filtered (stream, "%.*s: ",
                          ada_name_prefix_len (varstring), varstring);

    if (type_name != NULL && show <= 0 && !ada_is_aligner_type (type))
    {
        fprintf_filtered (stream, "%.*s",
                          ada_name_prefix_len (type_name), type_name);
        return;
    }

    if (ada_is_aligner_type (type))
        ada_print_type (ada_aligned_type (type), "", stream, show, level, flags);
    else if (ada_is_constrained_packed_array_type (type)
             && TYPE_CODE (type) != TYPE_CODE_PTR)
        print_array_type (type, stream, show, level, flags);
    else
        switch (TYPE_CODE (type))
        {
        default:
            fprintf_filtered (stream, "<");
            c_print_type (type, "", stream, show, level, flags);
            fprintf_filtered (stream, ">");
            break;
        case TYPE_CODE_PTR:
        case TYPE_CODE_TYPEDEF:
            fprintf_filtered (stream, "access ");
            ada_print_type (TYPE_TARGET_TYPE (type), "", stream, show, level,
                            flags);
            break;
        case TYPE_CODE_REF:
            fprintf_filtered (stream, "<ref> ");
            ada_print_type (TYPE_TARGET_TYPE (type), "", stream, show, level,
                            flags);
            break;
        case TYPE_CODE_ARRAY:
            print_array_type (type, stream, show, level, flags);
            break;
        case TYPE_CODE_BOOL:
            fprintf_filtered (stream, "(false, true)");
            break;
        case TYPE_CODE_INT:
            if (ada_is_fixed_point_type (type))
                print_fixed_point_type (type, stream);
            else
            {
                const char *name = ada_type_name (type);

                if (!ada_is_range_type_name (name))
                    fprintf_filtered (stream, _("<%d-byte integer>"),
                                      TYPE_LENGTH (type));
                else
                {
                    fprintf_filtered (stream, "range ");
                    print_range_type (type, stream);
                }
            }
            break;
        case TYPE_CODE_RANGE:
            if (ada_is_fixed_point_type (type))
                print_fixed_point_type (type, stream);
            else if (ada_is_modular_type (type))
                fprintf_filtered (stream, "mod %s",
                                  int_string (ada_modulus (type), 10, 0, 0, 1));
            else
            {
                fprintf_filtered (stream, "range ");
                print_range (type, stream);
            }
            break;
        case TYPE_CODE_FLT:
            fprintf_filtered (stream, _("<%d-byte float>"), TYPE_LENGTH (type));
            break;
        case TYPE_CODE_ENUM:
            if (show < 0)
                fprintf_filtered (stream, "(...)");
            else
                print_enum_type (type, stream);
            break;
        case TYPE_CODE_STRUCT:
            if (ada_is_array_descriptor_type (type))
                print_array_type (type, stream, show, level, flags);
            else if (ada_is_bogus_array_descriptor (type))
                fprintf_filtered (stream,
                                  _("array (?) of ? (<mal-formed descriptor>)"));
            else
                print_record_type (type, stream, show, level, flags);
            break;
        case TYPE_CODE_UNION:
            print_unchecked_union_type (type, stream, show, level, flags);
            break;
        case TYPE_CODE_FUNC:
            print_func_type (type, stream, varstring, flags);
            break;
        }
}
Example #3
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;
    }
}
Example #4
0
static void
print_array_type (struct type *type, struct ui_file *stream, int show,
                  int level, const struct type_print_options *flags)
{
    int bitsize;
    int n_indices;

    if (ada_is_constrained_packed_array_type (type))
        type = ada_coerce_to_simple_array_type (type);

    bitsize = 0;
    fprintf_filtered (stream, "array (");

    if (type == NULL)
    {
        fprintf_filtered (stream, _("<undecipherable array type>"));
        return;
    }

    n_indices = -1;
    if (ada_is_simple_array_type (type))
    {
        struct type *range_desc_type;
        struct type *arr_type;

        range_desc_type = ada_find_parallel_type (type, "___XA");
        ada_fixup_array_indexes_type (range_desc_type);

        bitsize = 0;
        if (range_desc_type == NULL)
        {
            for (arr_type = type; TYPE_CODE (arr_type) == TYPE_CODE_ARRAY;
                    arr_type = TYPE_TARGET_TYPE (arr_type))
            {
                if (arr_type != type)
                    fprintf_filtered (stream, ", ");
                print_range (TYPE_INDEX_TYPE (arr_type), stream);
                if (TYPE_FIELD_BITSIZE (arr_type, 0) > 0)
                    bitsize = TYPE_FIELD_BITSIZE (arr_type, 0);
            }
        }
        else
        {
            int k;

            n_indices = TYPE_NFIELDS (range_desc_type);
            for (k = 0, arr_type = type;
                    k < n_indices;
                    k += 1, arr_type = TYPE_TARGET_TYPE (arr_type))
            {
                if (k > 0)
                    fprintf_filtered (stream, ", ");
                print_range_type (TYPE_FIELD_TYPE (range_desc_type, k),
                                  stream);
                if (TYPE_FIELD_BITSIZE (arr_type, 0) > 0)
                    bitsize = TYPE_FIELD_BITSIZE (arr_type, 0);
            }
        }
    }
    else
    {
        int i, i0;

        for (i = i0 = ada_array_arity (type); i > 0; i -= 1)
            fprintf_filtered (stream, "%s<>", i == i0 ? "" : ", ");
    }

    fprintf_filtered (stream, ") of ");
    wrap_here ("");
    ada_print_type (ada_array_element_type (type, n_indices), "", stream,
                    show == 0 ? 0 : show - 1, level + 1, flags);
    if (bitsize > 0)
        fprintf_filtered (stream, " <packed: %d-bit elements>", bitsize);
}