gdb: rename get_type_arch to type::arch

... and update all users.

gdb/ChangeLog:

	* gdbtypes.h (get_type_arch): Rename to...
	(struct type) <arch>: ... this, update all users.

Change-Id: I0e3ef938a0afe798ac0da74a9976bbd1d082fc6f
This commit is contained in:
Simon Marchi 2021-01-28 10:12:10 -05:00
parent 6ac373717c
commit 8ee511afd8
30 changed files with 101 additions and 110 deletions

View File

@ -1,3 +1,8 @@
2021-01-28 Simon Marchi <simon.marchi@polymtl.ca>
* gdbtypes.h (get_type_arch): Rename to...
(struct type) <arch>: ... this, update all users.
2021-01-28 Simon Marchi <simon.marchi@polymtl.ca> 2021-01-28 Simon Marchi <simon.marchi@polymtl.ca>
* gdbtypes.h (struct type) <arch>: Rename to... * gdbtypes.h (struct type) <arch>: Rename to...

View File

@ -4525,13 +4525,12 @@ ada_convert_actual (struct value *actual, struct type *formal_type0)
static CORE_ADDR static CORE_ADDR
value_pointer (struct value *value, struct type *type) value_pointer (struct value *value, struct type *type)
{ {
struct gdbarch *gdbarch = get_type_arch (type);
unsigned len = TYPE_LENGTH (type); unsigned len = TYPE_LENGTH (type);
gdb_byte *buf = (gdb_byte *) alloca (len); gdb_byte *buf = (gdb_byte *) alloca (len);
CORE_ADDR addr; CORE_ADDR addr;
addr = value_address (value); addr = value_address (value);
gdbarch_address_to_pointer (gdbarch, type, buf, addr); gdbarch_address_to_pointer (type->arch (), type, buf, addr);
addr = extract_unsigned_integer (buf, len, type_byte_order (type)); addr = extract_unsigned_integer (buf, len, type_byte_order (type));
return addr; return addr;
} }
@ -11234,7 +11233,7 @@ ada_is_system_address_type (struct type *type)
static struct type * static struct type *
ada_scaling_type (struct type *type) ada_scaling_type (struct type *type)
{ {
return builtin_type (get_type_arch (type))->builtin_long_double; return builtin_type (type->arch ())->builtin_long_double;
} }
/* Assuming that TYPE is the representation of an Ada fixed-point /* Assuming that TYPE is the representation of an Ada fixed-point

View File

@ -788,7 +788,7 @@ ada_value_print_num (struct value *val, struct ui_file *stream, int recurse,
so we have to work-around this deficiency by handling so we have to work-around this deficiency by handling
System.Address values as a special case. */ System.Address values as a special case. */
struct gdbarch *gdbarch = get_type_arch (type); struct gdbarch *gdbarch = type->arch ();
struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr; struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
CORE_ADDR addr = extract_typed_address (valaddr, ptr_type); CORE_ADDR addr = extract_typed_address (valaddr, ptr_type);

View File

@ -1982,7 +1982,7 @@ update_watchpoint (struct watchpoint *b, int reparse)
for (tmp = &(b->loc); *tmp != NULL; tmp = &((*tmp)->next)) for (tmp = &(b->loc); *tmp != NULL; tmp = &((*tmp)->next))
; ;
*tmp = loc; *tmp = loc;
loc->gdbarch = get_type_arch (value_type (v)); loc->gdbarch = value_type (v)->arch ();
loc->pspace = frame_pspace; loc->pspace = frame_pspace;
loc->address = address_significant (loc->gdbarch, addr); loc->address = address_significant (loc->gdbarch, addr);

View File

@ -149,7 +149,7 @@ c_emit_char (int c, struct type *type,
{ {
const char *encoding; const char *encoding;
classify_type (type, get_type_arch (type), &encoding); classify_type (type, type->arch (), &encoding);
generic_emit_char (c, type, stream, quoter, encoding); generic_emit_char (c, type, stream, quoter, encoding);
} }
@ -161,7 +161,7 @@ language_defn::printchar (int c, struct type *type,
{ {
c_string_type str_type; c_string_type str_type;
str_type = classify_type (type, get_type_arch (type), NULL); str_type = classify_type (type, type->arch (), NULL);
switch (str_type) switch (str_type)
{ {
case C_CHAR: case C_CHAR:
@ -199,7 +199,7 @@ c_printstr (struct ui_file *stream, struct type *type,
const char *type_encoding; const char *type_encoding;
const char *encoding; const char *encoding;
str_type = (classify_type (type, get_type_arch (type), &type_encoding) str_type = (classify_type (type, type->arch (), &type_encoding)
& ~C_CHAR); & ~C_CHAR);
switch (str_type) switch (str_type)
{ {
@ -279,7 +279,7 @@ c_get_string (struct value *value, gdb::unique_xmalloc_ptr<gdb_byte> *buffer,
if (! c_textual_element_type (element_type, 0)) if (! c_textual_element_type (element_type, 0))
goto error; goto error;
classify_type (element_type, get_type_arch (element_type), charset); classify_type (element_type, element_type->arch (), charset);
width = TYPE_LENGTH (element_type); width = TYPE_LENGTH (element_type);
/* If the string lives in GDB's memory instead of the inferior's, /* If the string lives in GDB's memory instead of the inferior's,

View File

@ -528,7 +528,7 @@ c_type_print_modifier (struct type *type, struct ui_file *stream,
} }
address_space_id address_space_id
= address_space_type_instance_flags_to_name (get_type_arch (type), = address_space_type_instance_flags_to_name (type->arch (),
type->instance_flags ()); type->instance_flags ());
if (address_space_id) if (address_space_id)
{ {

View File

@ -144,7 +144,7 @@ print_unpacked_pointer (struct type *type, struct type *elttype,
const struct value_print_options *options) const struct value_print_options *options)
{ {
int want_space = 0; int want_space = 0;
struct gdbarch *gdbarch = get_type_arch (type); struct gdbarch *gdbarch = type->arch ();
if (elttype->code () == TYPE_CODE_FUNC) if (elttype->code () == TYPE_CODE_FUNC)
{ {
@ -333,7 +333,6 @@ c_value_print_ptr (struct value *val, struct ui_file *stream, int recurse,
} }
struct type *type = check_typedef (value_type (val)); struct type *type = check_typedef (value_type (val));
struct gdbarch *arch = get_type_arch (type);
const gdb_byte *valaddr = value_contents_for_printing (val); const gdb_byte *valaddr = value_contents_for_printing (val);
if (options->vtblprint && cp_is_vtbl_ptr_type (type)) if (options->vtblprint && cp_is_vtbl_ptr_type (type))
@ -344,7 +343,7 @@ c_value_print_ptr (struct value *val, struct ui_file *stream, int recurse,
TYPE_CODE_STRUCT.) */ TYPE_CODE_STRUCT.) */
CORE_ADDR addr = extract_typed_address (valaddr, type); CORE_ADDR addr = extract_typed_address (valaddr, type);
print_function_pointer_address (options, arch, addr, stream); print_function_pointer_address (options, type->arch (), addr, stream);
} }
else else
{ {
@ -373,13 +372,12 @@ c_value_print_struct (struct value *val, struct ui_file *stream, int recurse,
/* Print vtable entry - we only get here if NOT using /* Print vtable entry - we only get here if NOT using
-fvtable_thunks. (Otherwise, look under -fvtable_thunks. (Otherwise, look under
TYPE_CODE_PTR.) */ TYPE_CODE_PTR.) */
struct gdbarch *gdbarch = get_type_arch (type);
int offset = TYPE_FIELD_BITPOS (type, VTBL_FNADDR_OFFSET) / 8; int offset = TYPE_FIELD_BITPOS (type, VTBL_FNADDR_OFFSET) / 8;
struct type *field_type = type->field (VTBL_FNADDR_OFFSET).type (); struct type *field_type = type->field (VTBL_FNADDR_OFFSET).type ();
const gdb_byte *valaddr = value_contents_for_printing (val); const gdb_byte *valaddr = value_contents_for_printing (val);
CORE_ADDR addr = extract_typed_address (valaddr + offset, field_type); CORE_ADDR addr = extract_typed_address (valaddr + offset, field_type);
print_function_pointer_address (options, gdbarch, addr, stream); print_function_pointer_address (options, type->arch (), addr, stream);
} }
else else
cp_print_value_fields (val, stream, recurse, options, NULL, 0); cp_print_value_fields (val, stream, recurse, options, NULL, 0);

View File

@ -324,7 +324,7 @@ cp_print_value_fields (struct value *val, struct ui_file *stream,
i_offset += value_embedded_offset (val); i_offset += value_embedded_offset (val);
addr = extract_typed_address (valaddr + i_offset, i_type); addr = extract_typed_address (valaddr + i_offset, i_type);
print_function_pointer_address (opts, print_function_pointer_address (opts,
get_type_arch (type), type->arch (),
addr, stream); addr, stream);
} }
} }

View File

@ -52,8 +52,8 @@ public:
m_stride = type_length_units (elt_type); m_stride = type_length_units (elt_type);
else else
{ {
struct gdbarch *arch = get_type_arch (elt_type); int unit_size
int unit_size = gdbarch_addressable_memory_unit_size (arch); = gdbarch_addressable_memory_unit_size (elt_type->arch ());
m_stride /= (unit_size * 8); m_stride /= (unit_size * 8);
} }
}; };

View File

@ -82,7 +82,7 @@ f_language::get_encoding (struct type *type)
switch (TYPE_LENGTH (type)) switch (TYPE_LENGTH (type))
{ {
case 1: case 1:
encoding = target_charset (get_type_arch (type)); encoding = target_charset (type->arch ());
break; break;
case 4: case 4:
if (type_byte_order (type) == BFD_ENDIAN_BIG) if (type_byte_order (type) == BFD_ENDIAN_BIG)
@ -1416,8 +1416,8 @@ fortran_adjust_dynamic_array_base_address_hack (struct type *type,
stride = type_length_units (elt_type); stride = type_length_units (elt_type);
else else
{ {
struct gdbarch *arch = get_type_arch (elt_type); int unit_size
int unit_size = gdbarch_addressable_memory_unit_size (arch); = gdbarch_addressable_memory_unit_size (elt_type->arch ());
stride /= (unit_size * 8); stride /= (unit_size * 8);
} }

View File

@ -242,8 +242,8 @@ f_language::f_type_print_varspec_suffix (struct type *type,
fprintf_filtered (stream, ") "); fprintf_filtered (stream, ") ");
fprintf_filtered (stream, "("); fprintf_filtered (stream, "(");
if (nfields == 0 && type->is_prototyped ()) if (nfields == 0 && type->is_prototyped ())
print_type (builtin_f_type (get_type_arch (type))->builtin_void, print_type (builtin_f_type (type->arch ())->builtin_void,
"", stream, -1, 0, 0); "", stream, -1, 0, 0);
else else
for (i = 0; i < nfields; i++) for (i = 0; i < nfields; i++)
{ {
@ -342,8 +342,7 @@ f_language::f_type_print_base (struct type *type, struct ui_file *stream,
case TYPE_CODE_VOID: case TYPE_CODE_VOID:
{ {
gdbarch *gdbarch = get_type_arch (type); struct type *void_type = builtin_f_type (type->arch ())->builtin_void;
struct type *void_type = builtin_f_type (gdbarch)->builtin_void;
fprintf_filtered (stream, "%*s%s", level, "", void_type->name ()); fprintf_filtered (stream, "%*s%s", level, "", void_type->name ());
} }
break; break;

View File

@ -218,7 +218,7 @@ f_language::value_print_inner (struct value *val, struct ui_file *stream,
const struct value_print_options *options) const const struct value_print_options *options) const
{ {
struct type *type = check_typedef (value_type (val)); struct type *type = check_typedef (value_type (val));
struct gdbarch *gdbarch = get_type_arch (type); struct gdbarch *gdbarch = type->arch ();
int printed_field = 0; /* Number of fields printed. */ int printed_field = 0; /* Number of fields printed. */
struct type *elttype; struct type *elttype;
CORE_ADDR addr; CORE_ADDR addr;

View File

@ -158,7 +158,7 @@ extract_typed_address (const gdb_byte *buf, struct type *type)
_("extract_typed_address: " _("extract_typed_address: "
"type is not a pointer or reference")); "type is not a pointer or reference"));
return gdbarch_pointer_to_address (get_type_arch (type), type, buf); return gdbarch_pointer_to_address (type->arch (), type, buf);
} }
/* All 'store' functions accept a host-format integer and store a /* All 'store' functions accept a host-format integer and store a
@ -211,7 +211,7 @@ store_typed_address (gdb_byte *buf, struct type *type, CORE_ADDR addr)
_("store_typed_address: " _("store_typed_address: "
"type is not a pointer or reference")); "type is not a pointer or reference"));
gdbarch_address_to_pointer (get_type_arch (type), type, buf, addr); gdbarch_address_to_pointer (type->arch (), type, buf, addr);
} }
/* Copy a value from SOURCE of size SOURCE_SIZE bytes to DEST of size DEST_SIZE /* Copy a value from SOURCE of size SOURCE_SIZE bytes to DEST of size DEST_SIZE

View File

@ -232,24 +232,23 @@ alloc_type_copy (const struct type *type)
return alloc_type_arch (type->arch_owner ()); return alloc_type_arch (type->arch_owner ());
} }
/* If TYPE is gdbarch-associated, return that architecture. /* See gdbtypes.h. */
If TYPE is objfile-associated, return that objfile's architecture. */
struct gdbarch * gdbarch *
get_type_arch (const struct type *type) type::arch () const
{ {
struct gdbarch *arch; struct gdbarch *arch;
if (type->is_objfile_owned ()) if (this->is_objfile_owned ())
arch = type->objfile_owner ()->arch (); arch = this->objfile_owner ()->arch ();
else else
arch = type->arch_owner (); arch = this->arch_owner ();
/* The ARCH can be NULL if TYPE is associated with neither an objfile nor /* The ARCH can be NULL if TYPE is associated with neither an objfile nor
a gdbarch, however, this is very rare, and even then, in most cases a gdbarch, however, this is very rare, and even then, in most cases
that get_type_arch is called, we assume that a non-NULL value is that type::arch is called, we assume that a non-NULL value is
returned. */ returned. */
gdb_assert (arch != NULL); gdb_assert (arch != nullptr);
return arch; return arch;
} }
@ -273,8 +272,7 @@ get_target_type (struct type *type)
unsigned int unsigned int
type_length_units (struct type *type) type_length_units (struct type *type)
{ {
struct gdbarch *arch = get_type_arch (type); int unit_size = gdbarch_addressable_memory_unit_size (type->arch ());
int unit_size = gdbarch_addressable_memory_unit_size (arch);
return TYPE_LENGTH (type) / unit_size; return TYPE_LENGTH (type) / unit_size;
} }
@ -291,7 +289,7 @@ alloc_type_instance (struct type *oldtype)
/* Allocate the structure. */ /* Allocate the structure. */
if (!oldtype->is_objfile_owned ()) if (!oldtype->is_objfile_owned ())
type = GDBARCH_OBSTACK_ZALLOC (get_type_arch (oldtype), struct type); type = GDBARCH_OBSTACK_ZALLOC (oldtype->arch_owner (), struct type);
else else
type = OBSTACK_ZALLOC (&oldtype->objfile_owner ()->objfile_obstack, type = OBSTACK_ZALLOC (&oldtype->objfile_owner ()->objfile_obstack,
struct type); struct type);
@ -371,8 +369,7 @@ make_pointer_type (struct type *type, struct type **typeptr)
/* FIXME! Assumes the machine has only one representation for pointers! */ /* FIXME! Assumes the machine has only one representation for pointers! */
TYPE_LENGTH (ntype) TYPE_LENGTH (ntype) = gdbarch_ptr_bit (type->arch ()) / TARGET_CHAR_BIT;
= gdbarch_ptr_bit (get_type_arch (type)) / TARGET_CHAR_BIT;
ntype->set_code (TYPE_CODE_PTR); ntype->set_code (TYPE_CODE_PTR);
/* Mark pointers as unsigned. The target converts between pointers /* Mark pointers as unsigned. The target converts between pointers
@ -455,8 +452,7 @@ make_reference_type (struct type *type, struct type **typeptr,
references, and that it matches the (only) representation for references, and that it matches the (only) representation for
pointers! */ pointers! */
TYPE_LENGTH (ntype) = TYPE_LENGTH (ntype) = gdbarch_ptr_bit (type->arch ()) / TARGET_CHAR_BIT;
gdbarch_ptr_bit (get_type_arch (type)) / TARGET_CHAR_BIT;
ntype->set_code (refcode); ntype->set_code (refcode);
*reftype = ntype; *reftype = ntype;
@ -1617,8 +1613,7 @@ smash_to_memberptr_type (struct type *type, struct type *self_type,
set_type_self_type (type, self_type); set_type_self_type (type, self_type);
/* Assume that a data member pointer is the same size as a normal /* Assume that a data member pointer is the same size as a normal
pointer. */ pointer. */
TYPE_LENGTH (type) TYPE_LENGTH (type) = gdbarch_ptr_bit (to_type->arch ()) / TARGET_CHAR_BIT;
= gdbarch_ptr_bit (get_type_arch (to_type)) / TARGET_CHAR_BIT;
} }
/* Smash TYPE to be a type of pointer to methods type TO_TYPE. /* Smash TYPE to be a type of pointer to methods type TO_TYPE.
@ -2228,7 +2223,7 @@ resolve_dynamic_range (struct type *dyn_range_type,
I really don't think this is going to work with current GDB, the I really don't think this is going to work with current GDB, the
array indexing code in GDB seems to be pretty heavily tied to byte array indexing code in GDB seems to be pretty heavily tied to byte
offsets right now. Assuming 8 bits in a byte. */ offsets right now. Assuming 8 bits in a byte. */
struct gdbarch *gdbarch = get_type_arch (dyn_range_type); struct gdbarch *gdbarch = dyn_range_type->arch ();
int unit_size = gdbarch_addressable_memory_unit_size (gdbarch); int unit_size = gdbarch_addressable_memory_unit_size (gdbarch);
if (!byte_stride_p && (value % (unit_size * 8)) != 0) if (!byte_stride_p && (value % (unit_size * 8)) != 0)
error (_("bit strides that are not a multiple of the byte size " error (_("bit strides that are not a multiple of the byte size "
@ -2903,7 +2898,7 @@ check_typedef (struct type *type)
if (sym) if (sym)
TYPE_TARGET_TYPE (type) = SYMBOL_TYPE (sym); TYPE_TARGET_TYPE (type) = SYMBOL_TYPE (sym);
else /* TYPE_CODE_UNDEF */ else /* TYPE_CODE_UNDEF */
TYPE_TARGET_TYPE (type) = alloc_type_arch (get_type_arch (type)); TYPE_TARGET_TYPE (type) = alloc_type_arch (type->arch ());
} }
type = TYPE_TARGET_TYPE (type); type = TYPE_TARGET_TYPE (type);
@ -3071,7 +3066,7 @@ safe_parse_type (struct gdbarch *gdbarch, const char *p, int length)
static void static void
check_stub_method (struct type *type, int method_id, int signature_id) check_stub_method (struct type *type, int method_id, int signature_id)
{ {
struct gdbarch *gdbarch = get_type_arch (type); struct gdbarch *gdbarch = type->arch ();
struct fn_field *f; struct fn_field *f;
char *mangled_name = gdb_mangle_name (type, method_id, signature_id); char *mangled_name = gdb_mangle_name (type, method_id, signature_id);
char *demangled_name = gdb_demangle (mangled_name, char *demangled_name = gdb_demangle (mangled_name,
@ -3510,8 +3505,7 @@ type_align (struct type *type)
return raw_align; return raw_align;
/* Allow the architecture to provide an alignment. */ /* Allow the architecture to provide an alignment. */
struct gdbarch *arch = get_type_arch (type); ULONGEST align = gdbarch_type_align (type->arch (), type);
ULONGEST align = gdbarch_type_align (arch, type);
if (align != 0) if (align != 0)
return align; return align;
@ -3878,7 +3872,7 @@ is_unique_ancestor (struct type *base, struct value *val)
enum bfd_endian enum bfd_endian
type_byte_order (const struct type *type) type_byte_order (const struct type *type)
{ {
bfd_endian byteorder = gdbarch_byte_order (get_type_arch (type)); bfd_endian byteorder = gdbarch_byte_order (type->arch ());
if (type->endianity_is_not_default ()) if (type->endianity_is_not_default ())
{ {
if (byteorder == BFD_ENDIAN_BIG) if (byteorder == BFD_ENDIAN_BIG)
@ -5505,7 +5499,7 @@ copy_type_recursive (struct objfile *objfile,
if (*slot != NULL) if (*slot != NULL)
return ((struct type_pair *) *slot)->newobj; return ((struct type_pair *) *slot)->newobj;
new_type = alloc_type_arch (get_type_arch (type)); new_type = alloc_type_arch (type->arch ());
/* We must add the new type to the hash table immediately, in case /* We must add the new type to the hash table immediately, in case
we encounter this type again during a recursive call below. */ we encounter this type again during a recursive call below. */
@ -5518,7 +5512,7 @@ copy_type_recursive (struct objfile *objfile,
copy the entire thing and then update specific fields as needed. */ copy the entire thing and then update specific fields as needed. */
*TYPE_MAIN_TYPE (new_type) = *TYPE_MAIN_TYPE (type); *TYPE_MAIN_TYPE (new_type) = *TYPE_MAIN_TYPE (type);
new_type->set_owner (get_type_arch (type)); new_type->set_owner (type->arch ());
if (type->name ()) if (type->name ())
new_type->set_name (xstrdup (type->name ())); new_type->set_name (xstrdup (type->name ()));
@ -5844,10 +5838,8 @@ append_flags_type_field (struct type *type, int start_bitpos, int nr_bits,
void void
append_flags_type_flag (struct type *type, int bitpos, const char *name) append_flags_type_flag (struct type *type, int bitpos, const char *name)
{ {
struct gdbarch *gdbarch = get_type_arch (type);
append_flags_type_field (type, bitpos, 1, append_flags_type_field (type, bitpos, 1,
builtin_type (gdbarch)->builtin_bool, builtin_type (type->arch ())->builtin_bool,
name); name);
} }

View File

@ -1282,6 +1282,13 @@ struct type
return this->main_type->m_owner.gdbarch; return this->main_type->m_owner.gdbarch;
} }
/* Return the type's architecture. For types owned by an
architecture, that architecture is returned. For types owned by an
objfile, that objfile's architecture is returned.
The return value is always non-nullptr. */
gdbarch *arch () const;
/* * Return true if this is an integer type whose logical (bit) size /* * Return true if this is an integer type whose logical (bit) size
differs from its storage size; false otherwise. Always return differs from its storage size; false otherwise. Always return
false for non-integer (i.e., non-TYPE_SPECIFIC_INT) types. */ false for non-integer (i.e., non-TYPE_SPECIFIC_INT) types. */
@ -2258,12 +2265,6 @@ extern struct type *alloc_type (struct objfile *);
extern struct type *alloc_type_arch (struct gdbarch *); extern struct type *alloc_type_arch (struct gdbarch *);
extern struct type *alloc_type_copy (const struct type *); extern struct type *alloc_type_copy (const struct type *);
/* * Return the type's architecture. For types owned by an
architecture, that architecture is returned. For types owned by an
objfile, that objfile's architecture is returned. */
extern struct gdbarch *get_type_arch (const struct type *);
/* * This returns the target type (or NULL) of TYPE, also skipping /* * This returns the target type (or NULL) of TYPE, also skipping
past typedefs. */ past typedefs. */
@ -2661,9 +2662,9 @@ extern bool is_fixed_point_type (struct type *type);
extern void allocate_fixed_point_type_info (struct type *type); extern void allocate_fixed_point_type_info (struct type *type);
/* * When the type includes explicit byte ordering, return that. /* * When the type includes explicit byte ordering, return that.
Otherwise, the byte ordering from gdbarch_byte_order for Otherwise, the byte ordering from gdbarch_byte_order for
get_type_arch is returned. */ the type's arch is returned. */
extern enum bfd_endian type_byte_order (const struct type *type); extern enum bfd_endian type_byte_order (const struct type *type);
/* A flag to enable printing of debugging information of C++ /* A flag to enable printing of debugging information of C++

View File

@ -308,7 +308,7 @@ gnuv3_rtti_type (struct value *value,
return NULL; return NULL;
/* Determine architecture. */ /* Determine architecture. */
gdbarch = get_type_arch (values_type); gdbarch = values_type->arch ();
if (using_enc_p) if (using_enc_p)
*using_enc_p = 0; *using_enc_p = 0;
@ -422,7 +422,7 @@ gnuv3_virtual_fn_field (struct value **value_p,
error (_("Only classes can have virtual functions.")); error (_("Only classes can have virtual functions."));
/* Determine architecture. */ /* Determine architecture. */
gdbarch = get_type_arch (values_type); gdbarch = values_type->arch ();
/* Cast our value to the base class which defines this virtual /* Cast our value to the base class which defines this virtual
function. This takes care of any necessary `this' function. This takes care of any necessary `this'
@ -454,7 +454,7 @@ gnuv3_baseclass_offset (struct type *type, int index,
long int cur_base_offset, base_offset; long int cur_base_offset, base_offset;
/* Determine architecture. */ /* Determine architecture. */
gdbarch = get_type_arch (type); gdbarch = type->arch ();
ptr_type = builtin_type (gdbarch)->builtin_data_ptr; ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
/* If it isn't a virtual base, this is easy. The offset is in the /* If it isn't a virtual base, this is easy. The offset is in the
@ -611,7 +611,7 @@ gnuv3_print_method_ptr (const gdb_byte *contents,
struct ui_file *stream) struct ui_file *stream)
{ {
struct type *self_type = TYPE_SELF_TYPE (type); struct type *self_type = TYPE_SELF_TYPE (type);
struct gdbarch *gdbarch = get_type_arch (self_type); struct gdbarch *gdbarch = self_type->arch ();
CORE_ADDR ptr_value; CORE_ADDR ptr_value;
LONGEST adjustment; LONGEST adjustment;
int vbit; int vbit;
@ -691,9 +691,7 @@ gnuv3_print_method_ptr (const gdb_byte *contents,
static int static int
gnuv3_method_ptr_size (struct type *type) gnuv3_method_ptr_size (struct type *type)
{ {
struct gdbarch *gdbarch = get_type_arch (type); return 2 * TYPE_LENGTH (builtin_type (type->arch ())->builtin_data_ptr);
return 2 * TYPE_LENGTH (builtin_type (gdbarch)->builtin_data_ptr);
} }
/* GNU v3 implementation of cplus_make_method_ptr. */ /* GNU v3 implementation of cplus_make_method_ptr. */
@ -702,7 +700,7 @@ static void
gnuv3_make_method_ptr (struct type *type, gdb_byte *contents, gnuv3_make_method_ptr (struct type *type, gdb_byte *contents,
CORE_ADDR value, int is_virtual) CORE_ADDR value, int is_virtual)
{ {
struct gdbarch *gdbarch = get_type_arch (type); struct gdbarch *gdbarch = type->arch ();
int size = TYPE_LENGTH (builtin_type (gdbarch)->builtin_data_ptr); int size = TYPE_LENGTH (builtin_type (gdbarch)->builtin_data_ptr);
enum bfd_endian byte_order = type_byte_order (type); enum bfd_endian byte_order = type_byte_order (type);
@ -745,7 +743,7 @@ gnuv3_method_ptr_to_value (struct value **this_p, struct value *method_ptr)
method_type = TYPE_TARGET_TYPE (check_typedef (value_type (method_ptr))); method_type = TYPE_TARGET_TYPE (check_typedef (value_type (method_ptr)));
/* Extract the pointer to member. */ /* Extract the pointer to member. */
gdbarch = get_type_arch (self_type); gdbarch = self_type->arch ();
vbit = gnuv3_decode_method_ptr (gdbarch, contents, &ptr_value, &adjustment); vbit = gnuv3_decode_method_ptr (gdbarch, contents, &ptr_value, &adjustment);
/* First convert THIS to match the containing type of the pointer to /* First convert THIS to match the containing type of the pointer to
@ -978,7 +976,7 @@ gnuv3_print_vtable (struct value *value)
type = check_typedef (value_type (value)); type = check_typedef (value_type (value));
} }
gdbarch = get_type_arch (type); gdbarch = type->arch ();
vtable = NULL; vtable = NULL;
if (type->code () == TYPE_CODE_STRUCT) if (type->code () == TYPE_CODE_STRUCT)
@ -1107,7 +1105,7 @@ gnuv3_get_typeid (struct value *value)
/* Ignore top-level cv-qualifiers. */ /* Ignore top-level cv-qualifiers. */
type = make_cv_type (0, 0, type, NULL); type = make_cv_type (0, 0, type, NULL);
gdbarch = get_type_arch (type); gdbarch = type->arch ();
type_name = type_to_string (type); type_name = type_to_string (type);
if (type_name.empty ()) if (type_name.empty ())
@ -1161,7 +1159,7 @@ gnuv3_get_typeid (struct value *value)
static std::string static std::string
gnuv3_get_typename_from_type_info (struct value *type_info_ptr) gnuv3_get_typename_from_type_info (struct value *type_info_ptr)
{ {
struct gdbarch *gdbarch = get_type_arch (value_type (type_info_ptr)); struct gdbarch *gdbarch = value_type (type_info_ptr)->arch ();
struct bound_minimal_symbol typeinfo_sym; struct bound_minimal_symbol typeinfo_sym;
CORE_ADDR addr; CORE_ADDR addr;
const char *symname; const char *symname;

View File

@ -43,7 +43,7 @@ print_go_string (struct type *type,
struct value *val, struct value *val,
const struct value_print_options *options) const struct value_print_options *options)
{ {
struct gdbarch *gdbarch = get_type_arch (type); struct gdbarch *gdbarch = type->arch ();
struct type *elt_ptr_type = type->field (0).type (); struct type *elt_ptr_type = type->field (0).type ();
struct type *elt_type = TYPE_TARGET_TYPE (elt_ptr_type); struct type *elt_type = TYPE_TARGET_TYPE (elt_ptr_type);
LONGEST length; LONGEST length;

View File

@ -949,7 +949,7 @@ gdbscm_apply_val_pretty_printer (const struct extension_language_defn *extlang,
const struct language_defn *language) const struct language_defn *language)
{ {
struct type *type = value_type (value); struct type *type = value_type (value);
struct gdbarch *gdbarch = get_type_arch (type); struct gdbarch *gdbarch = type->arch ();
SCM exception = SCM_BOOL_F; SCM exception = SCM_BOOL_F;
SCM printer = SCM_BOOL_F; SCM printer = SCM_BOOL_F;
SCM val_obj = SCM_BOOL_F; SCM val_obj = SCM_BOOL_F;

View File

@ -671,7 +671,7 @@ gdbscm_value_subscript (SCM self, SCM index_scm)
struct value *index struct value *index
= vlscm_convert_value_from_scheme (FUNC_NAME, SCM_ARG2, index_scm, = vlscm_convert_value_from_scheme (FUNC_NAME, SCM_ARG2, index_scm,
&except_scm, &except_scm,
get_type_arch (type), type->arch (),
current_language); current_language);
if (index == NULL) if (index == NULL)
return except_scm; return except_scm;

View File

@ -251,7 +251,7 @@ find_function_addr (struct value *function,
struct type **function_type) struct type **function_type)
{ {
struct type *ftype = check_typedef (value_type (function)); struct type *ftype = check_typedef (value_type (function));
struct gdbarch *gdbarch = get_type_arch (ftype); struct gdbarch *gdbarch = ftype->arch ();
struct type *value_type = NULL; struct type *value_type = NULL;
/* Initialize it just to avoid a GCC false warning. */ /* Initialize it just to avoid a GCC false warning. */
CORE_ADDR funaddr = 0; CORE_ADDR funaddr = 0;

View File

@ -186,7 +186,7 @@ print_unpacked_pointer (struct type *type,
const struct value_print_options *options, const struct value_print_options *options,
struct ui_file *stream) struct ui_file *stream)
{ {
struct gdbarch *gdbarch = get_type_arch (type); struct gdbarch *gdbarch = type->arch ();
struct type *elttype = check_typedef (TYPE_TARGET_TYPE (type)); struct type *elttype = check_typedef (TYPE_TARGET_TYPE (type));
int want_space = 0; int want_space = 0;
@ -228,7 +228,7 @@ print_variable_at_address (struct type *type,
int recurse, int recurse,
const struct value_print_options *options) const struct value_print_options *options)
{ {
struct gdbarch *gdbarch = get_type_arch (type); struct gdbarch *gdbarch = type->arch ();
CORE_ADDR addr = unpack_pointer (type, valaddr); CORE_ADDR addr = unpack_pointer (type, valaddr);
struct type *elttype = check_typedef (TYPE_TARGET_TYPE (type)); struct type *elttype = check_typedef (TYPE_TARGET_TYPE (type));

View File

@ -70,7 +70,7 @@ pascal_language::value_print_inner (struct value *val,
{ {
struct type *type = check_typedef (value_type (val)); struct type *type = check_typedef (value_type (val));
struct gdbarch *gdbarch = get_type_arch (type); struct gdbarch *gdbarch = type->arch ();
enum bfd_endian byte_order = type_byte_order (type); enum bfd_endian byte_order = type_byte_order (type);
unsigned int i = 0; /* Number of characters printed */ unsigned int i = 0; /* Number of characters printed */
unsigned len; unsigned len;

View File

@ -304,7 +304,7 @@ print_formatted (struct value *val, int size,
/* We often wrap here if there are long symbolic names. */ /* We often wrap here if there are long symbolic names. */
wrap_here (" "); wrap_here (" ");
next_address = (value_address (val) next_address = (value_address (val)
+ gdb_print_insn (get_type_arch (type), + gdb_print_insn (type->arch (),
value_address (val), stream, value_address (val), stream,
&branch_delay_insns)); &branch_delay_insns));
return; return;
@ -331,7 +331,7 @@ print_formatted (struct value *val, int size,
static struct type * static struct type *
float_type_from_length (struct type *type) float_type_from_length (struct type *type)
{ {
struct gdbarch *gdbarch = get_type_arch (type); struct gdbarch *gdbarch = type->arch ();
const struct builtin_type *builtin = builtin_type (gdbarch); const struct builtin_type *builtin = builtin_type (gdbarch);
if (TYPE_LENGTH (type) == TYPE_LENGTH (builtin->builtin_float)) if (TYPE_LENGTH (type) == TYPE_LENGTH (builtin->builtin_float))
@ -353,7 +353,7 @@ print_scalar_formatted (const gdb_byte *valaddr, struct type *type,
const struct value_print_options *options, const struct value_print_options *options,
int size, struct ui_file *stream) int size, struct ui_file *stream)
{ {
struct gdbarch *gdbarch = get_type_arch (type); struct gdbarch *gdbarch = type->arch ();
unsigned int len = TYPE_LENGTH (type); unsigned int len = TYPE_LENGTH (type);
enum bfd_endian byte_order = type_byte_order (type); enum bfd_endian byte_order = type_byte_order (type);
@ -2370,7 +2370,7 @@ printf_wide_c_string (struct ui_file *stream, const char *format,
{ {
const gdb_byte *str; const gdb_byte *str;
size_t len; size_t len;
struct gdbarch *gdbarch = get_type_arch (value_type (value)); struct gdbarch *gdbarch = value_type (value)->arch ();
struct type *wctype = lookup_typename (current_language, struct type *wctype = lookup_typename (current_language,
"wchar_t", NULL, 0); "wchar_t", NULL, 0);
int wcwidth = TYPE_LENGTH (wctype); int wcwidth = TYPE_LENGTH (wctype);
@ -2438,7 +2438,7 @@ printf_floating (struct ui_file *stream, const char *format,
{ {
/* Parameter data. */ /* Parameter data. */
struct type *param_type = value_type (value); struct type *param_type = value_type (value);
struct gdbarch *gdbarch = get_type_arch (param_type); struct gdbarch *gdbarch = param_type->arch ();
/* Determine target type corresponding to the format string. */ /* Determine target type corresponding to the format string. */
struct type *fmt_type; struct type *fmt_type;
@ -2644,8 +2644,7 @@ ui_printf (const char *arg, struct ui_file *stream)
break; break;
case wide_char_arg: case wide_char_arg:
{ {
struct gdbarch *gdbarch struct gdbarch *gdbarch = value_type (val_args[i])->arch ();
= get_type_arch (value_type (val_args[i]));
struct type *wctype = lookup_typename (current_language, struct type *wctype = lookup_typename (current_language,
"wchar_t", NULL, 0); "wchar_t", NULL, 0);
struct type *valtype; struct type *valtype;

View File

@ -564,7 +564,7 @@ gdbpy_apply_val_pretty_printer (const struct extension_language_defn *extlang,
const struct language_defn *language) const struct language_defn *language)
{ {
struct type *type = value_type (value); struct type *type = value_type (value);
struct gdbarch *gdbarch = get_type_arch (type); struct gdbarch *gdbarch = type->arch ();
enum string_repr_result print_result; enum string_repr_result print_result;
if (value_lazy (value)) if (value_lazy (value))

View File

@ -516,7 +516,7 @@ rust_language::value_print_inner
that. */ that. */
struct type *elttype = check_typedef (TYPE_TARGET_TYPE (type)); struct type *elttype = check_typedef (TYPE_TARGET_TYPE (type));
CORE_ADDR addr = value_as_address (val); CORE_ADDR addr = value_as_address (val);
struct gdbarch *arch = get_type_arch (type); struct gdbarch *arch = type->arch ();
if (opts.addressprint) if (opts.addressprint)
{ {
@ -1919,7 +1919,7 @@ rust_language::emitchar (int ch, struct type *chtype,
{ {
if (!rust_chartype_p (chtype)) if (!rust_chartype_p (chtype))
generic_emit_char (ch, chtype, stream, quoter, generic_emit_char (ch, chtype, stream, quoter,
target_charset (get_type_arch (chtype))); target_charset (chtype->arch ()));
else if (ch == '\\' || ch == quoter) else if (ch == '\\' || ch == quoter)
fprintf_filtered (stream, "\\%c", ch); fprintf_filtered (stream, "\\%c", ch);
else if (ch == '\n') else if (ch == '\n')

View File

@ -202,7 +202,7 @@ value_subscripted_rvalue (struct value *array, LONGEST index, LONGEST lowerbound
LONGEST stride = array_type->bit_stride (); LONGEST stride = array_type->bit_stride ();
if (stride != 0) if (stride != 0)
{ {
struct gdbarch *arch = get_type_arch (elt_type); struct gdbarch *arch = elt_type->arch ();
int unit_size = gdbarch_addressable_memory_unit_size (arch); int unit_size = gdbarch_addressable_memory_unit_size (arch);
elt_size = stride / (unit_size * 8); elt_size = stride / (unit_size * 8);
} }
@ -539,7 +539,7 @@ value_x_binop (struct value *arg1, struct value *arg2, enum exp_opcode op,
struct value * struct value *
value_x_unop (struct value *arg1, enum exp_opcode op, enum noside noside) value_x_unop (struct value *arg1, enum exp_opcode op, enum noside noside)
{ {
struct gdbarch *gdbarch = get_type_arch (value_type (arg1)); struct gdbarch *gdbarch = value_type (arg1)->arch ();
char *ptr; char *ptr;
char tstr[13], mangle_tstr[13]; char tstr[13], mangle_tstr[13];
int static_memfuncp, nargs; int static_memfuncp, nargs;
@ -900,7 +900,7 @@ fixed_point_binop (struct value *arg1, struct value *arg2, enum exp_opcode op)
struct type *type2 = check_typedef (value_type (arg2)); struct type *type2 = check_typedef (value_type (arg2));
const struct language_defn *language = current_language; const struct language_defn *language = current_language;
struct gdbarch *gdbarch = get_type_arch (type1); struct gdbarch *gdbarch = type1->arch ();
struct value *val; struct value *val;
gdb_mpq v1, v2, res; gdb_mpq v1, v2, res;
@ -1967,7 +1967,7 @@ value_complement (struct value *arg1)
int int
value_bit_index (struct type *type, const gdb_byte *valaddr, int index) value_bit_index (struct type *type, const gdb_byte *valaddr, int index)
{ {
struct gdbarch *gdbarch = get_type_arch (type); struct gdbarch *gdbarch = type->arch ();
LONGEST low_bound, high_bound; LONGEST low_bound, high_bound;
LONGEST word; LONGEST word;
unsigned rel_index; unsigned rel_index;

View File

@ -590,7 +590,7 @@ value_cast (struct type *type, struct value *arg2)
otherwise occur when dealing with a target having two byte otherwise occur when dealing with a target having two byte
pointers and four byte addresses. */ pointers and four byte addresses. */
int addr_bit = gdbarch_addr_bit (get_type_arch (type2)); int addr_bit = gdbarch_addr_bit (type2->arch ());
LONGEST longest = value_as_long (arg2); LONGEST longest = value_as_long (arg2);
if (addr_bit < sizeof (LONGEST) * HOST_CHAR_BIT) if (addr_bit < sizeof (LONGEST) * HOST_CHAR_BIT)
@ -1100,7 +1100,7 @@ value_assign (struct value *toval, struct value *fromval)
{ {
case lval_internalvar: case lval_internalvar:
set_internalvar (VALUE_INTERNALVAR (toval), fromval); set_internalvar (VALUE_INTERNALVAR (toval), fromval);
return value_of_internalvar (get_type_arch (type), return value_of_internalvar (type->arch (),
VALUE_INTERNALVAR (toval)); VALUE_INTERNALVAR (toval));
case lval_internalvar_component: case lval_internalvar_component:

View File

@ -408,7 +408,7 @@ print_unpacked_pointer (struct type *type, struct type *elttype,
CORE_ADDR address, struct ui_file *stream, CORE_ADDR address, struct ui_file *stream,
const struct value_print_options *options) const struct value_print_options *options)
{ {
struct gdbarch *gdbarch = get_type_arch (type); struct gdbarch *gdbarch = type->arch ();
if (elttype->code () == TYPE_CODE_FUNC) if (elttype->code () == TYPE_CODE_FUNC)
{ {
@ -483,7 +483,7 @@ static void
print_ref_address (struct type *type, const gdb_byte *address_buffer, print_ref_address (struct type *type, const gdb_byte *address_buffer,
int embedded_offset, struct ui_file *stream) int embedded_offset, struct ui_file *stream)
{ {
struct gdbarch *gdbarch = get_type_arch (type); struct gdbarch *gdbarch = type->arch ();
if (address_buffer != NULL) if (address_buffer != NULL)
{ {
@ -673,7 +673,7 @@ generic_val_print_enum (struct type *type,
const struct value_print_options *options) const struct value_print_options *options)
{ {
LONGEST val; LONGEST val;
struct gdbarch *gdbarch = get_type_arch (type); struct gdbarch *gdbarch = type->arch ();
int unit_size = gdbarch_addressable_memory_unit_size (gdbarch); int unit_size = gdbarch_addressable_memory_unit_size (gdbarch);
gdb_assert (!options->format); gdb_assert (!options->format);
@ -694,7 +694,7 @@ generic_val_print_func (struct type *type,
struct value *original_value, struct value *original_value,
const struct value_print_options *options) const struct value_print_options *options)
{ {
struct gdbarch *gdbarch = get_type_arch (type); struct gdbarch *gdbarch = type->arch ();
gdb_assert (!options->format); gdb_assert (!options->format);
@ -1182,7 +1182,7 @@ val_print_type_code_flags (struct type *type, struct value *original_value,
+ embedded_offset); + embedded_offset);
ULONGEST val = unpack_long (type, valaddr); ULONGEST val = unpack_long (type, valaddr);
int field, nfields = type->num_fields (); int field, nfields = type->num_fields ();
struct gdbarch *gdbarch = get_type_arch (type); struct gdbarch *gdbarch = type->arch ();
struct type *bool_type = builtin_type (gdbarch)->builtin_bool; struct type *bool_type = builtin_type (gdbarch)->builtin_bool;
fputs_filtered ("[", stream); fputs_filtered ("[", stream);
@ -2713,7 +2713,7 @@ val_print_string (struct type *elttype, const char *encoding,
unsigned int fetchlimit; /* Maximum number of chars to print. */ unsigned int fetchlimit; /* Maximum number of chars to print. */
int bytes_read; int bytes_read;
gdb::unique_xmalloc_ptr<gdb_byte> buffer; /* Dynamically growable fetch buffer. */ gdb::unique_xmalloc_ptr<gdb_byte> buffer; /* Dynamically growable fetch buffer. */
struct gdbarch *gdbarch = get_type_arch (elttype); struct gdbarch *gdbarch = elttype->arch ();
enum bfd_endian byte_order = type_byte_order (elttype); enum bfd_endian byte_order = type_byte_order (elttype);
int width = TYPE_LENGTH (elttype); int width = TYPE_LENGTH (elttype);

View File

@ -363,7 +363,7 @@ struct value
struct gdbarch * struct gdbarch *
get_value_arch (const struct value *value) get_value_arch (const struct value *value)
{ {
return get_type_arch (value_type (value)); return value_type (value)->arch ();
} }
int int
@ -2674,7 +2674,7 @@ value_as_long (struct value *val)
CORE_ADDR CORE_ADDR
value_as_address (struct value *val) value_as_address (struct value *val)
{ {
struct gdbarch *gdbarch = get_type_arch (value_type (val)); struct gdbarch *gdbarch = value_type (val)->arch ();
/* Assume a CORE_ADDR can fit in a LONGEST (for now). Not sure /* Assume a CORE_ADDR can fit in a LONGEST (for now). Not sure
whether we want this to be true eventually. */ whether we want this to be true eventually. */

View File

@ -2207,7 +2207,7 @@ varobj_value_get_print_value (struct value *value,
thevalue = std::string (s.get ()); thevalue = std::string (s.get ());
len = thevalue.size (); len = thevalue.size ();
gdbarch = get_type_arch (value_type (value)); gdbarch = value_type (value)->arch ();
type = builtin_type (gdbarch)->builtin_char; type = builtin_type (gdbarch)->builtin_char;
if (!string_print) if (!string_print)