(get_objfile_arch): Add prototype.
* objfiles.c: Include "arch-utils.h".
(allocate_objfile): Look up gdbarch associated with bfd.
(get_objfile_arch): New function.
* Makefile (objfiles.o): Update dependencies.
* dwarf2-frame.c (decode_frame_entry_1): Replace current_gdbarch
by objfile arch.
* dwarf2loc.c (dwarf_expr_read_reg): Replace current_gdbarch
by frame arch.
(locexpr_describe_location): Replace current_gdbarch by
objfile arch.
* dwarf2read.c (die_type): Replace current_gdbarch by objfile arch.
(dwarf2_add_field): Likewise.
(read_tag_pointer_type): Likewise.
(read_base_type): Likewise.
(new_symbol): Likewise.
* coffread.c (decode_type): Add OBJFILE argument. Update callers.
(decode_base_type, decode_function_type): Likewise.
(coff_read_struct_type, coff_read_enum_type): Likewise.
(coff_symtab_read): Replace current_gdbarch by objfile arch.
(decode_base_type): Likewise.
(coff_read_enum_type): Likewise.
(coff_read_struct_type): Replace current_objfile by OBJFILE argument.
(coff_read_enum_type): Likewise.
* dbxread.c (read_dbx_symtab): Replace current_gdbarch by objfile arch.
(end_psymtab): Likewise.
(process_one_symbol): Likewise.
* mdebugread.c (parse_symbol): Replace current_gdbarch by objfile arch.
(parse_procedure): Likewise.
(parse_partial_symbols): Likewise.
* somread.c (som_symtab_read): Replace current_gdbarch by objfile arch.
* stabsread.c (define_symbol): Replace current_gdbarch by objfile arch.
Replace static pcc_promotion_type and pcc_unsigned_promotion_type by
built-in types.
(read_range_type): Replace current_gdbarch by objfile arch. Replace
static range_index_type by built-in type.
(read_one_struct_field): Replace current_gdbarch by objfile arch.
(read_enum_type): Likewise.
* xcoffread.c (read_xcoff_symtab): Replace current_gdbarch by
objfile arch.
+2008-03-26 Ulrich Weigand <uweigand@de.ibm.com>
+
+ * objfiles.h (struct objfile): New GDBARCH member.
+ (get_objfile_arch): Add prototype.
+ * objfiles.c: Include "arch-utils.h".
+ (allocate_objfile): Look up gdbarch associated with bfd.
+ (get_objfile_arch): New function.
+ * Makefile (objfiles.o): Update dependencies.
+
+ * dwarf2-frame.c (decode_frame_entry_1): Replace current_gdbarch
+ by objfile arch.
+ * dwarf2loc.c (dwarf_expr_read_reg): Replace current_gdbarch
+ by frame arch.
+ (locexpr_describe_location): Replace current_gdbarch by
+ objfile arch.
+ * dwarf2read.c (die_type): Replace current_gdbarch by objfile arch.
+ (dwarf2_add_field): Likewise.
+ (read_tag_pointer_type): Likewise.
+ (read_base_type): Likewise.
+ (new_symbol): Likewise.
+
+ * coffread.c (decode_type): Add OBJFILE argument. Update callers.
+ (decode_base_type, decode_function_type): Likewise.
+ (coff_read_struct_type, coff_read_enum_type): Likewise.
+ (coff_symtab_read): Replace current_gdbarch by objfile arch.
+ (decode_base_type): Likewise.
+ (coff_read_enum_type): Likewise.
+ (coff_read_struct_type): Replace current_objfile by OBJFILE argument.
+ (coff_read_enum_type): Likewise.
+
+ * dbxread.c (read_dbx_symtab): Replace current_gdbarch by objfile arch.
+ (end_psymtab): Likewise.
+ (process_one_symbol): Likewise.
+
+ * mdebugread.c (parse_symbol): Replace current_gdbarch by objfile arch.
+ (parse_procedure): Likewise.
+ (parse_partial_symbols): Likewise.
+
+ * somread.c (som_symtab_read): Replace current_gdbarch by objfile arch.
+
+ * stabsread.c (define_symbol): Replace current_gdbarch by objfile arch.
+ Replace static pcc_promotion_type and pcc_unsigned_promotion_type by
+ built-in types.
+ (read_range_type): Replace current_gdbarch by objfile arch. Replace
+ static range_index_type by built-in type.
+ (read_one_struct_field): Replace current_gdbarch by objfile arch.
+ (read_enum_type): Likewise.
+
+ * xcoffread.c (read_xcoff_symtab): Replace current_gdbarch by
+ objfile arch.
+
2008-03-26 Vladimir Prus <vladimir@codesourcery.com>
* varobj.h (varobj_floating_p): Declare.
$(objfiles_h) $(gdb_stabs_h) $(target_h) $(bcache_h) $(mdebugread_h) \
$(gdb_assert_h) $(gdb_stat_h) $(gdb_obstack_h) $(gdb_string_h) \
$(hashtab_h) $(breakpoint_h) $(block_h) $(dictionary_h) $(source_h) \
- $(parser_defs_h) $(expression_h) $(addrmap_h)
+ $(parser_defs_h) $(expression_h) $(addrmap_h) $(arch_utils_h)
observer.o: observer.c $(defs_h) $(observer_h) $(command_h) $(gdbcmd_h) \
$(observer_inc)
obsd-tdep.o: obsd-tdep.c $(defs_h) $(frame_h) $(symtab_h) $(obsd_tdep_h)
extern void stabsread_clear_cache (void);
-static struct type *coff_read_struct_type (int, int, int);
+static struct type *coff_read_struct_type (int, int, int,
+ struct objfile *);
static struct type *decode_base_type (struct coff_symbol *,
- unsigned int, union internal_auxent *);
+ unsigned int, union internal_auxent *,
+ struct objfile *);
static struct type *decode_type (struct coff_symbol *, unsigned int,
- union internal_auxent *);
+ union internal_auxent *,
+ struct objfile *);
static struct type *decode_function_type (struct coff_symbol *,
unsigned int,
- union internal_auxent *);
+ union internal_auxent *,
+ struct objfile *);
-static struct type *coff_read_enum_type (int, int, int);
+static struct type *coff_read_enum_type (int, int, int,
+ struct objfile *);
static struct symbol *process_coff_symbol (struct coff_symbol *,
union internal_auxent *,
coff_symtab_read (long symtab_offset, unsigned int nsyms,
struct objfile *objfile)
{
+ struct gdbarch *gdbarch = get_objfile_arch (objfile);
struct context_stack *new;
struct coff_symbol coff_symbol;
struct coff_symbol *cs = &coff_symbol;
cs->c_sclass == C_EXT || cs->c_sclass == C_THUMBEXTFUNC
|| cs->c_sclass == C_THUMBEXT ?
mst_text : mst_file_text;
- tmpaddr = gdbarch_smash_text_address
- (current_gdbarch, tmpaddr);
+ tmpaddr = gdbarch_smash_text_address (gdbarch, tmpaddr);
}
else if (bfd_section->flags & SEC_ALLOC
&& bfd_section->flags & SEC_LOAD)
msym = record_minimal_symbol (cs, tmpaddr, ms_type, sec, objfile);
if (msym)
- gdbarch_coff_make_msymbol_special
- (current_gdbarch, cs->c_sclass, msym);
+ gdbarch_coff_make_msymbol_special (gdbarch, cs->c_sclass, msym);
if (SDB_TYPE (cs->c_type))
{
{
SYMBOL_VALUE (sym) += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
SYMBOL_TYPE (sym) =
- lookup_function_type (decode_function_type (cs, cs->c_type, aux));
+ lookup_function_type (decode_function_type (cs, cs->c_type, aux, objfile));
SYMBOL_CLASS (sym) = LOC_BLOCK;
if (cs->c_sclass == C_STAT || cs->c_sclass == C_THUMBSTAT
}
else
{
- SYMBOL_TYPE (sym) = decode_type (cs, cs->c_type, aux);
+ SYMBOL_TYPE (sym) = decode_type (cs, cs->c_type, aux, objfile);
switch (cs->c_sclass)
{
case C_NULL:
static struct type *
decode_type (struct coff_symbol *cs, unsigned int c_type,
- union internal_auxent *aux)
+ union internal_auxent *aux, struct objfile *objfile)
{
struct type *type = 0;
unsigned int new_c_type;
new_c_type = DECREF (c_type);
if (ISPTR (c_type))
{
- type = decode_type (cs, new_c_type, aux);
+ type = decode_type (cs, new_c_type, aux, objfile);
type = lookup_pointer_type (type);
}
else if (ISFCN (c_type))
{
- type = decode_type (cs, new_c_type, aux);
+ type = decode_type (cs, new_c_type, aux, objfile);
type = lookup_function_type (type);
}
else if (ISARY (c_type))
*dim = *(dim + 1);
*dim = 0;
- base_type = decode_type (cs, new_c_type, aux);
+ base_type = decode_type (cs, new_c_type, aux, objfile);
index_type = builtin_type_int32;
range_type =
create_range_type ((struct type *) NULL, index_type, 0, n - 1);
}
}
- return decode_base_type (cs, BTYPE (c_type), aux);
+ return decode_base_type (cs, BTYPE (c_type), aux, objfile);
}
/* Decode a coff type specifier for function definition;
static struct type *
decode_function_type (struct coff_symbol *cs, unsigned int c_type,
- union internal_auxent *aux)
+ union internal_auxent *aux, struct objfile *objfile)
{
if (aux->x_sym.x_tagndx.l == 0)
cs->c_naux = 0; /* auxent refers to function, not base type */
- return decode_type (cs, DECREF (c_type), aux);
+ return decode_type (cs, DECREF (c_type), aux, objfile);
}
\f
/* basic C types */
static struct type *
decode_base_type (struct coff_symbol *cs, unsigned int c_type,
- union internal_auxent *aux)
+ union internal_auxent *aux, struct objfile *objfile)
{
+ struct gdbarch *gdbarch = get_objfile_arch (objfile);
struct type *type;
switch (c_type)
{
case T_NULL:
/* shows up with "void (*foo)();" structure members */
- return builtin_type (current_gdbarch)->builtin_void;
+ return builtin_type (gdbarch)->builtin_void;
#ifdef T_VOID
case T_VOID:
/* Intel 960 COFF has this symbol and meaning. */
- return builtin_type (current_gdbarch)->builtin_void;
+ return builtin_type (gdbarch)->builtin_void;
#endif
case T_CHAR:
- return builtin_type (current_gdbarch)->builtin_char;
+ return builtin_type (gdbarch)->builtin_char;
case T_SHORT:
- return builtin_type (current_gdbarch)->builtin_short;
+ return builtin_type (gdbarch)->builtin_short;
case T_INT:
- return builtin_type (current_gdbarch)->builtin_int;
+ return builtin_type (gdbarch)->builtin_int;
case T_LONG:
if (cs->c_sclass == C_FIELD
&& aux->x_sym.x_misc.x_lnsz.x_size
- > gdbarch_long_bit (current_gdbarch))
- return builtin_type (current_gdbarch)->builtin_long_long;
+ > gdbarch_long_bit (gdbarch))
+ return builtin_type (gdbarch)->builtin_long_long;
else
- return builtin_type (current_gdbarch)->builtin_long;
+ return builtin_type (gdbarch)->builtin_long;
case T_FLOAT:
- return builtin_type (current_gdbarch)->builtin_float;
+ return builtin_type (gdbarch)->builtin_float;
case T_DOUBLE:
- return builtin_type (current_gdbarch)->builtin_double;
+ return builtin_type (gdbarch)->builtin_double;
case T_LNGDBL:
- return builtin_type (current_gdbarch)->builtin_long_double;
+ return builtin_type (gdbarch)->builtin_long_double;
case T_STRUCT:
if (cs->c_naux != 1)
{
type = coff_read_struct_type (cs->c_symnum,
aux->x_sym.x_misc.x_lnsz.x_size,
- aux->x_sym.x_fcnary.x_fcn.x_endndx.l);
+ aux->x_sym.x_fcnary.x_fcn.x_endndx.l,
+ objfile);
}
return type;
{
type = coff_read_struct_type (cs->c_symnum,
aux->x_sym.x_misc.x_lnsz.x_size,
- aux->x_sym.x_fcnary.x_fcn.x_endndx.l);
+ aux->x_sym.x_fcnary.x_fcn.x_endndx.l,
+ objfile);
}
TYPE_CODE (type) = TYPE_CODE_UNION;
return type;
{
type = coff_read_enum_type (cs->c_symnum,
aux->x_sym.x_misc.x_lnsz.x_size,
- aux->x_sym.x_fcnary.x_fcn.x_endndx.l);
+ aux->x_sym.x_fcnary.x_fcn.x_endndx.l,
+ objfile);
}
return type;
break;
case T_UCHAR:
- return builtin_type (current_gdbarch)->builtin_unsigned_char;
+ return builtin_type (gdbarch)->builtin_unsigned_char;
case T_USHORT:
- return builtin_type (current_gdbarch)->builtin_unsigned_short;
+ return builtin_type (gdbarch)->builtin_unsigned_short;
case T_UINT:
- return builtin_type (current_gdbarch)->builtin_unsigned_int;
+ return builtin_type (gdbarch)->builtin_unsigned_int;
case T_ULONG:
if (cs->c_sclass == C_FIELD
&& aux->x_sym.x_misc.x_lnsz.x_size
- > gdbarch_long_bit (current_gdbarch))
- return builtin_type (current_gdbarch)->builtin_unsigned_long_long;
+ > gdbarch_long_bit (gdbarch))
+ return builtin_type (gdbarch)->builtin_unsigned_long_long;
else
- return builtin_type (current_gdbarch)->builtin_unsigned_long;
+ return builtin_type (gdbarch)->builtin_unsigned_long;
}
complaint (&symfile_complaints, _("Unexpected type for symbol %s"), cs->c_name);
- return builtin_type (current_gdbarch)->builtin_void;
+ return builtin_type (gdbarch)->builtin_void;
}
\f
/* This page contains subroutines of read_type. */
object describing the type. */
static struct type *
-coff_read_struct_type (int index, int length, int lastsym)
+coff_read_struct_type (int index, int length, int lastsym,
+ struct objfile *objfile)
{
struct nextfield
{
{
read_one_sym (ms, &sub_sym, &sub_aux);
name = ms->c_name;
- name = EXTERNAL_NAME (name, current_objfile->obfd);
+ name = EXTERNAL_NAME (name, objfile->obfd);
switch (ms->c_sclass)
{
/* Save the data. */
list->field.name =
- obsavestring (name,
- strlen (name),
- ¤t_objfile->objfile_obstack);
- FIELD_TYPE (list->field) = decode_type (ms, ms->c_type, &sub_aux);
+ obsavestring (name, strlen (name), &objfile->objfile_obstack);
+ FIELD_TYPE (list->field) = decode_type (ms, ms->c_type, &sub_aux,
+ objfile);
FIELD_BITPOS (list->field) = 8 * ms->c_value;
FIELD_BITSIZE (list->field) = 0;
FIELD_STATIC_KIND (list->field) = 0;
/* Save the data. */
list->field.name =
- obsavestring (name,
- strlen (name),
- ¤t_objfile->objfile_obstack);
- FIELD_TYPE (list->field) = decode_type (ms, ms->c_type, &sub_aux);
+ obsavestring (name, strlen (name), &objfile->objfile_obstack);
+ FIELD_TYPE (list->field) = decode_type (ms, ms->c_type, &sub_aux,
+ objfile);
FIELD_BITPOS (list->field) = ms->c_value;
FIELD_BITSIZE (list->field) = sub_aux.x_sym.x_misc.x_lnsz.x_size;
FIELD_STATIC_KIND (list->field) = 0;
Also defines the symbols that represent the values of the type. */
static struct type *
-coff_read_enum_type (int index, int length, int lastsym)
+coff_read_enum_type (int index, int length, int lastsym,
+ struct objfile *objfile)
{
+ struct gdbarch *gdbarch = get_objfile_arch (objfile);
struct symbol *sym;
struct type *type;
int nsyms = 0;
{
read_one_sym (ms, &sub_sym, &sub_aux);
name = ms->c_name;
- name = EXTERNAL_NAME (name, current_objfile->obfd);
+ name = EXTERNAL_NAME (name, objfile->obfd);
switch (ms->c_sclass)
{
case C_MOE:
sym = (struct symbol *) obstack_alloc
- (¤t_objfile->objfile_obstack,
- sizeof (struct symbol));
+ (&objfile->objfile_obstack, sizeof (struct symbol));
memset (sym, 0, sizeof (struct symbol));
DEPRECATED_SYMBOL_NAME (sym) =
- obsavestring (name, strlen (name),
- ¤t_objfile->objfile_obstack);
+ obsavestring (name, strlen (name), &objfile->objfile_obstack);
SYMBOL_CLASS (sym) = LOC_CONST;
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
SYMBOL_VALUE (sym) = ms->c_value;
if (length > 0)
TYPE_LENGTH (type) = length;
else /* Assume ints. */
- TYPE_LENGTH (type) = gdbarch_int_bit (current_gdbarch) / TARGET_CHAR_BIT;
+ TYPE_LENGTH (type) = gdbarch_int_bit (gdbarch) / TARGET_CHAR_BIT;
TYPE_CODE (type) = TYPE_CODE_ENUM;
TYPE_NFIELDS (type) = nsyms;
TYPE_FIELDS (type) = (struct field *)
static void
read_dbx_symtab (struct objfile *objfile)
{
+ struct gdbarch *gdbarch = get_objfile_arch (objfile);
struct external_nlist *bufp = 0; /* =0 avoids gcc -Wall glitch */
struct internal_nlist nlist;
CORE_ADDR text_addr;
don't relocate it. */
if (nlist.n_value == 0
- && gdbarch_sofun_address_maybe_missing (current_gdbarch))
+ && gdbarch_sofun_address_maybe_missing (gdbarch))
{
textlow_not_set = 1;
valu = 0;
nlist.n_value += ANOFFSET (objfile->section_offsets,
data_sect_index);
- if (gdbarch_static_transform_name_p (current_gdbarch))
- namestring = gdbarch_static_transform_name
- (current_gdbarch, namestring);
+ if (gdbarch_static_transform_name_p (gdbarch))
+ namestring = gdbarch_static_transform_name (gdbarch,
+ namestring);
add_psymbol_to_list (namestring, p - namestring,
VAR_DOMAIN, LOC_STATIC,
value for the bottom of the text seg in those cases. */
if (nlist.n_value == ANOFFSET (objfile->section_offsets,
SECT_OFF_TEXT (objfile))
- && gdbarch_sofun_address_maybe_missing (current_gdbarch))
+ && gdbarch_sofun_address_maybe_missing (gdbarch))
{
CORE_ADDR minsym_valu =
find_stab_function_addr (namestring,
nlist.n_value = minsym_valu;
}
if (pst && textlow_not_set
- && gdbarch_sofun_address_maybe_missing (current_gdbarch))
+ && gdbarch_sofun_address_maybe_missing (gdbarch))
{
pst->textlow = nlist.n_value;
textlow_not_set = 0;
value for the bottom of the text seg in those cases. */
if (nlist.n_value == ANOFFSET (objfile->section_offsets,
SECT_OFF_TEXT (objfile))
- && gdbarch_sofun_address_maybe_missing (current_gdbarch))
+ && gdbarch_sofun_address_maybe_missing (gdbarch))
{
CORE_ADDR minsym_valu =
find_stab_function_addr (namestring,
nlist.n_value = minsym_valu;
}
if (pst && textlow_not_set
- && gdbarch_sofun_address_maybe_missing (current_gdbarch))
+ && gdbarch_sofun_address_maybe_missing (gdbarch))
{
pst->textlow = nlist.n_value;
textlow_not_set = 0;
end_psymtab will set pst->texthigh to the proper value, which
is necessary if a module compiled without debugging info
follows this module. */
- if (pst && gdbarch_sofun_address_maybe_missing (current_gdbarch))
+ if (pst && gdbarch_sofun_address_maybe_missing (gdbarch))
{
end_psymtab (pst, psymtab_include_list, includes_used,
symnum * symbol_size,
{
int i;
struct objfile *objfile = pst->objfile;
+ struct gdbarch *gdbarch = get_objfile_arch (objfile);
if (capping_symbol_offset != -1)
LDSYMLEN (pst) = capping_symbol_offset - LDSYMOFF (pst);
last function in the file. */
if (pst->texthigh == 0 && last_function_name
- && gdbarch_sofun_address_maybe_missing (current_gdbarch))
+ && gdbarch_sofun_address_maybe_missing (gdbarch))
{
char *p;
int n;
last_function_name = NULL;
}
- if (!gdbarch_sofun_address_maybe_missing (current_gdbarch))
+ if (!gdbarch_sofun_address_maybe_missing (gdbarch))
;
/* this test will be true if the last .o file is only data */
else if (textlow_not_set)
struct section_offsets *section_offsets,
struct objfile *objfile)
{
+ struct gdbarch *gdbarch = get_objfile_arch (objfile);
struct context_stack *new;
/* This remembers the address of the start of a function. It is
used because in Solaris 2, N_LBRAC, N_RBRAC, and N_SLINE entries
/* Relocate for dynamic loading. */
valu += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
- valu = gdbarch_smash_text_address (current_gdbarch, valu);
+ valu = gdbarch_smash_text_address (gdbarch, valu);
last_function_start = valu;
goto define_a_symbol;
if (type == N_FUN
&& valu == ANOFFSET (section_offsets,
SECT_OFF_TEXT (objfile))
- && gdbarch_sofun_address_maybe_missing (current_gdbarch))
+ && gdbarch_sofun_address_maybe_missing (gdbarch))
{
CORE_ADDR minsym_valu =
find_stab_function_addr (name, last_source_file, objfile);
static gdb_byte *
decode_frame_entry_1 (struct comp_unit *unit, gdb_byte *start, int eh_frame_p)
{
+ struct gdbarch *gdbarch = get_objfile_arch (unit->objfile);
gdb_byte *buf, *end;
LONGEST length;
unsigned int bytes_read;
this is supposed to be the target address size from the associated
CU header. FIXME: We do not have a good way to determine the
latter. Always use the target pointer size for now. */
- cie->addr_size = gdbarch_ptr_bit (current_gdbarch) / TARGET_CHAR_BIT;
+ cie->addr_size = gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT;
/* We'll determine the final value later, but we need to
initialize it conservatively. */
if (augmentation[0] == 'e' && augmentation[1] == 'h')
{
/* Skip. */
- buf += TYPE_LENGTH (builtin_type_void_data_ptr);
+ buf += gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT;
augmentation += 2;
}
cie->return_address_register = read_unsigned_leb128 (unit->abfd, buf,
&bytes_read);
cie->return_address_register
- = dwarf2_frame_adjust_regnum (current_gdbarch,
+ = dwarf2_frame_adjust_regnum (gdbarch,
cie->return_address_register,
eh_frame_p);
dwarf_expr_read_reg (void *baton, int dwarf_regnum)
{
struct dwarf_expr_baton *debaton = (struct dwarf_expr_baton *) baton;
+ struct gdbarch *gdbarch = get_frame_arch (debaton->frame);
CORE_ADDR result;
int regnum;
- regnum = gdbarch_dwarf2_reg_to_regnum (current_gdbarch, dwarf_regnum);
- result = address_from_register (builtin_type_void_data_ptr,
+ regnum = gdbarch_dwarf2_reg_to_regnum (gdbarch, dwarf_regnum);
+ result = address_from_register (builtin_type (gdbarch)->builtin_data_ptr,
regnum, debaton->frame);
return result;
}
&& dlbaton->data[0] >= DW_OP_reg0
&& dlbaton->data[0] <= DW_OP_reg31)
{
- int regno = gdbarch_dwarf2_reg_to_regnum
- (current_gdbarch, dlbaton->data[0] - DW_OP_reg0);
+ struct objfile *objfile = dwarf2_per_cu_objfile (dlbaton->per_cu);
+ struct gdbarch *gdbarch = get_objfile_arch (objfile);
+ int regno = gdbarch_dwarf2_reg_to_regnum (gdbarch,
+ dlbaton->data[0] - DW_OP_reg0);
fprintf_filtered (stream,
"a variable in register %s",
- gdbarch_register_name (current_gdbarch, regno));
+ gdbarch_register_name (gdbarch, regno));
return 1;
}
struct dwarf2_cu *cu)
{
struct objfile *objfile = cu->objfile;
+ struct gdbarch *gdbarch = get_objfile_arch (objfile);
struct nextfield *new_field;
struct attribute *attr;
struct field *fp;
attr = dwarf2_attr (die, DW_AT_bit_offset, cu);
if (attr)
{
- if (gdbarch_bits_big_endian (current_gdbarch))
+ if (gdbarch_bits_big_endian (gdbarch))
{
/* For big endian bits, the DW_AT_bit_offset gives the
additional bit offset from the MSB of the containing
static void
read_tag_pointer_type (struct die_info *die, struct dwarf2_cu *cu)
{
+ struct gdbarch *gdbarch = get_objfile_arch (cu->objfile);
struct comp_unit_head *cu_header = &cu->header;
struct type *type;
struct attribute *attr_byte_size;
length accordingly. */
if (TYPE_LENGTH (type) != byte_size || addr_class != DW_ADDR_none)
{
- if (gdbarch_address_class_type_flags_p (current_gdbarch))
+ if (gdbarch_address_class_type_flags_p (gdbarch))
{
int type_flags;
type_flags = gdbarch_address_class_type_flags
- (current_gdbarch, byte_size, addr_class);
+ (gdbarch, byte_size, addr_class);
gdb_assert ((type_flags & ~TYPE_FLAG_ADDRESS_CLASS_ALL) == 0);
type = make_type_with_address_space (type, type_flags);
}
static void
read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
{
+ struct gdbarch *gdbarch = get_objfile_arch (cu->objfile);
struct type *base_type;
struct type *range_type;
struct attribute *attr;
complaint (&symfile_complaints,
_("DW_AT_type missing from DW_TAG_subrange_type"));
base_type
- = init_type (TYPE_CODE_INT, gdbarch_addr_bit (current_gdbarch) / 8,
+ = init_type (TYPE_CODE_INT, gdbarch_addr_bit (gdbarch) / 8,
0, NULL, cu->objfile);
}
new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
{
struct objfile *objfile = cu->objfile;
+ struct gdbarch *gdbarch = get_objfile_arch (objfile);
struct symbol *sym = NULL;
char *name;
struct attribute *attr = NULL;
to something sensible. */
if (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_VOID)
SYMBOL_TYPE (sym)
- = builtin_type (current_gdbarch)->nodebug_data_symbol;
+ = builtin_type (gdbarch)->nodebug_data_symbol;
attr = dwarf2_attr (die, DW_AT_const_value, cu);
if (attr)
static struct type *
die_type (struct die_info *die, struct dwarf2_cu *cu)
{
+ struct gdbarch *gdbarch = get_objfile_arch (cu->objfile);
struct type *type;
struct attribute *type_attr;
struct die_info *type_die;
if (!type_attr)
{
/* A missing DW_AT_type represents a void type. */
- return builtin_type (current_gdbarch)->builtin_void;
+ return builtin_type (gdbarch)->builtin_void;
}
else
type_die = follow_die_ref (die, type_attr, cu);
enum minimal_symbol_type ms_type,
asection *bfd_section, struct objfile *objfile)
{
+ struct gdbarch *gdbarch = get_objfile_arch (objfile);
+
if (ms_type == mst_text || ms_type == mst_file_text)
- address = gdbarch_smash_text_address (current_gdbarch, address);
+ address = gdbarch_smash_text_address (gdbarch, address);
return prim_record_minimal_symbol_and_info
(name, address, ms_type, NULL, bfd_section->index, bfd_section, objfile);
elf_symtab_read (struct objfile *objfile, int type,
long number_of_symbols, asymbol **symbol_table)
{
+ struct gdbarch *gdbarch = get_objfile_arch (objfile);
long storage_needed;
asymbol *sym;
long i;
}
if (msym != NULL)
msym->filename = filesymname;
- gdbarch_elf_make_msymbol_special (current_gdbarch, sym, msym);
+ gdbarch_elf_make_msymbol_special (gdbarch, sym, msym);
}
}
}
parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
struct section_offsets *section_offsets, struct objfile *objfile)
{
+ struct gdbarch *gdbarch = get_objfile_arch (objfile);
const bfd_size_type external_sym_size = debug_swap->external_sym_size;
void (*const swap_sym_in) (bfd *, void *, SYMR *) = debug_swap->swap_sym_in;
char *name;
/* Type could be missing if file is compiled without debugging info. */
if (SC_IS_UNDEF (sh->sc)
|| sh->sc == scNil || sh->index == indexNil)
- SYMBOL_TYPE (s) = builtin_type (current_gdbarch)->nodebug_data_symbol;
+ SYMBOL_TYPE (s) = builtin_type (gdbarch)->nodebug_data_symbol;
else
SYMBOL_TYPE (s) = parse_type (cur_fd, ax, sh->index, 0, bigend, name);
/* Value of a data symbol is its memory address */
that too. */
if (TYPE_LENGTH (t) == TYPE_NFIELDS (t)
|| TYPE_LENGTH (t) == 0)
- TYPE_LENGTH (t) =
- gdbarch_int_bit (current_gdbarch) / HOST_CHAR_BIT;
+ TYPE_LENGTH (t) = gdbarch_int_bit (gdbarch) / HOST_CHAR_BIT;
for (ext_tsym = ext_sh + external_sym_size;
;
ext_tsym += external_sym_size)
parse_procedure (PDR *pr, struct symtab *search_symtab,
struct partial_symtab *pst)
{
+ struct gdbarch *gdbarch = get_objfile_arch (pst->objfile);
struct symbol *s, *i;
struct block *b;
struct mdebug_extra_func_info *e;
if (processing_gcc_compilation == 0
&& found_ecoff_debugging_info == 0
&& TYPE_CODE (TYPE_TARGET_TYPE (SYMBOL_TYPE (s))) == TYPE_CODE_VOID)
- SYMBOL_TYPE (s) = builtin_type (current_gdbarch)->nodebug_text_symbol;
+ SYMBOL_TYPE (s) = builtin_type (gdbarch)->nodebug_text_symbol;
}
/* Parse the external symbol ES. Just call parse_symbol() after
static void
parse_partial_symbols (struct objfile *objfile)
{
+ struct gdbarch *gdbarch = get_objfile_arch (objfile);
const bfd_size_type external_sym_size = debug_swap->external_sym_size;
const bfd_size_type external_rfd_size = debug_swap->external_rfd_size;
const bfd_size_type external_ext_size = debug_swap->external_ext_size;
don't relocate it. */
if (sh.value == 0
- && gdbarch_sofun_address_maybe_missing
- (current_gdbarch))
+ && gdbarch_sofun_address_maybe_missing (gdbarch))
{
textlow_not_set = 1;
valu = 0;
case 'S':
sh.value += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile));
- if (gdbarch_static_transform_name_p (current_gdbarch))
+ if (gdbarch_static_transform_name_p (gdbarch))
namestring = gdbarch_static_transform_name
- (current_gdbarch, namestring);
+ (gdbarch, namestring);
add_psymbol_to_list (namestring, p - namestring,
VAR_DOMAIN, LOC_STATIC,
necessary if a module compiled without
debugging info follows this module. */
if (pst
- && gdbarch_sofun_address_maybe_missing
- (current_gdbarch))
+ && gdbarch_sofun_address_maybe_missing (gdbarch))
{
pst = (struct partial_symtab *) 0;
includes_used = 0;
#include "dictionary.h"
#include "source.h"
#include "addrmap.h"
+#include "arch-utils.h"
/* Prototypes for local functions */
}
if (abfd != NULL)
{
+ /* Look up the gdbarch associated with the BFD. */
+ objfile->gdbarch = gdbarch_from_bfd (abfd);
+
objfile->name = xstrdup (bfd_get_filename (abfd));
objfile->mtime = bfd_get_mtime (abfd);
return (objfile);
}
+/* Retrieve the gdbarch associated with OBJFILE. */
+struct gdbarch *
+get_objfile_arch (struct objfile *objfile)
+{
+ return objfile->gdbarch;
+}
+
/* Initialize entry point information for this objfile. */
void
bfd *obfd;
+ /* The gdbarch associated with the BFD. Note that this gdbarch is
+ determined solely from BFD information, without looking at target
+ information. The gdbarch determined from a running target may
+ differ from this e.g. with respect to register types and names. */
+
+ struct gdbarch *gdbarch;
+
/* The modification timestamp of the object file, as of the last time
we read its symbols. */
extern struct objfile *allocate_objfile (bfd *, int);
+extern struct gdbarch *get_objfile_arch (struct objfile *);
+
extern void init_entry_point_info (struct objfile *);
extern CORE_ADDR entry_point_address (void);
som_symtab_read (bfd *abfd, struct objfile *objfile,
struct section_offsets *section_offsets)
{
+ struct gdbarch *gdbarch = get_objfile_arch (objfile);
unsigned int number_of_symbols;
int val, dynamic;
char *stringtab;
ms_type = mst_text;
bufp->symbol_value += text_offset;
bufp->symbol_value = gdbarch_smash_text_address
- (current_gdbarch, bufp->symbol_value);
+ (gdbarch, bufp->symbol_value);
break;
case ST_ENTRY:
ms_type = mst_text;
bufp->symbol_value += text_offset;
bufp->symbol_value = gdbarch_smash_text_address
- (current_gdbarch, bufp->symbol_value);
+ (gdbarch, bufp->symbol_value);
break;
case ST_STUB:
ms_type = mst_solib_trampoline;
bufp->symbol_value += text_offset;
bufp->symbol_value = gdbarch_smash_text_address
- (current_gdbarch, bufp->symbol_value);
+ (gdbarch, bufp->symbol_value);
break;
case ST_DATA:
ms_type = mst_file_text;
bufp->symbol_value += text_offset;
bufp->symbol_value = gdbarch_smash_text_address
- (current_gdbarch, bufp->symbol_value);
+ (gdbarch, bufp->symbol_value);
check_strange_names:
/* Utah GCC 2.5, FSF GCC 2.6 and later generate correct local
ms_type = mst_file_text;
bufp->symbol_value += text_offset;
bufp->symbol_value = gdbarch_smash_text_address
- (current_gdbarch, bufp->symbol_value);
+ (gdbarch, bufp->symbol_value);
break;
case ST_ENTRY:
ms_type = mst_file_text;
bufp->symbol_value += text_offset;
bufp->symbol_value = gdbarch_smash_text_address
- (current_gdbarch, bufp->symbol_value);
+ (gdbarch, bufp->symbol_value);
break;
case ST_STUB:
ms_type = mst_solib_trampoline;
bufp->symbol_value += text_offset;
bufp->symbol_value = gdbarch_smash_text_address
- (current_gdbarch, bufp->symbol_value);
+ (gdbarch, bufp->symbol_value);
break;
define_symbol (CORE_ADDR valu, char *string, int desc, int type,
struct objfile *objfile)
{
+ struct gdbarch *gdbarch = get_objfile_arch (objfile);
struct symbol *sym;
char *p = (char *) find_name_end (string);
int deftype;
case 'X':
/* SunPRO (3.0 at least) static variable encoding. */
- if (gdbarch_static_transform_name_p (current_gdbarch))
+ if (gdbarch_static_transform_name_p (gdbarch))
goto normal;
/* ... fall through ... */
target arithmetic to get the value. real.c in GCC
probably has the necessary code. */
- dbl_type = builtin_type (current_gdbarch)->builtin_double;
+ dbl_type = builtin_type (gdbarch)->builtin_double;
dbl_valu =
obstack_alloc (&objfile->objfile_obstack,
TYPE_LENGTH (dbl_type));
types; other languages probably should have at least
unsigned as well as signed constants. */
- SYMBOL_TYPE (sym) = builtin_type (current_gdbarch)->builtin_long;
+ SYMBOL_TYPE (sym) = builtin_type (gdbarch)->builtin_long;
SYMBOL_VALUE (sym) = atoi (p);
SYMBOL_CLASS (sym) = LOC_CONST;
}
be promoted to the width of the calling conventions, with
a type which references itself. This type is turned into
a TYPE_CODE_VOID type by read_type, and we have to turn
- it back into builtin_type_int here.
- FIXME: Do we need a new builtin_type_promoted_int_arg ? */
+ it back into builtin_int here.
+ FIXME: Do we need a new builtin_promoted_int_arg ? */
if (TYPE_CODE (ptype) == TYPE_CODE_VOID)
- ptype = builtin_type_int;
+ ptype = builtin_type (gdbarch)->builtin_int;
TYPE_FIELD_TYPE (ftype, nparams) = ptype;
TYPE_FIELD_ARTIFICIAL (ftype, nparams++) = 0;
}
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
add_symbol_to_list (sym, &local_symbols);
- if (gdbarch_byte_order (current_gdbarch) != BFD_ENDIAN_BIG)
+ if (gdbarch_byte_order (gdbarch) != BFD_ENDIAN_BIG)
{
/* On little-endian machines, this crud is never necessary,
and, if the extra bytes contain garbage, is harmful. */
/* If it's gcc-compiled, if it says `short', believe it. */
if (processing_gcc_compilation
- || gdbarch_believe_pcc_promotion (current_gdbarch))
+ || gdbarch_believe_pcc_promotion (gdbarch))
break;
- if (!gdbarch_believe_pcc_promotion (current_gdbarch))
+ if (!gdbarch_believe_pcc_promotion (gdbarch))
{
- /* This is the signed type which arguments get promoted to. */
- static struct type *pcc_promotion_type;
- /* This is the unsigned type which arguments get promoted to. */
- static struct type *pcc_unsigned_promotion_type;
-
- /* Call it "int" because this is mainly C lossage. */
- if (pcc_promotion_type == NULL)
- pcc_promotion_type =
- init_type (TYPE_CODE_INT,
- gdbarch_int_bit (current_gdbarch) / TARGET_CHAR_BIT,
- 0, "int", NULL);
-
- if (pcc_unsigned_promotion_type == NULL)
- pcc_unsigned_promotion_type =
- init_type (TYPE_CODE_INT,
- gdbarch_int_bit (current_gdbarch) / TARGET_CHAR_BIT,
- TYPE_FLAG_UNSIGNED, "unsigned int", NULL);
-
/* If PCC says a parameter is a short or a char, it is
really an int. */
- if (TYPE_LENGTH (SYMBOL_TYPE (sym)) < TYPE_LENGTH (pcc_promotion_type)
+ if (TYPE_LENGTH (SYMBOL_TYPE (sym))
+ < gdbarch_int_bit (gdbarch) / TARGET_CHAR_BIT
&& TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_INT)
{
SYMBOL_TYPE (sym) =
TYPE_UNSIGNED (SYMBOL_TYPE (sym))
- ? pcc_unsigned_promotion_type
- : pcc_promotion_type;
+ ? builtin_type (gdbarch)->builtin_unsigned_int
+ : builtin_type (gdbarch)->builtin_int;
}
break;
}
if (local_symbols
&& local_symbols->nsyms > 0
- && gdbarch_stabs_argument_has_addr (current_gdbarch,
- SYMBOL_TYPE (sym)))
+ && gdbarch_stabs_argument_has_addr (gdbarch, SYMBOL_TYPE (sym)))
{
struct symbol *prev_sym;
prev_sym = local_symbols->symbol[local_symbols->nsyms - 1];
SYMBOL_TYPE (sym) = read_type (&p, objfile);
SYMBOL_CLASS (sym) = LOC_STATIC;
SYMBOL_VALUE_ADDRESS (sym) = valu;
- if (gdbarch_static_transform_name_p (current_gdbarch)
- && gdbarch_static_transform_name (current_gdbarch,
+ if (gdbarch_static_transform_name_p (gdbarch)
+ && gdbarch_static_transform_name (gdbarch,
DEPRECATED_SYMBOL_NAME (sym))
!= DEPRECATED_SYMBOL_NAME (sym))
{
if (msym != NULL)
{
DEPRECATED_SYMBOL_NAME (sym) = gdbarch_static_transform_name
- (current_gdbarch,
+ (gdbarch,
DEPRECATED_SYMBOL_NAME (sym));
SYMBOL_VALUE_ADDRESS (sym) = SYMBOL_VALUE_ADDRESS (msym);
}
SYMBOL_TYPE (sym) = read_type (&p, objfile);
SYMBOL_CLASS (sym) = LOC_STATIC;
SYMBOL_VALUE_ADDRESS (sym) = valu;
- if (gdbarch_static_transform_name_p (current_gdbarch)
- && gdbarch_static_transform_name (current_gdbarch,
+ if (gdbarch_static_transform_name_p (gdbarch)
+ && gdbarch_static_transform_name (gdbarch,
DEPRECATED_SYMBOL_NAME (sym))
!= DEPRECATED_SYMBOL_NAME (sym))
{
if (msym != NULL)
{
DEPRECATED_SYMBOL_NAME (sym) = gdbarch_static_transform_name
- (current_gdbarch,
+ (gdbarch,
DEPRECATED_SYMBOL_NAME (sym));
SYMBOL_VALUE_ADDRESS (sym) = SYMBOL_VALUE_ADDRESS (msym);
}
of by value, i.e. they will pass the address of a structure (in a
register or on the stack) instead of the structure itself. */
- if (gdbarch_stabs_argument_has_addr (current_gdbarch, SYMBOL_TYPE (sym))
+ if (gdbarch_stabs_argument_has_addr (gdbarch, SYMBOL_TYPE (sym))
&& (SYMBOL_CLASS (sym) == LOC_REGPARM || SYMBOL_CLASS (sym) == LOC_ARG))
{
/* We have to convert LOC_REGPARM to LOC_REGPARM_ADDR (for
read_one_struct_field (struct field_info *fip, char **pp, char *p,
struct type *type, struct objfile *objfile)
{
+ struct gdbarch *gdbarch = get_objfile_arch (objfile);
+
fip->list->field.name =
obsavestring (*pp, p - *pp, &objfile->objfile_obstack);
*pp = p + 1;
== TARGET_CHAR_BIT * TYPE_LENGTH (field_type)
|| (TYPE_CODE (field_type) == TYPE_CODE_ENUM
&& FIELD_BITSIZE (fip->list->field)
- == gdbarch_int_bit (current_gdbarch))
+ == gdbarch_int_bit (gdbarch))
)
&&
FIELD_BITPOS (fip->list->field) % 8 == 0)
read_enum_type (char **pp, struct type *type,
struct objfile *objfile)
{
+ struct gdbarch *gdbarch = get_objfile_arch (objfile);
char *p;
char *name;
long n;
/* Now fill in the fields of the type-structure. */
- TYPE_LENGTH (type) = gdbarch_int_bit (current_gdbarch) / HOST_CHAR_BIT;
+ TYPE_LENGTH (type) = gdbarch_int_bit (gdbarch) / HOST_CHAR_BIT;
TYPE_CODE (type) = TYPE_CODE_ENUM;
TYPE_FLAGS (type) &= ~TYPE_FLAG_STUB;
if (unsigned_enum)
read_range_type (char **pp, int typenums[2], int type_size,
struct objfile *objfile)
{
+ struct gdbarch *gdbarch = get_objfile_arch (objfile);
char *orig_pp = *pp;
int rangenums[2];
long n2, n3;
/* We don't know its size. It is unsigned int or unsigned
long. GCC 2.3.3 uses this for long long too, but that is
just a GDB 3.5 compatibility hack. */
- bits = gdbarch_int_bit (current_gdbarch);
+ bits = gdbarch_int_bit (gdbarch);
}
return init_type (TYPE_CODE_INT, bits / TARGET_CHAR_BIT,
else if (n3 == 0 && n2 < 0
&& (self_subrange
|| n2 == -gdbarch_long_long_bit
- (current_gdbarch) / TARGET_CHAR_BIT))
+ (gdbarch) / TARGET_CHAR_BIT))
return init_type (TYPE_CODE_INT, -n2, 0, NULL, objfile);
else if (n2 == -n3 - 1)
{
handle_true_range:
if (self_subrange)
- index_type = builtin_type_int;
+ index_type = builtin_type (gdbarch)->builtin_int;
else
index_type = *dbx_lookup_type (rangenums);
if (index_type == NULL)
/* Does this actually ever happen? Is that why we are worrying
about dealing with it rather than just calling error_type? */
- static struct type *range_type_index;
-
complaint (&symfile_complaints,
_("base type %d of range type is not defined"), rangenums[1]);
- if (range_type_index == NULL)
- range_type_index =
- init_type (TYPE_CODE_INT,
- gdbarch_int_bit (current_gdbarch) / TARGET_CHAR_BIT,
- 0, "range type index type", NULL);
- index_type = range_type_index;
+
+ index_type = builtin_type (gdbarch)->builtin_int;
}
result_type = create_range_type ((struct type *) NULL, index_type, n2, n3);
static struct symbol *
process_xcoff_symbol (struct coff_symbol *cs, struct objfile *objfile)
{
+ struct gdbarch *gdbarch = get_objfile_arch (objfile);
struct symbol onesymbol;
struct symbol *sym = &onesymbol;
struct symbol *sym2 = NULL;
patch_block_stabs (), unless the file was compiled without -g. */
DEPRECATED_SYMBOL_NAME (sym) = SYMNAME_ALLOC (name, symname_alloced);
- SYMBOL_TYPE (sym) = builtin_type (current_gdbarch)->nodebug_text_symbol;
+ SYMBOL_TYPE (sym) = builtin_type (gdbarch)->nodebug_text_symbol;
SYMBOL_CLASS (sym) = LOC_BLOCK;
SYMBOL_DUP (sym, sym2);
else
{
/* In case we can't figure out the type, provide default. */
- SYMBOL_TYPE (sym) = builtin_type (current_gdbarch)->nodebug_data_symbol;
+ SYMBOL_TYPE (sym) = builtin_type (gdbarch)->nodebug_data_symbol;
switch (cs->c_sclass)
{
case 'S':
symbol.n_value += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile));
- if (gdbarch_static_transform_name_p (current_gdbarch))
+ if (gdbarch_static_transform_name_p (gdbarch))
namestring = gdbarch_static_transform_name
- (current_gdbarch, namestring);
+ (gdbarch, namestring);
add_psymbol_to_list (namestring, p - namestring,
VAR_DOMAIN, LOC_STATIC,