* gdbtypes.c (make_pointer_type, make_reference_type,

smash_to_memberptr_type, lookup_array_range_type, check_stub_method):
	Use type architecture instead of current_gdbarch.

	* gdbtypes.h (address_space_name_to_int, address_space_int_to_name):
	Add GDBARCH paramter.
	* gdbtypes.c (address_space_name_to_int, address_space_int_to_name):
	Add GDBARCH parameter.   Use it instead of current_gdbarch.
	* c-typeprint.c (c_type_print_modifier): Update call.
	* parse.c (push_type_address_space): Likewise.

	* findvar.c (extract_typed_address, store_typed_address): Use type
	architecture instead of current_gdbarch.

	* value.c (value_as_address, unpack_field_as_long): Use type architecture
	instead of current_gdbarch.

	* doublest.c (floatformat_from_length): Add GDBARCH argument.  Use it
	instead of current_gdbarch.
	(floatformat_from_type): Pass type architecture.

	* infcall.c (find_function_addr): Use type architecture instead
	of current_gdbarch.

	* valarith.c (value_bitstring_subscript, value_x_binop, value_neg,
	value_bit_index): Use type architecture instead of current_gdbarch.
	* valops.c (value_cast, value_slice): Likewise.

	* value.h (modify_field): Add TYPE argument.
	* value.c (modify_field): Add TYPE argument.  Use type architecture
	instead of current_gdbarch.
	(set_internalvar_component): Likewise.
	* eval.c (evaluate_struct_tuple): Update call.
	* valops.c (value_assign): Likewise.
	* ada-lang.c (modify_general_field): Likewise.  Add TYPE argument.
	(make_array_descriptor): Update calls.
	(move_bits): Add BITS_BIG_ENDIAN_P argument.  Use it instead of
	current_gdbarch.
	(ada_value_assign, value_assign_to_component): Update calls.
	(decode_packed_array, ada_value_primitive_packed_val, ada_value_assign,
	value_assign_to_component): Use type arch instead of current_gdbarch.

	* printcmd.c (float_type_from_length): Remove GDBARCH argument,
	use type architecture instead.
	(print_scalar_formatted, printf_command): Update calls.  Use type
	architecture instead of current_gdbarch.
	* valprint.c (val_print_type_code_int): Use type architecture
	instead of current_gdbarch.
	* varobj.c (value_get_print_value): Likewise.
	* python/python-prettyprint.c (print_string_repr): Add GDBARCH
	argument.  Use it instead of current_gdbarch.
	(apply_val_pretty_printer): Update call.

	* ada-valprint.c (ada_val_print_1): Use type architecture instead
	of current_gdbarch.
	* c-valprint.c (print_function_pointer_address): Add GDBARCH argument.
	Use it instead of current_gdbarch.
	(c_val_print): Update calls passing type architecture.
	* f-valprint.c (f_val_print): Use type architecture instead of
	current_gdbarch.
	* jv-valprint (java_value_print): Likewise.
	* m2-valprint.c (print_function_pointer_address): Add GDBARCH argument.
	Use it instead of current_gdbarch.
	(print_unpacked_pointer): Update calls passing type architecture.
	* scm-valprint.c (scm_scmval_print): Use type architecture instead of
	current_gdbarch.

	* gnu-v3-abi.c (get_class_arch): Remove.
	(gnuv3_rtti_type): Use get_type_arch instead of get_class_arch.  Remove
	special-case check for Java classes.
	(gnuv3_virtual_fn_field, gnuv3_baseclass_offset, gnuv3_print_method_ptr,
	gnuv3_method_ptr_size, gnuv3_make_method_ptr, gnuv3_method_ptr_to_value):
	Use get_type_arch instead of get_class_arch.
This commit is contained in:
Ulrich Weigand 2009-07-02 12:57:14 +00:00
parent e9bb382b83
commit 5081068481
25 changed files with 220 additions and 147 deletions

View File

@ -1,3 +1,79 @@
2009-07-02 Ulrich Weigand <uweigand@de.ibm.com>
* gdbtypes.c (make_pointer_type, make_reference_type,
smash_to_memberptr_type, lookup_array_range_type, check_stub_method):
Use type architecture instead of current_gdbarch.
* gdbtypes.h (address_space_name_to_int, address_space_int_to_name):
Add GDBARCH paramter.
* gdbtypes.c (address_space_name_to_int, address_space_int_to_name):
Add GDBARCH parameter. Use it instead of current_gdbarch.
* c-typeprint.c (c_type_print_modifier): Update call.
* parse.c (push_type_address_space): Likewise.
* findvar.c (extract_typed_address, store_typed_address): Use type
architecture instead of current_gdbarch.
* value.c (value_as_address, unpack_field_as_long): Use type architecture
instead of current_gdbarch.
* doublest.c (floatformat_from_length): Add GDBARCH argument. Use it
instead of current_gdbarch.
(floatformat_from_type): Pass type architecture.
* infcall.c (find_function_addr): Use type architecture instead
of current_gdbarch.
* valarith.c (value_bitstring_subscript, value_x_binop, value_neg,
value_bit_index): Use type architecture instead of current_gdbarch.
* valops.c (value_cast, value_slice): Likewise.
* value.h (modify_field): Add TYPE argument.
* value.c (modify_field): Add TYPE argument. Use type architecture
instead of current_gdbarch.
(set_internalvar_component): Likewise.
* eval.c (evaluate_struct_tuple): Update call.
* valops.c (value_assign): Likewise.
* ada-lang.c (modify_general_field): Likewise. Add TYPE argument.
(make_array_descriptor): Update calls.
(move_bits): Add BITS_BIG_ENDIAN_P argument. Use it instead of
current_gdbarch.
(ada_value_assign, value_assign_to_component): Update calls.
(decode_packed_array, ada_value_primitive_packed_val, ada_value_assign,
value_assign_to_component): Use type arch instead of current_gdbarch.
* printcmd.c (float_type_from_length): Remove GDBARCH argument,
use type architecture instead.
(print_scalar_formatted, printf_command): Update calls. Use type
architecture instead of current_gdbarch.
* valprint.c (val_print_type_code_int): Use type architecture
instead of current_gdbarch.
* varobj.c (value_get_print_value): Likewise.
* python/python-prettyprint.c (print_string_repr): Add GDBARCH
argument. Use it instead of current_gdbarch.
(apply_val_pretty_printer): Update call.
* ada-valprint.c (ada_val_print_1): Use type architecture instead
of current_gdbarch.
* c-valprint.c (print_function_pointer_address): Add GDBARCH argument.
Use it instead of current_gdbarch.
(c_val_print): Update calls passing type architecture.
* f-valprint.c (f_val_print): Use type architecture instead of
current_gdbarch.
* jv-valprint (java_value_print): Likewise.
* m2-valprint.c (print_function_pointer_address): Add GDBARCH argument.
Use it instead of current_gdbarch.
(print_unpacked_pointer): Update calls passing type architecture.
* scm-valprint.c (scm_scmval_print): Use type architecture instead of
current_gdbarch.
* gnu-v3-abi.c (get_class_arch): Remove.
(gnuv3_rtti_type): Use get_type_arch instead of get_class_arch. Remove
special-case check for Java classes.
(gnuv3_virtual_fn_field, gnuv3_baseclass_offset, gnuv3_print_method_ptr,
gnuv3_method_ptr_size, gnuv3_make_method_ptr, gnuv3_method_ptr_to_value):
Use get_type_arch instead of get_class_arch.
2009-07-02 Ulrich Weigand <uweigand@de.ibm.com> 2009-07-02 Ulrich Weigand <uweigand@de.ibm.com>
* gdbtypes.h (TYPE_OBJFILE_OWNED, TYPE_OWNER): New macros. * gdbtypes.h (TYPE_OBJFILE_OWNED, TYPE_OWNER): New macros.

View File

@ -67,7 +67,7 @@
static void extract_string (CORE_ADDR addr, char *buf); static void extract_string (CORE_ADDR addr, char *buf);
static void modify_general_field (char *, LONGEST, int, int); static void modify_general_field (struct type *, char *, LONGEST, int, int);
static struct type *desc_base_type (struct type *); static struct type *desc_base_type (struct type *);
@ -182,7 +182,7 @@ static struct value *decode_packed_array (struct value *);
static struct value *value_subscript_packed (struct value *, int, static struct value *value_subscript_packed (struct value *, int,
struct value **); struct value **);
static void move_bits (gdb_byte *, int, const gdb_byte *, int, int); static void move_bits (gdb_byte *, int, const gdb_byte *, int, int, int);
static struct value *coerce_unspec_val_to_type (struct value *, static struct value *coerce_unspec_val_to_type (struct value *,
struct type *); struct type *);
@ -1214,9 +1214,10 @@ static char *bound_name[] = {
/* Like modify_field, but allows bitpos > wordlength. */ /* Like modify_field, but allows bitpos > wordlength. */
static void static void
modify_general_field (char *addr, LONGEST fieldval, int bitpos, int bitsize) modify_general_field (struct type *type, char *addr,
LONGEST fieldval, int bitpos, int bitsize)
{ {
modify_field (addr + bitpos / 8, fieldval, bitpos % 8, bitsize); modify_field (type, addr + bitpos / 8, fieldval, bitpos % 8, bitsize);
} }
@ -1832,7 +1833,7 @@ decode_packed_array (struct value *arr)
return NULL; return NULL;
} }
if (gdbarch_bits_big_endian (current_gdbarch) if (gdbarch_bits_big_endian (get_type_arch (value_type (arr)))
&& ada_is_modular_type (value_type (arr))) && ada_is_modular_type (value_type (arr)))
{ {
/* This is a (right-justified) modular type representing a packed /* This is a (right-justified) modular type representing a packed
@ -1956,7 +1957,7 @@ ada_value_primitive_packed_val (struct value *obj, const gdb_byte *valaddr,
int len = (bit_size + bit_offset + HOST_CHAR_BIT - 1) / 8; int len = (bit_size + bit_offset + HOST_CHAR_BIT - 1) / 8;
/* Transmit bytes from least to most significant; delta is the direction /* Transmit bytes from least to most significant; delta is the direction
the indices move. */ the indices move. */
int delta = gdbarch_bits_big_endian (current_gdbarch) ? -1 : 1; int delta = gdbarch_bits_big_endian (get_type_arch (type)) ? -1 : 1;
type = ada_check_typedef (type); type = ada_check_typedef (type);
@ -2005,7 +2006,7 @@ ada_value_primitive_packed_val (struct value *obj, const gdb_byte *valaddr,
memset (unpacked, 0, TYPE_LENGTH (type)); memset (unpacked, 0, TYPE_LENGTH (type));
return v; return v;
} }
else if (gdbarch_bits_big_endian (current_gdbarch)) else if (gdbarch_bits_big_endian (get_type_arch (type)))
{ {
src = len - 1; src = len - 1;
if (has_negatives (type) if (has_negatives (type)
@ -2091,7 +2092,7 @@ ada_value_primitive_packed_val (struct value *obj, const gdb_byte *valaddr,
not overlap. */ not overlap. */
static void static void
move_bits (gdb_byte *target, int targ_offset, const gdb_byte *source, move_bits (gdb_byte *target, int targ_offset, const gdb_byte *source,
int src_offset, int n) int src_offset, int n, int bits_big_endian_p)
{ {
unsigned int accum, mask; unsigned int accum, mask;
int accum_bits, chunk_size; int accum_bits, chunk_size;
@ -2100,7 +2101,7 @@ move_bits (gdb_byte *target, int targ_offset, const gdb_byte *source,
targ_offset %= HOST_CHAR_BIT; targ_offset %= HOST_CHAR_BIT;
source += src_offset / HOST_CHAR_BIT; source += src_offset / HOST_CHAR_BIT;
src_offset %= HOST_CHAR_BIT; src_offset %= HOST_CHAR_BIT;
if (gdbarch_bits_big_endian (current_gdbarch)) if (bits_big_endian_p)
{ {
accum = (unsigned char) *source; accum = (unsigned char) *source;
source += 1; source += 1;
@ -2192,12 +2193,12 @@ ada_value_assign (struct value *toval, struct value *fromval)
from_size = value_bitsize (fromval); from_size = value_bitsize (fromval);
if (from_size == 0) if (from_size == 0)
from_size = TYPE_LENGTH (value_type (fromval)) * TARGET_CHAR_BIT; from_size = TYPE_LENGTH (value_type (fromval)) * TARGET_CHAR_BIT;
if (gdbarch_bits_big_endian (current_gdbarch)) if (gdbarch_bits_big_endian (get_type_arch (type)))
move_bits (buffer, value_bitpos (toval), move_bits (buffer, value_bitpos (toval),
value_contents (fromval), from_size - bits, bits); value_contents (fromval), from_size - bits, bits, 1);
else else
move_bits (buffer, value_bitpos (toval), value_contents (fromval), move_bits (buffer, value_bitpos (toval),
0, bits); value_contents (fromval), 0, bits, 0);
write_memory (to_addr, buffer, len); write_memory (to_addr, buffer, len);
if (deprecated_memory_changed_hook) if (deprecated_memory_changed_hook)
deprecated_memory_changed_hook (to_addr, len); deprecated_memory_changed_hook (to_addr, len);
@ -2236,16 +2237,16 @@ value_assign_to_component (struct value *container, struct value *component,
else else
bits = value_bitsize (component); bits = value_bitsize (component);
if (gdbarch_bits_big_endian (current_gdbarch)) if (gdbarch_bits_big_endian (get_type_arch (value_type (container))))
move_bits (value_contents_writeable (container) + offset_in_container, move_bits (value_contents_writeable (container) + offset_in_container,
value_bitpos (container) + bit_offset_in_container, value_bitpos (container) + bit_offset_in_container,
value_contents (val), value_contents (val),
TYPE_LENGTH (value_type (component)) * TARGET_CHAR_BIT - bits, TYPE_LENGTH (value_type (component)) * TARGET_CHAR_BIT - bits,
bits); bits, 1);
else else
move_bits (value_contents_writeable (container) + offset_in_container, move_bits (value_contents_writeable (container) + offset_in_container,
value_bitpos (container) + bit_offset_in_container, value_bitpos (container) + bit_offset_in_container,
value_contents (val), 0, bits); value_contents (val), 0, bits, 0);
} }
/* The value of the element of array ARR at the ARITY indices given in IND. /* The value of the element of array ARR at the ARITY indices given in IND.
@ -3834,11 +3835,13 @@ make_array_descriptor (struct type *type, struct value *arr,
for (i = ada_array_arity (ada_check_typedef (value_type (arr))); i > 0; i -= 1) for (i = ada_array_arity (ada_check_typedef (value_type (arr))); i > 0; i -= 1)
{ {
modify_general_field (value_contents_writeable (bounds), modify_general_field (value_type (bounds),
value_contents_writeable (bounds),
ada_array_bound (arr, i, 0), ada_array_bound (arr, i, 0),
desc_bound_bitpos (bounds_type, i, 0), desc_bound_bitpos (bounds_type, i, 0),
desc_bound_bitsize (bounds_type, i, 0)); desc_bound_bitsize (bounds_type, i, 0));
modify_general_field (value_contents_writeable (bounds), modify_general_field (value_type (bounds),
value_contents_writeable (bounds),
ada_array_bound (arr, i, 1), ada_array_bound (arr, i, 1),
desc_bound_bitpos (bounds_type, i, 1), desc_bound_bitpos (bounds_type, i, 1),
desc_bound_bitsize (bounds_type, i, 1)); desc_bound_bitsize (bounds_type, i, 1));
@ -3846,12 +3849,14 @@ make_array_descriptor (struct type *type, struct value *arr,
bounds = ensure_lval (bounds, gdbarch, sp); bounds = ensure_lval (bounds, gdbarch, sp);
modify_general_field (value_contents_writeable (descriptor), modify_general_field (value_type (descriptor),
value_contents_writeable (descriptor),
value_address (ensure_lval (arr, gdbarch, sp)), value_address (ensure_lval (arr, gdbarch, sp)),
fat_pntr_data_bitpos (desc_type), fat_pntr_data_bitpos (desc_type),
fat_pntr_data_bitsize (desc_type)); fat_pntr_data_bitsize (desc_type));
modify_general_field (value_contents_writeable (descriptor), modify_general_field (value_type (descriptor),
value_contents_writeable (descriptor),
value_address (bounds), value_address (bounds),
fat_pntr_bounds_bitpos (desc_type), fat_pntr_bounds_bitpos (desc_type),
fat_pntr_bounds_bitsize (desc_type)); fat_pntr_bounds_bitsize (desc_type));

View File

@ -746,7 +746,7 @@ ada_val_print_1 (struct type *type, const gdb_byte *valaddr0,
struct value *func = ada_vax_float_print_function (type); struct value *func = ada_vax_float_print_function (type);
if (func != 0) if (func != 0)
{ {
struct gdbarch *gdbarch = current_gdbarch; struct gdbarch *gdbarch = get_type_arch (type);
CORE_ADDR addr; CORE_ADDR addr;
addr = value_as_address (call_function_by_hand (func, 1, &val)); addr = value_as_address (call_function_by_hand (func, 1, &val));
val_print_string (builtin_type (gdbarch)->builtin_true_char, val_print_string (builtin_type (gdbarch)->builtin_true_char,
@ -785,20 +785,15 @@ ada_val_print_1 (struct type *type, const gdb_byte *valaddr0,
opts.format = format; opts.format = format;
print_scalar_formatted (valaddr, type, &opts, 0, stream); print_scalar_formatted (valaddr, type, &opts, 0, stream);
} }
else if (ada_is_system_address_type (type) else if (ada_is_system_address_type (type))
&& TYPE_OBJFILE (type) != NULL)
{ {
/* FIXME: We want to print System.Address variables using /* FIXME: We want to print System.Address variables using
the same format as for any access type. But for some the same format as for any access type. But for some
reason GNAT encodes the System.Address type as an int, reason GNAT encodes the System.Address type as an int,
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. */
We do this only for System.Address types defined in an struct gdbarch *gdbarch = get_type_arch (type);
objfile. For the built-in version of System.Address we
have installed the proper type to begin with. */
struct gdbarch *gdbarch = get_objfile_arch (TYPE_OBJFILE (type));
struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr; struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
fprintf_filtered (stream, "("); fprintf_filtered (stream, "(");

View File

@ -338,7 +338,8 @@ c_type_print_modifier (struct type *type, struct ui_file *stream,
did_print_modifier = 1; did_print_modifier = 1;
} }
address_space_id = address_space_int_to_name (TYPE_INSTANCE_FLAGS (type)); address_space_id = address_space_int_to_name (get_type_arch (type),
TYPE_INSTANCE_FLAGS (type));
if (address_space_id) if (address_space_id)
{ {
if (did_print_modifier || need_pre_space) if (did_print_modifier || need_pre_space)

View File

@ -36,11 +36,10 @@
stream STREAM. */ stream STREAM. */
static void static void
print_function_pointer_address (CORE_ADDR address, struct ui_file *stream, print_function_pointer_address (struct gdbarch *gdbarch, CORE_ADDR address,
int addressprint) struct ui_file *stream, int addressprint)
{ {
CORE_ADDR func_addr = gdbarch_convert_from_func_ptr_addr (current_gdbarch, CORE_ADDR func_addr = gdbarch_convert_from_func_ptr_addr (gdbarch, address,
address,
&current_target); &current_target);
/* If the function pointer is represented by a description, print the /* If the function pointer is represented by a description, print the
@ -153,6 +152,7 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
CORE_ADDR address, struct ui_file *stream, int recurse, CORE_ADDR address, struct ui_file *stream, int recurse,
const struct value_print_options *options) const struct value_print_options *options)
{ {
struct gdbarch *gdbarch = get_type_arch (type);
unsigned int i = 0; /* Number of characters printed */ unsigned int i = 0; /* Number of characters printed */
unsigned len; unsigned len;
struct type *elttype, *unresolved_elttype; struct type *elttype, *unresolved_elttype;
@ -252,7 +252,8 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
-fvtable_thunks. (Otherwise, look under TYPE_CODE_STRUCT.) */ -fvtable_thunks. (Otherwise, look under TYPE_CODE_STRUCT.) */
CORE_ADDR addr CORE_ADDR addr
= extract_typed_address (valaddr + embedded_offset, type); = extract_typed_address (valaddr + embedded_offset, type);
print_function_pointer_address (addr, stream, options->addressprint); print_function_pointer_address (gdbarch, addr, stream,
options->addressprint);
break; break;
} }
unresolved_elttype = TYPE_TARGET_TYPE (type); unresolved_elttype = TYPE_TARGET_TYPE (type);
@ -264,7 +265,7 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
if (TYPE_CODE (elttype) == TYPE_CODE_FUNC) if (TYPE_CODE (elttype) == TYPE_CODE_FUNC)
{ {
/* Try to print what function it points to. */ /* Try to print what function it points to. */
print_function_pointer_address (addr, stream, print_function_pointer_address (gdbarch, addr, stream,
options->addressprint); options->addressprint);
/* Return value is irrelevant except for string pointers. */ /* Return value is irrelevant except for string pointers. */
return (0); return (0);
@ -382,7 +383,8 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
CORE_ADDR addr CORE_ADDR addr
= extract_typed_address (valaddr + offset, field_type); = extract_typed_address (valaddr + offset, field_type);
print_function_pointer_address (addr, stream, options->addressprint); print_function_pointer_address (gdbarch, addr, stream,
options->addressprint);
} }
else else
cp_print_value_fields (type, type, valaddr, embedded_offset, address, stream, cp_print_value_fields (type, type, valaddr, embedded_offset, address, stream,

View File

@ -761,27 +761,27 @@ floatformat_from_doublest (const struct floatformat *fmt,
but not passed on by GDB. This should be fixed. */ but not passed on by GDB. This should be fixed. */
static const struct floatformat * static const struct floatformat *
floatformat_from_length (int len) floatformat_from_length (struct gdbarch *gdbarch, int len)
{ {
const struct floatformat *format; const struct floatformat *format;
if (len * TARGET_CHAR_BIT == gdbarch_float_bit (current_gdbarch)) if (len * TARGET_CHAR_BIT == gdbarch_float_bit (gdbarch))
format = gdbarch_float_format (current_gdbarch) format = gdbarch_float_format (gdbarch)
[gdbarch_byte_order (current_gdbarch)]; [gdbarch_byte_order (gdbarch)];
else if (len * TARGET_CHAR_BIT == gdbarch_double_bit (current_gdbarch)) else if (len * TARGET_CHAR_BIT == gdbarch_double_bit (gdbarch))
format = gdbarch_double_format (current_gdbarch) format = gdbarch_double_format (gdbarch)
[gdbarch_byte_order (current_gdbarch)]; [gdbarch_byte_order (gdbarch)];
else if (len * TARGET_CHAR_BIT == gdbarch_long_double_bit (current_gdbarch)) else if (len * TARGET_CHAR_BIT == gdbarch_long_double_bit (gdbarch))
format = gdbarch_long_double_format (current_gdbarch) format = gdbarch_long_double_format (gdbarch)
[gdbarch_byte_order (current_gdbarch)]; [gdbarch_byte_order (gdbarch)];
/* On i386 the 'long double' type takes 96 bits, /* On i386 the 'long double' type takes 96 bits,
while the real number of used bits is only 80, while the real number of used bits is only 80,
both in processor and in memory. both in processor and in memory.
The code below accepts the real bit size. */ The code below accepts the real bit size. */
else if ((gdbarch_long_double_format (current_gdbarch) != NULL) else if ((gdbarch_long_double_format (gdbarch) != NULL)
&& (len * TARGET_CHAR_BIT == && (len * TARGET_CHAR_BIT ==
gdbarch_long_double_format (current_gdbarch)[0]->totalsize)) gdbarch_long_double_format (gdbarch)[0]->totalsize))
format = gdbarch_long_double_format (current_gdbarch) format = gdbarch_long_double_format (gdbarch)
[gdbarch_byte_order (current_gdbarch)]; [gdbarch_byte_order (gdbarch)];
else else
format = NULL; format = NULL;
if (format == NULL) if (format == NULL)
@ -793,11 +793,12 @@ floatformat_from_length (int len)
const struct floatformat * const struct floatformat *
floatformat_from_type (const struct type *type) floatformat_from_type (const struct type *type)
{ {
struct gdbarch *gdbarch = get_type_arch (type);
gdb_assert (TYPE_CODE (type) == TYPE_CODE_FLT); gdb_assert (TYPE_CODE (type) == TYPE_CODE_FLT);
if (TYPE_FLOATFORMAT (type) != NULL) if (TYPE_FLOATFORMAT (type) != NULL)
return TYPE_FLOATFORMAT (type)[gdbarch_byte_order (current_gdbarch)]; return TYPE_FLOATFORMAT (type)[gdbarch_byte_order (gdbarch)];
else else
return floatformat_from_length (TYPE_LENGTH (type)); return floatformat_from_length (gdbarch, TYPE_LENGTH (type));
} }
/* Extract a floating-point number of type TYPE from a target-order /* Extract a floating-point number of type TYPE from a target-order

View File

@ -354,8 +354,8 @@ evaluate_struct_tuple (struct value *struct_val,
bitpos += TYPE_FIELD_BITPOS (substruct_type, subfieldno); bitpos += TYPE_FIELD_BITPOS (substruct_type, subfieldno);
addr = value_contents_writeable (struct_val) + bitpos / 8; addr = value_contents_writeable (struct_val) + bitpos / 8;
if (bitsize) if (bitsize)
modify_field (addr, value_as_long (val), modify_field (struct_type, addr,
bitpos % 8, bitsize); value_as_long (val), bitpos % 8, bitsize);
else else
memcpy (addr, value_contents (val), memcpy (addr, value_contents (val),
TYPE_LENGTH (value_type (val))); TYPE_LENGTH (value_type (val)));

View File

@ -245,6 +245,7 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
CORE_ADDR address, struct ui_file *stream, int recurse, CORE_ADDR address, struct ui_file *stream, int recurse,
const struct value_print_options *options) const struct value_print_options *options)
{ {
struct gdbarch *gdbarch = get_type_arch (type);
unsigned int i = 0; /* Number of characters printed */ unsigned int i = 0; /* Number of characters printed */
struct type *elttype; struct type *elttype;
LONGEST val; LONGEST val;
@ -256,7 +257,7 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
{ {
case TYPE_CODE_STRING: case TYPE_CODE_STRING:
f77_get_dynamic_length_of_aggregate (type); f77_get_dynamic_length_of_aggregate (type);
LA_PRINT_STRING (stream, builtin_type (current_gdbarch)->builtin_char, LA_PRINT_STRING (stream, builtin_type (gdbarch)->builtin_char,
valaddr, TYPE_LENGTH (type), 0, options); valaddr, TYPE_LENGTH (type), 0, options);
break; break;

View File

@ -173,7 +173,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 (current_gdbarch, type, buf); return gdbarch_pointer_to_address (get_type_arch (type), type, buf);
} }
@ -242,7 +242,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 (current_gdbarch, type, buf, addr); gdbarch_address_to_pointer (get_type_arch (type), type, buf, addr);
} }

View File

@ -291,8 +291,8 @@ make_pointer_type (struct type *type, struct type **typeptr)
/* FIXME! Assume the machine has only one representation for /* FIXME! Assume the machine has only one representation for
pointers! */ pointers! */
TYPE_LENGTH (ntype) = TYPE_LENGTH (ntype)
gdbarch_ptr_bit (current_gdbarch) / TARGET_CHAR_BIT; = gdbarch_ptr_bit (get_type_arch (type)) / TARGET_CHAR_BIT;
TYPE_CODE (ntype) = TYPE_CODE_PTR; TYPE_CODE (ntype) = TYPE_CODE_PTR;
/* Mark pointers as unsigned. The target converts between pointers /* Mark pointers as unsigned. The target converts between pointers
@ -369,7 +369,8 @@ 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) = gdbarch_ptr_bit (current_gdbarch) / TARGET_CHAR_BIT; TYPE_LENGTH (ntype) =
gdbarch_ptr_bit (get_type_arch (type)) / TARGET_CHAR_BIT;
TYPE_CODE (ntype) = TYPE_CODE_REF; TYPE_CODE (ntype) = TYPE_CODE_REF;
if (!TYPE_REFERENCE_TYPE (type)) /* Remember it, if don't have one. */ if (!TYPE_REFERENCE_TYPE (type)) /* Remember it, if don't have one. */
@ -438,9 +439,8 @@ lookup_function_type (struct type *type)
/* Identify address space identifier by name -- /* Identify address space identifier by name --
return the integer flag defined in gdbtypes.h. */ return the integer flag defined in gdbtypes.h. */
extern int extern int
address_space_name_to_int (char *space_identifier) address_space_name_to_int (struct gdbarch *gdbarch, char *space_identifier)
{ {
struct gdbarch *gdbarch = current_gdbarch;
int type_flags; int type_flags;
/* Check for known address space delimiters. */ /* Check for known address space delimiters. */
if (!strcmp (space_identifier, "code")) if (!strcmp (space_identifier, "code"))
@ -460,9 +460,8 @@ address_space_name_to_int (char *space_identifier)
gdbtypes.h -- return the string version of the adress space name. */ gdbtypes.h -- return the string version of the adress space name. */
const char * const char *
address_space_int_to_name (int space_flag) address_space_int_to_name (struct gdbarch *gdbarch, int space_flag)
{ {
struct gdbarch *gdbarch = current_gdbarch;
if (space_flag & TYPE_INSTANCE_FLAG_CODE_SPACE) if (space_flag & TYPE_INSTANCE_FLAG_CODE_SPACE)
return "code"; return "code";
else if (space_flag & TYPE_INSTANCE_FLAG_DATA_SPACE) else if (space_flag & TYPE_INSTANCE_FLAG_DATA_SPACE)
@ -855,7 +854,7 @@ struct type *
lookup_array_range_type (struct type *element_type, lookup_array_range_type (struct type *element_type,
int low_bound, int high_bound) int low_bound, int high_bound)
{ {
struct gdbarch *gdbarch = current_gdbarch; struct gdbarch *gdbarch = get_type_arch (element_type);
struct type *index_type = builtin_type (gdbarch)->builtin_int; struct type *index_type = builtin_type (gdbarch)->builtin_int;
struct type *range_type struct type *range_type
= create_range_type (NULL, index_type, low_bound, high_bound); = create_range_type (NULL, index_type, low_bound, high_bound);
@ -978,7 +977,8 @@ smash_to_memberptr_type (struct type *type, struct type *domain,
TYPE_DOMAIN_TYPE (type) = domain; TYPE_DOMAIN_TYPE (type) = domain;
/* 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) = gdbarch_ptr_bit (current_gdbarch) / TARGET_CHAR_BIT; TYPE_LENGTH (type)
= gdbarch_ptr_bit (get_type_arch (to_type)) / TARGET_CHAR_BIT;
TYPE_CODE (type) = TYPE_CODE_MEMBERPTR; TYPE_CODE (type) = TYPE_CODE_MEMBERPTR;
} }
@ -1535,7 +1535,7 @@ safe_parse_type (struct gdbarch *gdbarch, 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 = current_gdbarch; struct gdbarch *gdbarch = get_type_arch (type);
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 = cplus_demangle (mangled_name, char *demangled_name = cplus_demangle (mangled_name,

View File

@ -1187,9 +1187,9 @@ extern struct type *make_cv_type (int, int, struct type *, struct type **);
extern void replace_type (struct type *, struct type *); extern void replace_type (struct type *, struct type *);
extern int address_space_name_to_int (char *); extern int address_space_name_to_int (struct gdbarch *, char *);
extern const char *address_space_int_to_name (int); extern const char *address_space_int_to_name (struct gdbarch *, int);
extern struct type *make_type_with_address_space (struct type *type, extern struct type *make_type_with_address_space (struct type *type,
int space_identifier); int space_identifier);

View File

@ -45,21 +45,6 @@ gnuv3_is_operator_name (const char *name)
} }
/* Determine architecture of class DOMAIN. This architecture is used
to query C++ ABI details (types, method pointer layout, etc.).
Note that we assume DOMAIN must have been allocated with an OBJFILE;
GDB does not provide any built-in class types. Thus we use the
architecture of that OBJFILE to define the C++ ABI. */
static struct gdbarch *
get_class_arch (struct type *domain)
{
gdb_assert (TYPE_CODE (domain) == TYPE_CODE_CLASS);
gdb_assert (TYPE_OBJFILE (domain) != NULL);
return get_objfile_arch (TYPE_OBJFILE (domain));
}
/* To help us find the components of a vtable, we build ourselves a /* To help us find the components of a vtable, we build ourselves a
GDB type object representing the vtable structure. Following the GDB type object representing the vtable structure. Following the
V3 ABI, it goes something like this: V3 ABI, it goes something like this:
@ -227,14 +212,8 @@ gnuv3_rtti_type (struct value *value,
if (TYPE_CODE (values_type) != TYPE_CODE_CLASS) if (TYPE_CODE (values_type) != TYPE_CODE_CLASS)
return NULL; return NULL;
/* This routine may be called for Java types that do not have
a proper objfile. Just return NULL for those. */
if (!TYPE_OBJFILE (values_type)
|| !TYPE_OBJFILE (values_type)->obfd)
return NULL;
/* Determine architecture. */ /* Determine architecture. */
gdbarch = get_class_arch (values_type); gdbarch = get_type_arch (values_type);
vtable_type = gdbarch_data (gdbarch, vtable_type_gdbarch_data); vtable_type = gdbarch_data (gdbarch, vtable_type_gdbarch_data);
/* If we can't find the virtual table pointer for values_type, we /* If we can't find the virtual table pointer for values_type, we
@ -386,7 +365,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_class_arch (values_type); gdbarch = get_type_arch (values_type);
/* 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'
@ -420,7 +399,7 @@ gnuv3_baseclass_offset (struct type *type, int index, const bfd_byte *valaddr,
int vbasetype_vptr_fieldno; int vbasetype_vptr_fieldno;
/* Determine architecture. */ /* Determine architecture. */
gdbarch = get_class_arch (type); gdbarch = get_type_arch (type);
vtable_type = gdbarch_data (gdbarch, vtable_type_gdbarch_data); vtable_type = gdbarch_data (gdbarch, vtable_type_gdbarch_data);
ptr_type = builtin_type (gdbarch)->builtin_data_ptr; ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
@ -574,7 +553,7 @@ gnuv3_print_method_ptr (const gdb_byte *contents,
struct ui_file *stream) struct ui_file *stream)
{ {
struct type *domain = TYPE_DOMAIN_TYPE (type); struct type *domain = TYPE_DOMAIN_TYPE (type);
struct gdbarch *gdbarch = get_class_arch (domain); struct gdbarch *gdbarch = get_type_arch (domain);
CORE_ADDR ptr_value; CORE_ADDR ptr_value;
LONGEST adjustment; LONGEST adjustment;
int vbit; int vbit;
@ -640,7 +619,7 @@ static int
gnuv3_method_ptr_size (struct type *type) gnuv3_method_ptr_size (struct type *type)
{ {
struct type *domain_type = check_typedef (TYPE_DOMAIN_TYPE (type)); struct type *domain_type = check_typedef (TYPE_DOMAIN_TYPE (type));
struct gdbarch *gdbarch = get_class_arch (domain_type); struct gdbarch *gdbarch = get_type_arch (domain_type);
return 2 * TYPE_LENGTH (builtin_type (gdbarch)->builtin_data_ptr); return 2 * TYPE_LENGTH (builtin_type (gdbarch)->builtin_data_ptr);
} }
@ -651,7 +630,7 @@ gnuv3_make_method_ptr (struct type *type, gdb_byte *contents,
CORE_ADDR value, int is_virtual) CORE_ADDR value, int is_virtual)
{ {
struct type *domain_type = check_typedef (TYPE_DOMAIN_TYPE (type)); struct type *domain_type = check_typedef (TYPE_DOMAIN_TYPE (type));
struct gdbarch *gdbarch = get_class_arch (domain_type); struct gdbarch *gdbarch = get_type_arch (domain_type);
int size = TYPE_LENGTH (builtin_type (gdbarch)->builtin_data_ptr); int size = TYPE_LENGTH (builtin_type (gdbarch)->builtin_data_ptr);
/* FIXME drow/2006-12-24: The adjustment of "this" is currently /* FIXME drow/2006-12-24: The adjustment of "this" is currently
@ -693,7 +672,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_class_arch (domain_type); gdbarch = get_type_arch (domain_type);
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

View File

@ -231,6 +231,7 @@ CORE_ADDR
find_function_addr (struct value *function, struct type **retval_type) find_function_addr (struct value *function, struct type **retval_type)
{ {
struct type *ftype = check_typedef (value_type (function)); struct type *ftype = check_typedef (value_type (function));
struct gdbarch *gdbarch = get_type_arch (ftype);
enum type_code code = TYPE_CODE (ftype); enum type_code code = TYPE_CODE (ftype);
struct type *value_type = NULL; struct type *value_type = NULL;
CORE_ADDR funaddr; CORE_ADDR funaddr;
@ -251,8 +252,7 @@ find_function_addr (struct value *function, struct type **retval_type)
if (TYPE_CODE (ftype) == TYPE_CODE_FUNC if (TYPE_CODE (ftype) == TYPE_CODE_FUNC
|| TYPE_CODE (ftype) == TYPE_CODE_METHOD) || TYPE_CODE (ftype) == TYPE_CODE_METHOD)
{ {
funaddr = gdbarch_convert_from_func_ptr_addr (current_gdbarch, funaddr = gdbarch_convert_from_func_ptr_addr (gdbarch, funaddr,
funaddr,
&current_target); &current_target);
value_type = TYPE_TARGET_TYPE (ftype); value_type = TYPE_TARGET_TYPE (ftype);
} }
@ -273,8 +273,7 @@ find_function_addr (struct value *function, struct type **retval_type)
CORE_ADDR nfunaddr; CORE_ADDR nfunaddr;
funaddr = value_as_address (value_addr (function)); funaddr = value_as_address (value_addr (function));
nfunaddr = funaddr; nfunaddr = funaddr;
funaddr = gdbarch_convert_from_func_ptr_addr (current_gdbarch, funaddr = gdbarch_convert_from_func_ptr_addr (gdbarch, funaddr,
funaddr,
&current_target); &current_target);
if (funaddr != nfunaddr) if (funaddr != nfunaddr)
found_descriptor = 1; found_descriptor = 1;
@ -289,7 +288,7 @@ find_function_addr (struct value *function, struct type **retval_type)
if (retval_type != NULL) if (retval_type != NULL)
*retval_type = value_type; *retval_type = value_type;
return funaddr + gdbarch_deprecated_function_start_offset (current_gdbarch); return funaddr + gdbarch_deprecated_function_start_offset (gdbarch);
} }
/* For CALL_DUMMY_ON_STACK, push a breakpoint sequence that the called /* For CALL_DUMMY_ON_STACK, push a breakpoint sequence that the called

View File

@ -38,7 +38,7 @@ int
java_value_print (struct value *val, struct ui_file *stream, java_value_print (struct value *val, struct ui_file *stream,
const struct value_print_options *options) const struct value_print_options *options)
{ {
struct gdbarch *gdbarch = current_gdbarch; struct gdbarch *gdbarch = get_type_arch (value_type (val));
struct type *type; struct type *type;
CORE_ADDR address; CORE_ADDR address;
int i; int i;

View File

@ -46,11 +46,10 @@ m2_print_array_contents (struct type *type, const gdb_byte *valaddr,
stream STREAM. */ stream STREAM. */
static void static void
print_function_pointer_address (CORE_ADDR address, struct ui_file *stream, print_function_pointer_address (struct gdbarch *gdbarch, CORE_ADDR address,
int addressprint) struct ui_file *stream, int addressprint)
{ {
CORE_ADDR func_addr = gdbarch_convert_from_func_ptr_addr (current_gdbarch, CORE_ADDR func_addr = gdbarch_convert_from_func_ptr_addr (gdbarch, address,
address,
&current_target); &current_target);
/* If the function pointer is represented by a description, print the /* If the function pointer is represented by a description, print the
@ -213,12 +212,14 @@ 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 type *elttype = check_typedef (TYPE_TARGET_TYPE (type)); struct type *elttype = check_typedef (TYPE_TARGET_TYPE (type));
if (TYPE_CODE (elttype) == TYPE_CODE_FUNC) if (TYPE_CODE (elttype) == TYPE_CODE_FUNC)
{ {
/* Try to print what function it points to. */ /* Try to print what function it points to. */
print_function_pointer_address (addr, stream, options->addressprint); print_function_pointer_address (gdbarch, addr, stream,
options->addressprint);
/* Return value is irrelevant except for string pointers. */ /* Return value is irrelevant except for string pointers. */
return 0; return 0;
} }

View File

@ -1227,7 +1227,7 @@ push_type_int (int n)
void void
push_type_address_space (char *string) push_type_address_space (char *string)
{ {
push_type_int (address_space_name_to_int (string)); push_type_int (address_space_name_to_int (parse_gdbarch, string));
} }
enum type_pieces enum type_pieces

View File

@ -317,8 +317,9 @@ print_formatted (struct value *val, int size,
/* Return builtin floating point type of same length as TYPE. /* Return builtin floating point type of same length as TYPE.
If no such type is found, return TYPE itself. */ If no such type is found, return TYPE itself. */
static struct type * static struct type *
float_type_from_length (struct gdbarch *gdbarch, struct type *type) float_type_from_length (struct type *type)
{ {
struct gdbarch *gdbarch = get_type_arch (type);
const struct builtin_type *builtin = builtin_type (gdbarch); const struct builtin_type *builtin = builtin_type (gdbarch);
unsigned int len = TYPE_LENGTH (type); unsigned int len = TYPE_LENGTH (type);
@ -344,7 +345,7 @@ print_scalar_formatted (const void *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 = current_gdbarch; struct gdbarch *gdbarch = get_type_arch (type);
LONGEST val_long = 0; LONGEST val_long = 0;
unsigned int len = TYPE_LENGTH (type); unsigned int len = TYPE_LENGTH (type);
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
@ -466,7 +467,7 @@ print_scalar_formatted (const void *valaddr, struct type *type,
break; break;
case 'f': case 'f':
type = float_type_from_length (current_gdbarch, type); type = float_type_from_length (type);
print_floating (valaddr, type, stream); print_floating (valaddr, type, stream);
break; break;
@ -2275,8 +2276,9 @@ printf_command (char *arg, int from_tty)
gdb_byte *str; gdb_byte *str;
CORE_ADDR tem; CORE_ADDR tem;
int j; int j;
struct type *wctype = lookup_typename (current_language, struct gdbarch *gdbarch
current_gdbarch, = get_type_arch (value_type (val_args[i]));
struct type *wctype = lookup_typename (current_language, gdbarch,
"wchar_t", NULL, 0); "wchar_t", NULL, 0);
int wcwidth = TYPE_LENGTH (wctype); int wcwidth = TYPE_LENGTH (wctype);
gdb_byte *buf = alloca (wcwidth); gdb_byte *buf = alloca (wcwidth);
@ -2315,8 +2317,9 @@ printf_command (char *arg, int from_tty)
break; break;
case wide_char_arg: case wide_char_arg:
{ {
struct type *wctype = lookup_typename (current_language, struct gdbarch *gdbarch
current_gdbarch, = get_type_arch (value_type (val_args[i]));
struct type *wctype = lookup_typename (current_language, gdbarch,
"wchar_t", NULL, 0); "wchar_t", NULL, 0);
struct type *valtype; struct type *valtype;
struct obstack output; struct obstack output;
@ -2352,7 +2355,7 @@ printf_command (char *arg, int from_tty)
/* If format string wants a float, unchecked-convert the value /* If format string wants a float, unchecked-convert the value
to floating point of the same size. */ to floating point of the same size. */
type = float_type_from_length (current_gdbarch, type); type = float_type_from_length (type);
val = unpack_double (type, value_contents (val_args[i]), &inv); val = unpack_double (type, value_contents (val_args[i]), &inv);
if (inv) if (inv)
error (_("Invalid floating value found in program.")); error (_("Invalid floating value found in program."));
@ -2369,7 +2372,7 @@ printf_command (char *arg, int from_tty)
/* If format string wants a float, unchecked-convert the value /* If format string wants a float, unchecked-convert the value
to floating point of the same size. */ to floating point of the same size. */
type = float_type_from_length (current_gdbarch, type); type = float_type_from_length (type);
val = unpack_double (type, value_contents (val_args[i]), &inv); val = unpack_double (type, value_contents (val_args[i]), &inv);
if (inv) if (inv)
error (_("Invalid floating value found in program.")); error (_("Invalid floating value found in program."));
@ -2423,6 +2426,7 @@ printf_command (char *arg, int from_tty)
/* Parameter data. */ /* Parameter data. */
struct type *param_type = value_type (val_args[i]); struct type *param_type = value_type (val_args[i]);
unsigned int param_len = TYPE_LENGTH (param_type); unsigned int param_len = TYPE_LENGTH (param_type);
struct gdbarch *gdbarch = get_type_arch (param_type);
/* DFP output data. */ /* DFP output data. */
struct value *dfp_value = NULL; struct value *dfp_value = NULL;
@ -2451,18 +2455,18 @@ printf_command (char *arg, int from_tty)
if (*sos == 'H') if (*sos == 'H')
{ {
dfp_len = 4; dfp_len = 4;
dfp_type = builtin_type (current_gdbarch)->builtin_decfloat; dfp_type = builtin_type (gdbarch)->builtin_decfloat;
} }
else if (*sos == 'D' && *(sos - 1) == 'D') else if (*sos == 'D' && *(sos - 1) == 'D')
{ {
dfp_len = 16; dfp_len = 16;
dfp_type = builtin_type (current_gdbarch)->builtin_declong; dfp_type = builtin_type (gdbarch)->builtin_declong;
sos--; sos--;
} }
else else
{ {
dfp_len = 8; dfp_len = 8;
dfp_type = builtin_type (current_gdbarch)->builtin_decdouble; dfp_type = builtin_type (gdbarch)->builtin_decdouble;
} }
} }

View File

@ -181,7 +181,8 @@ static void
print_string_repr (PyObject *printer, const char *hint, print_string_repr (PyObject *printer, const char *hint,
struct ui_file *stream, int recurse, struct ui_file *stream, int recurse,
const struct value_print_options *options, const struct value_print_options *options,
const struct language_defn *language) const struct language_defn *language,
struct gdbarch *gdbarch)
{ {
char *output; char *output;
struct value *replacement = NULL; struct value *replacement = NULL;
@ -190,7 +191,7 @@ print_string_repr (PyObject *printer, const char *hint,
if (output) if (output)
{ {
if (hint && !strcmp (hint, "string")) if (hint && !strcmp (hint, "string"))
LA_PRINT_STRING (stream, builtin_type (current_gdbarch)->builtin_char, LA_PRINT_STRING (stream, builtin_type (gdbarch)->builtin_char,
(gdb_byte *) output, strlen (output), (gdb_byte *) output, strlen (output),
0, options); 0, options);
else else
@ -466,6 +467,7 @@ apply_val_pretty_printer (struct type *type, const gdb_byte *valaddr,
const struct value_print_options *options, const struct value_print_options *options,
const struct language_defn *language) const struct language_defn *language)
{ {
struct gdbarch *gdbarch = get_type_arch (type);
PyObject *printer = NULL; PyObject *printer = NULL;
PyObject *val_obj = NULL; PyObject *val_obj = NULL;
struct value *value; struct value *value;
@ -498,7 +500,8 @@ apply_val_pretty_printer (struct type *type, const gdb_byte *valaddr,
make_cleanup (free_current_contents, &hint); make_cleanup (free_current_contents, &hint);
/* Print the section */ /* Print the section */
print_string_repr (printer, hint, stream, recurse, options, language); print_string_repr (printer, hint, stream, recurse, options, language,
gdbarch);
print_children (printer, hint, stream, recurse, options, language); print_children (printer, hint, stream, recurse, options, language);
result = 1; result = 1;

View File

@ -179,6 +179,8 @@ scm_scmval_print (struct type *type, LONGEST svalue,
struct ui_file *stream, int recurse, struct ui_file *stream, int recurse,
const struct value_print_options *options) const struct value_print_options *options)
{ {
struct gdbarch *gdbarch = get_type_arch (type);
#define SCM_SIZE (TYPE_LENGTH (type)) #define SCM_SIZE (TYPE_LENGTH (type))
taloop: taloop:
switch (7 & (int) svalue) switch (7 & (int) svalue)
@ -193,7 +195,7 @@ taloop:
if (SCM_ICHRP (svalue)) if (SCM_ICHRP (svalue))
{ {
svalue = SCM_ICHR (svalue); svalue = SCM_ICHR (svalue);
scm_printchar (svalue, builtin_type (current_gdbarch)->builtin_char, scm_printchar (svalue, builtin_type (gdbarch)->builtin_char,
stream); stream);
break; break;
} }

View File

@ -233,7 +233,7 @@ value_bitstring_subscript (struct type *type,
byte = *((char *) value_contents (bitstring) + offset); byte = *((char *) value_contents (bitstring) + offset);
bit_index = index % TARGET_CHAR_BIT; bit_index = index % TARGET_CHAR_BIT;
byte >>= (gdbarch_bits_big_endian (current_gdbarch) ? byte >>= (gdbarch_bits_big_endian (get_type_arch (bitstring_type)) ?
TARGET_CHAR_BIT - 1 - bit_index : bit_index); TARGET_CHAR_BIT - 1 - bit_index : bit_index);
v = value_from_longest (type, byte & 1); v = value_from_longest (type, byte & 1);
@ -471,7 +471,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 = current_gdbarch; struct gdbarch *gdbarch = get_type_arch (value_type (arg1));
struct value **argvec; struct value **argvec;
char *ptr, *mangle_ptr; char *ptr, *mangle_ptr;
char tstr[13], mangle_tstr[13]; char tstr[13], mangle_tstr[13];
@ -1479,7 +1479,7 @@ value_neg (struct value *arg1)
memcpy (decbytes, value_contents (arg1), len); memcpy (decbytes, value_contents (arg1), len);
if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_LITTLE) if (gdbarch_byte_order (get_type_arch (type)) == BFD_ENDIAN_LITTLE)
decbytes[len-1] = decbytes[len - 1] | 0x80; decbytes[len-1] = decbytes[len - 1] | 0x80;
else else
decbytes[0] = decbytes[0] | 0x80; decbytes[0] = decbytes[0] | 0x80;
@ -1521,6 +1521,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);
LONGEST low_bound, high_bound; LONGEST low_bound, high_bound;
LONGEST word; LONGEST word;
unsigned rel_index; unsigned rel_index;
@ -1532,7 +1533,7 @@ value_bit_index (struct type *type, const gdb_byte *valaddr, int index)
rel_index = index - low_bound; rel_index = index - low_bound;
word = extract_unsigned_integer (valaddr + (rel_index / TARGET_CHAR_BIT), 1); word = extract_unsigned_integer (valaddr + (rel_index / TARGET_CHAR_BIT), 1);
rel_index %= TARGET_CHAR_BIT; rel_index %= TARGET_CHAR_BIT;
if (gdbarch_bits_big_endian (current_gdbarch)) if (gdbarch_bits_big_endian (gdbarch))
rel_index = TARGET_CHAR_BIT - 1 - rel_index; rel_index = TARGET_CHAR_BIT - 1 - rel_index;
return (word >> rel_index) & 1; return (word >> rel_index) & 1;
} }

View File

@ -471,7 +471,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 (current_gdbarch); int addr_bit = gdbarch_addr_bit (get_type_arch (type2));
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)
@ -808,7 +808,7 @@ value_assign (struct value *toval, struct value *fromval)
(int) sizeof (LONGEST) * HOST_CHAR_BIT); (int) sizeof (LONGEST) * HOST_CHAR_BIT);
read_memory (value_address (toval), buffer, changed_len); read_memory (value_address (toval), buffer, changed_len);
modify_field (buffer, value_as_long (fromval), modify_field (type, buffer, value_as_long (fromval),
value_bitpos (toval), value_bitsize (toval)); value_bitpos (toval), value_bitsize (toval));
changed_addr = value_address (toval); changed_addr = value_address (toval);
dest_buffer = buffer; dest_buffer = buffer;
@ -869,9 +869,8 @@ value_assign (struct value *toval, struct value *fromval)
value_offset (toval), value_offset (toval),
changed_len, buffer); changed_len, buffer);
modify_field (buffer, value_as_long (fromval), modify_field (type, buffer, value_as_long (fromval),
value_bitpos (toval), value_bitpos (toval), value_bitsize (toval));
value_bitsize (toval));
put_frame_register_bytes (frame, value_reg, put_frame_register_bytes (frame, value_reg,
value_offset (toval), value_offset (toval),
@ -2947,7 +2946,7 @@ value_slice (struct value *array, int lowbound, int length)
else if (element > 0) else if (element > 0)
{ {
int j = i % TARGET_CHAR_BIT; int j = i % TARGET_CHAR_BIT;
if (gdbarch_bits_big_endian (current_gdbarch)) if (gdbarch_bits_big_endian (get_type_arch (array_type)))
j = TARGET_CHAR_BIT - 1 - j; j = TARGET_CHAR_BIT - 1 - j;
value_contents_raw (slice)[i / TARGET_CHAR_BIT] |= (1 << j); value_contents_raw (slice)[i / TARGET_CHAR_BIT] |= (1 << j);
} }

View File

@ -401,7 +401,7 @@ void
val_print_type_code_int (struct type *type, const gdb_byte *valaddr, val_print_type_code_int (struct type *type, const gdb_byte *valaddr,
struct ui_file *stream) struct ui_file *stream)
{ {
enum bfd_endian byte_order = gdbarch_byte_order (current_gdbarch); enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type));
if (TYPE_LENGTH (type) > sizeof (LONGEST)) if (TYPE_LENGTH (type) > sizeof (LONGEST))
{ {

View File

@ -1162,7 +1162,7 @@ set_internalvar_component (struct internalvar *var, int offset, int bitpos,
addr = value_contents_writeable (var->u.value); addr = value_contents_writeable (var->u.value);
if (bitsize) if (bitsize)
modify_field (addr + offset, modify_field (value_type (var->u.value), addr + offset,
value_as_long (newval), bitpos, bitsize); value_as_long (newval), bitpos, bitsize);
else else
memcpy (addr + offset, value_contents (newval), memcpy (addr + offset, value_contents (newval),
@ -1505,13 +1505,15 @@ value_as_double (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));
/* 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. */
#if 0 #if 0
/* gdbarch_addr_bits_remove is wrong if we are being called for a /* gdbarch_addr_bits_remove is wrong if we are being called for a
non-address (e.g. argument to "signal", "info break", etc.), or non-address (e.g. argument to "signal", "info break", etc.), or
for pointers to char, in which the low bits *are* significant. */ for pointers to char, in which the low bits *are* significant. */
return gdbarch_addr_bits_remove (current_gdbarch, value_as_long (val)); return gdbarch_addr_bits_remove (gdbarch, value_as_long (val));
#else #else
/* There are several targets (IA-64, PowerPC, and others) which /* There are several targets (IA-64, PowerPC, and others) which
@ -1596,8 +1598,8 @@ value_as_address (struct value *val)
if (TYPE_CODE (value_type (val)) != TYPE_CODE_PTR if (TYPE_CODE (value_type (val)) != TYPE_CODE_PTR
&& TYPE_CODE (value_type (val)) != TYPE_CODE_REF && TYPE_CODE (value_type (val)) != TYPE_CODE_REF
&& gdbarch_integer_to_address_p (current_gdbarch)) && gdbarch_integer_to_address_p (gdbarch))
return gdbarch_integer_to_address (current_gdbarch, value_type (val), return gdbarch_integer_to_address (gdbarch, value_type (val),
value_contents (val)); value_contents (val));
return unpack_long (value_type (val), value_contents (val)); return unpack_long (value_type (val), value_contents (val));
@ -1988,7 +1990,7 @@ unpack_field_as_long (struct type *type, const gdb_byte *valaddr, int fieldno)
/* Extract bits. See comment above. */ /* Extract bits. See comment above. */
if (gdbarch_bits_big_endian (current_gdbarch)) if (gdbarch_bits_big_endian (get_type_arch (type)))
lsbcount = (sizeof val * 8 - bitpos % 8 - bitsize); lsbcount = (sizeof val * 8 - bitpos % 8 - bitsize);
else else
lsbcount = (bitpos % 8); lsbcount = (bitpos % 8);
@ -2020,7 +2022,8 @@ unpack_field_as_long (struct type *type, const gdb_byte *valaddr, int fieldno)
0 <= BITPOS, where lbits is the size of a LONGEST in bits. */ 0 <= BITPOS, where lbits is the size of a LONGEST in bits. */
void void
modify_field (gdb_byte *addr, LONGEST fieldval, int bitpos, int bitsize) modify_field (struct type *type, gdb_byte *addr,
LONGEST fieldval, int bitpos, int bitsize)
{ {
ULONGEST oword; ULONGEST oword;
ULONGEST mask = (ULONGEST) -1 >> (8 * sizeof (ULONGEST) - bitsize); ULONGEST mask = (ULONGEST) -1 >> (8 * sizeof (ULONGEST) - bitsize);
@ -2044,7 +2047,7 @@ modify_field (gdb_byte *addr, LONGEST fieldval, int bitpos, int bitsize)
oword = extract_unsigned_integer (addr, sizeof oword); oword = extract_unsigned_integer (addr, sizeof oword);
/* Shifting for bit field depends on endianness of the target machine. */ /* Shifting for bit field depends on endianness of the target machine. */
if (gdbarch_bits_big_endian (current_gdbarch)) if (gdbarch_bits_big_endian (get_type_arch (type)))
bitpos = sizeof (oword) * 8 - bitpos - bitsize; bitpos = sizeof (oword) * 8 - bitpos - bitsize;
oword &= ~(mask << bitpos); oword &= ~(mask << bitpos);

View File

@ -589,8 +589,8 @@ extern void release_value (struct value *val);
extern int record_latest_value (struct value *val); extern int record_latest_value (struct value *val);
extern void modify_field (gdb_byte *addr, LONGEST fieldval, int bitpos, extern void modify_field (struct type *type, gdb_byte *addr,
int bitsize); LONGEST fieldval, int bitpos, int bitsize);
extern void type_print (struct type *type, char *varstring, extern void type_print (struct type *type, char *varstring,
struct ui_file *stream, int show); struct ui_file *stream, int show);

View File

@ -2263,8 +2263,9 @@ value_get_print_value (struct value *value, enum varobj_display_formats format,
opts.raw = 1; opts.raw = 1;
if (thevalue) if (thevalue)
{ {
struct gdbarch *gdbarch = get_type_arch (value_type (value));
make_cleanup (xfree, thevalue); make_cleanup (xfree, thevalue);
LA_PRINT_STRING (stb, builtin_type (current_gdbarch)->builtin_char, LA_PRINT_STRING (stb, builtin_type (gdbarch)->builtin_char,
(gdb_byte *) thevalue, strlen (thevalue), (gdb_byte *) thevalue, strlen (thevalue),
0, &opts); 0, &opts);
} }