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;
}
set_value_component_location (result, val);
set_value_bitsize (result, value_bitsize (val));
set_value_bitpos (result, value_bitpos (val));
- VALUE_ADDRESS (result) += value_offset (val);
+ set_value_address (result, value_address (val));
if (value_lazy (val)
|| TYPE_LENGTH (type) > TYPE_LENGTH (value_type (val)))
set_value_lazy (result, 1);
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)),
- VALUE_ADDRESS (val) + value_offset (val));
+ return value_from_longest (data_type, value_address (val));
}
/* True iff TYPE indicates a "thick" array pointer type. */
if (TYPE_CODE (type) == TYPE_CODE_PTR)
addr = value_as_long (arr);
else
- addr = VALUE_ADDRESS (arr) + value_offset (arr);
+ addr = value_address (arr);
return
value_from_longest (lookup_pointer_type (bounds_type),
}
/* 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. */
else if (VALUE_LVAL (obj) == lval_memory && value_lazy (obj))
{
v = value_at (type,
- VALUE_ADDRESS (obj) + value_offset (obj) + offset);
+ value_address (obj) + offset);
bytes = (unsigned char *) alloca (len);
- read_memory (VALUE_ADDRESS (v), bytes, len);
+ read_memory (value_address (v), bytes, len);
}
else
{
if (obj != NULL)
{
+ CORE_ADDR new_addr;
set_value_component_location (v, obj);
- VALUE_ADDRESS (v) += value_offset (obj) + offset;
+ new_addr = value_address (obj) + offset;
set_value_bitpos (v, bit_offset + value_bitpos (obj));
set_value_bitsize (v, bit_size);
if (value_bitpos (v) >= HOST_CHAR_BIT)
{
- VALUE_ADDRESS (v) += 1;
+ ++new_addr;
set_value_bitpos (v, value_bitpos (v) - HOST_CHAR_BIT);
}
+ set_value_address (v, new_addr);
}
else
set_value_bitsize (v, bit_size);
int from_size;
char *buffer = (char *) alloca (len);
struct value *val;
- CORE_ADDR to_addr = VALUE_ADDRESS (toval) + value_offset (toval);
+ CORE_ADDR to_addr = value_address (toval);
if (TYPE_CODE (type) == TYPE_CODE_FLT)
fromval = value_cast (type, fromval);
struct value *val)
{
LONGEST offset_in_container =
- (LONGEST) (VALUE_ADDRESS (component) + value_offset (component)
- - VALUE_ADDRESS (container) - value_offset (container));
+ (LONGEST) (value_address (component) - value_address (container));
int bit_offset_in_container =
value_bitpos (component) - value_bitpos (container);
int bits;
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));
(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 an lvalue containing the value VAL. This is the identity on
lvalues, and otherwise has the side-effect of pushing a copy of VAL
on the stack, using and updating *SP as the stack pointer, and
- returning an lvalue whose VALUE_ADDRESS points to the copy. */
+ returning an lvalue whose value_address points to the copy. */
static struct value *
ensure_lval (struct value *val, CORE_ADDR *sp)
indicated. */
if (gdbarch_inner_than (current_gdbarch, 1, 2))
{
- /* Stack grows downward. Align SP and VALUE_ADDRESS (val) after
+ /* Stack grows downward. Align SP and value_address (val) after
reserving sufficient space. */
*sp -= len;
if (gdbarch_frame_align_p (current_gdbarch))
*sp = gdbarch_frame_align (current_gdbarch, *sp);
- VALUE_ADDRESS (val) = *sp;
+ set_value_address (val, *sp);
}
else
{
then again, re-align the frame. */
if (gdbarch_frame_align_p (current_gdbarch))
*sp = gdbarch_frame_align (current_gdbarch, *sp);
- VALUE_ADDRESS (val) = *sp;
+ set_value_address (val, *sp);
*sp += len;
if (gdbarch_frame_align_p (current_gdbarch))
*sp = gdbarch_frame_align (current_gdbarch, *sp);
}
VALUE_LVAL (val) = lval_memory;
- write_memory (VALUE_ADDRESS (val), value_contents_raw (val), len);
+ write_memory (value_address (val), value_contents_raw (val), len);
}
return val;
bounds = ensure_lval (bounds, sp);
modify_general_field (value_contents_writeable (descriptor),
- VALUE_ADDRESS (ensure_lval (arr, sp)),
+ value_address (ensure_lval (arr, sp)),
fat_pntr_data_bitpos (desc_type),
fat_pntr_data_bitsize (desc_type));
modify_general_field (value_contents_writeable (descriptor),
- VALUE_ADDRESS (bounds),
+ value_address (bounds),
fat_pntr_bounds_bitpos (desc_type),
fat_pntr_bounds_bitsize (desc_type));
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)
{
ada_to_fixed_value (struct value *val)
{
return ada_to_fixed_value_create (value_type (val),
- VALUE_ADDRESS (val) + value_offset (val),
+ value_address (val),
val);
}
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;
}
return
coerce_unspec_val_to_type
(val, ada_to_fixed_type (raw_real_type, 0,
- VALUE_ADDRESS (val) + value_offset (val),
+ value_address (val),
NULL, 1));
}
}
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)