aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2021-01-28 10:12:10 -0500
committerSimon Marchi <simon.marchi@polymtl.ca>2021-01-28 10:12:10 -0500
commit8ee511afd84972c2019518725295440b3d2676bc (patch)
tree80875b064bc5fd0a182bda2c123be6aade583907
parent6ac373717c28cc2befebd1e926dc5fcf39dda39f (diff)
downloadgdb-8ee511afd84972c2019518725295440b3d2676bc.zip
gdb-8ee511afd84972c2019518725295440b3d2676bc.tar.gz
gdb-8ee511afd84972c2019518725295440b3d2676bc.tar.bz2
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
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/ada-lang.c5
-rw-r--r--gdb/ada-valprint.c2
-rw-r--r--gdb/breakpoint.c2
-rw-r--r--gdb/c-lang.c8
-rw-r--r--gdb/c-typeprint.c2
-rw-r--r--gdb/c-valprint.c8
-rw-r--r--gdb/cp-valprint.c2
-rw-r--r--gdb/f-array-walker.h4
-rw-r--r--gdb/f-lang.c6
-rw-r--r--gdb/f-typeprint.c7
-rw-r--r--gdb/f-valprint.c2
-rw-r--r--gdb/findvar.c4
-rw-r--r--gdb/gdbtypes.c50
-rw-r--r--gdb/gdbtypes.h19
-rw-r--r--gdb/gnu-v3-abi.c22
-rw-r--r--gdb/go-valprint.c2
-rw-r--r--gdb/guile/scm-pretty-print.c2
-rw-r--r--gdb/guile/scm-value.c2
-rw-r--r--gdb/infcall.c2
-rw-r--r--gdb/m2-valprint.c4
-rw-r--r--gdb/p-valprint.c2
-rw-r--r--gdb/printcmd.c13
-rw-r--r--gdb/python/py-prettyprint.c2
-rw-r--r--gdb/rust-lang.c4
-rw-r--r--gdb/valarith.c8
-rw-r--r--gdb/valops.c4
-rw-r--r--gdb/valprint.c12
-rw-r--r--gdb/value.c4
-rw-r--r--gdb/varobj.c2
30 files changed, 101 insertions, 110 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 88dfba7..8a23b21 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
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>
+
* gdbtypes.h (struct type) <arch>: Rename to...
<arch_owner>: ... this, update all users.
<objfile>: Rename to...
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index d0baf5a..70296f9 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -4525,13 +4525,12 @@ ada_convert_actual (struct value *actual, struct type *formal_type0)
static CORE_ADDR
value_pointer (struct value *value, struct type *type)
{
- struct gdbarch *gdbarch = get_type_arch (type);
unsigned len = TYPE_LENGTH (type);
gdb_byte *buf = (gdb_byte *) alloca (len);
CORE_ADDR addr;
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));
return addr;
}
@@ -11234,7 +11233,7 @@ ada_is_system_address_type (struct type *type)
static struct 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
diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c
index b391ea0..8af9ef0 100644
--- a/gdb/ada-valprint.c
+++ b/gdb/ada-valprint.c
@@ -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
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;
CORE_ADDR addr = extract_typed_address (valaddr, ptr_type);
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 70b0d88..f318a12 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -1982,7 +1982,7 @@ update_watchpoint (struct watchpoint *b, int reparse)
for (tmp = &(b->loc); *tmp != NULL; tmp = &((*tmp)->next))
;
*tmp = loc;
- loc->gdbarch = get_type_arch (value_type (v));
+ loc->gdbarch = value_type (v)->arch ();
loc->pspace = frame_pspace;
loc->address = address_significant (loc->gdbarch, addr);
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index 91a04d7..626dbc4 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -149,7 +149,7 @@ c_emit_char (int c, struct type *type,
{
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);
}
@@ -161,7 +161,7 @@ language_defn::printchar (int c, struct type *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)
{
case C_CHAR:
@@ -199,7 +199,7 @@ c_printstr (struct ui_file *stream, struct type *type,
const char *type_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);
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))
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);
/* If the string lives in GDB's memory instead of the inferior's,
diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c
index 03612c0..b861aaf 100644
--- a/gdb/c-typeprint.c
+++ b/gdb/c-typeprint.c
@@ -528,7 +528,7 @@ c_type_print_modifier (struct type *type, struct ui_file *stream,
}
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 ());
if (address_space_id)
{
diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
index f538cad..9c82869 100644
--- a/gdb/c-valprint.c
+++ b/gdb/c-valprint.c
@@ -144,7 +144,7 @@ print_unpacked_pointer (struct type *type, struct type *elttype,
const struct value_print_options *options)
{
int want_space = 0;
- struct gdbarch *gdbarch = get_type_arch (type);
+ struct gdbarch *gdbarch = type->arch ();
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 gdbarch *arch = get_type_arch (type);
const gdb_byte *valaddr = value_contents_for_printing (val);
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.) */
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
{
@@ -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
-fvtable_thunks. (Otherwise, look under
TYPE_CODE_PTR.) */
- struct gdbarch *gdbarch = get_type_arch (type);
int offset = TYPE_FIELD_BITPOS (type, VTBL_FNADDR_OFFSET) / 8;
struct type *field_type = type->field (VTBL_FNADDR_OFFSET).type ();
const gdb_byte *valaddr = value_contents_for_printing (val);
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
cp_print_value_fields (val, stream, recurse, options, NULL, 0);
diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c
index 87a2d76..d303c83 100644
--- a/gdb/cp-valprint.c
+++ b/gdb/cp-valprint.c
@@ -324,7 +324,7 @@ cp_print_value_fields (struct value *val, struct ui_file *stream,
i_offset += value_embedded_offset (val);
addr = extract_typed_address (valaddr + i_offset, i_type);
print_function_pointer_address (opts,
- get_type_arch (type),
+ type->arch (),
addr, stream);
}
}
diff --git a/gdb/f-array-walker.h b/gdb/f-array-walker.h
index 9346820..49a32be 100644
--- a/gdb/f-array-walker.h
+++ b/gdb/f-array-walker.h
@@ -52,8 +52,8 @@ public:
m_stride = type_length_units (elt_type);
else
{
- struct gdbarch *arch = get_type_arch (elt_type);
- int unit_size = gdbarch_addressable_memory_unit_size (arch);
+ int unit_size
+ = gdbarch_addressable_memory_unit_size (elt_type->arch ());
m_stride /= (unit_size * 8);
}
};
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index 8329109..bd6ef20 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -82,7 +82,7 @@ f_language::get_encoding (struct type *type)
switch (TYPE_LENGTH (type))
{
case 1:
- encoding = target_charset (get_type_arch (type));
+ encoding = target_charset (type->arch ());
break;
case 4:
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);
else
{
- struct gdbarch *arch = get_type_arch (elt_type);
- int unit_size = gdbarch_addressable_memory_unit_size (arch);
+ int unit_size
+ = gdbarch_addressable_memory_unit_size (elt_type->arch ());
stride /= (unit_size * 8);
}
diff --git a/gdb/f-typeprint.c b/gdb/f-typeprint.c
index 6bf3705..976fc38 100644
--- a/gdb/f-typeprint.c
+++ b/gdb/f-typeprint.c
@@ -242,8 +242,8 @@ f_language::f_type_print_varspec_suffix (struct type *type,
fprintf_filtered (stream, ") ");
fprintf_filtered (stream, "(");
if (nfields == 0 && type->is_prototyped ())
- print_type (builtin_f_type (get_type_arch (type))->builtin_void,
- "", stream, -1, 0, 0);
+ print_type (builtin_f_type (type->arch ())->builtin_void,
+ "", stream, -1, 0, 0);
else
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:
{
- gdbarch *gdbarch = get_type_arch (type);
- struct type *void_type = builtin_f_type (gdbarch)->builtin_void;
+ struct type *void_type = builtin_f_type (type->arch ())->builtin_void;
fprintf_filtered (stream, "%*s%s", level, "", void_type->name ());
}
break;
diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c
index 066827f..240daaf 100644
--- a/gdb/f-valprint.c
+++ b/gdb/f-valprint.c
@@ -218,7 +218,7 @@ f_language::value_print_inner (struct value *val, struct ui_file *stream,
const struct value_print_options *options) const
{
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. */
struct type *elttype;
CORE_ADDR addr;
diff --git a/gdb/findvar.c b/gdb/findvar.c
index 79f0ad2..6abcd3a 100644
--- a/gdb/findvar.c
+++ b/gdb/findvar.c
@@ -158,7 +158,7 @@ extract_typed_address (const gdb_byte *buf, struct type *type)
_("extract_typed_address: "
"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
@@ -211,7 +211,7 @@ store_typed_address (gdb_byte *buf, struct type *type, CORE_ADDR addr)
_("store_typed_address: "
"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
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 638c8a6..4dd1a6a 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -232,24 +232,23 @@ alloc_type_copy (const struct type *type)
return alloc_type_arch (type->arch_owner ());
}
-/* If TYPE is gdbarch-associated, return that architecture.
- If TYPE is objfile-associated, return that objfile's architecture. */
+/* See gdbtypes.h. */
-struct gdbarch *
-get_type_arch (const struct type *type)
+gdbarch *
+type::arch () const
{
struct gdbarch *arch;
- if (type->is_objfile_owned ())
- arch = type->objfile_owner ()->arch ();
+ if (this->is_objfile_owned ())
+ arch = this->objfile_owner ()->arch ();
else
- arch = type->arch_owner ();
+ arch = this->arch_owner ();
/* 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
- 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. */
- gdb_assert (arch != NULL);
+ gdb_assert (arch != nullptr);
return arch;
}
@@ -273,8 +272,7 @@ get_target_type (struct type *type)
unsigned int
type_length_units (struct type *type)
{
- struct gdbarch *arch = get_type_arch (type);
- int unit_size = gdbarch_addressable_memory_unit_size (arch);
+ int unit_size = gdbarch_addressable_memory_unit_size (type->arch ());
return TYPE_LENGTH (type) / unit_size;
}
@@ -291,7 +289,7 @@ alloc_type_instance (struct type *oldtype)
/* Allocate the structure. */
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
type = OBSTACK_ZALLOC (&oldtype->objfile_owner ()->objfile_obstack,
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! */
- TYPE_LENGTH (ntype)
- = gdbarch_ptr_bit (get_type_arch (type)) / TARGET_CHAR_BIT;
+ TYPE_LENGTH (ntype) = gdbarch_ptr_bit (type->arch ()) / TARGET_CHAR_BIT;
ntype->set_code (TYPE_CODE_PTR);
/* 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
pointers! */
- TYPE_LENGTH (ntype) =
- gdbarch_ptr_bit (get_type_arch (type)) / TARGET_CHAR_BIT;
+ TYPE_LENGTH (ntype) = gdbarch_ptr_bit (type->arch ()) / TARGET_CHAR_BIT;
ntype->set_code (refcode);
*reftype = ntype;
@@ -1617,8 +1613,7 @@ smash_to_memberptr_type (struct type *type, struct type *self_type,
set_type_self_type (type, self_type);
/* Assume that a data member pointer is the same size as a normal
pointer. */
- TYPE_LENGTH (type)
- = gdbarch_ptr_bit (get_type_arch (to_type)) / TARGET_CHAR_BIT;
+ TYPE_LENGTH (type) = gdbarch_ptr_bit (to_type->arch ()) / TARGET_CHAR_BIT;
}
/* 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
array indexing code in GDB seems to be pretty heavily tied to 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);
if (!byte_stride_p && (value % (unit_size * 8)) != 0)
error (_("bit strides that are not a multiple of the byte size "
@@ -2903,7 +2898,7 @@ check_typedef (struct type *type)
if (sym)
TYPE_TARGET_TYPE (type) = SYMBOL_TYPE (sym);
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);
@@ -3071,7 +3066,7 @@ safe_parse_type (struct gdbarch *gdbarch, const char *p, int length)
static void
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;
char *mangled_name = gdb_mangle_name (type, method_id, signature_id);
char *demangled_name = gdb_demangle (mangled_name,
@@ -3510,8 +3505,7 @@ type_align (struct type *type)
return raw_align;
/* Allow the architecture to provide an alignment. */
- struct gdbarch *arch = get_type_arch (type);
- ULONGEST align = gdbarch_type_align (arch, type);
+ ULONGEST align = gdbarch_type_align (type->arch (), type);
if (align != 0)
return align;
@@ -3878,7 +3872,7 @@ is_unique_ancestor (struct type *base, struct value *val)
enum bfd_endian
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 (byteorder == BFD_ENDIAN_BIG)
@@ -5505,7 +5499,7 @@ copy_type_recursive (struct objfile *objfile,
if (*slot != NULL)
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 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. */
*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 ())
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
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,
- builtin_type (gdbarch)->builtin_bool,
+ builtin_type (type->arch ())->builtin_bool,
name);
}
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index df3b84b..40b1aed 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -1282,6 +1282,13 @@ struct type
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
differs from its storage size; false otherwise. Always return
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_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
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);
/* * When the type includes explicit byte ordering, return that.
- Otherwise, the byte ordering from gdbarch_byte_order for
- get_type_arch is returned. */
-
+ Otherwise, the byte ordering from gdbarch_byte_order for
+ the type's arch is returned. */
+
extern enum bfd_endian type_byte_order (const struct type *type);
/* A flag to enable printing of debugging information of C++
diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c
index db1080d..8461535 100644
--- a/gdb/gnu-v3-abi.c
+++ b/gdb/gnu-v3-abi.c
@@ -308,7 +308,7 @@ gnuv3_rtti_type (struct value *value,
return NULL;
/* Determine architecture. */
- gdbarch = get_type_arch (values_type);
+ gdbarch = values_type->arch ();
if (using_enc_p)
*using_enc_p = 0;
@@ -422,7 +422,7 @@ gnuv3_virtual_fn_field (struct value **value_p,
error (_("Only classes can have virtual functions."));
/* Determine architecture. */
- gdbarch = get_type_arch (values_type);
+ gdbarch = values_type->arch ();
/* Cast our value to the base class which defines this virtual
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;
/* Determine architecture. */
- gdbarch = get_type_arch (type);
+ gdbarch = type->arch ();
ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
/* 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 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;
LONGEST adjustment;
int vbit;
@@ -691,9 +691,7 @@ gnuv3_print_method_ptr (const gdb_byte *contents,
static int
gnuv3_method_ptr_size (struct type *type)
{
- struct gdbarch *gdbarch = get_type_arch (type);
-
- return 2 * TYPE_LENGTH (builtin_type (gdbarch)->builtin_data_ptr);
+ return 2 * TYPE_LENGTH (builtin_type (type->arch ())->builtin_data_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,
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);
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)));
/* 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);
/* 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));
}
- gdbarch = get_type_arch (type);
+ gdbarch = type->arch ();
vtable = NULL;
if (type->code () == TYPE_CODE_STRUCT)
@@ -1107,7 +1105,7 @@ gnuv3_get_typeid (struct value *value)
/* Ignore top-level cv-qualifiers. */
type = make_cv_type (0, 0, type, NULL);
- gdbarch = get_type_arch (type);
+ gdbarch = type->arch ();
type_name = type_to_string (type);
if (type_name.empty ())
@@ -1161,7 +1159,7 @@ gnuv3_get_typeid (struct value *value)
static std::string
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;
CORE_ADDR addr;
const char *symname;
diff --git a/gdb/go-valprint.c b/gdb/go-valprint.c
index 73429c6..e04ea6b 100644
--- a/gdb/go-valprint.c
+++ b/gdb/go-valprint.c
@@ -43,7 +43,7 @@ print_go_string (struct type *type,
struct value *val,
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_type = TYPE_TARGET_TYPE (elt_ptr_type);
LONGEST length;
diff --git a/gdb/guile/scm-pretty-print.c b/gdb/guile/scm-pretty-print.c
index 2a1ee16..605615e 100644
--- a/gdb/guile/scm-pretty-print.c
+++ b/gdb/guile/scm-pretty-print.c
@@ -949,7 +949,7 @@ gdbscm_apply_val_pretty_printer (const struct extension_language_defn *extlang,
const struct language_defn *language)
{
struct type *type = value_type (value);
- struct gdbarch *gdbarch = get_type_arch (type);
+ struct gdbarch *gdbarch = type->arch ();
SCM exception = SCM_BOOL_F;
SCM printer = SCM_BOOL_F;
SCM val_obj = SCM_BOOL_F;
diff --git a/gdb/guile/scm-value.c b/gdb/guile/scm-value.c
index a71fb93..5999516 100644
--- a/gdb/guile/scm-value.c
+++ b/gdb/guile/scm-value.c
@@ -671,7 +671,7 @@ gdbscm_value_subscript (SCM self, SCM index_scm)
struct value *index
= vlscm_convert_value_from_scheme (FUNC_NAME, SCM_ARG2, index_scm,
&except_scm,
- get_type_arch (type),
+ type->arch (),
current_language);
if (index == NULL)
return except_scm;
diff --git a/gdb/infcall.c b/gdb/infcall.c
index 7fb3a88..2332f29 100644
--- a/gdb/infcall.c
+++ b/gdb/infcall.c
@@ -251,7 +251,7 @@ find_function_addr (struct value *function,
struct type **function_type)
{
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;
/* Initialize it just to avoid a GCC false warning. */
CORE_ADDR funaddr = 0;
diff --git a/gdb/m2-valprint.c b/gdb/m2-valprint.c
index c984546..be21cbb 100644
--- a/gdb/m2-valprint.c
+++ b/gdb/m2-valprint.c
@@ -186,7 +186,7 @@ print_unpacked_pointer (struct type *type,
const struct value_print_options *options,
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));
int want_space = 0;
@@ -228,7 +228,7 @@ print_variable_at_address (struct type *type,
int recurse,
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);
struct type *elttype = check_typedef (TYPE_TARGET_TYPE (type));
diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c
index c01685e..9a52fe1 100644
--- a/gdb/p-valprint.c
+++ b/gdb/p-valprint.c
@@ -70,7 +70,7 @@ pascal_language::value_print_inner (struct value *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);
unsigned int i = 0; /* Number of characters printed */
unsigned len;
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index 2e56d28..332d971 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -304,7 +304,7 @@ print_formatted (struct value *val, int size,
/* We often wrap here if there are long symbolic names. */
wrap_here (" ");
next_address = (value_address (val)
- + gdb_print_insn (get_type_arch (type),
+ + gdb_print_insn (type->arch (),
value_address (val), stream,
&branch_delay_insns));
return;
@@ -331,7 +331,7 @@ print_formatted (struct value *val, int size,
static struct 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);
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,
int size, struct ui_file *stream)
{
- struct gdbarch *gdbarch = get_type_arch (type);
+ struct gdbarch *gdbarch = type->arch ();
unsigned int len = TYPE_LENGTH (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;
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,
"wchar_t", NULL, 0);
int wcwidth = TYPE_LENGTH (wctype);
@@ -2438,7 +2438,7 @@ printf_floating (struct ui_file *stream, const char *format,
{
/* Parameter data. */
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. */
struct type *fmt_type;
@@ -2644,8 +2644,7 @@ ui_printf (const char *arg, struct ui_file *stream)
break;
case wide_char_arg:
{
- struct gdbarch *gdbarch
- = get_type_arch (value_type (val_args[i]));
+ struct gdbarch *gdbarch = value_type (val_args[i])->arch ();
struct type *wctype = lookup_typename (current_language,
"wchar_t", NULL, 0);
struct type *valtype;
diff --git a/gdb/python/py-prettyprint.c b/gdb/python/py-prettyprint.c
index 3e6b14b..7c0fdaa 100644
--- a/gdb/python/py-prettyprint.c
+++ b/gdb/python/py-prettyprint.c
@@ -564,7 +564,7 @@ gdbpy_apply_val_pretty_printer (const struct extension_language_defn *extlang,
const struct language_defn *language)
{
struct type *type = value_type (value);
- struct gdbarch *gdbarch = get_type_arch (type);
+ struct gdbarch *gdbarch = type->arch ();
enum string_repr_result print_result;
if (value_lazy (value))
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index ca9a749..80f1f59 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -516,7 +516,7 @@ rust_language::value_print_inner
that. */
struct type *elttype = check_typedef (TYPE_TARGET_TYPE (type));
CORE_ADDR addr = value_as_address (val);
- struct gdbarch *arch = get_type_arch (type);
+ struct gdbarch *arch = type->arch ();
if (opts.addressprint)
{
@@ -1919,7 +1919,7 @@ rust_language::emitchar (int ch, struct type *chtype,
{
if (!rust_chartype_p (chtype))
generic_emit_char (ch, chtype, stream, quoter,
- target_charset (get_type_arch (chtype)));
+ target_charset (chtype->arch ()));
else if (ch == '\\' || ch == quoter)
fprintf_filtered (stream, "\\%c", ch);
else if (ch == '\n')
diff --git a/gdb/valarith.c b/gdb/valarith.c
index 81d48aa..3150309 100644
--- a/gdb/valarith.c
+++ b/gdb/valarith.c
@@ -202,7 +202,7 @@ value_subscripted_rvalue (struct value *array, LONGEST index, LONGEST lowerbound
LONGEST stride = array_type->bit_stride ();
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);
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 *
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 tstr[13], mangle_tstr[13];
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));
const struct language_defn *language = current_language;
- struct gdbarch *gdbarch = get_type_arch (type1);
+ struct gdbarch *gdbarch = type1->arch ();
struct value *val;
gdb_mpq v1, v2, res;
@@ -1967,7 +1967,7 @@ value_complement (struct value *arg1)
int
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 word;
unsigned rel_index;
diff --git a/gdb/valops.c b/gdb/valops.c
index d0d5628..fec821a 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -590,7 +590,7 @@ value_cast (struct type *type, struct value *arg2)
otherwise occur when dealing with a target having two byte
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);
if (addr_bit < sizeof (LONGEST) * HOST_CHAR_BIT)
@@ -1100,7 +1100,7 @@ value_assign (struct value *toval, struct value *fromval)
{
case lval_internalvar:
set_internalvar (VALUE_INTERNALVAR (toval), fromval);
- return value_of_internalvar (get_type_arch (type),
+ return value_of_internalvar (type->arch (),
VALUE_INTERNALVAR (toval));
case lval_internalvar_component:
diff --git a/gdb/valprint.c b/gdb/valprint.c
index 2c3541e..340a329 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -408,7 +408,7 @@ print_unpacked_pointer (struct type *type, struct type *elttype,
CORE_ADDR address, struct ui_file *stream,
const struct value_print_options *options)
{
- struct gdbarch *gdbarch = get_type_arch (type);
+ struct gdbarch *gdbarch = type->arch ();
if (elttype->code () == TYPE_CODE_FUNC)
{
@@ -483,7 +483,7 @@ static void
print_ref_address (struct type *type, const gdb_byte *address_buffer,
int embedded_offset, struct ui_file *stream)
{
- struct gdbarch *gdbarch = get_type_arch (type);
+ struct gdbarch *gdbarch = type->arch ();
if (address_buffer != NULL)
{
@@ -673,7 +673,7 @@ generic_val_print_enum (struct type *type,
const struct value_print_options *options)
{
LONGEST val;
- struct gdbarch *gdbarch = get_type_arch (type);
+ struct gdbarch *gdbarch = type->arch ();
int unit_size = gdbarch_addressable_memory_unit_size (gdbarch);
gdb_assert (!options->format);
@@ -694,7 +694,7 @@ generic_val_print_func (struct type *type,
struct value *original_value,
const struct value_print_options *options)
{
- struct gdbarch *gdbarch = get_type_arch (type);
+ struct gdbarch *gdbarch = type->arch ();
gdb_assert (!options->format);
@@ -1182,7 +1182,7 @@ val_print_type_code_flags (struct type *type, struct value *original_value,
+ embedded_offset);
ULONGEST val = unpack_long (type, valaddr);
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;
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. */
int bytes_read;
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);
int width = TYPE_LENGTH (elttype);
diff --git a/gdb/value.c b/gdb/value.c
index 3551b80..4135d5e 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -363,7 +363,7 @@ struct value
struct gdbarch *
get_value_arch (const struct value *value)
{
- return get_type_arch (value_type (value));
+ return value_type (value)->arch ();
}
int
@@ -2674,7 +2674,7 @@ value_as_long (struct value *val)
CORE_ADDR
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
whether we want this to be true eventually. */
diff --git a/gdb/varobj.c b/gdb/varobj.c
index 085942c..7928d90 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -2207,7 +2207,7 @@ varobj_value_get_print_value (struct value *value,
thevalue = std::string (s.get ());
len = thevalue.size ();
- gdbarch = get_type_arch (value_type (value));
+ gdbarch = value_type (value)->arch ();
type = builtin_type (gdbarch)->builtin_char;
if (!string_print)