static int fat_pntr_bounds_bitsize (struct type *);
-static struct type *desc_data_type (struct type *);
+static struct type *desc_data_target_type (struct type *);
static struct value *desc_data (struct value *);
*, const char *, int,
domain_enum, int);
-static struct symtab *symtab_for_sym (struct symbol *);
-
static struct value *resolve_subexp (struct expression **, int *, int,
struct type *);
static char *result = NULL;
xfree (result);
- result = (char *) xmalloc ((strlen (str) + 3) * sizeof (char));
-
- sprintf (result, "<%s>", str);
+ result = xstrprintf ("<%s>", str);
return result;
}
ada_main_name (void)
{
struct minimal_symbol *msym;
- CORE_ADDR main_program_name_addr;
- static char main_program_name[1024];
+ static char *main_program_name = NULL;
/* For Ada, the name of the main procedure is stored in a specific
string constant, generated by the binder. Look for that symbol,
if (msym != NULL)
{
+ CORE_ADDR main_program_name_addr;
+ int err_code;
+
main_program_name_addr = SYMBOL_VALUE_ADDRESS (msym);
if (main_program_name_addr == 0)
error (_("Invalid address for Ada main program name."));
- extract_string (main_program_name_addr, main_program_name);
+ xfree (main_program_name);
+ target_read_string (main_program_name_addr, &main_program_name,
+ 1024, &err_code);
+
+ if (err_code != 0)
+ return NULL;
return main_program_name;
}
if (encoded[0] == '<')
strcpy (decoded, encoded);
else
- sprintf (decoded, "<%s>", encoded);
+ xsnprintf (decoded, decoding_buffer_size, "<%s>", encoded);
return decoded;
}
thin_data_pntr (struct value *val)
{
struct type *type = value_type (val);
+ struct type *data_type = desc_data_target_type (thin_descriptor_type (type));
+ data_type = lookup_pointer_type (data_type);
+
if (TYPE_CODE (type) == TYPE_CODE_PTR)
- return value_cast (desc_data_type (thin_descriptor_type (type)),
- value_copy (val));
+ return value_cast (data_type, value_copy (val));
else
- return value_from_longest (desc_data_type (thin_descriptor_type (type)),
+ return value_from_longest (data_type,
VALUE_ADDRESS (val) + value_offset (val));
}
}
/* If TYPE is the type of an array descriptor (fat or thin pointer) or a
- pointer to one, the type of its array data (a
- pointer-to-array-with-no-bounds type); otherwise, NULL. Use
- ada_type_of_array to get an array type with bounds data. */
+ pointer to one, the type of its array data (a array-with-no-bounds type);
+ otherwise, NULL. Use ada_type_of_array to get an array type with bounds
+ data. */
static struct type *
-desc_data_type (struct type *type)
+desc_data_target_type (struct type *type)
{
type = desc_base_type (type);
/* NOTE: The following is bogus; see comment in desc_bounds. */
if (is_thin_pntr (type))
- return lookup_pointer_type
- (desc_base_type (TYPE_FIELD_TYPE (thin_descriptor_type (type), 1)));
+ return desc_base_type (TYPE_FIELD_TYPE (thin_descriptor_type (type), 1));
else if (is_thick_pntr (type))
- return lookup_struct_elt_type (type, "P_ARRAY", 1);
- else
- return NULL;
+ {
+ struct type *data_type = lookup_struct_elt_type (type, "P_ARRAY", 1);
+
+ if (data_type
+ && TYPE_CODE (ada_check_typedef (data_type)) == TYPE_CODE_PTR)
+ return TYPE_TARGET_TYPE (data_type);
+ }
+
+ return NULL;
}
/* If ARR is an array descriptor (fat or thin pointer), a pointer to
int
ada_is_array_descriptor_type (struct type *type)
{
- struct type *data_type = desc_data_type (type);
+ struct type *data_type = desc_data_target_type (type);
if (type == NULL)
return 0;
type = ada_check_typedef (type);
- return
- data_type != NULL
- && ((TYPE_CODE (data_type) == TYPE_CODE_PTR
- && TYPE_TARGET_TYPE (data_type) != NULL
- && TYPE_CODE (TYPE_TARGET_TYPE (data_type)) == TYPE_CODE_ARRAY)
- || TYPE_CODE (data_type) == TYPE_CODE_ARRAY)
- && desc_arity (desc_bounds_type (type)) > 0;
+ return (data_type != NULL
+ && TYPE_CODE (data_type) == TYPE_CODE_ARRAY
+ && desc_arity (desc_bounds_type (type)) > 0);
}
/* Non-zero iff type is a partially mal-formed GNAT array
if (!bounds)
return
- ada_check_typedef (TYPE_TARGET_TYPE (desc_data_type (value_type (arr))));
+ ada_check_typedef (desc_data_target_type (value_type (arr)));
else
{
struct type *elt_type;
struct type *
ada_coerce_to_simple_array_type (struct type *type)
{
- struct value *mark = value_mark ();
- struct value *dummy = value_from_longest (builtin_type_int32, 0);
- struct type *result;
- deprecated_set_value_type (dummy, type);
- result = ada_type_of_array (dummy, 0);
- value_free_to_mark (mark);
- return result;
+ if (ada_is_packed_array_type (type))
+ return decode_packed_array_type (type);
+
+ if (ada_is_array_descriptor_type (type))
+ return ada_check_typedef (desc_data_target_type (type));
+
+ return type;
}
/* Non-zero iff TYPE represents a standard GNAT packed-array type. */
int k;
struct type *p_array_type;
- p_array_type = desc_data_type (type);
+ p_array_type = desc_data_target_type (type);
k = ada_array_arity (type);
if (k == 0)
/* Initially p_array_type = elt_type(*)[]...(k times)...[]. */
if (nindices >= 0 && k > nindices)
k = nindices;
- p_array_type = TYPE_TARGET_TYPE (p_array_type);
while (k > 0 && p_array_type != NULL)
{
p_array_type = ada_check_typedef (TYPE_TARGET_TYPE (p_array_type));
case UNOP_QUAL:
*pos += 3;
- resolve_subexp (expp, pos, 1, exp->elts[pc + 1].type);
+ resolve_subexp (expp, pos, 1, check_typedef (exp->elts[pc + 1].type));
break;
case OP_ATR_MODULUS:
(SYMBOL_CLASS (syms[i].sym) == LOC_CONST
&& SYMBOL_TYPE (syms[i].sym) != NULL
&& TYPE_CODE (SYMBOL_TYPE (syms[i].sym)) == TYPE_CODE_ENUM);
- struct symtab *symtab = symtab_for_sym (syms[i].sym);
+ struct symtab *symtab = syms[i].sym->symtab;
if (SYMBOL_LINE (syms[i].sym) != 0 && symtab != NULL)
printf_unfiltered (_("[%d] %s at %s:%d\n"),
return NULL;
}
-/* Find a symbol table containing symbol SYM or NULL if none. */
-
-static struct symtab *
-symtab_for_sym (struct symbol *sym)
-{
- struct symtab *s;
- struct objfile *objfile;
- struct block *b;
- struct symbol *tmp_sym;
- struct dict_iterator iter;
- int j;
-
- ALL_PRIMARY_SYMTABS (objfile, s)
- {
- switch (SYMBOL_CLASS (sym))
- {
- case LOC_CONST:
- case LOC_STATIC:
- case LOC_TYPEDEF:
- case LOC_REGISTER:
- case LOC_LABEL:
- case LOC_BLOCK:
- case LOC_CONST_BYTES:
- b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), GLOBAL_BLOCK);
- ALL_BLOCK_SYMBOLS (b, iter, tmp_sym) if (sym == tmp_sym)
- return s;
- b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), STATIC_BLOCK);
- ALL_BLOCK_SYMBOLS (b, iter, tmp_sym) if (sym == tmp_sym)
- return s;
- break;
- default:
- break;
- }
- switch (SYMBOL_CLASS (sym))
- {
- case LOC_REGISTER:
- case LOC_ARG:
- case LOC_REF_ARG:
- case LOC_REGPARM_ADDR:
- case LOC_LOCAL:
- case LOC_TYPEDEF:
- case LOC_COMPUTED:
- for (j = FIRST_LOCAL_BLOCK;
- j < BLOCKVECTOR_NBLOCKS (BLOCKVECTOR (s)); j += 1)
- {
- b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), j);
- ALL_BLOCK_SYMBOLS (b, iter, tmp_sym) if (sym == tmp_sym)
- return s;
- }
- break;
- default:
- break;
- }
- }
- return NULL;
-}
-
/* Return a minimal symbol matching NAME according to Ada decoding
rules. Returns NULL if there is no such minimal symbol. Names
prefixed with "standard__" are handled specially: "standard__" is
}
}
-
/* Add symbols from BLOCK matching identifier NAME in DOMAIN to
vector *defn_symbols, updating the list of symbols in OBSTACKP
(if necessary). If WILD, treat as NAME with a wildcard prefix.
return sym;
}
-/* Find a type named NAME. Ignores ambiguity. */
+/* Find a type named NAME. Ignores ambiguity. This routine will look
+ solely for types defined by debug info, it will not search the GDB
+ primitive types. */
struct type *
ada_find_any_type (const char *name)
{
struct symbol *sym = ada_find_any_symbol (name);
- struct type *type = NULL;
if (sym != NULL)
- type = SYMBOL_TYPE (sym);
+ return SYMBOL_TYPE (sym);
- if (type == NULL)
- type = language_lookup_primitive_type_by_name
- (language_def (language_ada), current_gdbarch, name);
-
- return type;
+ return NULL;
}
/* Given NAME and an associated BLOCK, search all symbols for
function_name = function_name + 5;
rename = (char *) alloca (rename_len * sizeof (char));
- sprintf (rename, "%s__%s___XR", function_name, name);
+ xsnprintf (rename, rename_len * sizeof (char), "%s__%s___XR",
+ function_name, name);
}
else
{
const int rename_len = strlen (name) + 6;
rename = (char *) alloca (rename_len * sizeof (char));
- sprintf (rename, "%s___XR", name);
+ xsnprintf (rename, rename_len * sizeof (char), "%s___XR", name);
}
return ada_find_any_symbol (rename);
int xvz_found = 0;
LONGEST size;
- sprintf (xvz_name, "%s___XVZ", name);
+ xsnprintf (xvz_name, strlen (name) + 7, "%s___XVZ", name);
size = get_int_var_value (xvz_name, &xvz_found);
if (xvz_found && TYPE_LENGTH (fixed_record_type) != size)
{
GROW_VECT (result, result_len, 16);
if (isascii (v) && isprint (v))
- sprintf (result, "'%c'", v);
+ xsnprintf (result, result_len, "'%c'", v);
else if (name[1] == 'U')
- sprintf (result, "[\"%02x\"]", v);
+ xsnprintf (result, result_len, "[\"%02x\"]", v);
else
- sprintf (result, "[\"%04x\"]", v);
+ xsnprintf (result, result_len, "[\"%04x\"]", v);
return result;
}
case UNOP_IN_RANGE:
(*pos) += 2;
arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
- type = exp->elts[pc + 1].type;
+ type = check_typedef (exp->elts[pc + 1].type);
if (noside == EVAL_SKIP)
goto nosideret;
case OP_ATR_MODULUS:
{
- struct type *type_arg = exp->elts[pc + 2].type;
+ struct type *type_arg = check_typedef (exp->elts[pc + 2].type);
evaluate_subexp (NULL_TYPE, exp, pos, EVAL_SKIP);
if (noside == EVAL_SKIP)
struct type *base_type;
char *subtype_info;
+ /* Also search primitive types if type symbol could not be found. */
+ if (raw_type == NULL)
+ raw_type = language_lookup_primitive_type_by_name
+ (language_def (language_ada), current_gdbarch, name);
+
if (raw_type == NULL)
base_type = builtin_type_int32;
else if (TYPE_CODE (raw_type) == TYPE_CODE_RANGE)