From df86565b31bf12aab6fdceade49169bc6f378b13 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Wed, 21 Sep 2022 11:05:21 -0400 Subject: gdb: remove TYPE_LENGTH Remove the macro, replace all uses with calls to type::length. Change-Id: Ib9bdc954576860b21190886534c99103d6a47afb --- gdb/aarch64-tdep.c | 60 ++++++------ gdb/ada-lang.c | 116 +++++++++++----------- gdb/ada-lex.l | 2 +- gdb/ada-tasks.c | 4 +- gdb/ada-typeprint.c | 4 +- gdb/ada-valprint.c | 24 ++--- gdb/alpha-tdep.c | 32 +++---- gdb/amd64-tdep.c | 26 ++--- gdb/amd64-windows-tdep.c | 26 ++--- gdb/arc-tdep.c | 12 +-- gdb/arm-tdep.c | 48 +++++----- gdb/auxv.c | 8 +- gdb/avr-tdep.c | 22 ++--- gdb/ax-gdb.c | 32 +++---- gdb/bfin-tdep.c | 10 +- gdb/bpf-tdep.c | 6 +- gdb/breakpoint.c | 4 +- gdb/c-exp.y | 2 +- gdb/c-lang.c | 18 ++-- gdb/c-typeprint.c | 2 +- gdb/c-valprint.c | 16 ++-- gdb/c-varobj.c | 4 +- gdb/cli/cli-dump.c | 4 +- gdb/coffread.c | 4 +- gdb/compile/compile-c-support.c | 4 +- gdb/compile/compile-c-types.c | 16 ++-- gdb/compile/compile-cplus-types.c | 12 +-- gdb/compile/compile-object-load.c | 14 +-- gdb/corefile.c | 4 +- gdb/cp-valprint.c | 12 +-- gdb/cris-tdep.c | 8 +- gdb/csky-tdep.c | 4 +- gdb/ctfread.c | 2 +- gdb/d-valprint.c | 2 +- gdb/dwarf2/cu.c | 2 +- gdb/dwarf2/expr.c | 40 ++++---- gdb/dwarf2/loc.c | 10 +- gdb/dwarf2/read.c | 44 ++++----- gdb/elfread.c | 4 +- gdb/eval.c | 54 +++++------ gdb/f-exp.y | 2 +- gdb/f-lang.c | 60 ++++++------ gdb/f-lang.h | 2 +- gdb/f-valprint.c | 12 +-- gdb/fbsd-tdep.c | 6 +- gdb/findcmd.c | 2 +- gdb/findvar.c | 20 ++-- gdb/frame.c | 4 +- gdb/frv-tdep.c | 8 +- gdb/ft32-tdep.c | 8 +- gdb/gdbarch-selftests.c | 14 +-- gdb/gdbtypes.c | 91 +++++++++--------- gdb/gdbtypes.h | 9 +- gdb/gnu-v2-abi.c | 4 +- gdb/gnu-v3-abi.c | 36 +++---- gdb/go-exp.y | 2 +- gdb/go-lang.c | 2 +- gdb/guile/scm-math.c | 6 +- gdb/guile/scm-pretty-print.c | 2 +- gdb/guile/scm-type.c | 2 +- gdb/guile/scm-value.c | 4 +- gdb/h8300-tdep.c | 39 ++++---- gdb/hppa-tdep.c | 34 +++---- gdb/i386-darwin-tdep.c | 8 +- gdb/i386-tdep.c | 48 +++++----- gdb/ia64-tdep.c | 42 ++++---- gdb/infcall.c | 20 ++-- gdb/infcmd.c | 2 +- gdb/infrun.c | 14 +-- gdb/iq2000-tdep.c | 18 ++-- gdb/jit.c | 4 +- gdb/linux-record.c | 2 +- gdb/linux-tdep.c | 24 ++--- gdb/lm32-tdep.c | 18 ++-- gdb/loongarch-tdep.c | 6 +- gdb/m2-exp.y | 2 +- gdb/m2-lang.h | 6 +- gdb/m2-typeprint.c | 10 +- gdb/m2-valprint.c | 14 +-- gdb/m32c-tdep.c | 38 ++++---- gdb/m32r-tdep.c | 10 +- gdb/m68hc11-tdep.c | 18 ++-- gdb/m68k-bsd-tdep.c | 2 +- gdb/m68k-tdep.c | 16 ++-- gdb/mdebugread.c | 6 +- gdb/mep-tdep.c | 30 +++--- gdb/mi/mi-cmd-stack.c | 2 +- gdb/microblaze-tdep.c | 8 +- gdb/mips-tdep.c | 114 +++++++++++----------- gdb/mn10300-tdep.c | 16 ++-- gdb/moxie-tdep.c | 6 +- gdb/msp430-tdep.c | 6 +- gdb/nds32-tdep.c | 10 +- gdb/netbsd-tdep.c | 10 +- gdb/nios2-tdep.c | 12 +-- gdb/objfiles.c | 2 +- gdb/opencl-lang.c | 40 ++++---- gdb/or1k-tdep.c | 8 +- gdb/p-exp.y | 2 +- gdb/p-lang.c | 6 +- gdb/p-typeprint.c | 2 +- gdb/p-valprint.c | 20 ++-- gdb/ppc-linux-nat.c | 4 +- gdb/ppc-linux-tdep.c | 2 +- gdb/ppc-netbsd-tdep.c | 10 +- gdb/ppc-sysv-tdep.c | 196 +++++++++++++++++++------------------- gdb/printcmd.c | 38 ++++---- gdb/procfs.c | 4 +- gdb/python/py-inferior.c | 2 +- gdb/python/py-prettyprint.c | 2 +- gdb/python/py-type.c | 2 +- gdb/python/py-unwind.c | 6 +- gdb/python/py-value.c | 4 +- gdb/ravenscar-thread.c | 2 +- gdb/regcache.c | 6 +- gdb/riscv-tdep.c | 52 +++++----- gdb/rl78-tdep.c | 10 +- gdb/rs6000-aix-tdep.c | 16 ++-- gdb/rs6000-lynx178-tdep.c | 16 ++-- gdb/rs6000-tdep.c | 4 +- gdb/rust-lang.c | 20 ++-- gdb/rx-tdep.c | 14 +-- gdb/s12z-tdep.c | 4 +- gdb/s390-tdep.c | 28 +++--- gdb/sh-tdep.c | 24 ++--- gdb/solib-darwin.c | 12 +-- gdb/solib-svr4.c | 6 +- gdb/sparc-tdep.c | 32 +++---- gdb/sparc64-tdep.c | 28 +++--- gdb/stabsread.c | 10 +- gdb/stack.c | 6 +- gdb/stap-probe.c | 8 +- gdb/symmisc.c | 4 +- gdb/target-float.c | 24 ++--- gdb/tic6x-tdep.c | 12 +-- gdb/tilegx-tdep.c | 14 +-- gdb/tracepoint.c | 8 +- gdb/typeprint.c | 12 +-- gdb/v850-tdep.c | 26 ++--- gdb/valarith.c | 60 ++++++------ gdb/valops.c | 52 +++++----- gdb/valprint.c | 30 +++--- gdb/valprint.h | 2 +- gdb/value.c | 54 +++++------ gdb/value.h | 2 +- gdb/vax-tdep.c | 4 +- gdb/windows-tdep.c | 16 ++-- gdb/xstormy16-tdep.c | 16 ++-- gdb/xtensa-tdep.c | 28 +++--- gdb/z80-tdep.c | 2 +- 150 files changed, 1320 insertions(+), 1323 deletions(-) (limited to 'gdb') diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c index 744348c..d038704 100644 --- a/gdb/aarch64-tdep.c +++ b/gdb/aarch64-tdep.c @@ -1454,10 +1454,10 @@ aarch64_type_align (gdbarch *gdbarch, struct type *t) { /* Use the natural alignment for vector types (the same for scalar type), but the maximum alignment is 128-bit. */ - if (TYPE_LENGTH (t) > 16) + if (t->length () > 16) return 16; else - return TYPE_LENGTH (t); + return t->length (); } /* Allow the common code to calculate the alignment. */ @@ -1483,12 +1483,12 @@ aapcs_is_vfp_call_or_return_candidate_1 (struct type *type, { case TYPE_CODE_FLT: case TYPE_CODE_DECFLOAT: - if (TYPE_LENGTH (type) > 16) + if (type->length () > 16) return -1; if (*fundamental_type == nullptr) *fundamental_type = type; - else if (TYPE_LENGTH (type) != TYPE_LENGTH (*fundamental_type) + else if (type->length () != (*fundamental_type)->length () || type->code () != (*fundamental_type)->code ()) return -1; @@ -1497,12 +1497,12 @@ aapcs_is_vfp_call_or_return_candidate_1 (struct type *type, case TYPE_CODE_COMPLEX: { struct type *target_type = check_typedef (type->target_type ()); - if (TYPE_LENGTH (target_type) > 16) + if (target_type->length () > 16) return -1; if (*fundamental_type == nullptr) *fundamental_type = target_type; - else if (TYPE_LENGTH (target_type) != TYPE_LENGTH (*fundamental_type) + else if (target_type->length () != (*fundamental_type)->length () || target_type->code () != (*fundamental_type)->code ()) return -1; @@ -1513,12 +1513,12 @@ aapcs_is_vfp_call_or_return_candidate_1 (struct type *type, { if (type->is_vector ()) { - if (TYPE_LENGTH (type) != 8 && TYPE_LENGTH (type) != 16) + if (type->length () != 8 && type->length () != 16) return -1; if (*fundamental_type == nullptr) *fundamental_type = type; - else if (TYPE_LENGTH (type) != TYPE_LENGTH (*fundamental_type) + else if (type->length () != (*fundamental_type)->length () || type->code () != (*fundamental_type)->code ()) return -1; @@ -1533,7 +1533,7 @@ aapcs_is_vfp_call_or_return_candidate_1 (struct type *type, if (count == -1) return count; - count *= (TYPE_LENGTH (type) / TYPE_LENGTH (target_type)); + count *= (type->length () / target_type->length ()); return count; } } @@ -1561,8 +1561,8 @@ aapcs_is_vfp_call_or_return_candidate_1 (struct type *type, /* Ensure there is no padding between the fields (allowing for empty zero length structs) */ int ftype_length = (*fundamental_type == nullptr) - ? 0 : TYPE_LENGTH (*fundamental_type); - if (count * ftype_length != TYPE_LENGTH (type)) + ? 0 : (*fundamental_type)->length (); + if (count * ftype_length != type->length ()) return -1; return count; @@ -1645,7 +1645,7 @@ pass_in_x (struct gdbarch *gdbarch, struct regcache *regcache, struct value *arg) { enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); - int len = TYPE_LENGTH (type); + int len = type->length (); enum type_code typecode = type->code (); int regnum = AARCH64_X0_REGNUM + info->ngrn; const bfd_byte *buf = value_contents (arg).data (); @@ -1719,7 +1719,7 @@ pass_on_stack (struct aarch64_call_info *info, struct type *type, struct value *arg) { const bfd_byte *buf = value_contents (arg).data (); - int len = TYPE_LENGTH (type); + int len = type->length (); int align; stack_item_t item; @@ -1765,7 +1765,7 @@ pass_in_x_or_stack (struct gdbarch *gdbarch, struct regcache *regcache, struct aarch64_call_info *info, struct type *type, struct value *arg) { - int len = TYPE_LENGTH (type); + int len = type->length (); int nregs = (len + X_REGISTER_SIZE - 1) / X_REGISTER_SIZE; /* PCS C.13 - Pass in registers if we have enough spare */ @@ -1794,7 +1794,7 @@ pass_in_v_vfp_candidate (struct gdbarch *gdbarch, struct regcache *regcache, { case TYPE_CODE_FLT: case TYPE_CODE_DECFLOAT: - return pass_in_v (gdbarch, regcache, info, TYPE_LENGTH (arg_type), + return pass_in_v (gdbarch, regcache, info, arg_type->length (), value_contents (arg).data ()); break; @@ -1803,17 +1803,17 @@ pass_in_v_vfp_candidate (struct gdbarch *gdbarch, struct regcache *regcache, const bfd_byte *buf = value_contents (arg).data (); struct type *target_type = check_typedef (arg_type->target_type ()); - if (!pass_in_v (gdbarch, regcache, info, TYPE_LENGTH (target_type), + if (!pass_in_v (gdbarch, regcache, info, target_type->length (), buf)) return false; - return pass_in_v (gdbarch, regcache, info, TYPE_LENGTH (target_type), - buf + TYPE_LENGTH (target_type)); + return pass_in_v (gdbarch, regcache, info, target_type->length (), + buf + target_type->length ()); } case TYPE_CODE_ARRAY: if (arg_type->is_vector ()) - return pass_in_v (gdbarch, regcache, info, TYPE_LENGTH (arg_type), + return pass_in_v (gdbarch, regcache, info, arg_type->length (), value_contents (arg).data ()); /* fall through. */ @@ -1902,7 +1902,7 @@ aarch64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, int len, elements; arg_type = check_typedef (value_type (arg)); - len = TYPE_LENGTH (arg_type); + len = arg_type->length (); /* If arg can be passed in v registers as per the AAPCS64, then do so if if there are enough spare registers. */ @@ -2293,7 +2293,7 @@ aarch64_extract_return_value (struct type *type, struct regcache *regs, if (aapcs_is_vfp_call_or_return_candidate (type, &elements, &fundamental_type)) { - int len = TYPE_LENGTH (fundamental_type); + int len = fundamental_type->length (); for (int i = 0; i < elements; i++) { @@ -2322,7 +2322,7 @@ aarch64_extract_return_value (struct type *type, struct regcache *regs, /* If the type is a plain integer, then the access is straight-forward. Otherwise we have to play around a bit more. */ - int len = TYPE_LENGTH (type); + int len = type->length (); int regno = AARCH64_X0_REGNUM; ULONGEST tmp; @@ -2343,7 +2343,7 @@ aarch64_extract_return_value (struct type *type, struct regcache *regs, /* For a structure or union the behaviour is as if the value had been stored to word-aligned memory and then loaded into registers with 64-bit load instruction(s). */ - int len = TYPE_LENGTH (type); + int len = type->length (); int regno = AARCH64_X0_REGNUM; bfd_byte buf[X_REGISTER_SIZE]; @@ -2377,7 +2377,7 @@ aarch64_return_in_memory (struct gdbarch *gdbarch, struct type *type) return 0; } - if (TYPE_LENGTH (type) > 16 + if (type->length () > 16 || !language_pass_by_reference (type).trivially_copyable) { /* PCS B.6 Aggregates larger than 16 bytes are passed by @@ -2404,7 +2404,7 @@ aarch64_store_return_value (struct type *type, struct regcache *regs, if (aapcs_is_vfp_call_or_return_candidate (type, &elements, &fundamental_type)) { - int len = TYPE_LENGTH (fundamental_type); + int len = fundamental_type->length (); for (int i = 0; i < elements; i++) { @@ -2430,7 +2430,7 @@ aarch64_store_return_value (struct type *type, struct regcache *regs, || TYPE_IS_REFERENCE (type) || type->code () == TYPE_CODE_ENUM) { - if (TYPE_LENGTH (type) <= X_REGISTER_SIZE) + if (type->length () <= X_REGISTER_SIZE) { /* Values of one word or less are zero/sign-extended and returned in r0. */ @@ -2445,7 +2445,7 @@ aarch64_store_return_value (struct type *type, struct regcache *regs, /* Integral values greater than one word are stored in consecutive registers starting with r0. This will always be a multiple of the regiser size. */ - int len = TYPE_LENGTH (type); + int len = type->length (); int regno = AARCH64_X0_REGNUM; while (len > 0) @@ -2461,7 +2461,7 @@ aarch64_store_return_value (struct type *type, struct regcache *regs, /* For a structure or union the behaviour is as if the value had been stored to word-aligned memory and then loaded into registers with 64-bit load instruction(s). */ - int len = TYPE_LENGTH (type); + int len = type->length (); int regno = AARCH64_X0_REGNUM; bfd_byte tmpbuf[X_REGISTER_SIZE]; @@ -2504,7 +2504,7 @@ aarch64_return_value (struct gdbarch *gdbarch, struct value *func_value, CORE_ADDR addr; regcache->cooked_read (AARCH64_STRUCT_RETURN_REGNUM, &addr); - read_memory (addr, readbuf, TYPE_LENGTH (valtype)); + read_memory (addr, readbuf, valtype->length ()); } return RETURN_VALUE_ABI_RETURNS_ADDRESS; @@ -2753,7 +2753,7 @@ aarch64_pseudo_read_value_1 (struct gdbarch *gdbarch, if (regcache->raw_read (v_regnum, reg_buf) != REG_VALID) mark_value_bytes_unavailable (result_value, 0, - TYPE_LENGTH (value_type (result_value))); + value_type (result_value)->length ()); else memcpy (value_contents_raw (result_value).data (), reg_buf, regsize); diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 9342566..d539c50 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -560,12 +560,12 @@ coerce_unspec_val_to_type (struct value *val, struct type *type) else if (value_lazy (val) /* Be careful not to make a lazy not_lval value. */ || (VALUE_LVAL (val) != not_lval - && TYPE_LENGTH (type) > TYPE_LENGTH (value_type (val)))) + && type->length () > value_type (val)->length ())) result = allocate_value_lazy (type); else { result = allocate_value (type); - value_contents_copy (result, 0, val, 0, TYPE_LENGTH (type)); + value_contents_copy (result, 0, val, 0, type->length ()); } set_value_component_location (result, val); set_value_bitsize (result, value_bitsize (val)); @@ -646,9 +646,9 @@ static LONGEST max_of_type (struct type *t) { if (t->is_unsigned ()) - return (LONGEST) umax_of_size (TYPE_LENGTH (t)); + return (LONGEST) umax_of_size (t->length ()); else - return max_of_size (TYPE_LENGTH (t)); + return max_of_size (t->length ()); } /* Minimum value of integral type T, as a signed quantity. */ @@ -658,7 +658,7 @@ min_of_type (struct type *t) if (t->is_unsigned ()) return 0; else - return min_of_size (TYPE_LENGTH (t)); + return min_of_size (t->length ()); } /* The largest value in the domain of TYPE, a discrete type, as an integer. */ @@ -1832,7 +1832,7 @@ desc_bounds (struct value *arr) return value_from_longest (lookup_pointer_type (bounds_type), - addr - TYPE_LENGTH (bounds_type)); + addr - bounds_type->length ()); } else if (is_thick_pntr (type)) @@ -1880,7 +1880,7 @@ fat_pntr_bounds_bitsize (struct type *type) if (TYPE_FIELD_BITSIZE (type, 1) > 0) return TYPE_FIELD_BITSIZE (type, 1); else - return 8 * TYPE_LENGTH (ada_check_typedef (type->field (1).type ())); + return 8 * ada_check_typedef (type->field (1).type ())->length (); } /* If TYPE is the type of an array descriptor (fat or thin pointer) or a @@ -1946,7 +1946,7 @@ fat_pntr_data_bitsize (struct type *type) if (TYPE_FIELD_BITSIZE (type, 0) > 0) return TYPE_FIELD_BITSIZE (type, 0); else - return TARGET_CHAR_BIT * TYPE_LENGTH (type->field (0).type ()); + return TARGET_CHAR_BIT * type->field (0).type ()->length (); } /* If BOUNDS is an array-bounds structure (or pointer to one), return @@ -1985,7 +1985,7 @@ desc_bound_bitsize (struct type *type, int i, int which) if (TYPE_FIELD_BITSIZE (type, 2 * i + which - 2) > 0) return TYPE_FIELD_BITSIZE (type, 2 * i + which - 2); else - return 8 * TYPE_LENGTH (type->field (2 * i + which - 2).type ()); + return 8 * type->field (2 * i + which - 2).type ()->length (); } /* If TYPE is the type of an array-bounds structure, the type of its @@ -2517,7 +2517,7 @@ decode_constrained_packed_array (struct value *arr) const gdb_byte *valaddr = value_contents_for_printing (arr).data (); CORE_ADDR address = value_address (arr); gdb::array_view view - = gdb::make_array_view (valaddr, TYPE_LENGTH (type)); + = gdb::make_array_view (valaddr, type->length ()); type = resolve_dynamic_type (type, view, address); recursively_update_array_bitsize (type); @@ -2538,7 +2538,7 @@ decode_constrained_packed_array (struct value *arr) bit_size += 1; mod >>= 1; } - bit_pos = HOST_CHAR_BIT * TYPE_LENGTH (value_type (arr)) - bit_size; + bit_pos = HOST_CHAR_BIT * value_type (arr)->length () - bit_size; arr = ada_value_primitive_packed_val (arr, NULL, bit_pos / HOST_CHAR_BIT, bit_pos % HOST_CHAR_BIT, @@ -2790,7 +2790,7 @@ ada_value_primitive_packed_val (struct value *obj, const gdb_byte *valaddr, is_big_endian, has_negatives (type), is_scalar); type = resolve_dynamic_type (type, staging, 0); - if (TYPE_LENGTH (type) < (bit_size + HOST_CHAR_BIT - 1) / HOST_CHAR_BIT) + if (type->length () < (bit_size + HOST_CHAR_BIT - 1) / HOST_CHAR_BIT) { /* This happens when the length of the object is dynamic, and is actually smaller than the space reserved for it. @@ -2799,7 +2799,7 @@ ada_value_primitive_packed_val (struct value *obj, const gdb_byte *valaddr, normally equal to the maximum size of its element. But, in reality, each element only actually spans a portion of that stride. */ - bit_size = TYPE_LENGTH (type) * HOST_CHAR_BIT; + bit_size = type->length () * HOST_CHAR_BIT; } } @@ -2848,11 +2848,11 @@ ada_value_primitive_packed_val (struct value *obj, const gdb_byte *valaddr, if (bit_size == 0) { - memset (unpacked, 0, TYPE_LENGTH (type)); + memset (unpacked, 0, type->length ()); return v; } - if (staging.size () == TYPE_LENGTH (type)) + if (staging.size () == type->length ()) { /* Small short-cut: If we've unpacked the data into a buffer of the same size as TYPE's length, then we can reuse that, @@ -2861,7 +2861,7 @@ ada_value_primitive_packed_val (struct value *obj, const gdb_byte *valaddr, } else ada_unpack_from_contents (src, bit_offset, bit_size, - unpacked, TYPE_LENGTH (type), + unpacked, type->length (), is_big_endian, has_negatives (type), is_scalar); return v; @@ -2907,7 +2907,7 @@ ada_value_assign (struct value *toval, struct value *fromval) read_memory (to_addr, buffer, len); from_size = value_bitsize (fromval); if (from_size == 0) - from_size = TYPE_LENGTH (value_type (fromval)) * TARGET_CHAR_BIT; + from_size = value_type (fromval)->length () * TARGET_CHAR_BIT; const int is_big_endian = type_byte_order (type) == BFD_ENDIAN_BIG; ULONGEST from_offset = 0; @@ -2921,7 +2921,7 @@ ada_value_assign (struct value *toval, struct value *fromval) val = value_copy (toval); memcpy (value_contents_raw (val).data (), value_contents (fromval).data (), - TYPE_LENGTH (type)); + type->length ()); deprecated_set_value_type (val, type); return val; @@ -2955,7 +2955,7 @@ value_assign_to_component (struct value *container, struct value *component, val = value_cast (value_type (component), val); if (value_bitsize (component) == 0) - bits = TARGET_CHAR_BIT * TYPE_LENGTH (value_type (component)); + bits = TARGET_CHAR_BIT * value_type (component)->length (); else bits = value_bitsize (component); @@ -2965,7 +2965,7 @@ value_assign_to_component (struct value *container, struct value *component, if (is_scalar_type (check_typedef (value_type (component)))) src_offset - = TYPE_LENGTH (value_type (component)) * TARGET_CHAR_BIT - bits; + = value_type (component)->length () * TARGET_CHAR_BIT - bits; else src_offset = 0; copy_bitwise ((value_contents_writeable (container).data () @@ -3112,7 +3112,7 @@ ada_value_slice_from_ptr (struct value *array_ptr, struct type *type, ULONGEST stride = TYPE_FIELD_BITSIZE (slice_type, 0) / 8; if (stride == 0) - stride = TYPE_LENGTH (type0->target_type ()); + stride = type0->target_type ()->length (); base = value_as_address (array_ptr) + (*low_pos - *base_low_pos) * stride; return value_at_lazy (slice_type, base); @@ -3920,7 +3920,7 @@ ada_type_match (struct type *ftype, struct type *atype) return 0; atype = atype->target_type (); /* This can only happen if the actual argument is 'null'. */ - if (atype->code () == TYPE_CODE_INT && TYPE_LENGTH (atype) == 0) + if (atype->code () == TYPE_CODE_INT && atype->length () == 0) return 1; return ada_type_match (ftype->target_type (), atype); case TYPE_CODE_INT: @@ -4346,7 +4346,7 @@ ensure_lval (struct value *val) if (VALUE_LVAL (val) == not_lval || VALUE_LVAL (val) == lval_internalvar) { - int len = TYPE_LENGTH (ada_check_typedef (value_type (val))); + int len = ada_check_typedef (value_type (val))->length (); const CORE_ADDR addr = value_as_long (value_allocate_space_in_inferior (len)); @@ -4556,7 +4556,7 @@ ada_convert_actual (struct value *actual, struct type *formal_type0) static CORE_ADDR value_pointer (struct value *value, struct type *type) { - unsigned len = TYPE_LENGTH (type); + unsigned len = type->length (); gdb_byte *buf = (gdb_byte *) alloca (len); CORE_ADDR addr; @@ -6399,7 +6399,7 @@ value_tag_from_contents_and_address (struct type *type, gdb::array_view contents; if (valaddr != nullptr) - contents = gdb::make_array_view (valaddr, TYPE_LENGTH (type)); + contents = gdb::make_array_view (valaddr, type->length ()); struct type *resolved_type = resolve_dynamic_type (type, contents, address); if (find_struct_field ("_tag", resolved_type, 0, &tag_type, &tag_byte_offset, NULL, NULL, NULL)) @@ -6493,7 +6493,7 @@ ada_tag_value_at_base_address (struct value *obj) /* Storage_Offset'Last is used to indicate that a dynamic offset to top is used. In this situation the offset is stored just after the tag, in the object itself. */ - ULONGEST last = (((ULONGEST) 1) << (8 * TYPE_LENGTH (offset_type) - 1)) - 1; + ULONGEST last = (((ULONGEST) 1) << (8 * offset_type->length () - 1)) - 1; if (offset_to_top == last) { struct value *tem = value_addr (tag); @@ -7960,8 +7960,7 @@ ada_template_to_fixed_record_type_1 (struct type *type, an overflow should not happen in practice. So rather than adding overflow recovery code to this already complex code, we just assume that it's not going to happen. */ - fld_bit_len = - TYPE_LENGTH (rtype->field (f).type ()) * TARGET_CHAR_BIT; + fld_bit_len = rtype->field (f).type ()->length () * TARGET_CHAR_BIT; } else { @@ -7992,7 +7991,7 @@ ada_template_to_fixed_record_type_1 (struct type *type, field_type = ada_typedef_target_type (field_type); fld_bit_len = - TYPE_LENGTH (ada_check_typedef (field_type)) * TARGET_CHAR_BIT; + ada_check_typedef (field_type)->length () * TARGET_CHAR_BIT; } } if (off + fld_bit_len > bit_len) @@ -8039,8 +8038,7 @@ ada_template_to_fixed_record_type_1 (struct type *type, rtype->field (variant_field).set_type (branch_type); rtype->field (variant_field).set_name ("S"); fld_bit_len = - TYPE_LENGTH (rtype->field (variant_field).type ()) * - TARGET_CHAR_BIT; + rtype->field (variant_field).type ()->length () * TARGET_CHAR_BIT; if (off + fld_bit_len > bit_len) bit_len = off + fld_bit_len; @@ -8055,17 +8053,17 @@ ada_template_to_fixed_record_type_1 (struct type *type, probably in the debug info. In that case, we don't round up the size of the resulting type. If this record is not part of another structure, the current RTYPE length might be good enough for our purposes. */ - if (TYPE_LENGTH (type) <= 0) + if (type->length () <= 0) { if (rtype->name ()) warning (_("Invalid type size for `%s' detected: %s."), - rtype->name (), pulongest (TYPE_LENGTH (type))); + rtype->name (), pulongest (type->length ())); else warning (_("Invalid type size for detected: %s."), - pulongest (TYPE_LENGTH (type))); + pulongest (type->length ())); } else - rtype->set_length (align_up (TYPE_LENGTH (rtype), TYPE_LENGTH (type))); + rtype->set_length (align_up (rtype->length (), type->length ())); value_free_to_mark (mark); return rtype; @@ -8198,7 +8196,7 @@ to_record_with_fixed_variant_part (struct type *type, const gdb_byte *valaddr, rtype->set_name (ada_type_name (type)); rtype->set_is_fixed_instance (true); - rtype->set_length (TYPE_LENGTH (type)); + rtype->set_length (type->length ()); branch_type = to_fixed_variant_branch_type (type->field (variant_field).type (), @@ -8221,11 +8219,11 @@ to_record_with_fixed_variant_part (struct type *type, const gdb_byte *valaddr, rtype->field (variant_field).set_type (branch_type); rtype->field (variant_field).set_name ("S"); TYPE_FIELD_BITSIZE (rtype, variant_field) = 0; - rtype->set_length (TYPE_LENGTH (rtype) + TYPE_LENGTH (branch_type)); + rtype->set_length (rtype->length () + branch_type->length ()); } - rtype->set_length (TYPE_LENGTH (rtype) - - TYPE_LENGTH (type->field (variant_field).type ())); + rtype->set_length (rtype->length () + - type->field (variant_field).type ()->length ()); value_free_to_mark (mark); return rtype; @@ -8529,13 +8527,13 @@ to_fixed_array_type (struct type *type0, struct value *dval, type was a regular (non-packed) array type. As a result, the bitsize of the array elements needs to be set again, and the array length needs to be recomputed based on that bitsize. */ - int len = TYPE_LENGTH (result) / TYPE_LENGTH (result->target_type ()); + int len = result->length () / result->target_type ()->length (); int elt_bitsize = TYPE_FIELD_BITSIZE (type0, 0); TYPE_FIELD_BITSIZE (result, 0) = TYPE_FIELD_BITSIZE (type0, 0); result->set_length (len * elt_bitsize / HOST_CHAR_BIT); - if (TYPE_LENGTH (result) * HOST_CHAR_BIT < len * elt_bitsize) - result->set_length (TYPE_LENGTH (result) + 1); + if (result->length () * HOST_CHAR_BIT < len * elt_bitsize) + result->set_length (result->length () + 1); } result->set_is_fixed_instance (true); @@ -8628,7 +8626,7 @@ ada_to_fixed_type_1 (struct type *type, const gdb_byte *valaddr, xvz_name, except.what ()); } - if (xvz_found && TYPE_LENGTH (fixed_record_type) != size) + if (xvz_found && fixed_record_type->length () != size) { fixed_record_type = copy_type (fixed_record_type); fixed_record_type->set_length (size); @@ -9282,8 +9280,8 @@ ada_promote_array_of_integrals (struct type *type, struct value *val) gdb_assert (is_integral_type (type->target_type ())); gdb_assert (value_type (val)->code () == TYPE_CODE_ARRAY); gdb_assert (is_integral_type (value_type (val)->target_type ())); - gdb_assert (TYPE_LENGTH (type->target_type ()) - > TYPE_LENGTH (value_type (val)->target_type ())); + gdb_assert (type->target_type ()->length () + > value_type (val)->target_type ()->length ()); if (!get_array_bounds (type, &lo, &hi)) error (_("unable to determine array bounds")); @@ -9295,7 +9293,7 @@ ada_promote_array_of_integrals (struct type *type, struct value *val) for (i = 0; i < hi - lo + 1; i++) { struct value *elt = value_cast (elt_type, value_subscript (val, lo + i)); - int elt_len = TYPE_LENGTH (elt_type); + int elt_len = elt_type->length (); copy (value_contents_all (elt), res_contents.slice (elt_len * i, elt_len)); } @@ -9332,16 +9330,14 @@ coerce_for_assign (struct type *type, struct value *val) if (is_integral_type (type->target_type ()) && is_integral_type (type2->target_type ()) - && TYPE_LENGTH (type2->target_type ()) - < TYPE_LENGTH (type->target_type ())) + && type2->target_type ()->length () < type->target_type ()->length ()) { /* Allow implicit promotion of the array elements to a wider type. */ return ada_promote_array_of_integrals (type, val); } - if (TYPE_LENGTH (type2->target_type ()) - != TYPE_LENGTH (type->target_type ())) + if (type2->target_type ()->length () != type->target_type ()->length ()) error (_("Incompatible types in assignment")); deprecated_set_value_type (val, type); } @@ -9414,7 +9410,7 @@ ada_value_binop (struct value *arg1, struct value *arg2, enum exp_opcode op) val = allocate_value (type1); store_unsigned_integer (value_contents_raw (val).data (), - TYPE_LENGTH (value_type (val)), + value_type (val)->length (), type_byte_order (type1), v); return val; } @@ -9444,10 +9440,10 @@ ada_value_equal (struct value *arg1, struct value *arg2) /* FIXME: The following works only for types whose representations use all bits (no padding or undefined bits) and do not have user-defined equality. */ - return (TYPE_LENGTH (arg1_type) == TYPE_LENGTH (arg2_type) + return (arg1_type->length () == arg2_type->length () && memcmp (value_contents (arg1).data (), value_contents (arg2).data (), - TYPE_LENGTH (arg1_type)) == 0); + arg1_type->length ()) == 0); } return value_equal (arg1, arg2); } @@ -10198,7 +10194,7 @@ ada_atr_size (struct type *expect_type, return value_zero (builtin_type (exp->gdbarch)->builtin_int, not_lval); else return value_from_longest (builtin_type (exp->gdbarch)->builtin_int, - TARGET_CHAR_BIT * TYPE_LENGTH (type)); + TARGET_CHAR_BIT * type->length ()); } /* A helper function for UNOP_ABS. */ @@ -10667,7 +10663,7 @@ ada_string_operation::evaluate (struct type *expect_type, const std::string &str = std::get<0> (m_storage); const char *encoding; - switch (TYPE_LENGTH (char_type)) + switch (char_type->length ()) { case 1: { @@ -10698,7 +10694,7 @@ ada_string_operation::evaluate (struct type *expect_type, default: error (_("unexpected character type size %s"), - pulongest (TYPE_LENGTH (char_type))); + pulongest (char_type->length ())); } auto_obstack converted; @@ -10710,7 +10706,7 @@ ada_string_operation::evaluate (struct type *expect_type, struct type *stringtype = lookup_array_range_type (char_type, 1, obstack_object_size (&converted) - / TYPE_LENGTH (char_type)); + / char_type->length ()); struct value *val = allocate_value (stringtype); memcpy (value_contents_raw (val).data (), obstack_base (&converted), @@ -11529,7 +11525,7 @@ to_fixed_range_type (struct type *raw_type, struct value *dval) /* create_static_range_type alters the resulting type's length to match the size of the base_type, which is not what we want. Set it back to the original range type's length. */ - type->set_length (TYPE_LENGTH (raw_type)); + type->set_length (raw_type->length ()); type->set_name (name); return type; } @@ -12034,7 +12030,7 @@ ada_exception_message_1 (void) e_msg_val = ada_coerce_to_simple_array (e_msg_val); gdb_assert (e_msg_val != NULL); - e_msg_len = TYPE_LENGTH (value_type (e_msg_val)); + e_msg_len = value_type (e_msg_val)->length (); /* If the message string is empty, then treat it as if there was no exception message. */ @@ -13548,7 +13544,7 @@ public: /* Create the equivalent of the System.Storage_Elements.Storage_Offset type. This is a signed integral type whose size is the same as the size of addresses. */ - unsigned int addr_length = TYPE_LENGTH (system_addr_ptr); + unsigned int addr_length = system_addr_ptr->length (); add (arch_integer_type (gdbarch, addr_length * HOST_CHAR_BIT, 0, "storage_offset")); diff --git a/gdb/ada-lex.l b/gdb/ada-lex.l index ed88d50..3a3647b 100644 --- a/gdb/ada-lex.l +++ b/gdb/ada-lex.l @@ -455,7 +455,7 @@ processInt (struct parser_state *par_state, const char *base0, yylval.typed_val_float.type = fp_type; result.write (gdb::make_array_view (yylval.typed_val_float.val, - TYPE_LENGTH (fp_type)), + fp_type->length ()), type_byte_order (fp_type), true); diff --git a/gdb/ada-tasks.c b/gdb/ada-tasks.c index 1e617a4..85d1aac 100644 --- a/gdb/ada-tasks.c +++ b/gdb/ada-tasks.c @@ -818,7 +818,7 @@ add_ada_task (CORE_ADDR task_id, struct inferior *inf) static bool read_known_tasks_array (struct ada_tasks_inferior_data *data) { - const int target_ptr_byte = TYPE_LENGTH (data->known_tasks_element); + const int target_ptr_byte = data->known_tasks_element->length (); const int known_tasks_size = target_ptr_byte * data->known_tasks_length; gdb_byte *known_tasks = (gdb_byte *) alloca (known_tasks_size); int i; @@ -845,7 +845,7 @@ read_known_tasks_array (struct ada_tasks_inferior_data *data) static bool read_known_tasks_list (struct ada_tasks_inferior_data *data) { - const int target_ptr_byte = TYPE_LENGTH (data->known_tasks_element); + const int target_ptr_byte = data->known_tasks_element->length (); gdb_byte *known_tasks = (gdb_byte *) alloca (target_ptr_byte); CORE_ADDR task_id; const struct ada_tasks_pspace_data *pspace_data diff --git a/gdb/ada-typeprint.c b/gdb/ada-typeprint.c index d412c3b..c79226f 100644 --- a/gdb/ada-typeprint.c +++ b/gdb/ada-typeprint.c @@ -1019,7 +1019,7 @@ ada_print_type (struct type *type0, const char *varstring, if (!ada_is_range_type_name (name)) fprintf_styled (stream, metadata_style.style (), _("<%s-byte integer>"), - pulongest (TYPE_LENGTH (type))); + pulongest (type->length ())); else { gdb_printf (stream, "range "); @@ -1046,7 +1046,7 @@ ada_print_type (struct type *type0, const char *varstring, case TYPE_CODE_FLT: fprintf_styled (stream, metadata_style.style (), _("<%s-byte float>"), - pulongest (TYPE_LENGTH (type))); + pulongest (type->length ())); break; case TYPE_CODE_ENUM: if (show < 0) diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c index 938300b..59f0be4 100644 --- a/gdb/ada-valprint.c +++ b/gdb/ada-valprint.c @@ -195,12 +195,12 @@ val_print_packed_array_elements (struct type *type, const gdb_byte *valaddr, (i * bitsize) / HOST_CHAR_BIT, (i * bitsize) % HOST_CHAR_BIT, bitsize, elttype); - if (TYPE_LENGTH (check_typedef (value_type (v0))) - != TYPE_LENGTH (check_typedef (value_type (v1)))) + if (check_typedef (value_type (v0))->length () + != check_typedef (value_type (v1))->length ()) break; if (!value_contents_eq (v0, value_embedded_offset (v0), v1, value_embedded_offset (v1), - TYPE_LENGTH (check_typedef (value_type (v0))))) + check_typedef (value_type (v0))->length ())) break; } @@ -363,7 +363,7 @@ void ada_printchar (int c, struct type *type, struct ui_file *stream) { gdb_puts ("'", stream); - ada_emit_char (c, type, stream, '\'', TYPE_LENGTH (type)); + ada_emit_char (c, type, stream, '\'', type->length ()); gdb_puts ("'", stream); } @@ -540,7 +540,7 @@ ada_printstr (struct ui_file *stream, struct type *type, const char *encoding, int force_ellipses, const struct value_print_options *options) { - printstr (stream, type, string, length, force_ellipses, TYPE_LENGTH (type), + printstr (stream, type, string, length, force_ellipses, type->length (), options); } @@ -697,10 +697,10 @@ ada_val_print_string (struct type *type, const gdb_byte *valaddr, Similarly, the size of ELTTYPE should also be non-null, since it's a character-like type. */ gdb_assert (elttype != NULL); - gdb_assert (TYPE_LENGTH (elttype) != 0); + gdb_assert (elttype->length () != 0); - eltlen = TYPE_LENGTH (elttype); - len = TYPE_LENGTH (type) / eltlen; + eltlen = elttype->length (); + len = type->length () / eltlen; /* If requested, look for the first null char and only print elements up to it. */ @@ -732,7 +732,7 @@ ada_value_print_ptr (struct value *val, { if (!options->format && value_type (val)->target_type ()->code () == TYPE_CODE_INT - && TYPE_LENGTH (value_type (val)->target_type ()) == 0) + && value_type (val)->target_type ()->length () == 0) { gdb_puts ("null", stream); return; @@ -1023,7 +1023,7 @@ ada_value_print_inner (struct value *val, struct ui_file *stream, int recurse, const gdb_byte *valaddr = value_contents_for_printing (val).data (); CORE_ADDR address = value_address (val); gdb::array_view view - = gdb::make_array_view (valaddr, TYPE_LENGTH (type)); + = gdb::make_array_view (valaddr, type->length ()); type = ada_check_typedef (resolve_dynamic_type (type, view, address)); if (type != saved_type) { @@ -1094,11 +1094,11 @@ ada_value_print (struct value *val0, struct ui_file *stream, "void *" pointers. */ if (type->code () == TYPE_CODE_PTR && !(type->target_type ()->code () == TYPE_CODE_INT - && TYPE_LENGTH (type->target_type ()) == 0)) + && type->target_type ()->length () == 0)) { /* Hack: don't print (char *) for char strings. Their type is indicated by the quoted string anyway. */ - if (TYPE_LENGTH (type->target_type ()) != sizeof (char) + if (type->target_type ()->length () != sizeof (char) || type->target_type ()->code () != TYPE_CODE_INT || type->target_type ()->is_unsigned ()) { diff --git a/gdb/alpha-tdep.c b/gdb/alpha-tdep.c index 44efc8e..1dc9b98 100644 --- a/gdb/alpha-tdep.c +++ b/gdb/alpha-tdep.c @@ -234,7 +234,7 @@ alpha_convert_register_p (struct gdbarch *gdbarch, int regno, struct type *type) { return (regno >= ALPHA_FP0_REGNUM && regno < ALPHA_FP0_REGNUM + 31 - && TYPE_LENGTH (type) == 4); + && type->length () == 4); } static int @@ -257,7 +257,7 @@ alpha_register_to_value (struct frame_info *frame, int regnum, /* Convert to VALTYPE. */ - gdb_assert (TYPE_LENGTH (valtype) == 4); + gdb_assert (valtype->length () == 4); alpha_sts (gdbarch, out, value_contents_all (value).data ()); release_value (value); @@ -270,7 +270,7 @@ alpha_value_to_register (struct frame_info *frame, int regnum, { gdb_byte out[ALPHA_REGISTER_SIZE]; - gdb_assert (TYPE_LENGTH (valtype) == 4); + gdb_assert (valtype->length () == 4); gdb_assert (register_size (get_frame_arch (frame), regnum) <= ALPHA_REGISTER_SIZE); alpha_lds (get_frame_arch (frame), out, in); @@ -334,14 +334,14 @@ alpha_push_dummy_call (struct gdbarch *gdbarch, struct value *function, case TYPE_CODE_CHAR: case TYPE_CODE_RANGE: case TYPE_CODE_ENUM: - if (TYPE_LENGTH (arg_type) == 4) + if (arg_type->length () == 4) { /* 32-bit values must be sign-extended to 64 bits even if the base data type is unsigned. */ arg_type = builtin_type (gdbarch)->builtin_int32; arg = value_cast (arg_type, arg); } - if (TYPE_LENGTH (arg_type) < ALPHA_REGISTER_SIZE) + if (arg_type->length () < ALPHA_REGISTER_SIZE) { arg_type = builtin_type (gdbarch)->builtin_int64; arg = value_cast (arg_type, arg); @@ -352,14 +352,14 @@ alpha_push_dummy_call (struct gdbarch *gdbarch, struct value *function, /* "float" arguments loaded in registers must be passed in register format, aka "double". */ if (accumulate_size < sizeof (arg_reg_buffer) - && TYPE_LENGTH (arg_type) == 4) + && arg_type->length () == 4) { arg_type = builtin_type (gdbarch)->builtin_double; arg = value_cast (arg_type, arg); } /* Tru64 5.1 has a 128-bit long double, and passes this by invisible reference. No one else uses this data type. */ - else if (TYPE_LENGTH (arg_type) == 16) + else if (arg_type->length () == 16) { /* Allocate aligned storage. */ sp = (sp & -16) - 16; @@ -380,7 +380,7 @@ alpha_push_dummy_call (struct gdbarch *gdbarch, struct value *function, /* Tru64 5.1 has a 128-bit long double, and passes this by invisible reference. */ - if (TYPE_LENGTH (arg_type) == 32) + if (arg_type->length () == 32) { /* Allocate aligned storage. */ sp = (sp & -16) - 16; @@ -397,7 +397,7 @@ alpha_push_dummy_call (struct gdbarch *gdbarch, struct value *function, default: break; } - m_arg->len = TYPE_LENGTH (arg_type); + m_arg->len = arg_type->length (); m_arg->offset = accumulate_size; accumulate_size = (accumulate_size + m_arg->len + 7) & ~7; m_arg->contents = value_contents (arg).data (); @@ -481,7 +481,7 @@ alpha_extract_return_value (struct type *valtype, struct regcache *regcache, switch (valtype->code ()) { case TYPE_CODE_FLT: - switch (TYPE_LENGTH (valtype)) + switch (valtype->length ()) { case 4: regcache->cooked_read (ALPHA_FP0_REGNUM, raw_buffer); @@ -504,7 +504,7 @@ alpha_extract_return_value (struct type *valtype, struct regcache *regcache, break; case TYPE_CODE_COMPLEX: - switch (TYPE_LENGTH (valtype)) + switch (valtype->length ()) { case 8: /* ??? This isn't correct wrt the ABI, but it's what GCC does. */ @@ -530,7 +530,7 @@ alpha_extract_return_value (struct type *valtype, struct regcache *regcache, default: /* Assume everything else degenerates to an integer. */ regcache_cooked_read_unsigned (regcache, ALPHA_V0_REGNUM, &l); - store_unsigned_integer (valbuf, TYPE_LENGTH (valtype), byte_order, l); + store_unsigned_integer (valbuf, valtype->length (), byte_order, l); break; } } @@ -549,7 +549,7 @@ alpha_store_return_value (struct type *valtype, struct regcache *regcache, switch (valtype->code ()) { case TYPE_CODE_FLT: - switch (TYPE_LENGTH (valtype)) + switch (valtype->length ()) { case 4: alpha_lds (gdbarch, raw_buffer, valbuf); @@ -573,7 +573,7 @@ alpha_store_return_value (struct type *valtype, struct regcache *regcache, break; case TYPE_CODE_COMPLEX: - switch (TYPE_LENGTH (valtype)) + switch (valtype->length ()) { case 8: /* ??? This isn't correct wrt the ABI, but it's what GCC does. */ @@ -601,7 +601,7 @@ alpha_store_return_value (struct type *valtype, struct regcache *regcache, /* Assume everything else degenerates to an integer. */ /* 32-bit values must be sign-extended to 64 bits even if the base data type is unsigned. */ - if (TYPE_LENGTH (valtype) == 4) + if (valtype->length () == 4) valtype = builtin_type (gdbarch)->builtin_int32; l = unpack_long (valtype, valbuf); regcache_cooked_write_unsigned (regcache, ALPHA_V0_REGNUM, l); @@ -626,7 +626,7 @@ alpha_return_value (struct gdbarch *gdbarch, struct value *function, { ULONGEST addr; regcache_raw_read_unsigned (regcache, ALPHA_V0_REGNUM, &addr); - read_memory (addr, readbuf, TYPE_LENGTH (type)); + read_memory (addr, readbuf, type->length ()); } return RETURN_VALUE_ABI_RETURNS_ADDRESS; diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c index 4d416a4..ea2b3b1 100644 --- a/gdb/amd64-tdep.c +++ b/gdb/amd64-tdep.c @@ -376,7 +376,7 @@ amd64_pseudo_register_read_value (struct gdbarch *gdbarch, memcpy (buf, raw_buf + 1, 1); else mark_value_bytes_unavailable (result_value, 0, - TYPE_LENGTH (value_type (result_value))); + value_type (result_value)->length ()); } else { @@ -386,7 +386,7 @@ amd64_pseudo_register_read_value (struct gdbarch *gdbarch, memcpy (buf, raw_buf, 1); else mark_value_bytes_unavailable (result_value, 0, - TYPE_LENGTH (value_type (result_value))); + value_type (result_value)->length ()); } } else if (i386_dword_regnum_p (gdbarch, regnum)) @@ -399,7 +399,7 @@ amd64_pseudo_register_read_value (struct gdbarch *gdbarch, memcpy (buf, raw_buf, 4); else mark_value_bytes_unavailable (result_value, 0, - TYPE_LENGTH (value_type (result_value))); + value_type (result_value)->length ()); } else i386_pseudo_register_read_into_value (gdbarch, regcache, regnum, @@ -559,7 +559,7 @@ amd64_has_unaligned_fields (struct type *type) the caller). */ if (field_is_static (&type->field (i)) || (TYPE_FIELD_BITSIZE (type, i) == 0 - && TYPE_LENGTH (subtype) == 0) + && subtype->length () == 0) || TYPE_FIELD_PACKED (type, i)) continue; @@ -597,7 +597,7 @@ amd64_classify_aggregate_field (struct type *type, int i, int bitsize = TYPE_FIELD_BITSIZE (type, i); if (bitsize == 0) - bitsize = TYPE_LENGTH (subtype) * 8; + bitsize = subtype->length () * 8; /* Ignore static fields, or empty fields, for example nested empty structures.*/ @@ -666,7 +666,7 @@ amd64_classify_aggregate (struct type *type, enum amd64_reg_class theclass[2]) loc_bitpos attributes, which will cause an assert to trigger within the unaligned field check. As classes with virtual bases are not trivially copyable, checking that first avoids this problem. */ - if (TYPE_LENGTH (type) > 16 + if (type->length () > 16 || !language_pass_by_reference (type).trivially_copyable || amd64_has_unaligned_fields (type)) { @@ -688,7 +688,7 @@ amd64_classify_aggregate (struct type *type, enum amd64_reg_class theclass[2]) /* All fields in an array have the same type. */ amd64_classify (subtype, theclass); - if (TYPE_LENGTH (type) > 8 && theclass[1] == AMD64_NO_CLASS) + if (type->length () > 8 && theclass[1] == AMD64_NO_CLASS) theclass[1] = theclass[0]; } else @@ -724,7 +724,7 @@ static void amd64_classify (struct type *type, enum amd64_reg_class theclass[2]) { enum type_code code = type->code (); - int len = TYPE_LENGTH (type); + int len = type->length (); theclass[0] = theclass[1] = AMD64_NO_CLASS; @@ -791,7 +791,7 @@ amd64_return_value (struct gdbarch *gdbarch, struct value *function, gdb_byte *readbuf, const gdb_byte *writebuf) { enum amd64_reg_class theclass[2]; - int len = TYPE_LENGTH (type); + int len = type->length (); static int integer_regnum[] = { AMD64_RAX_REGNUM, AMD64_RDX_REGNUM }; static int sse_regnum[] = { AMD64_XMM0_REGNUM, AMD64_XMM1_REGNUM }; int integer_reg = 0; @@ -821,7 +821,7 @@ amd64_return_value (struct gdbarch *gdbarch, struct value *function, ULONGEST addr; regcache_raw_read_unsigned (regcache, AMD64_RAX_REGNUM, &addr); - read_memory (addr, readbuf, TYPE_LENGTH (type)); + read_memory (addr, readbuf, type->length ()); } return RETURN_VALUE_ABI_RETURNS_ADDRESS; @@ -955,7 +955,7 @@ if (return_method == return_method_struct) for (i = 0; i < nargs; i++) { struct type *type = value_type (args[i]); - int len = TYPE_LENGTH (type); + int len = type->length (); enum amd64_reg_class theclass[2]; int needed_integer_regs = 0; int needed_sse_regs = 0; @@ -1040,7 +1040,7 @@ if (return_method == return_method_struct) { struct type *type = value_type (stack_args[i]); const gdb_byte *valbuf = value_contents (stack_args[i]).data (); - int len = TYPE_LENGTH (type); + int len = type->length (); write_memory (sp + element * 8, valbuf, len); element += ((len + 7) / 8); @@ -3071,7 +3071,7 @@ amd64_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc) struct gdbarch *gdbarch = get_frame_arch (frame); i386_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); int jb_pc_offset = tdep->jb_pc_offset; - int len = TYPE_LENGTH (builtin_type (gdbarch)->builtin_func_ptr); + int len = builtin_type (gdbarch)->builtin_func_ptr->length (); /* If JB_PC_OFFSET is -1, we have no way to find out where the longjmp will land. */ diff --git a/gdb/amd64-windows-tdep.c b/gdb/amd64-windows-tdep.c index 1f779fb..8573e4c 100644 --- a/gdb/amd64-windows-tdep.c +++ b/gdb/amd64-windows-tdep.c @@ -126,10 +126,10 @@ amd64_windows_passed_by_integer_register (struct type *type) case TYPE_CODE_STRUCT: case TYPE_CODE_UNION: case TYPE_CODE_COMPLEX: - return (TYPE_LENGTH (type) == 1 - || TYPE_LENGTH (type) == 2 - || TYPE_LENGTH (type) == 4 - || TYPE_LENGTH (type) == 8); + return (type->length () == 1 + || type->length () == 2 + || type->length () == 4 + || type->length () == 8); default: return 0; @@ -144,7 +144,7 @@ amd64_windows_passed_by_xmm_register (struct type *type) { return ((type->code () == TYPE_CODE_FLT || type->code () == TYPE_CODE_DECFLOAT) - && (TYPE_LENGTH (type) == 4 || TYPE_LENGTH (type) == 8)); + && (type->length () == 4 || type->length () == 8)); } /* Return non-zero iff an argument of the given TYPE should be passed @@ -180,7 +180,7 @@ amd64_windows_adjust_args_passed_by_pointer (struct value **args, { struct type *type = value_type (args[i]); const gdb_byte *valbuf = value_contents (args[i]).data (); - const int len = TYPE_LENGTH (type); + const int len = type->length (); /* Store a copy of that argument on the stack, aligned to a 16 bytes boundary, and then use the copy's address as @@ -208,9 +208,9 @@ amd64_windows_store_arg_in_reg (struct regcache *regcache, const gdb_byte *valbuf = value_contents (arg).data (); gdb_byte buf[8]; - gdb_assert (TYPE_LENGTH (type) <= 8); + gdb_assert (type->length () <= 8); memset (buf, 0, sizeof buf); - memcpy (buf, valbuf, std::min (TYPE_LENGTH (type), (ULONGEST) 8)); + memcpy (buf, valbuf, std::min (type->length (), (ULONGEST) 8)); regcache->cooked_write (regno, buf); } @@ -252,7 +252,7 @@ amd64_windows_push_arguments (struct regcache *regcache, int nargs, for (i = 0; i < nargs; i++) { struct type *type = value_type (args[i]); - int len = TYPE_LENGTH (type); + int len = type->length (); int on_stack_p = 1; if (reg_idx < ARRAY_SIZE (amd64_windows_dummy_call_integer_regs)) @@ -297,8 +297,8 @@ amd64_windows_push_arguments (struct regcache *regcache, int nargs, struct type *type = value_type (stack_args[i]); const gdb_byte *valbuf = value_contents (stack_args[i]).data (); - write_memory (sp + element * 8, valbuf, TYPE_LENGTH (type)); - element += ((TYPE_LENGTH (type) + 7) / 8); + write_memory (sp + element * 8, valbuf, type->length ()); + element += ((type->length () + 7) / 8); } return sp; @@ -357,7 +357,7 @@ amd64_windows_return_value (struct gdbarch *gdbarch, struct value *function, struct type *type, struct regcache *regcache, gdb_byte *readbuf, const gdb_byte *writebuf) { - int len = TYPE_LENGTH (type); + int len = type->length (); int regnum = -1; /* See if our value is returned through a register. If it is, then @@ -399,7 +399,7 @@ amd64_windows_return_value (struct gdbarch *gdbarch, struct value *function, ULONGEST addr; regcache_raw_read_unsigned (regcache, AMD64_RAX_REGNUM, &addr); - read_memory (addr, readbuf, TYPE_LENGTH (type)); + read_memory (addr, readbuf, type->length ()); } return RETURN_VALUE_ABI_RETURNS_ADDRESS; } diff --git a/gdb/arc-tdep.c b/gdb/arc-tdep.c index 11e0551..ee5cd87 100644 --- a/gdb/arc-tdep.c +++ b/gdb/arc-tdep.c @@ -761,7 +761,7 @@ arc_push_dummy_call (struct gdbarch *gdbarch, struct value *function, argument's size up to an integral number of words. */ for (int i = 0; i < nargs; i++) { - unsigned int len = TYPE_LENGTH (value_type (args[i])); + unsigned int len = value_type (args[i])->length (); unsigned int space = align_up (len, 4); total_space += space; @@ -776,7 +776,7 @@ arc_push_dummy_call (struct gdbarch *gdbarch, struct value *function, gdb_byte *data = memory_image; for (int i = 0; i < nargs; i++) { - unsigned int len = TYPE_LENGTH (value_type (args[i])); + unsigned int len = value_type (args[i])->length (); unsigned int space = align_up (len, 4); memcpy (data, value_contents (args[i]).data (), (size_t) len); @@ -906,7 +906,7 @@ static void arc_extract_return_value (struct gdbarch *gdbarch, struct type *type, struct regcache *regcache, gdb_byte *valbuf) { - unsigned int len = TYPE_LENGTH (type); + unsigned int len = type->length (); arc_debug_printf ("called"); @@ -957,7 +957,7 @@ static void arc_store_return_value (struct gdbarch *gdbarch, struct type *type, struct regcache *regcache, const gdb_byte *valbuf) { - unsigned int len = TYPE_LENGTH (type); + unsigned int len = type->length (); arc_debug_printf ("called"); @@ -1029,7 +1029,7 @@ arc_return_value (struct gdbarch *gdbarch, struct value *function, stored. Otherwise, the result is returned in registers. */ int is_struct_return = (valtype->code () == TYPE_CODE_STRUCT || valtype->code () == TYPE_CODE_UNION - || TYPE_LENGTH (valtype) > 2 * ARC_REGISTER_SIZE); + || valtype->length () > 2 * ARC_REGISTER_SIZE); arc_debug_printf ("readbuf = %s, writebuf = %s", host_address_to_string (readbuf), @@ -2237,7 +2237,7 @@ arc_type_align (struct gdbarch *gdbarch, struct type *type) case TYPE_CODE_METHODPTR: case TYPE_CODE_MEMBERPTR: type = check_typedef (type); - return std::min (4, TYPE_LENGTH (type)); + return std::min (4, type->length ()); default: return 0; } diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index 7333fa6..2810232 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -4132,10 +4132,10 @@ arm_type_align (gdbarch *gdbarch, struct type *t) { /* Use the natural alignment for vector types (the same for scalar type), but the maximum alignment is 64-bit. */ - if (TYPE_LENGTH (t) > 8) + if (t->length () > 8) return 8; else - return TYPE_LENGTH (t); + return t->length (); } /* Allow the common code to calculate the alignment. */ @@ -4218,7 +4218,7 @@ arm_vfp_cprc_sub_candidate (struct type *t, switch (t->code ()) { case TYPE_CODE_FLT: - switch (TYPE_LENGTH (t)) + switch (t->length ()) { case 4: if (*base_type == VFP_CPRC_UNKNOWN) @@ -4250,7 +4250,7 @@ arm_vfp_cprc_sub_candidate (struct type *t, }; */ - switch (TYPE_LENGTH (t)) + switch (t->length ()) { case 8: if (*base_type == VFP_CPRC_UNKNOWN) @@ -4277,7 +4277,7 @@ arm_vfp_cprc_sub_candidate (struct type *t, { /* A 64-bit or 128-bit containerized vector type are VFP CPRCs. */ - switch (TYPE_LENGTH (t)) + switch (t->length ()) { case 8: if (*base_type == VFP_CPRC_UNKNOWN) @@ -4300,7 +4300,7 @@ arm_vfp_cprc_sub_candidate (struct type *t, base_type); if (count == -1) return -1; - if (TYPE_LENGTH (t) == 0) + if (t->length () == 0) { gdb_assert (count == 0); return 0; @@ -4308,8 +4308,8 @@ arm_vfp_cprc_sub_candidate (struct type *t, else if (count == 0) return -1; unitlen = arm_vfp_cprc_unit_length (*base_type); - gdb_assert ((TYPE_LENGTH (t) % unitlen) == 0); - return TYPE_LENGTH (t) / unitlen; + gdb_assert ((t->length () % unitlen) == 0); + return t->length () / unitlen; } } break; @@ -4330,7 +4330,7 @@ arm_vfp_cprc_sub_candidate (struct type *t, return -1; count += sub_count; } - if (TYPE_LENGTH (t) == 0) + if (t->length () == 0) { gdb_assert (count == 0); return 0; @@ -4338,7 +4338,7 @@ arm_vfp_cprc_sub_candidate (struct type *t, else if (count == 0) return -1; unitlen = arm_vfp_cprc_unit_length (*base_type); - if (TYPE_LENGTH (t) != unitlen * count) + if (t->length () != unitlen * count) return -1; return count; } @@ -4356,7 +4356,7 @@ arm_vfp_cprc_sub_candidate (struct type *t, return -1; count = (count > sub_count ? count : sub_count); } - if (TYPE_LENGTH (t) == 0) + if (t->length () == 0) { gdb_assert (count == 0); return 0; @@ -4364,7 +4364,7 @@ arm_vfp_cprc_sub_candidate (struct type *t, else if (count == 0) return -1; unitlen = arm_vfp_cprc_unit_length (*base_type); - if (TYPE_LENGTH (t) != unitlen * count) + if (t->length () != unitlen * count) return -1; return count; } @@ -4484,7 +4484,7 @@ arm_push_dummy_call (struct gdbarch *gdbarch, struct value *function, int may_use_core_reg = 1; arg_type = check_typedef (value_type (args[argnum])); - len = TYPE_LENGTH (arg_type); + len = arg_type->length (); target_type = arg_type->target_type (); typecode = arg_type->code (); val = value_contents (args[argnum]).data (); @@ -8705,7 +8705,7 @@ arm_extract_return_value (struct type *type, struct regcache *regs, not using the VFP ABI code. */ case ARM_FLOAT_VFP: regs->cooked_read (ARM_A1_REGNUM, valbuf); - if (TYPE_LENGTH (type) > 4) + if (type->length () > 4) regs->cooked_read (ARM_A1_REGNUM + 1, valbuf + ARM_INT_REGISTER_SIZE); break; @@ -8728,7 +8728,7 @@ arm_extract_return_value (struct type *type, struct regcache *regs, /* If the type is a plain integer, then the access is straight-forward. Otherwise we have to play around a bit more. */ - int len = TYPE_LENGTH (type); + int len = type->length (); int regno = ARM_A1_REGNUM; ULONGEST tmp; @@ -8750,7 +8750,7 @@ arm_extract_return_value (struct type *type, struct regcache *regs, /* For a structure or union the behaviour is as if the value had been stored to word-aligned memory and then loaded into registers with 32-bit load instruction(s). */ - int len = TYPE_LENGTH (type); + int len = type->length (); int regno = ARM_A1_REGNUM; bfd_byte tmpbuf[ARM_INT_REGISTER_SIZE]; @@ -8788,7 +8788,7 @@ arm_return_in_memory (struct gdbarch *gdbarch, struct type *type) { /* Vector values should be returned using ARM registers if they are not over 16 bytes. */ - return (TYPE_LENGTH (type) > 16); + return (type->length () > 16); } arm_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); @@ -8796,7 +8796,7 @@ arm_return_in_memory (struct gdbarch *gdbarch, struct type *type) { /* The AAPCS says all aggregates not larger than a word are returned in a register. */ - if (TYPE_LENGTH (type) <= ARM_INT_REGISTER_SIZE + if (type->length () <= ARM_INT_REGISTER_SIZE && language_pass_by_reference (type).trivially_copyable) return 0; @@ -8808,7 +8808,7 @@ arm_return_in_memory (struct gdbarch *gdbarch, struct type *type) /* All aggregate types that won't fit in a register must be returned in memory. */ - if (TYPE_LENGTH (type) > ARM_INT_REGISTER_SIZE + if (type->length () > ARM_INT_REGISTER_SIZE || !language_pass_by_reference (type).trivially_copyable) return 1; @@ -8913,7 +8913,7 @@ arm_store_return_value (struct type *type, struct regcache *regs, not using the VFP ABI code. */ case ARM_FLOAT_VFP: regs->cooked_write (ARM_A1_REGNUM, valbuf); - if (TYPE_LENGTH (type) > 4) + if (type->length () > 4) regs->cooked_write (ARM_A1_REGNUM + 1, valbuf + ARM_INT_REGISTER_SIZE); break; @@ -8932,7 +8932,7 @@ arm_store_return_value (struct type *type, struct regcache *regs, || TYPE_IS_REFERENCE (type) || type->code () == TYPE_CODE_ENUM) { - if (TYPE_LENGTH (type) <= 4) + if (type->length () <= 4) { /* Values of one word or less are zero/sign-extended and returned in r0. */ @@ -8947,7 +8947,7 @@ arm_store_return_value (struct type *type, struct regcache *regs, /* Integral values greater than one word are stored in consecutive registers starting with r0. This will always be a multiple of the regiser size. */ - int len = TYPE_LENGTH (type); + int len = type->length (); int regno = ARM_A1_REGNUM; while (len > 0) @@ -8963,7 +8963,7 @@ arm_store_return_value (struct type *type, struct regcache *regs, /* For a structure or union the behaviour is as if the value had been stored to word-aligned memory and then loaded into registers with 32-bit load instruction(s). */ - int len = TYPE_LENGTH (type); + int len = type->length (); int regno = ARM_A1_REGNUM; bfd_byte tmpbuf[ARM_INT_REGISTER_SIZE]; @@ -9053,7 +9053,7 @@ arm_return_value (struct gdbarch *gdbarch, struct value *function, CORE_ADDR addr; regcache->cooked_read (ARM_A1_REGNUM, &addr); - read_memory (addr, readbuf, TYPE_LENGTH (valtype)); + read_memory (addr, readbuf, valtype->length ()); } return RETURN_VALUE_ABI_RETURNS_ADDRESS; } diff --git a/gdb/auxv.c b/gdb/auxv.c index 6154988..b248f99 100644 --- a/gdb/auxv.c +++ b/gdb/auxv.c @@ -84,7 +84,7 @@ ld_so_xfer_auxv (gdb_byte *readbuf, struct bound_minimal_symbol msym; CORE_ADDR data_address, pointer_address; struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr; - size_t ptr_size = TYPE_LENGTH (ptr_type); + size_t ptr_size = ptr_type->length (); size_t auxv_pair_size = 2 * ptr_size; gdb_byte *ptr_buf = (gdb_byte *) alloca (ptr_size); LONGEST retval; @@ -255,7 +255,7 @@ generic_auxv_parse (struct gdbarch *gdbarch, gdb_byte **readptr, int sizeof_auxv_type) { struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr; - const int sizeof_auxv_val = TYPE_LENGTH (ptr_type); + const int sizeof_auxv_val = ptr_type->length (); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); gdb_byte *ptr = *readptr; @@ -286,7 +286,7 @@ default_auxv_parse (struct target_ops *ops, gdb_byte **readptr, { struct gdbarch *gdbarch = target_gdbarch (); struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr; - const int sizeof_auxv_type = TYPE_LENGTH (ptr_type); + const int sizeof_auxv_type = ptr_type->length (); return generic_auxv_parse (gdbarch, readptr, endptr, typep, valp, sizeof_auxv_type); @@ -299,7 +299,7 @@ svr4_auxv_parse (struct gdbarch *gdbarch, gdb_byte **readptr, gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp) { struct type *int_type = builtin_type (gdbarch)->builtin_int; - const int sizeof_auxv_type = TYPE_LENGTH (int_type); + const int sizeof_auxv_type = int_type->length (); return generic_auxv_parse (gdbarch, readptr, endptr, typep, valp, sizeof_auxv_type); diff --git a/gdb/avr-tdep.c b/gdb/avr-tdep.c index f020d21..fa66d83 100644 --- a/gdb/avr-tdep.c +++ b/gdb/avr-tdep.c @@ -315,7 +315,7 @@ avr_address_to_pointer (struct gdbarch *gdbarch, if (AVR_TYPE_ADDRESS_CLASS_FLASH (type)) { /* A data pointer in flash is byte addressed. */ - store_unsigned_integer (buf, TYPE_LENGTH (type), byte_order, + store_unsigned_integer (buf, type->length (), byte_order, avr_convert_iaddr_to_raw (addr)); } /* Is it a code address? */ @@ -324,13 +324,13 @@ avr_address_to_pointer (struct gdbarch *gdbarch, { /* A code pointer is word (16 bits) addressed. We shift the address down by 1 bit to convert it to a pointer. */ - store_unsigned_integer (buf, TYPE_LENGTH (type), byte_order, + store_unsigned_integer (buf, type->length (), byte_order, avr_convert_iaddr_to_raw (addr >> 1)); } else { /* Strip off any upper segment bits. */ - store_unsigned_integer (buf, TYPE_LENGTH (type), byte_order, + store_unsigned_integer (buf, type->length (), byte_order, avr_convert_saddr_to_raw (addr)); } } @@ -341,7 +341,7 @@ avr_pointer_to_address (struct gdbarch *gdbarch, { enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); CORE_ADDR addr - = extract_unsigned_integer (buf, TYPE_LENGTH (type), byte_order); + = extract_unsigned_integer (buf, type->length (), byte_order); /* Is it a data address in flash? */ if (AVR_TYPE_ADDRESS_CLASS_FLASH (type)) @@ -946,27 +946,27 @@ avr_return_value (struct gdbarch *gdbarch, struct value *function, if ((valtype->code () == TYPE_CODE_STRUCT || valtype->code () == TYPE_CODE_UNION || valtype->code () == TYPE_CODE_ARRAY) - && TYPE_LENGTH (valtype) > 8) + && valtype->length () > 8) return RETURN_VALUE_STRUCT_CONVENTION; - if (TYPE_LENGTH (valtype) <= 2) + if (valtype->length () <= 2) lsb_reg = 24; - else if (TYPE_LENGTH (valtype) <= 4) + else if (valtype->length () <= 4) lsb_reg = 22; - else if (TYPE_LENGTH (valtype) <= 8) + else if (valtype->length () <= 8) lsb_reg = 18; else gdb_assert_not_reached ("unexpected type length"); if (writebuf != NULL) { - for (i = 0; i < TYPE_LENGTH (valtype); i++) + for (i = 0; i < valtype->length (); i++) regcache->cooked_write (lsb_reg + i, writebuf + i); } if (readbuf != NULL) { - for (i = 0; i < TYPE_LENGTH (valtype); i++) + for (i = 0; i < valtype->length (); i++) regcache->cooked_read (lsb_reg + i, readbuf + i); } @@ -1302,7 +1302,7 @@ avr_push_dummy_call (struct gdbarch *gdbarch, struct value *function, struct value *arg = args[i]; struct type *type = check_typedef (value_type (arg)); const bfd_byte *contents = value_contents (arg).data (); - int len = TYPE_LENGTH (type); + int len = type->length (); /* Calculate the potential last register needed. E.g. For length 2, registers regnum and regnum-1 (say 25 and 24) diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c index 44a2f96..a52a5bf 100644 --- a/gdb/ax-gdb.c +++ b/gdb/ax-gdb.c @@ -221,7 +221,7 @@ gen_trace_static_fields (struct agent_expr *ax, { /* Initialize the TYPE_LENGTH if it is a typedef. */ check_typedef (value.type); - ax_const_l (ax, TYPE_LENGTH (value.type)); + ax_const_l (ax, value.type->length ()); ax_simple (ax, aop_trace); } break; @@ -292,7 +292,7 @@ gen_traced_pop (struct agent_expr *ax, struct axs_value *value) "const8 SIZE trace" is also three bytes, does the same thing, and the simplest code which generates that will also work correctly for objects with large sizes. */ - ax_const_l (ax, TYPE_LENGTH (value->type)); + ax_const_l (ax, value->type->length ()); ax_simple (ax, aop_trace); } } @@ -337,7 +337,7 @@ gen_sign_extend (struct agent_expr *ax, struct type *type) { /* Do we need to sign-extend this? */ if (!type->is_unsigned ()) - ax_ext (ax, TYPE_LENGTH (type) * TARGET_CHAR_BIT); + ax_ext (ax, type->length () * TARGET_CHAR_BIT); } @@ -347,7 +347,7 @@ gen_sign_extend (struct agent_expr *ax, struct type *type) static void gen_extend (struct agent_expr *ax, struct type *type) { - int bits = TYPE_LENGTH (type) * TARGET_CHAR_BIT; + int bits = type->length () * TARGET_CHAR_BIT; /* I just had to. */ ((type->is_unsigned () ? ax_zero_ext : ax_ext) (ax, bits)); @@ -363,7 +363,7 @@ gen_fetch (struct agent_expr *ax, struct type *type) if (ax->tracing) { /* Record the area of memory we're about to fetch. */ - ax_trace_quick (ax, TYPE_LENGTH (type)); + ax_trace_quick (ax, type->length ()); } if (type->code () == TYPE_CODE_RANGE) @@ -380,7 +380,7 @@ gen_fetch (struct agent_expr *ax, struct type *type) case TYPE_CODE_BOOL: /* It's a scalar value, so we know how to dereference it. How many bytes long is it? */ - switch (TYPE_LENGTH (type)) + switch (type->length ()) { case 8 / TARGET_CHAR_BIT: ax_simple (ax, aop_ref8); @@ -761,8 +761,8 @@ gen_usual_unary (struct agent_expr *ax, struct axs_value *value) static int type_wider_than (struct type *type1, struct type *type2) { - return (TYPE_LENGTH (type1) > TYPE_LENGTH (type2) - || (TYPE_LENGTH (type1) == TYPE_LENGTH (type2) + return (type1->length () > type2->length () + || (type1->length () == type2->length () && type1->is_unsigned () && !type2->is_unsigned ())); } @@ -784,12 +784,12 @@ gen_conversion (struct agent_expr *ax, struct type *from, struct type *to) /* If we're converting to a narrower type, then we need to clear out the upper bits. */ - if (TYPE_LENGTH (to) < TYPE_LENGTH (from)) + if (to->length () < from->length ()) gen_extend (ax, to); /* If the two values have equal width, but different signednesses, then we need to extend. */ - else if (TYPE_LENGTH (to) == TYPE_LENGTH (from)) + else if (to->length () == from->length ()) { if (from->is_unsigned () != to->is_unsigned ()) gen_extend (ax, to); @@ -797,7 +797,7 @@ gen_conversion (struct agent_expr *ax, struct type *from, struct type *to) /* If we're converting to a wider type, and becoming unsigned, then we need to zero out any possible sign bits. */ - else if (TYPE_LENGTH (to) > TYPE_LENGTH (from)) + else if (to->length () > from->length ()) { if (to->is_unsigned ()) gen_extend (ax, to); @@ -948,9 +948,9 @@ gen_scale (struct agent_expr *ax, enum agent_op op, struct type *type) { struct type *element = type->target_type (); - if (TYPE_LENGTH (element) != 1) + if (element->length () != 1) { - ax_const_l (ax, TYPE_LENGTH (element)); + ax_const_l (ax, element->length ()); ax_simple (ax, op); } } @@ -997,8 +997,8 @@ gen_ptrdiff (struct agent_expr *ax, struct axs_value *value, gdb_assert (value1->type->is_pointer_or_reference ()); gdb_assert (value2->type->is_pointer_or_reference ()); - if (TYPE_LENGTH (value1->type->target_type ()) - != TYPE_LENGTH (value2->type->target_type ())) + if (value1->type->target_type ()->length () + != value2->type->target_type ()->length ()) error (_("\ First argument of `-' is a pointer, but second argument is neither\n\ an integer nor a pointer of the same type.")); @@ -1810,7 +1810,7 @@ unop_sizeof_operation::do_generate_ax (struct expression *exp, /* Throw away the code we just generated. */ ax->len = start; - ax_const_l (ax, TYPE_LENGTH (value->type)); + ax_const_l (ax, value->type->length ()); value->kind = axs_rvalue; value->type = builtin_type (ax->gdbarch)->builtin_int; } diff --git a/gdb/bfin-tdep.c b/gdb/bfin-tdep.c index 3e801a9..dc1ee51 100644 --- a/gdb/bfin-tdep.c +++ b/gdb/bfin-tdep.c @@ -511,7 +511,7 @@ bfin_push_dummy_call (struct gdbarch *gdbarch, { struct type *value_type = value_enclosing_type (args[i]); - total_len += align_up (TYPE_LENGTH (value_type), 4); + total_len += align_up (value_type->length (), 4); } /* At least twelve bytes of stack space must be allocated for the function's @@ -527,7 +527,7 @@ bfin_push_dummy_call (struct gdbarch *gdbarch, { struct type *value_type = value_enclosing_type (args[i]); struct type *arg_type = check_typedef (value_type); - int container_len = align_up (TYPE_LENGTH (arg_type), 4); + int container_len = align_up (arg_type->length (), 4); sp -= container_len; write_memory (sp, value_contents (args[i]).data (), container_len); @@ -612,7 +612,7 @@ bfin_extract_return_value (struct type *type, struct gdbarch *gdbarch = regs->arch (); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); bfd_byte *valbuf = dst; - int len = TYPE_LENGTH (type); + int len = type->length (); ULONGEST tmp; int regno = BFIN_R0_REGNUM; @@ -641,7 +641,7 @@ bfin_store_return_value (struct type *type, registers starting with R0. This will always be a multiple of the register size. */ - int len = TYPE_LENGTH (type); + int len = type->length (); int regno = BFIN_R0_REGNUM; gdb_assert (len <= 8); @@ -668,7 +668,7 @@ bfin_return_value (struct gdbarch *gdbarch, gdb_byte *readbuf, const gdb_byte *writebuf) { - if (TYPE_LENGTH (type) > 8) + if (type->length () > 8) return RETURN_VALUE_STRUCT_CONVENTION; if (readbuf) diff --git a/gdb/bpf-tdep.c b/gdb/bpf-tdep.c index 4c08509..b50988f 100644 --- a/gdb/bpf-tdep.c +++ b/gdb/bpf-tdep.c @@ -265,7 +265,7 @@ static void bpf_extract_return_value (struct type *type, struct regcache *regcache, gdb_byte *valbuf) { - int len = TYPE_LENGTH (type); + int len = type->length (); gdb_byte vbuf[8]; gdb_assert (len <= 8); @@ -279,7 +279,7 @@ static void bpf_store_return_value (struct type *type, struct regcache *regcache, const gdb_byte *valbuf) { - int len = TYPE_LENGTH (type); + int len = type->length (); gdb_byte vbuf[8]; gdb_assert (len <= 8); @@ -295,7 +295,7 @@ bpf_return_value (struct gdbarch *gdbarch, struct value *function, struct type *type, struct regcache *regcache, gdb_byte *readbuf, const gdb_byte *writebuf) { - int len = TYPE_LENGTH (type); + int len = type->length (); if (len > 8) return RETURN_VALUE_STRUCT_CONVENTION; diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index bff3bac..002f4a9 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -2120,7 +2120,7 @@ update_watchpoint (struct watchpoint *b, int reparse) loc->length = ((bitpos % 8) + bitsize + 7) / 8; } else - loc->length = TYPE_LENGTH (value_type (v)); + loc->length = value_type (v)->length (); loc->watchpoint_type = type; } @@ -10259,7 +10259,7 @@ can_use_hardware_watchpoint (const std::vector &vals) len = (target_exact_watchpoints && is_scalar_type_recursive (vtype))? - 1 : TYPE_LENGTH (value_type (v)); + 1 : value_type (v)->length (); num_regs = target_region_ok_for_hw_watchpoint (vaddr, len); if (!num_regs) diff --git a/gdb/c-exp.y b/gdb/c-exp.y index abd5b67..5a3569a 100644 --- a/gdb/c-exp.y +++ b/gdb/c-exp.y @@ -957,7 +957,7 @@ exp : SIZEOF '(' type ')' %prec UNARY type = check_typedef (type->target_type ()); pstate->push_new - (int_type, TYPE_LENGTH (type)); + (int_type, type->length ()); } ; diff --git a/gdb/c-lang.c b/gdb/c-lang.c index 59ecdd3..86e0af7 100644 --- a/gdb/c-lang.c +++ b/gdb/c-lang.c @@ -280,7 +280,7 @@ c_get_string (struct value *value, gdb::unique_xmalloc_ptr *buffer, if (! c_textual_element_type (element_type, 0)) goto error; classify_type (element_type, element_type->arch (), charset); - width = TYPE_LENGTH (element_type); + width = element_type->length (); /* If the string lives in GDB's memory instead of the inferior's, then we just need to copy it to BUFFER. Also, since such strings @@ -433,9 +433,9 @@ emit_numeric_character (struct type *type, unsigned long value, { gdb_byte *buffer; - buffer = (gdb_byte *) alloca (TYPE_LENGTH (type)); + buffer = (gdb_byte *) alloca (type->length ()); pack_long (buffer, type, value); - obstack_grow (output, buffer, TYPE_LENGTH (type)); + obstack_grow (output, buffer, type->length ()); } /* Convert an octal escape sequence. TYPE is the target character @@ -645,7 +645,7 @@ c_string_operation::evaluate (struct type *expect_type, { LONGEST value; - if (obstack_object_size (&output) != TYPE_LENGTH (type)) + if (obstack_object_size (&output) != type->length ()) error (_("Could not convert character " "constant to target character set")); value = unpack_long (type, (gdb_byte *) obstack_base (&output)); @@ -656,19 +656,19 @@ c_string_operation::evaluate (struct type *expect_type, int i; /* Write the terminating character. */ - for (i = 0; i < TYPE_LENGTH (type); ++i) + for (i = 0; i < type->length (); ++i) obstack_1grow (&output, 0); if (satisfy_expected) { LONGEST low_bound, high_bound; - int element_size = TYPE_LENGTH (type); + int element_size = type->length (); if (!get_discrete_bounds (expect_type->index_type (), &low_bound, &high_bound)) { low_bound = 0; - high_bound = (TYPE_LENGTH (expect_type) / element_size) - 1; + high_bound = (expect_type->length () / element_size) - 1; } if (obstack_object_size (&output) / element_size > (high_bound - low_bound + 1)) @@ -707,8 +707,8 @@ c_is_string_type_p (struct type *type) { /* See if target type looks like a string. */ struct type *array_target_type = type->target_type (); - return (TYPE_LENGTH (type) > 0 - && TYPE_LENGTH (array_target_type) > 0 + return (type->length () > 0 + && array_target_type->length () > 0 && c_textual_element_type (array_target_type, 0)); } case TYPE_CODE_STRING: diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c index d7e33ba..3a611cd 100644 --- a/gdb/c-typeprint.c +++ b/gdb/c-typeprint.c @@ -1188,7 +1188,7 @@ c_type_print_base_struct_union (struct type *type, struct ui_file *stream, the whole struct/union. */ local_podata.end_bitpos = podata->end_bitpos - - TYPE_LENGTH (type->field (i).type ()) * TARGET_CHAR_BIT; + - type->field (i).type ()->length () * TARGET_CHAR_BIT; } c_print_type_1 (type->field (i).type (), diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c index a93280c..9b73d97 100644 --- a/gdb/c-valprint.c +++ b/gdb/c-valprint.c @@ -98,7 +98,7 @@ c_textual_element_type (struct type *type, char format) /* Print this as a string if we can manage it. For now, no wide character support. */ if (true_type->code () == TYPE_CODE_INT - && TYPE_LENGTH (true_type) == 1) + && true_type->length () == 1) return 1; } else @@ -107,7 +107,7 @@ c_textual_element_type (struct type *type, char format) flag, then we treat it as text; otherwise, we assume it's being used as data. */ if (true_type->code () == TYPE_CODE_INT - && TYPE_LENGTH (true_type) == 1 + && true_type->length () == 1 && !TYPE_NOTTEXT (true_type)) return 1; } @@ -241,7 +241,7 @@ c_value_print_array (struct value *val, struct type *unresolved_elttype = type->target_type (); struct type *elttype = check_typedef (unresolved_elttype); - if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (unresolved_elttype) > 0) + if (type->length () > 0 && unresolved_elttype->length () > 0) { LONGEST low_bound, high_bound; int eltlen, len; @@ -250,16 +250,16 @@ c_value_print_array (struct value *val, if (!get_array_bounds (type, &low_bound, &high_bound)) error (_("Could not determine the array high bound")); - eltlen = TYPE_LENGTH (elttype); + eltlen = elttype->length (); len = high_bound - low_bound + 1; /* Print arrays of textual chars with a string syntax, as long as the entire array is valid. */ if (c_textual_element_type (unresolved_elttype, options->format) - && value_bytes_available (val, 0, TYPE_LENGTH (type)) + && value_bytes_available (val, 0, type->length ()) && !value_bits_any_optimized_out (val, 0, - TARGET_CHAR_BIT * TYPE_LENGTH (type))) + TARGET_CHAR_BIT * type->length ())) { int force_ellipses = 0; @@ -569,8 +569,8 @@ c_value_print (struct value *val, struct ui_file *stream, superclass of the object's type. In this case it is better to leave the object as-is. */ if (!(full - && (TYPE_LENGTH (real_type) - < TYPE_LENGTH (value_enclosing_type (val))))) + && (real_type->length () + < value_enclosing_type (val)->length ()))) val = value_cast (real_type, val); gdb_printf (stream, "(%s%s) ", real_type->name (), diff --git a/gdb/c-varobj.c b/gdb/c-varobj.c index 957e7f3..4911e37 100644 --- a/gdb/c-varobj.c +++ b/gdb/c-varobj.c @@ -191,9 +191,9 @@ c_number_of_children (const struct varobj *var) switch (type->code ()) { case TYPE_CODE_ARRAY: - if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (target) > 0 + if (type->length () > 0 && target->length () > 0 && (type->bounds ()->high.kind () != PROP_UNDEFINED)) - children = TYPE_LENGTH (type) / TYPE_LENGTH (target); + children = type->length () / target->length (); else /* If we don't know how many elements there are, don't display any. */ diff --git a/gdb/cli/cli-dump.c b/gdb/cli/cli-dump.c index 33c162b..a790883 100644 --- a/gdb/cli/cli-dump.c +++ b/gdb/cli/cli-dump.c @@ -225,7 +225,7 @@ dump_value_to_file (const char *cmd, const char *mode, const char *file_format) /* Have everything. Open/write the data. */ if (file_format == NULL || strcmp (file_format, "binary") == 0) dump_binary_file (filename.get (), mode, value_contents (val).data (), - TYPE_LENGTH (value_type (val))); + value_type (val)->length ()); else { CORE_ADDR vaddr; @@ -242,7 +242,7 @@ dump_value_to_file (const char *cmd, const char *mode, const char *file_format) dump_bfd_file (filename.get (), mode, file_format, vaddr, value_contents (val).data (), - TYPE_LENGTH (value_type (val))); + value_type (val)->length ()); } } diff --git a/gdb/coffread.c b/gdb/coffread.c index 8019789..babf6bd 100644 --- a/gdb/coffread.c +++ b/gdb/coffread.c @@ -1509,7 +1509,7 @@ patch_opaque_types (struct symtab *s) if (real_sym->aclass () == LOC_TYPEDEF && real_sym->domain () == VAR_DOMAIN && real_sym->type ()->code () == TYPE_CODE_PTR - && TYPE_LENGTH (real_sym->type ()->target_type ()) != 0) + && real_sym->type ()->target_type ()->length () != 0) { const char *name = real_sym->linkage_name (); int hash = hashname (name); @@ -1699,7 +1699,7 @@ process_coff_symbol (struct coff_symbol *cs, references work themselves out via the magic of coff_lookup_type. */ if (sym->type ()->code () == TYPE_CODE_PTR - && TYPE_LENGTH (sym->type ()->target_type ()) == 0 + && sym->type ()->target_type ()->length () == 0 && sym->type ()->target_type ()->code () != TYPE_CODE_UNDEF) { diff --git a/gdb/compile/compile-c-support.c b/gdb/compile/compile-c-support.c index 81356f0..19fcf00 100644 --- a/gdb/compile/compile-c-support.c +++ b/gdb/compile/compile-c-support.c @@ -252,7 +252,7 @@ generate_register_struct (struct ui_file *stream, struct gdbarch *gdbarch, case TYPE_CODE_INT: { const char *mode - = c_get_mode_for_size (TYPE_LENGTH (regtype)); + = c_get_mode_for_size (regtype->length ()); if (mode != NULL) { @@ -275,7 +275,7 @@ generate_register_struct (struct ui_file *stream, struct gdbarch *gdbarch, " __attribute__((__aligned__(" "__BIGGEST_ALIGNMENT__)))", regname.c_str (), - pulongest (TYPE_LENGTH (regtype))); + pulongest (regtype->length ())); } gdb_puts (";\n", stream); } diff --git a/gdb/compile/compile-c-types.c b/gdb/compile/compile-c-types.c index d92bd20..5cfbecc 100644 --- a/gdb/compile/compile-c-types.c +++ b/gdb/compile/compile-c-types.c @@ -110,7 +110,7 @@ convert_struct_or_union (compile_c_instance *context, struct type *type) field_type = context->convert_type (type->field (i).type ()); if (bitsize == 0) - bitsize = 8 * TYPE_LENGTH (type->field (i).type ()); + bitsize = 8 * type->field (i).type ()->length (); context->plugin ().build_add_field (result, type->field (i).name (), field_type, @@ -118,7 +118,7 @@ convert_struct_or_union (compile_c_instance *context, struct type *type) type->field (i).loc_bitpos ()); } - context->plugin ().finish_record_or_union (result, TYPE_LENGTH (type)); + context->plugin ().finish_record_or_union (result, type->length ()); return result; } @@ -131,7 +131,7 @@ convert_enum (compile_c_instance *context, struct type *type) int i; int_type = context->plugin ().int_type_v0 (type->is_unsigned (), - TYPE_LENGTH (type)); + type->length ()); result = context->plugin ().build_enum_type (int_type); for (i = 0; i < type->num_fields (); ++i) @@ -196,16 +196,16 @@ convert_int (compile_c_instance *context, struct type *type) { if (type->has_no_signedness ()) { - gdb_assert (TYPE_LENGTH (type) == 1); + gdb_assert (type->length () == 1); return context->plugin ().char_type (); } return context->plugin ().int_type (type->is_unsigned (), - TYPE_LENGTH (type), + type->length (), type->name ()); } else return context->plugin ().int_type_v0 (type->is_unsigned (), - TYPE_LENGTH (type)); + type->length ()); } /* Convert a floating-point type to its gcc representation. */ @@ -214,10 +214,10 @@ static gcc_type convert_float (compile_c_instance *context, struct type *type) { if (context->plugin ().version () >= GCC_C_FE_VERSION_1) - return context->plugin ().float_type (TYPE_LENGTH (type), + return context->plugin ().float_type (type->length (), type->name ()); else - return context->plugin ().float_type_v0 (TYPE_LENGTH (type)); + return context->plugin ().float_type_v0 (type->length ()); } /* Convert the 'void' type to its gcc representation. */ diff --git a/gdb/compile/compile-cplus-types.c b/gdb/compile/compile-cplus-types.c index 6f666e2..245345d 100644 --- a/gdb/compile/compile-cplus-types.c +++ b/gdb/compile/compile-cplus-types.c @@ -648,7 +648,7 @@ compile_cplus_convert_struct_or_union_members | get_field_access_flag (type, i); if (bitsize == 0) - bitsize = 8 * TYPE_LENGTH (type->field (i).type ()); + bitsize = 8 * type->field (i).type ()->length (); instance->plugin ().build_field (field_name, field_type, field_flags, bitsize, @@ -891,7 +891,7 @@ compile_cplus_convert_struct_or_union (compile_cplus_instance *instance, compile_cplus_convert_struct_or_union_members (instance, type, result); /* All finished. */ - instance->plugin ().finish_class_type (name.get (), TYPE_LENGTH (type)); + instance->plugin ().finish_class_type (name.get (), type->length ()); /* Pop all scopes. */ instance->leave_scope (); @@ -926,7 +926,7 @@ compile_cplus_convert_enum (compile_cplus_instance *instance, struct type *type, gcc_type int_type = instance->plugin ().get_int_type (type->is_unsigned (), - TYPE_LENGTH (type), nullptr); + type->length (), nullptr); gcc_type result = instance->plugin ().start_enum_type (name.get (), int_type, GCC_CP_SYMBOL_ENUM | nested_access @@ -1012,12 +1012,12 @@ compile_cplus_convert_int (compile_cplus_instance *instance, struct type *type) { if (type->has_no_signedness ()) { - gdb_assert (TYPE_LENGTH (type) == 1); + gdb_assert (type->length () == 1); return instance->plugin ().get_char_type (); } return instance->plugin ().get_int_type - (type->is_unsigned (), TYPE_LENGTH (type), type->name ()); + (type->is_unsigned (), type->length (), type->name ()); } /* Convert a floating-point type to its gcc representation. */ @@ -1027,7 +1027,7 @@ compile_cplus_convert_float (compile_cplus_instance *instance, struct type *type) { return instance->plugin ().get_float_type - (TYPE_LENGTH (type), type->name ()); + (type->length (), type->name ()); } /* Convert the 'void' type to its gcc representation. */ diff --git a/gdb/compile/compile-object-load.c b/gdb/compile/compile-object-load.c index aede3bc..f3573cb 100644 --- a/gdb/compile/compile-object-load.c +++ b/gdb/compile/compile-object-load.c @@ -557,7 +557,7 @@ store_regs (struct type *regs_type, CORE_ADDR regs_base) ULONGEST reg_offset; struct type *reg_type = check_typedef (regs_type->field (fieldno).type ()); - ULONGEST reg_size = TYPE_LENGTH (reg_type); + ULONGEST reg_size = reg_type->length (); int regnum; struct value *regval; CORE_ADDR inferior_addr; @@ -806,15 +806,15 @@ compile_object_load (const compile_file_names &file_names, { /* Use read-only non-executable memory protection. */ regs_addr = gdbarch_infcall_mmap (target_gdbarch (), - TYPE_LENGTH (regs_type), + regs_type->length (), GDB_MMAP_PROT_READ); gdb_assert (regs_addr != 0); - setup_sections_data.munmap_list.add (regs_addr, TYPE_LENGTH (regs_type)); + setup_sections_data.munmap_list.add (regs_addr, regs_type->length ()); if (compile_debug) gdb_printf (gdb_stdlog, "allocated %s bytes at %s for registers\n", paddress (target_gdbarch (), - TYPE_LENGTH (regs_type)), + regs_type->length ()), paddress (target_gdbarch (), regs_addr)); store_regs (regs_type, regs_addr); } @@ -827,17 +827,17 @@ compile_object_load (const compile_file_names &file_names, return NULL; check_typedef (out_value_type); out_value_addr = gdbarch_infcall_mmap (target_gdbarch (), - TYPE_LENGTH (out_value_type), + out_value_type->length (), (GDB_MMAP_PROT_READ | GDB_MMAP_PROT_WRITE)); gdb_assert (out_value_addr != 0); setup_sections_data.munmap_list.add (out_value_addr, - TYPE_LENGTH (out_value_type)); + out_value_type->length ()); if (compile_debug) gdb_printf (gdb_stdlog, "allocated %s bytes at %s for printed value\n", paddress (target_gdbarch (), - TYPE_LENGTH (out_value_type)), + out_value_type->length ()), paddress (target_gdbarch (), out_value_addr)); } diff --git a/gdb/corefile.c b/gdb/corefile.c index 71f8157..6a226cc 100644 --- a/gdb/corefile.c +++ b/gdb/corefile.c @@ -335,9 +335,9 @@ read_code_unsigned_integer (CORE_ADDR memaddr, int len, CORE_ADDR read_memory_typed_address (CORE_ADDR addr, struct type *type) { - gdb_byte *buf = (gdb_byte *) alloca (TYPE_LENGTH (type)); + gdb_byte *buf = (gdb_byte *) alloca (type->length ()); - read_memory (addr, buf, TYPE_LENGTH (type)); + read_memory (addr, buf, type->length ()); return extract_typed_address (buf, type); } diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c index 86bc57b..fac558d 100644 --- a/gdb/cp-valprint.c +++ b/gdb/cp-valprint.c @@ -451,12 +451,12 @@ cp_print_value (struct value *val, struct ui_file *stream, clobbered by the user program. Make sure that it still points to a valid memory location. */ - if (boffset < 0 || boffset >= TYPE_LENGTH (type)) + if (boffset < 0 || boffset >= type->length ()) { - gdb::byte_vector buf (TYPE_LENGTH (baseclass)); + gdb::byte_vector buf (baseclass->length ()); if (target_read_memory (address + boffset, buf.data (), - TYPE_LENGTH (baseclass)) != 0) + baseclass->length ()) != 0) skip = 1; base_val = value_from_contents_and_address (baseclass, buf.data (), @@ -652,7 +652,7 @@ cp_find_class_member (struct type **self_p, int *fieldno, for (i = 0; i < TYPE_N_BASECLASSES (self); i++) { LONGEST bitpos = self->field (i).loc_bitpos (); - LONGEST bitsize = 8 * TYPE_LENGTH (self->field (i).type ()); + LONGEST bitsize = 8 * self->field (i).type ()->length (); if (offset >= bitpos && offset < bitpos + bitsize) { @@ -679,7 +679,7 @@ cp_print_class_member (const gdb_byte *valaddr, struct type *type, int fieldno; val = extract_signed_integer (valaddr, - TYPE_LENGTH (type), + type->length (), byte_order); /* Pointers to data members are usually byte offsets into an object. @@ -763,7 +763,7 @@ test_print_fields (gdbarch *arch) value *val = allocate_value (the_struct); gdb_byte *contents = value_contents_writeable (val).data (); - store_unsigned_integer (contents, TYPE_LENGTH (value_enclosing_type (val)), + store_unsigned_integer (contents, value_enclosing_type (val)->length (), gdbarch_byte_order (arch), 0xe9); string_file out; diff --git a/gdb/cris-tdep.c b/gdb/cris-tdep.c index 73110d9..549bc06 100644 --- a/gdb/cris-tdep.c +++ b/gdb/cris-tdep.c @@ -821,7 +821,7 @@ cris_push_dummy_call (struct gdbarch *gdbarch, struct value *function, int reg_demand; int i; - len = TYPE_LENGTH (value_type (args[argnum])); + len = value_type (args[argnum])->length (); val = value_contents (args[argnum]).data (); /* How may registers worth of storage do we need for this argument? */ @@ -1611,7 +1611,7 @@ cris_store_return_value (struct type *type, struct regcache *regcache, struct gdbarch *gdbarch = regcache->arch (); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); ULONGEST val; - int len = TYPE_LENGTH (type); + int len = type->length (); if (len <= 4) { @@ -1779,7 +1779,7 @@ cris_extract_return_value (struct type *type, struct regcache *regcache, struct gdbarch *gdbarch = regcache->arch (); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); ULONGEST val; - int len = TYPE_LENGTH (type); + int len = type->length (); if (len <= 4) { @@ -1808,7 +1808,7 @@ cris_return_value (struct gdbarch *gdbarch, struct value *function, { if (type->code () == TYPE_CODE_STRUCT || type->code () == TYPE_CODE_UNION - || TYPE_LENGTH (type) > 8) + || type->length () > 8) /* Structs, unions, and anything larger than 8 bytes (2 registers) goes on the stack. */ return RETURN_VALUE_STRUCT_CONVENTION; diff --git a/gdb/csky-tdep.c b/gdb/csky-tdep.c index ca0111f..cbf12c1 100644 --- a/gdb/csky-tdep.c +++ b/gdb/csky-tdep.c @@ -802,7 +802,7 @@ csky_push_dummy_call (struct gdbarch *gdbarch, struct value *function, const gdb_byte *val; arg_type = check_typedef (value_type (args[argnum])); - len = TYPE_LENGTH (arg_type); + len = arg_type->length (); val = value_contents (args[argnum]).data (); /* Copy the argument to argument registers or the dummy stack. @@ -869,7 +869,7 @@ csky_return_value (struct gdbarch *gdbarch, struct value *function, { CORE_ADDR regval; enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); - int len = TYPE_LENGTH (valtype); + int len = valtype->length (); unsigned int ret_regnum = CSKY_RET_REGNUM; /* Csky abi specifies that return values larger than 8 bytes diff --git a/gdb/ctfread.c b/gdb/ctfread.c index 890cb91..4e866b8 100644 --- a/gdb/ctfread.c +++ b/gdb/ctfread.c @@ -749,7 +749,7 @@ read_enum_type (struct ctf_context *ccp, ctf_id_t tid) type->set_code (TYPE_CODE_ENUM); type->set_length (ctf_type_size (fp, tid)); /* Set the underlying type based on its ctf_type_size bits. */ - type->set_target_type (objfile_int_type (of, TYPE_LENGTH (type), false)); + type->set_target_type (objfile_int_type (of, type->length (), false)); set_type_align (type, ctf_type_align (fp, tid)); return set_tid_type (of, tid, type); diff --git a/gdb/d-valprint.c b/gdb/d-valprint.c index 85b3da3..947c4ae 100644 --- a/gdb/d-valprint.c +++ b/gdb/d-valprint.c @@ -40,7 +40,7 @@ dynamic_array_type (struct type *type, && strcmp (type->field (1).name (), "ptr") == 0 && !value_bits_any_optimized_out (val, TARGET_CHAR_BIT * embedded_offset, - TARGET_CHAR_BIT * TYPE_LENGTH (type))) + TARGET_CHAR_BIT * type->length ())) { CORE_ADDR addr; struct type *elttype; diff --git a/gdb/dwarf2/cu.c b/gdb/dwarf2/cu.c index fe95d7e..e95208e 100644 --- a/gdb/dwarf2/cu.c +++ b/gdb/dwarf2/cu.c @@ -110,7 +110,7 @@ dwarf2_cu::addr_type () const struct type *addr_type = lookup_pointer_type (void_type); int addr_size = this->per_cu->addr_size (); - if (TYPE_LENGTH (addr_type) == addr_size) + if (addr_type->length () == addr_size) return addr_type; addr_type = addr_sized_int_type (addr_type->is_unsigned ()); diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c index ed8366d..d3e3e97 100644 --- a/gdb/dwarf2/expr.c +++ b/gdb/dwarf2/expr.c @@ -182,14 +182,14 @@ rw_pieced_value (value *v, value *from, bool check_optimized) == BFD_ENDIAN_BIG)) { /* Use the least significant bits of FROM. */ - max_offset = 8 * TYPE_LENGTH (value_type (from)); + max_offset = 8 * value_type (from)->length (); offset = max_offset - value_bitsize (v); } else max_offset = value_bitsize (v); } else - max_offset = 8 * TYPE_LENGTH (value_type (v)); + max_offset = 8 * value_type (v)->length (); /* Advance to the first non-skipped piece. */ for (i = 0; i < c->pieces.size () && bits_to_skip >= c->pieces[i].size; i++) @@ -368,7 +368,7 @@ rw_pieced_value (value *v, value *from, bool check_optimized) gdbarch *objfile_gdbarch = c->per_objfile->objfile->arch (); ULONGEST stack_value_size_bits - = 8 * TYPE_LENGTH (value_type (p->v.value)); + = 8 * value_type (p->v.value)->length (); /* Use zeroes if piece reaches beyond stack value. */ if (p->offset + p->size > stack_value_size_bits) @@ -515,7 +515,7 @@ indirect_pieced_value (value *value) if (type->code () != TYPE_CODE_PTR) return NULL; - int bit_length = 8 * TYPE_LENGTH (type); + int bit_length = 8 * type->length (); LONGEST bit_offset = 8 * value_offset (value); if (value_bitsize (value)) bit_offset += value_bitpos (value); @@ -581,7 +581,7 @@ coerce_pieced_ref (const value *value) struct type *type = check_typedef (value_type (value)); if (value_bits_synthetic_pointer (value, value_embedded_offset (value), - TARGET_CHAR_BIT * TYPE_LENGTH (type))) + TARGET_CHAR_BIT * type->length ())) { const piece_closure *closure = (piece_closure *) value_computed_closure (value); @@ -930,7 +930,7 @@ dwarf_expr_context::fetch_result (struct type *type, struct type *subobj_type, bit_size += piece.size; /* Complain if the expression is larger than the size of the outer type. */ - if (bit_size > 8 * TYPE_LENGTH (type)) + if (bit_size > 8 * type->length ()) invalid_synthetic_pointer (); piece_closure *c @@ -974,7 +974,7 @@ dwarf_expr_context::fetch_result (struct type *type, struct type *subobj_type, instead of . */ value *tmp = allocate_value (subobj_type); value_contents_copy (tmp, 0, retval, 0, - TYPE_LENGTH (subobj_type)); + subobj_type->length ()); retval = tmp; } } @@ -1016,9 +1016,9 @@ dwarf_expr_context::fetch_result (struct type *type, struct type *subobj_type, case DWARF_VALUE_STACK: { value *val = this->fetch (0); - size_t n = TYPE_LENGTH (value_type (val)); - size_t len = TYPE_LENGTH (subobj_type); - size_t max = TYPE_LENGTH (type); + size_t n = value_type (val)->length (); + size_t len = subobj_type->length (); + size_t max = type->length (); if (subobj_offset + len > max) invalid_synthetic_pointer (); @@ -1036,7 +1036,7 @@ dwarf_expr_context::fetch_result (struct type *type, struct type *subobj_type, case DWARF_VALUE_LITERAL: { - size_t n = TYPE_LENGTH (subobj_type); + size_t n = subobj_type->length (); if (subobj_offset + n > this->m_len) invalid_synthetic_pointer (); @@ -1100,7 +1100,7 @@ dwarf_require_integral (struct type *type) static struct type * get_unsigned_type (struct gdbarch *gdbarch, struct type *type) { - switch (TYPE_LENGTH (type)) + switch (type->length ()) { case 1: return builtin_type (gdbarch)->builtin_uint8; @@ -1122,7 +1122,7 @@ get_unsigned_type (struct gdbarch *gdbarch, struct type *type) static struct type * get_signed_type (struct gdbarch *gdbarch, struct type *type) { - switch (TYPE_LENGTH (type)) + switch (type->length ()) { case 1: return builtin_type (gdbarch)->builtin_int8; @@ -1308,7 +1308,7 @@ base_types_equal_p (struct type *t1, struct type *t2) return 0; if (t1->is_unsigned () != t2->is_unsigned ()) return 0; - return TYPE_LENGTH (t1) == TYPE_LENGTH (t2); + return t1->length () == t2->length (); } /* If length () != addr_size) { ULONGEST datum = extract_unsigned_integer (buf, addr_size, byte_order); - buf = (gdb_byte *) alloca (TYPE_LENGTH (type)); - store_unsigned_integer (buf, TYPE_LENGTH (type), + buf = (gdb_byte *) alloca (type->length ()); + store_unsigned_integer (buf, type->length (), byte_order, datum); } @@ -2302,7 +2302,7 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr, type = get_base_type (type_die_cu_off); - if (TYPE_LENGTH (type) != n) + if (type->length () != n) error (_("DW_OP_const_type has different sizes for type and data")); result_val = value_from_contents (type, data); @@ -2350,8 +2350,8 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr, { /* Nothing. */ } - else if (TYPE_LENGTH (type) - != TYPE_LENGTH (value_type (result_val))) + else if (type->length () + != value_type (result_val)->length ()) error (_("DW_OP_reinterpret has wrong size")); else result_val diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c index 9463f48..ad45d57 100644 --- a/gdb/dwarf2/loc.c +++ b/gdb/dwarf2/loc.c @@ -1364,7 +1364,7 @@ value_of_dwarf_reg_entry (struct type *type, struct frame_info *frame, return outer_val; target_val = dwarf_entry_parameter_to_value (parameter, - TYPE_LENGTH (target_type), + target_type->length (), target_type, caller_frame, caller_per_cu, caller_per_objfile); @@ -1375,7 +1375,7 @@ value_of_dwarf_reg_entry (struct type *type, struct frame_info *frame, /* Copy the referencing pointer to the new computed value. */ memcpy (value_contents_raw (val).data (), value_contents_raw (outer_val).data (), - TYPE_LENGTH (checked_type)); + checked_type->length ()); set_value_lazy (val, 0); return val; @@ -1430,7 +1430,7 @@ fetch_const_value_from_synthetic_pointer (sect_offset die, LONGEST byte_offset, if (bytes != NULL) { if (byte_offset >= 0 - && byte_offset + TYPE_LENGTH (type->target_type ()) <= len) + && byte_offset + type->target_type ()->length () <= len) { bytes += byte_offset; result = value_from_contents (type->target_type (), bytes); @@ -1526,7 +1526,7 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame, free_values.free_to_mark (); retval = allocate_value (subobj_type); mark_value_bytes_unavailable (retval, 0, - TYPE_LENGTH (subobj_type)); + subobj_type->length ()); return retval; } else if (ex.error == NO_ENTRY_VALUE_ERROR) @@ -1672,7 +1672,7 @@ dwarf2_evaluate_property (const struct dynamic_prop *prop, gdb_assert (baton->property_type != NULL); struct type *type = check_typedef (baton->property_type); - if (TYPE_LENGTH (type) < sizeof (CORE_ADDR) + if (type->length () < sizeof (CORE_ADDR) && !type->is_unsigned ()) { /* If we have a valid return candidate and it's value diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index ef988d7..0ad9bda 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -8191,7 +8191,7 @@ quirk_rust_enum (struct type *type, struct objfile *objfile) /* In Rust, each element should have the size of the enclosing enum. */ - type->field (i).type ()->set_length (TYPE_LENGTH (type)); + type->field (i).type ()->set_length (type->length ()); /* Remove the discriminant field, if it exists. */ struct type *sub_type = type->field (i).type (); @@ -9012,7 +9012,7 @@ dwarf2_compute_name (const char *name, { v = allocate_value (type); memcpy (value_contents_writeable (v).data (), bytes, - TYPE_LENGTH (type)); + type->length ()); } else v = value_from_longest (type, value); @@ -13613,7 +13613,7 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die, the bit field must be inferred from the type attribute of the data member containing the bit field. */ - anonymous_size = TYPE_LENGTH (fp->type ()); + anonymous_size = fp->type ()->length (); } fp->set_loc_bitpos (fp->loc_bitpos () + anonymous_size * bits_per_byte @@ -14655,7 +14655,7 @@ read_structure_type (struct die_info *die, struct dwarf2_cu *cu) maybe_set_alignment (cu, die, type); - if (producer_is_icc_lt_14 (cu) && (TYPE_LENGTH (type) == 0)) + if (producer_is_icc_lt_14 (cu) && (type->length () == 0)) { /* ICC<14 does not output the required DW_AT_declaration on incomplete types, but gives them a size of zero. */ @@ -15227,8 +15227,8 @@ read_enumeration_type (struct die_info *die, struct dwarf2_cu *cu) type->set_is_unsigned (underlying_type->is_unsigned ()); - if (TYPE_LENGTH (type) == 0) - type->set_length (TYPE_LENGTH (underlying_type)); + if (type->length () == 0) + type->set_length (underlying_type->length ()); if (TYPE_RAW_ALIGN (type) == 0 && TYPE_RAW_ALIGN (underlying_type) != 0) @@ -15409,7 +15409,7 @@ recognize_bound_expression (struct die_info *die, enum dwarf_attribute name, return false; field->set_loc_bitpos (8 * offset); - if (size != TYPE_LENGTH (field->type ())) + if (size != field->type ()->length ()) FIELD_BITSIZE (*field) = 8 * size; return true; @@ -15524,7 +15524,7 @@ quirk_ada_thick_pointer (struct die_info *die, struct dwarf2_cu *cu, int last_fieldno = range_fields.size () - 1; int bounds_size = (bounds->field (last_fieldno).loc_bitpos () / 8 - + TYPE_LENGTH (bounds->field (last_fieldno).type ())); + + bounds->field (last_fieldno).type ()->length ()); bounds->set_length (align_up (bounds_size, max_align)); /* Rewrite the existing array type in place. Specifically, we @@ -15559,8 +15559,8 @@ quirk_ada_thick_pointer (struct die_info *die, struct dwarf2_cu *cu, result->field (1).set_loc_bitpos (8 * bounds_offset); result->set_name (type->name ()); - result->set_length (TYPE_LENGTH (result->field (0).type ()) - + TYPE_LENGTH (result->field (1).type ())); + result->set_length (result->field (0).type ()->length () + + result->field (1).type ()->length ()); return result; } @@ -15700,7 +15700,7 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu) attr = dwarf2_attr (die, DW_AT_byte_size, cu); if (attr != nullptr && attr->form_is_unsigned ()) { - if (attr->as_unsigned () >= TYPE_LENGTH (type)) + if (attr->as_unsigned () >= type->length ()) type->set_length (attr->as_unsigned ()); else complaint (_("DW_AT_byte_size for array type smaller " @@ -16158,7 +16158,7 @@ read_tag_pointer_type (struct die_info *die, struct dwarf2_cu *cu) /* If the pointer size, alignment, or address class is different than the default, create a type variant marked as such and set the length accordingly. */ - if (TYPE_LENGTH (type) != byte_size + if (type->length () != byte_size || (alignment != 0 && TYPE_RAW_ALIGN (type) != 0 && alignment != TYPE_RAW_ALIGN (type)) || addr_class != DW_ADDR_none) @@ -16172,7 +16172,7 @@ read_tag_pointer_type (struct die_info *die, struct dwarf2_cu *cu) == 0); type = make_type_with_address_space (type, type_flags); } - else if (TYPE_LENGTH (type) != byte_size) + else if (type->length () != byte_size) { complaint (_("invalid pointer size %d"), byte_size); } @@ -17088,7 +17088,7 @@ dwarf2_init_complex_target_type (struct dwarf2_cu *cu, /* If the type we found doesn't match the size we were looking for, then pretend we didn't find a type at all, the complex target type we create will then be nameless. */ - if (tt != nullptr && TYPE_LENGTH (tt) * TARGET_CHAR_BIT != bits) + if (tt != nullptr && tt->length () * TARGET_CHAR_BIT != bits) tt = nullptr; const char *name = (tt == nullptr) ? nullptr : tt->name (); @@ -17280,14 +17280,14 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu) if (TYPE_SPECIFIC_FIELD (type) == TYPE_SPECIFIC_INT) { attr = dwarf2_attr (die, DW_AT_bit_size, cu); - if (attr != nullptr && attr->as_unsigned () <= 8 * TYPE_LENGTH (type)) + if (attr != nullptr && attr->as_unsigned () <= 8 * type->length ()) { unsigned real_bit_size = attr->as_unsigned (); attr = dwarf2_attr (die, DW_AT_data_bit_offset, cu); /* Only use the attributes if they make sense together. */ if (attr == nullptr || (attr->as_unsigned () + real_bit_size - <= 8 * TYPE_LENGTH (type))) + <= 8 * type->length ())) { TYPE_MAIN_TYPE (type)->type_specific.int_stuff.bit_size = real_bit_size; @@ -17618,7 +17618,7 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) the bounds as signed, and thus sign-extend their values, when the base type is signed. */ negative_mask = - -((ULONGEST) 1 << (TYPE_LENGTH (base_type) * TARGET_CHAR_BIT - 1)); + -((ULONGEST) 1 << (base_type->length () * TARGET_CHAR_BIT - 1)); if (low.kind () == PROP_CONST && !base_type->is_unsigned () && (low.const_val () & negative_mask)) low.set_const_val (low.const_val () | negative_mask); @@ -21188,10 +21188,10 @@ dwarf2_const_value_attr (const struct attribute *attr, struct type *type, { gdb_byte *data; - if (TYPE_LENGTH (type) != cu_header->addr_size) + if (type->length () != cu_header->addr_size) dwarf2_const_value_length_mismatch_complaint (name, cu_header->addr_size, - TYPE_LENGTH (type)); + type->length ()); /* Symbols of this form are reasonably rare, so we just piggyback on the existing location code rather than writing a new implementation of symbol_computed_ops. */ @@ -21226,9 +21226,9 @@ dwarf2_const_value_attr (const struct attribute *attr, struct type *type, case DW_FORM_exprloc: case DW_FORM_data16: blk = attr->as_block (); - if (TYPE_LENGTH (type) != blk->size) + if (type->length () != blk->size) dwarf2_const_value_length_mismatch_complaint (name, blk->size, - TYPE_LENGTH (type)); + type->length ()); *bytes = blk->data; break; @@ -22523,7 +22523,7 @@ write_constant_as_bytes (struct obstack *obstack, { gdb_byte *result; - *len = TYPE_LENGTH (type); + *len = type->length (); result = (gdb_byte *) obstack_alloc (obstack, *len); store_unsigned_integer (result, *len, byte_order, value); diff --git a/gdb/elfread.c b/gdb/elfread.c index 77e5865..8aee634 100644 --- a/gdb/elfread.c +++ b/gdb/elfread.c @@ -553,7 +553,7 @@ elf_rel_plt_read (minimal_symbol_reader &reader, bfd_size_type reloc_count, reloc; struct gdbarch *gdbarch = objfile->arch (); struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr; - size_t ptr_size = TYPE_LENGTH (ptr_type); + size_t ptr_size = ptr_type->length (); if (objfile->separate_debug_objfile_backlink) return; @@ -819,7 +819,7 @@ elf_gnu_ifunc_resolve_by_got (const char *name, CORE_ADDR *addr_p) bfd *obfd = objfile->obfd.get (); struct gdbarch *gdbarch = objfile->arch (); struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr; - size_t ptr_size = TYPE_LENGTH (ptr_type); + size_t ptr_size = ptr_type->length (); CORE_ADDR pointer_address, addr; asection *plt; gdb_byte *buf = (gdb_byte *) alloca (ptr_size); diff --git a/gdb/eval.c b/gdb/eval.c index a6e295d..55e130d 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -245,7 +245,7 @@ unop_promote (const struct language_defn *language, struct gdbarch *gdbarch, { struct type *builtin_int = builtin_type (gdbarch)->builtin_int; - if (TYPE_LENGTH (type1) < TYPE_LENGTH (builtin_int)) + if (type1->length () < builtin_int->length ()) *arg1 = value_cast (builtin_int, *arg1); } break; @@ -306,8 +306,8 @@ binop_promote (const struct language_defn *language, struct gdbarch *gdbarch, version 6.7 for backward compatibility. If either arg was long double, make sure that value is also long double. Otherwise use double. */ - if (TYPE_LENGTH (type1) * 8 > gdbarch_double_bit (gdbarch) - || TYPE_LENGTH (type2) * 8 > gdbarch_double_bit (gdbarch)) + if (type1->length () * 8 > gdbarch_double_bit (gdbarch) + || type2->length () * 8 > gdbarch_double_bit (gdbarch)) promoted_type = builtin_type (gdbarch)->builtin_long_double; else promoted_type = builtin_type (gdbarch)->builtin_double; @@ -324,8 +324,8 @@ binop_promote (const struct language_defn *language, struct gdbarch *gdbarch, /* FIXME: Also mixed integral/booleans, with result an integer. */ { const struct builtin_type *builtin = builtin_type (gdbarch); - unsigned int promoted_len1 = TYPE_LENGTH (type1); - unsigned int promoted_len2 = TYPE_LENGTH (type2); + unsigned int promoted_len1 = type1->length (); + unsigned int promoted_len2 = type2->length (); int is_unsigned1 = type1->is_unsigned (); int is_unsigned2 = type2->is_unsigned (); unsigned int result_len; @@ -333,15 +333,15 @@ binop_promote (const struct language_defn *language, struct gdbarch *gdbarch, /* Determine type length and signedness after promotion for both operands. */ - if (promoted_len1 < TYPE_LENGTH (builtin->builtin_int)) + if (promoted_len1 < builtin->builtin_int->length ()) { is_unsigned1 = 0; - promoted_len1 = TYPE_LENGTH (builtin->builtin_int); + promoted_len1 = builtin->builtin_int->length (); } - if (promoted_len2 < TYPE_LENGTH (builtin->builtin_int)) + if (promoted_len2 < builtin->builtin_int->length ()) { is_unsigned2 = 0; - promoted_len2 = TYPE_LENGTH (builtin->builtin_int); + promoted_len2 = builtin->builtin_int->length (); } if (promoted_len1 > promoted_len2) @@ -366,13 +366,13 @@ binop_promote (const struct language_defn *language, struct gdbarch *gdbarch, case language_cplus: case language_asm: case language_objc: - if (result_len <= TYPE_LENGTH (builtin->builtin_int)) + if (result_len <= builtin->builtin_int->length ()) { promoted_type = (unsigned_operation ? builtin->builtin_unsigned_int : builtin->builtin_int); } - else if (result_len <= TYPE_LENGTH (builtin->builtin_long)) + else if (result_len <= builtin->builtin_long->length ()) { promoted_type = (unsigned_operation ? builtin->builtin_unsigned_long @@ -386,16 +386,16 @@ binop_promote (const struct language_defn *language, struct gdbarch *gdbarch, } break; case language_opencl: - if (result_len <= TYPE_LENGTH (lookup_signed_typename - (language, "int"))) + if (result_len + <= lookup_signed_typename (language, "int")->length()) { promoted_type = (unsigned_operation ? lookup_unsigned_typename (language, "int") : lookup_signed_typename (language, "int")); } - else if (result_len <= TYPE_LENGTH (lookup_signed_typename - (language, "long"))) + else if (result_len + <= lookup_signed_typename (language, "long")->length()) { promoted_type = (unsigned_operation @@ -2408,7 +2408,7 @@ array_operation::evaluate_struct_tuple (struct value *struct_val, value_as_long (val), bitpos % 8, bitsize); else memcpy (addr, value_contents (val).data (), - TYPE_LENGTH (value_type (val))); + value_type (val)->length ()); } return struct_val; @@ -2431,7 +2431,7 @@ array_operation::evaluate (struct type *expect_type, { struct value *rec = allocate_value (expect_type); - memset (value_contents_raw (rec).data (), '\0', TYPE_LENGTH (type)); + memset (value_contents_raw (rec).data (), '\0', type->length ()); return evaluate_struct_tuple (rec, exp, noside, nargs); } @@ -2441,16 +2441,16 @@ array_operation::evaluate (struct type *expect_type, struct type *range_type = type->index_type (); struct type *element_type = type->target_type (); struct value *array = allocate_value (expect_type); - int element_size = TYPE_LENGTH (check_typedef (element_type)); + int element_size = check_typedef (element_type)->length (); LONGEST low_bound, high_bound, index; if (!get_discrete_bounds (range_type, &low_bound, &high_bound)) { low_bound = 0; - high_bound = (TYPE_LENGTH (type) / element_size) - 1; + high_bound = (type->length () / element_size) - 1; } index = low_bound; - memset (value_contents_raw (array).data (), 0, TYPE_LENGTH (expect_type)); + memset (value_contents_raw (array).data (), 0, expect_type->length ()); for (tem = nargs; --nargs >= 0;) { struct value *element; @@ -2487,7 +2487,7 @@ array_operation::evaluate (struct type *expect_type, if (!get_discrete_bounds (element_type, &low_bound, &high_bound)) error (_("(power)set type with unknown size")); - memset (valaddr, '\0', TYPE_LENGTH (type)); + memset (valaddr, '\0', type->length ()); int idx = 0; for (tem = 0; tem < nargs; tem++) { @@ -2555,11 +2555,11 @@ unop_extract_operation::evaluate (struct type *expect_type, value *old_value = std::get<0> (m_storage)->evaluate (nullptr, exp, noside); struct type *type = get_type (); - if (TYPE_LENGTH (type) > TYPE_LENGTH (value_type (old_value))) + if (type->length () > value_type (old_value)->length ()) error (_("length type is larger than the value type")); struct value *result = allocate_value (type); - value_contents_copy (result, 0, old_value, 0, TYPE_LENGTH (type)); + value_contents_copy (result, 0, old_value, 0, type->length ()); return result; } @@ -2730,7 +2730,7 @@ evaluate_subexp_for_sizeof_base (struct expression *exp, struct type *type) if (exp->language_defn->la_language == language_cplus && (TYPE_IS_REFERENCE (type))) type = check_typedef (type->target_type ()); - return value_from_longest (size_type, (LONGEST) TYPE_LENGTH (type)); + return value_from_longest (size_type, (LONGEST) type->length ()); } namespace expr @@ -2757,7 +2757,7 @@ var_msym_value_operation::evaluate_for_sizeof (struct expression *exp, /* FIXME: This should be size_t. */ struct type *size_type = builtin_type (exp->gdbarch)->builtin_int; - return value_from_longest (size_type, TYPE_LENGTH (type)); + return value_from_longest (size_type, type->length ()); } value * @@ -2784,7 +2784,7 @@ subscript_operation::evaluate_for_sizeof (struct expression *exp, struct type *size_type = builtin_type (exp->gdbarch)->builtin_int; return value_from_longest - (size_type, (LONGEST) TYPE_LENGTH (value_type (val))); + (size_type, (LONGEST) value_type (val)->length ()); } } } @@ -2808,7 +2808,7 @@ unop_ind_base_operation::evaluate_for_sizeof (struct expression *exp, type = value_type (value_ind (val)); /* FIXME: This should be size_t. */ struct type *size_type = builtin_type (exp->gdbarch)->builtin_int; - return value_from_longest (size_type, (LONGEST) TYPE_LENGTH (type)); + return value_from_longest (size_type, (LONGEST) type->length ()); } value * diff --git a/gdb/f-exp.y b/gdb/f-exp.y index 6264108..1de7da2 100644 --- a/gdb/f-exp.y +++ b/gdb/f-exp.y @@ -618,7 +618,7 @@ exp : SIZEOF '(' type ')' %prec UNARY $3 = check_typedef ($3); pstate->push_new (parse_f_type (pstate)->builtin_integer, - TYPE_LENGTH ($3)); + $3->length ()); } ; diff --git a/gdb/f-lang.c b/gdb/f-lang.c index 422e531..0be913e 100644 --- a/gdb/f-lang.c +++ b/gdb/f-lang.c @@ -82,7 +82,7 @@ f_language::get_encoding (struct type *type) { const char *encoding; - switch (TYPE_LENGTH (type)) + switch (type->length ()) { case 1: encoding = target_charset (type->arch ()); @@ -141,7 +141,7 @@ fortran_bounds_all_dims (bool lbound_p, /* Walk the array dimensions backwards due to the way the array will be laid out in memory, the first dimension will be the most inner. */ - LONGEST elm_len = TYPE_LENGTH (elm_type); + LONGEST elm_len = elm_type->length (); for (LONGEST dst_offset = elm_len * (ndimensions - 1); dst_offset >= 0; dst_offset -= elm_len) @@ -156,9 +156,9 @@ fortran_bounds_all_dims (bool lbound_p, /* And copy the value into the result value. */ struct value *v = value_from_longest (elm_type, b); - gdb_assert (dst_offset + TYPE_LENGTH (value_type (v)) - <= TYPE_LENGTH (value_type (result))); - gdb_assert (TYPE_LENGTH (value_type (v)) == elm_len); + gdb_assert (dst_offset + value_type (v)->length () + <= value_type (result)->length ()); + gdb_assert (value_type (v)->length () == elm_len); value_contents_copy (result, dst_offset, v, 0, elm_len); /* Peel another dimension of the array. */ @@ -283,8 +283,8 @@ protected: void copy_element_to_dest (struct value *elt) { value_contents_copy (m_dest, m_dest_offset, elt, 0, - TYPE_LENGTH (value_type (elt))); - m_dest_offset += TYPE_LENGTH (value_type (elt)); + value_type (elt)->length ()); + m_dest_offset += value_type (elt)->length (); } /* The value being written to. */ @@ -447,8 +447,8 @@ fortran_associated (struct gdbarch *gdbarch, const language_defn *lang, if (pointer_target_type->code () != target_target_type->code () || (pointer_target_type->code () != TYPE_CODE_ARRAY - && (TYPE_LENGTH (pointer_target_type) - != TYPE_LENGTH (target_target_type)))) + && (pointer_target_type->length () + != target_target_type->length ()))) error (_("arguments to associated must be of same type and kind")); /* If TARGET is not in memory, or the original pointer is specifically @@ -721,7 +721,7 @@ fortran_array_shape (struct gdbarch *gdbarch, const language_defn *lang, struct type *elm_type = builtin_f_type (gdbarch)->builtin_integer; struct type *result_type = create_array_type (nullptr, elm_type, range); struct value *result = allocate_value (result_type); - LONGEST elm_len = TYPE_LENGTH (elm_type); + LONGEST elm_len = elm_type->length (); /* Walk the array dimensions backwards due to the way the array will be laid out in memory, the first dimension will be the most inner. @@ -741,9 +741,9 @@ fortran_array_shape (struct gdbarch *gdbarch, const language_defn *lang, /* And copy the value into the result value. */ struct value *v = value_from_longest (elm_type, dim_size); - gdb_assert (dst_offset + TYPE_LENGTH (value_type (v)) - <= TYPE_LENGTH (value_type (result))); - gdb_assert (TYPE_LENGTH (value_type (v)) == elm_len); + gdb_assert (dst_offset + value_type (v)->length () + <= value_type (result)->length ()); + gdb_assert (value_type (v)->length () == elm_len); value_contents_copy (result, dst_offset, v, 0, elm_len); /* Peel another dimension of the array. */ @@ -1018,9 +1018,9 @@ eval_op_f_kind (struct type *expect_type, struct expression *exp, if (!type->target_type ()) return value_from_longest (builtin_type (exp->gdbarch)->builtin_int, - TYPE_LENGTH (type)); + type->length ()); return value_from_longest (builtin_type (exp->gdbarch)->builtin_int, - TYPE_LENGTH (type->target_type ())); + type->target_type ()->length ()); } /* A helper function for UNOP_FORTRAN_ALLOCATED. */ @@ -1153,7 +1153,7 @@ fortran_undetermined::value_subarray (value *array, of an element at each dimension of the new slice array. Initially the elements of the inner most dimension of the array are the same inner most elements as the original ARRAY. */ - LONGEST slice_element_size = TYPE_LENGTH (inner_element_type); + LONGEST slice_element_size = inner_element_type->length (); /* Start off assuming all data is contiguous, this will be set to false if access to any dimension results in non-contiguous data. */ @@ -1234,7 +1234,7 @@ fortran_undetermined::value_subarray (value *array, LONGEST ub = f77_get_upperbound (dim_type); LONGEST sd = index_type->bit_stride (); if (sd == 0) - sd = TYPE_LENGTH (target_type) * 8; + sd = target_type->length () * 8; if (fortran_array_slicing_debug) { @@ -1247,9 +1247,9 @@ fortran_undetermined::value_subarray (value *array, debug_printf ("| | |-> Bit stride: %s\n", plongest (sd)); debug_printf ("| | |-> Byte stride: %s\n", plongest (sd / 8)); debug_printf ("| | |-> Type size: %s\n", - pulongest (TYPE_LENGTH (dim_type))); + pulongest (dim_type->length ())); debug_printf ("| | '-> Target type size: %s\n", - pulongest (TYPE_LENGTH (target_type))); + pulongest (target_type->length ())); debug_printf ("| |-> Accessing:\n"); debug_printf ("| | |-> Low bound: %s\n", plongest (low)); @@ -1282,7 +1282,7 @@ fortran_undetermined::value_subarray (value *array, LONGEST remainder = high - last_elem; if (low > high) { - offset += std::abs (remainder) * TYPE_LENGTH (target_type); + offset += std::abs (remainder) * target_type->length (); if (stride > 0) error (_("incorrect stride and boundary combination")); } @@ -1336,7 +1336,7 @@ fortran_undetermined::value_subarray (value *array, LONGEST ub = f77_get_upperbound (dim_type); LONGEST sd = index_type->bit_stride () / 8; if (sd == 0) - sd = TYPE_LENGTH (target_type); + sd = target_type->length (); if (fortran_array_slicing_debug) { @@ -1348,9 +1348,9 @@ fortran_undetermined::value_subarray (value *array, debug_printf ("| | |-> High bound: %s\n", plongest (ub)); debug_printf ("| | |-> Byte stride: %s\n", plongest (sd)); debug_printf ("| | |-> Type size: %s\n", - pulongest (TYPE_LENGTH (dim_type))); + pulongest (dim_type->length ())); debug_printf ("| | '-> Target type size: %s\n", - pulongest (TYPE_LENGTH (target_type))); + pulongest (target_type->length ())); debug_printf ("| '-> Accessing:\n"); debug_printf ("| '-> Index: %s\n", plongest (index)); @@ -1427,7 +1427,7 @@ fortran_undetermined::value_subarray (value *array, p_low.set_const_val (d.low); p_high.set_const_val (d.high); - p_stride.set_const_val (TYPE_LENGTH (repacked_array_type)); + p_stride.set_const_val (repacked_array_type->length ()); struct type *new_range = create_range_type_with_stride ((struct type *) NULL, @@ -1442,8 +1442,8 @@ fortran_undetermined::value_subarray (value *array, array value DEST. */ struct value *dest = allocate_value (repacked_array_type); if (value_lazy (array) - || (total_offset + TYPE_LENGTH (array_slice_type) - > TYPE_LENGTH (check_typedef (value_type (array))))) + || (total_offset + array_slice_type->length () + > check_typedef (value_type (array))->length ())) { fortran_array_walker p (array_slice_type, value_address (array) + total_offset, dest); @@ -1467,8 +1467,8 @@ fortran_undetermined::value_subarray (value *array, just create a new lazy value pointing at the memory where the contents we're looking for exist. */ if (value_lazy (array) - || (total_offset + TYPE_LENGTH (array_slice_type) - > TYPE_LENGTH (check_typedef (value_type (array))))) + || (total_offset + array_slice_type->length () + > check_typedef (value_type (array))->length ())) array = value_at_lazy (array_slice_type, value_address (array) + total_offset); else @@ -1634,7 +1634,7 @@ fortran_structop_operation::evaluate (struct type *expect_type, const gdb_byte *valaddr = value_contents_for_printing (elt).data (); CORE_ADDR address = value_address (elt); gdb::array_view view - = gdb::make_array_view (valaddr, TYPE_LENGTH (elt_type)); + = gdb::make_array_view (valaddr, elt_type->length ()); elt_type = resolve_dynamic_type (elt_type, view, address); } elt = value_zero (elt_type, VALUE_LVAL (elt)); @@ -1875,7 +1875,7 @@ fortran_argument_convert (struct value *value, bool is_artificial) if (VALUE_LVAL (value) != lval_memory) { struct type *type = value_type (value); - const int length = TYPE_LENGTH (type); + const int length = type->length (); const CORE_ADDR addr = value_as_long (value_allocate_space_in_inferior (length)); write_memory (addr, value_contents (value).data (), length); diff --git a/gdb/f-lang.h b/gdb/f-lang.h index 0107a08..6a97fab 100644 --- a/gdb/f-lang.h +++ b/gdb/f-lang.h @@ -175,7 +175,7 @@ public: { const char *type_encoding = get_encoding (elttype); - if (TYPE_LENGTH (elttype) == 4) + if (elttype->length () == 4) gdb_puts ("4_", stream); if (!encoding || !*encoding) diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c index 2dda1b8..37e597a 100644 --- a/gdb/f-valprint.c +++ b/gdb/f-valprint.c @@ -92,7 +92,7 @@ f77_get_dynamic_length_of_aggregate (struct type *type) /* Patch in a valid length value. */ type->set_length ((upper_bound - lower_bound + 1) - * TYPE_LENGTH (check_typedef (type->target_type ()))); + * check_typedef (type->target_type ())->length ()); } /* Per-dimension statistics. */ @@ -264,7 +264,7 @@ public: bool repeated = (m_options->repeat_count_threshold < UINT_MAX && elt_type_prev != nullptr && value_contents_eq (m_val, elt_off_prev, m_val, elt_off, - TYPE_LENGTH (elt_type))); + elt_type->length ())); if (repeated) m_nrepeats++; @@ -363,7 +363,7 @@ private: } else return value_contents_eq (val, offset1, val, offset2, - TYPE_LENGTH (type)); + type->length ()); } /* The number of elements printed so far. */ @@ -446,7 +446,7 @@ f_language::value_print_inner (struct value *val, struct ui_file *stream, case TYPE_CODE_STRING: f77_get_dynamic_length_of_aggregate (type); printstr (stream, builtin_type (gdbarch)->builtin_char, valaddr, - TYPE_LENGTH (type), NULL, 0, options); + type->length (), NULL, 0, options); break; case TYPE_CODE_ARRAY: @@ -458,7 +458,7 @@ f_language::value_print_inner (struct value *val, struct ui_file *stream, f77_get_dynamic_length_of_aggregate (type); printstr (stream, ch_type, valaddr, - TYPE_LENGTH (type) / TYPE_LENGTH (ch_type), NULL, 0, + type->length () / ch_type->length (), NULL, 0, options); } break; @@ -494,7 +494,7 @@ f_language::value_print_inner (struct value *val, struct ui_file *stream, /* For a pointer to char or unsigned char, also print the string pointed to, unless pointer is null. */ - if (TYPE_LENGTH (elttype) == 1 + if (elttype->length () == 1 && elttype->code () == TYPE_CODE_INT && (options->format == 0 || options->format == 's') && addr != 0) diff --git a/gdb/fbsd-tdep.c b/gdb/fbsd-tdep.c index 5eec49b..4037010 100644 --- a/gdb/fbsd-tdep.c +++ b/gdb/fbsd-tdep.c @@ -1608,13 +1608,13 @@ fbsd_get_siginfo_type (struct gdbarch *gdbarch) /* __pid_t */ pid_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF, - TYPE_LENGTH (int32_type) * TARGET_CHAR_BIT, "__pid_t"); + int32_type->length () * TARGET_CHAR_BIT, "__pid_t"); pid_type->set_target_type (int32_type); pid_type->set_target_is_stub (true); /* __uid_t */ uid_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF, - TYPE_LENGTH (uint32_type) * TARGET_CHAR_BIT, + uint32_type->length () * TARGET_CHAR_BIT, "__uid_t"); uid_type->set_target_type (uint32_type); pid_type->set_target_is_stub (true); @@ -2030,7 +2030,7 @@ fbsd_get_thread_local_address (struct gdbarch *gdbarch, CORE_ADDR dtv_addr, CORE_ADDR addr = gdbarch_pointer_to_address (gdbarch, builtin->builtin_data_ptr, buf); - addr += (tls_index + 1) * TYPE_LENGTH (builtin->builtin_data_ptr); + addr += (tls_index + 1) * builtin->builtin_data_ptr->length (); if (target_read_memory (addr, buf, sizeof buf) != 0) throw_error (TLS_GENERIC_ERROR, _("Cannot find thread-local variables on this target")); diff --git a/gdb/findcmd.c b/gdb/findcmd.c index ed2cea7..889e31b 100644 --- a/gdb/findcmd.c +++ b/gdb/findcmd.c @@ -187,7 +187,7 @@ parse_find_args (const char *args, ULONGEST *max_countp, { const gdb_byte *contents = value_contents (v).data (); pattern_buf.insert (pattern_buf.end (), contents, - contents + TYPE_LENGTH (t)); + contents + t->length ()); } if (*s == ',') diff --git a/gdb/findvar.c b/gdb/findvar.c index 36c0945..b388d82 100644 --- a/gdb/findvar.c +++ b/gdb/findvar.c @@ -318,7 +318,7 @@ unsigned_pointer_to_address (struct gdbarch *gdbarch, { enum bfd_endian byte_order = type_byte_order (type); - return extract_unsigned_integer (buf, TYPE_LENGTH (type), byte_order); + return extract_unsigned_integer (buf, type->length (), byte_order); } CORE_ADDR @@ -327,7 +327,7 @@ signed_pointer_to_address (struct gdbarch *gdbarch, { enum bfd_endian byte_order = type_byte_order (type); - return extract_signed_integer (buf, TYPE_LENGTH (type), byte_order); + return extract_signed_integer (buf, type->length (), byte_order); } /* Given an address, store it as a pointer of type TYPE in target @@ -338,7 +338,7 @@ unsigned_address_to_pointer (struct gdbarch *gdbarch, struct type *type, { enum bfd_endian byte_order = type_byte_order (type); - store_unsigned_integer (buf, TYPE_LENGTH (type), byte_order, addr); + store_unsigned_integer (buf, type->length (), byte_order, addr); } void @@ -347,7 +347,7 @@ address_to_signed_pointer (struct gdbarch *gdbarch, struct type *type, { enum bfd_endian byte_order = type_byte_order (type); - store_signed_integer (buf, TYPE_LENGTH (type), byte_order, addr); + store_signed_integer (buf, type->length (), byte_order, addr); } /* See value.h. */ @@ -595,7 +595,7 @@ language_defn::read_var_value (struct symbol *var, } /* Put the constant back in target format. */ v = allocate_value (type); - store_signed_integer (value_contents_raw (v).data (), TYPE_LENGTH (type), + store_signed_integer (value_contents_raw (v).data (), type->length (), type_byte_order (type), var->value_longest ()); VALUE_LVAL (v) = not_lval; return v; @@ -624,7 +624,7 @@ language_defn::read_var_value (struct symbol *var, } v = allocate_value (type); memcpy (value_contents_raw (v).data (), var->value_bytes (), - TYPE_LENGTH (type)); + type->length ()); VALUE_LVAL (v) = not_lval; return v; @@ -796,7 +796,7 @@ struct value * default_value_from_register (struct gdbarch *gdbarch, struct type *type, int regnum, struct frame_id frame_id) { - int len = TYPE_LENGTH (type); + int len = type->length (); struct value *value = allocate_value (type); struct frame_info *frame; @@ -902,9 +902,9 @@ value_from_register (struct type *type, int regnum, struct frame_info *frame) if (!ok) { if (optim) - mark_value_bytes_optimized_out (v, 0, TYPE_LENGTH (type)); + mark_value_bytes_optimized_out (v, 0, type->length ()); if (unavail) - mark_value_bytes_unavailable (v, 0, TYPE_LENGTH (type)); + mark_value_bytes_unavailable (v, 0, type->length ()); } } else @@ -947,7 +947,7 @@ address_from_register (int regnum, struct frame_info *frame) pointer types. Avoid constructing a value object in those cases. */ if (gdbarch_convert_register_p (gdbarch, regnum, type)) { - gdb_byte *buf = (gdb_byte *) alloca (TYPE_LENGTH (type)); + gdb_byte *buf = (gdb_byte *) alloca (type->length ()); int optim, unavail, ok; ok = gdbarch_register_to_value (gdbarch, frame, regnum, type, diff --git a/gdb/frame.c b/gdb/frame.c index e6bebf5..fc883b3 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -1157,9 +1157,9 @@ frame_register_unwind (frame_info *next_frame, int regnum, { if (!*optimizedp && !*unavailablep) memcpy (bufferp, value_contents_all (value).data (), - TYPE_LENGTH (value_type (value))); + value_type (value)->length ()); else - memset (bufferp, 0, TYPE_LENGTH (value_type (value))); + memset (bufferp, 0, value_type (value)->length ()); } /* Dispose of the new value. This prevents watchpoints from diff --git a/gdb/frv-tdep.c b/gdb/frv-tdep.c index 251baf8..a7e3405 100644 --- a/gdb/frv-tdep.c +++ b/gdb/frv-tdep.c @@ -1110,7 +1110,7 @@ frv_extract_return_value (struct type *type, struct regcache *regcache, { struct gdbarch *gdbarch = regcache->arch (); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); - int len = TYPE_LENGTH (type); + int len = type->length (); if (len <= 4) { @@ -1216,7 +1216,7 @@ frv_push_dummy_call (struct gdbarch *gdbarch, struct value *function, stack_space = 0; for (argnum = 0; argnum < nargs; ++argnum) - stack_space += align_up (TYPE_LENGTH (value_type (args[argnum])), 4); + stack_space += align_up (value_type (args[argnum])->length (), 4); stack_space -= (6 * 4); if (stack_space > 0) @@ -1237,7 +1237,7 @@ frv_push_dummy_call (struct gdbarch *gdbarch, struct value *function, { arg = args[argnum]; arg_type = check_typedef (value_type (arg)); - len = TYPE_LENGTH (arg_type); + len = arg_type->length (); typecode = arg_type->code (); if (typecode == TYPE_CODE_STRUCT || typecode == TYPE_CODE_UNION) @@ -1319,7 +1319,7 @@ static void frv_store_return_value (struct type *type, struct regcache *regcache, const gdb_byte *valbuf) { - int len = TYPE_LENGTH (type); + int len = type->length (); if (len <= 4) { diff --git a/gdb/ft32-tdep.c b/gdb/ft32-tdep.c index 500c691..4ba3e9f 100644 --- a/gdb/ft32-tdep.c +++ b/gdb/ft32-tdep.c @@ -129,7 +129,7 @@ ft32_store_return_value (struct type *type, struct regcache *regcache, struct gdbarch *gdbarch = regcache->arch (); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); CORE_ADDR regval; - int len = TYPE_LENGTH (type); + int len = type->length (); /* Things always get returned in RET1_REGNUM, RET2_REGNUM. */ regval = extract_unsigned_integer (valbuf, len > 4 ? 4 : len, byte_order); @@ -331,7 +331,7 @@ ft32_pointer_to_address (struct gdbarch *gdbarch, { enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); CORE_ADDR addr - = extract_unsigned_integer (buf, TYPE_LENGTH (type), byte_order); + = extract_unsigned_integer (buf, type->length (), byte_order); if (TYPE_ADDRESS_CLASS_1 (type)) return addr; @@ -397,7 +397,7 @@ ft32_extract_return_value (struct type *type, struct regcache *regcache, struct gdbarch *gdbarch = regcache->arch (); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); bfd_byte *valbuf = dst; - int len = TYPE_LENGTH (type); + int len = type->length (); ULONGEST tmp; /* By using store_unsigned_integer we avoid having to do @@ -421,7 +421,7 @@ ft32_return_value (struct gdbarch *gdbarch, struct value *function, struct type *valtype, struct regcache *regcache, gdb_byte *readbuf, const gdb_byte *writebuf) { - if (TYPE_LENGTH (valtype) > 8) + if (valtype->length () > 8) return RETURN_VALUE_STRUCT_CONVENTION; else { diff --git a/gdb/gdbarch-selftests.c b/gdb/gdbarch-selftests.c index 198346b..68d340f 100644 --- a/gdb/gdbarch-selftests.c +++ b/gdb/gdbarch-selftests.c @@ -82,7 +82,7 @@ register_to_value_test (struct gdbarch *gdbarch) { if (gdbarch_convert_register_p (gdbarch, regnum, type)) { - std::vector expected (TYPE_LENGTH (type), 0); + std::vector expected (type->length (), 0); if (type->code () == TYPE_CODE_FLT) { @@ -99,12 +99,12 @@ register_to_value_test (struct gdbarch *gdbarch) expected.data ()); /* Allocate two bytes more for overflow check. */ - std::vector buf (TYPE_LENGTH (type) + 2, 0); + std::vector buf (type->length () + 2, 0); int optim, unavail, ok; /* Set the fingerprint in the last two bytes. */ - buf [TYPE_LENGTH (type)]= 'w'; - buf [TYPE_LENGTH (type) + 1]= 'l'; + buf [type->length ()]= 'w'; + buf [type->length () + 1]= 'l'; ok = gdbarch_register_to_value (gdbarch, frame, regnum, type, buf.data (), &optim, &unavail); @@ -112,10 +112,10 @@ register_to_value_test (struct gdbarch *gdbarch) SELF_CHECK (!optim); SELF_CHECK (!unavail); - SELF_CHECK (buf[TYPE_LENGTH (type)] == 'w'); - SELF_CHECK (buf[TYPE_LENGTH (type) + 1] == 'l'); + SELF_CHECK (buf[type->length ()] == 'w'); + SELF_CHECK (buf[type->length () + 1] == 'l'); - for (auto k = 0; k < TYPE_LENGTH(type); k++) + for (auto k = 0; k < type->length (); k++) SELF_CHECK (buf[k] == expected[k]); } } diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index a306c1a..643bb0a 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -281,7 +281,7 @@ type_length_units (struct type *type) { int unit_size = gdbarch_addressable_memory_unit_size (type->arch ()); - return TYPE_LENGTH (type) / unit_size; + return type->length () / unit_size; } /* Alloc a new type instance structure, fill it with some defaults, @@ -388,7 +388,7 @@ make_pointer_type (struct type *type, struct type **typeptr) chain = TYPE_CHAIN (ntype); while (chain != ntype) { - chain->set_length (TYPE_LENGTH (ntype)); + chain->set_length (ntype->length ()); chain = TYPE_CHAIN (chain); } @@ -468,7 +468,7 @@ make_reference_type (struct type *type, struct type **typeptr, chain = TYPE_CHAIN (ntype); while (chain != ntype) { - chain->set_length (TYPE_LENGTH (ntype)); + chain->set_length (ntype->length ()); chain = TYPE_CHAIN (chain); } @@ -671,7 +671,7 @@ make_qualified_type (struct type *type, type_instance_flags new_flags, ntype->set_instance_flags (new_flags); /* Set length of new type to that of the original type. */ - ntype->set_length (TYPE_LENGTH (type)); + ntype->set_length (type->length ()); return ntype; } @@ -824,7 +824,7 @@ replace_type (struct type *ntype, struct type *type) call replace_type(). */ gdb_assert (TYPE_ADDRESS_CLASS_ALL (chain) == 0); - chain->set_length (TYPE_LENGTH (type)); + chain->set_length (type->length ()); chain = TYPE_CHAIN (chain); } while (ntype != chain); @@ -936,7 +936,7 @@ create_range_type (struct type *result_type, struct type *index_type, /* The INDEX_TYPE should be a type capable of holding the upper and lower bounds, as such a zero sized, or void type makes no sense. */ gdb_assert (index_type->code () != TYPE_CODE_VOID); - gdb_assert (TYPE_LENGTH (index_type) > 0); + gdb_assert (index_type->length () > 0); if (result_type == NULL) result_type = alloc_type_copy (index_type); @@ -945,7 +945,7 @@ create_range_type (struct type *result_type, struct type *index_type, if (index_type->is_stub ()) result_type->set_target_is_stub (true); else - result_type->set_length (TYPE_LENGTH (check_typedef (index_type))); + result_type->set_length (check_typedef (index_type)->length ()); range_bounds *bounds = (struct range_bounds *) TYPE_ZALLOC (result_type, sizeof (range_bounds)); @@ -1096,11 +1096,11 @@ get_discrete_low_bound (struct type *type) return 0; case TYPE_CODE_INT: - if (TYPE_LENGTH (type) > sizeof (LONGEST)) /* Too big */ + if (type->length () > sizeof (LONGEST)) /* Too big */ return {}; if (!type->is_unsigned ()) - return -(1 << (TYPE_LENGTH (type) * TARGET_CHAR_BIT - 1)); + return -(1 << (type->length () * TARGET_CHAR_BIT - 1)); /* fall through */ case TYPE_CODE_CHAR: @@ -1163,12 +1163,12 @@ get_discrete_high_bound (struct type *type) return 1; case TYPE_CODE_INT: - if (TYPE_LENGTH (type) > sizeof (LONGEST)) /* Too big */ + if (type->length () > sizeof (LONGEST)) /* Too big */ return {}; if (!type->is_unsigned ()) { - LONGEST low = -(1 << (TYPE_LENGTH (type) * TARGET_CHAR_BIT - 1)); + LONGEST low = -(1 << (type->length () * TARGET_CHAR_BIT - 1)); return -low - 1; } @@ -1176,9 +1176,9 @@ get_discrete_high_bound (struct type *type) case TYPE_CODE_CHAR: { /* This round-about calculation is to avoid shifting by - TYPE_LENGTH (type) * TARGET_CHAR_BIT, which will not work - if TYPE_LENGTH (type) == sizeof (LONGEST). */ - LONGEST high = 1 << (TYPE_LENGTH (type) * TARGET_CHAR_BIT - 1); + type->length () * TARGET_CHAR_BIT, which will not work + if type->length () == sizeof (LONGEST). */ + LONGEST high = 1 << (type->length () * TARGET_CHAR_BIT - 1); return (high - 1) | high; } @@ -1310,7 +1310,7 @@ update_static_array_size (struct type *type) type->set_length (((std::abs (stride) * element_count) + 7) / 8); } else - type->set_length (TYPE_LENGTH (element_type) + type->set_length (element_type->length () * (high_bound - low_bound + 1)); /* If this array's element is itself an array with a bit stride, @@ -1319,7 +1319,7 @@ update_static_array_size (struct type *type) wrong size when trying to find elements of the outer array. */ if (element_type->code () == TYPE_CODE_ARRAY - && TYPE_LENGTH (element_type) != 0 + && element_type->length () != 0 && TYPE_FIELD_BITSIZE (element_type, 0) != 0 && get_array_bounds (element_type, &low_bound, &high_bound) && high_bound >= low_bound) @@ -1400,7 +1400,7 @@ create_array_type_with_stride (struct type *result_type, } /* TYPE_TARGET_STUB will take care of zero length arrays. */ - if (TYPE_LENGTH (result_type) == 0) + if (result_type->length () == 0) result_type->set_target_is_stub (true); return result_type; @@ -1909,10 +1909,10 @@ get_unsigned_type_max (struct type *type) type = check_typedef (type); gdb_assert (type->code () == TYPE_CODE_INT && type->is_unsigned ()); - gdb_assert (TYPE_LENGTH (type) <= sizeof (ULONGEST)); + gdb_assert (type->length () <= sizeof (ULONGEST)); /* Written this way to avoid overflow. */ - n = TYPE_LENGTH (type) * TARGET_CHAR_BIT; + n = type->length () * TARGET_CHAR_BIT; return ((((ULONGEST) 1 << (n - 1)) - 1) << 1) | 1; } @@ -1926,9 +1926,9 @@ get_signed_type_minmax (struct type *type, LONGEST *min, LONGEST *max) type = check_typedef (type); gdb_assert (type->code () == TYPE_CODE_INT && !type->is_unsigned ()); - gdb_assert (TYPE_LENGTH (type) <= sizeof (LONGEST)); + gdb_assert (type->length () <= sizeof (LONGEST)); - n = TYPE_LENGTH (type) * TARGET_CHAR_BIT; + n = type->length () * TARGET_CHAR_BIT; *min = -((ULONGEST) 1 << (n - 1)); *max = ((ULONGEST) 1 << (n - 1)) - 1; } @@ -1942,9 +1942,9 @@ get_pointer_type_max (struct type *type) type = check_typedef (type); gdb_assert (type->code () == TYPE_CODE_PTR); - gdb_assert (TYPE_LENGTH (type) <= sizeof (CORE_ADDR)); + gdb_assert (type->length () <= sizeof (CORE_ADDR)); - n = TYPE_LENGTH (type) * TARGET_CHAR_BIT; + n = type->length () * TARGET_CHAR_BIT; return ((((CORE_ADDR) 1 << (n - 1)) - 1) << 1) | 1; } @@ -2501,8 +2501,8 @@ resolve_dynamic_union (struct type *type, resolved_type->field (i).set_type (t); struct type *real_type = check_typedef (t); - if (TYPE_LENGTH (real_type) > max_len) - max_len = TYPE_LENGTH (real_type); + if (real_type->length () > max_len) + max_len = real_type->length (); } resolved_type->set_length (max_len); @@ -2595,7 +2595,7 @@ compute_variant_fields_inner (struct type *type, LONGEST bitsize = TYPE_FIELD_BITSIZE (type, idx); LONGEST size = bitsize / 8; if (size == 0) - size = TYPE_LENGTH (type->field (idx).type ()); + size = type->field (idx).type ()->length (); gdb_byte bits[sizeof (ULONGEST)]; read_memory (addr, bits, size); @@ -2761,7 +2761,7 @@ resolve_dynamic_struct (struct type *type, struct type *real_type = check_typedef (resolved_type->field (i).type ()); - new_bit_length += (TYPE_LENGTH (real_type) * TARGET_CHAR_BIT); + new_bit_length += (real_type->length () * TARGET_CHAR_BIT); } /* Normally, we would use the position and size of the last field @@ -3148,7 +3148,7 @@ check_typedef (struct type *type) } else if (type->code () == TYPE_CODE_RANGE) { - type->set_length (TYPE_LENGTH (target_type)); + type->set_length (target_type->length ()); type->set_target_is_stub (false); } else if (type->code () == TYPE_CODE_ARRAY @@ -3159,7 +3159,7 @@ check_typedef (struct type *type) type = make_qualified_type (type, instance_flags, NULL); /* Cache TYPE_LENGTH for future use. */ - orig_type->set_length (TYPE_LENGTH (type)); + orig_type->set_length (type->length ()); return type; } @@ -3581,7 +3581,7 @@ init_complex_type (const char *name, struct type *target_type) t = alloc_type_copy (target_type); set_type_code (t, TYPE_CODE_COMPLEX); - t->set_length (2 * TYPE_LENGTH (target_type)); + t->set_length (2 * target_type->length ()); t->set_name (name); t->set_target_type (target_type); @@ -4330,7 +4330,7 @@ check_types_equal (struct type *type1, struct type *type2, return true; if (type1->code () != type2->code () - || TYPE_LENGTH (type1) != TYPE_LENGTH (type2) + || type1->length () != type2->length () || type1->is_unsigned () != type2->is_unsigned () || type1->has_no_signedness () != type2->has_no_signedness () || type1->endianity_is_not_default () != type2->endianity_is_not_default () @@ -4602,7 +4602,7 @@ rank_one_type_parm_int (struct type *parm, struct type *arg, struct value *value switch (arg->code ()) { case TYPE_CODE_INT: - if (TYPE_LENGTH (arg) == TYPE_LENGTH (parm)) + if (arg->length () == parm->length ()) { /* Deal with signed, unsigned, and plain chars and signed and unsigned ints. */ @@ -4662,7 +4662,7 @@ rank_one_type_parm_int (struct type *parm, struct type *arg, struct value *value else return INTEGER_CONVERSION_BADNESS; } - else if (TYPE_LENGTH (arg) < TYPE_LENGTH (parm)) + else if (arg->length () < parm->length ()) return INTEGER_PROMOTION_BADNESS; else return INTEGER_CONVERSION_BADNESS; @@ -4721,9 +4721,9 @@ rank_one_type_parm_char (struct type *parm, struct type *arg, struct value *valu case TYPE_CODE_FLT: return INT_FLOAT_CONVERSION_BADNESS; case TYPE_CODE_INT: - if (TYPE_LENGTH (arg) > TYPE_LENGTH (parm)) + if (arg->length () > parm->length ()) return INTEGER_CONVERSION_BADNESS; - else if (TYPE_LENGTH (arg) < TYPE_LENGTH (parm)) + else if (arg->length () < parm->length ()) return INTEGER_PROMOTION_BADNESS; /* fall through */ case TYPE_CODE_CHAR: @@ -4811,9 +4811,9 @@ rank_one_type_parm_float (struct type *parm, struct type *arg, struct value *val switch (arg->code ()) { case TYPE_CODE_FLT: - if (TYPE_LENGTH (arg) < TYPE_LENGTH (parm)) + if (arg->length () < parm->length ()) return FLOAT_PROMOTION_BADNESS; - else if (TYPE_LENGTH (arg) == TYPE_LENGTH (parm)) + else if (arg->length () == parm->length ()) return EXACT_MATCH_BADNESS; else return FLOAT_CONVERSION_BADNESS; @@ -5348,7 +5348,7 @@ recursive_dump_type (struct type *type, int spaces) } gdb_puts ("\n"); gdb_printf ("%*slength %s\n", spaces, "", - pulongest (TYPE_LENGTH (type))); + pulongest (type->length ())); if (type->is_objfile_owned ()) gdb_printf ("%*sobjfile %s\n", spaces, "", host_address_to_string (type->objfile_owner ())); @@ -5660,7 +5660,7 @@ copy_type_recursive (struct type *type, htab_t copied_types) new_type->set_name (xstrdup (type->name ())); new_type->set_instance_flags (type->instance_flags ()); - new_type->set_length (TYPE_LENGTH (type)); + new_type->set_length (type->length ()); /* Copy the fields. */ if (type->num_fields ()) @@ -5789,7 +5789,7 @@ copy_type (const struct type *type) { struct type *new_type = alloc_type_copy (type); new_type->set_instance_flags (type->instance_flags ()); - new_type->set_length (TYPE_LENGTH (type)); + new_type->set_length (type->length ()); memcpy (TYPE_MAIN_TYPE (new_type), TYPE_MAIN_TYPE (type), sizeof (struct main_type)); if (type->main_type->dyn_prop_list != NULL) @@ -5952,7 +5952,7 @@ void append_flags_type_field (struct type *type, int start_bitpos, int nr_bits, struct type *field_type, const char *name) { - int type_bitsize = TYPE_LENGTH (type) * TARGET_CHAR_BIT; + int type_bitsize = type->length () * TARGET_CHAR_BIT; int field_nr = type->num_fields (); gdb_assert (type->code () == TYPE_CODE_FLAGS); @@ -6027,16 +6027,17 @@ append_composite_type_field_aligned (struct type *t, const char *name, if (t->code () == TYPE_CODE_UNION) { - if (TYPE_LENGTH (t) < TYPE_LENGTH (field)) - t->set_length (TYPE_LENGTH (field)); + if (t->length () < field->length ()) + t->set_length (field->length ()); } else if (t->code () == TYPE_CODE_STRUCT) { - t->set_length (TYPE_LENGTH (t) + TYPE_LENGTH (field)); + t->set_length (t->length () + field->length ()); if (t->num_fields () > 1) { f->set_loc_bitpos - (f[-1].loc_bitpos () + (TYPE_LENGTH (f[-1].type ()) * TARGET_CHAR_BIT)); + (f[-1].loc_bitpos () + + (f[-1].type ()->length () * TARGET_CHAR_BIT)); if (alignment) { diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 6d12a48..94d4b66 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -1045,6 +1045,10 @@ struct type this->main_type->name = name; } + /* Note that if thistype is a TYPEDEF type, you have to call check_typedef. + But check_typedef does set the TYPE_LENGTH of the TYPEDEF type, + so you only have to call check_typedef once. Since allocate_value + calls check_typedef, VALUE_TYPE (X)->length () is safe. */ ULONGEST length () const { return this->m_length; @@ -2111,11 +2115,6 @@ extern void allocate_gnat_aux_type (struct type *); #define TYPE_REFERENCE_TYPE(thistype) (thistype)->reference_type #define TYPE_RVALUE_REFERENCE_TYPE(thistype) (thistype)->rvalue_reference_type #define TYPE_CHAIN(thistype) (thistype)->chain -/* * Note that if thistype is a TYPEDEF type, you have to call check_typedef. - But check_typedef does set the TYPE_LENGTH of the TYPEDEF type, - so you only have to call check_typedef once. Since allocate_value - calls check_typedef, TYPE_LENGTH (VALUE_TYPE (X)) is safe. */ -#define TYPE_LENGTH(thistype) ((thistype)->length ()) /* * Return the alignment of the type in target addressable memory units, or 0 if no alignment was specified. */ diff --git a/gdb/gnu-v2-abi.c b/gdb/gnu-v2-abi.c index dd55069..bc7d748 100644 --- a/gdb/gnu-v2-abi.c +++ b/gdb/gnu-v2-abi.c @@ -267,7 +267,7 @@ gnuv2_value_rtti_type (struct value *v, int *full, LONGEST *top, int *using_enc) TYPE_VPTR_FIELDNO(rtti_type)) / 8; if (top && ((*top) >0)) { - if (TYPE_LENGTH(rtti_type) > TYPE_LENGTH(known_type)) + if (rtti_type->length () > known_type->length ()) { if (full) *full=0; @@ -365,7 +365,7 @@ gnuv2_baseclass_offset (struct type *type, int index, field_type = check_typedef (type->field (i).type ()); field_offset = type->field (i).loc_bitpos () / 8; - field_length = TYPE_LENGTH (field_type); + field_length = field_type->length (); if (!value_bytes_available (val, embedded_offset + field_offset, field_length)) diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c index cd2f371..ed604ce 100644 --- a/gdb/gnu-v3-abi.c +++ b/gdb/gnu-v3-abi.c @@ -142,28 +142,28 @@ get_gdb_vtable_type (struct gdbarch *arch) field->set_name ("vcall_and_vbase_offsets"); field->set_type (lookup_array_range_type (ptrdiff_type, 0, -1)); field->set_loc_bitpos (offset * TARGET_CHAR_BIT); - offset += TYPE_LENGTH (field->type ()); + offset += field->type ()->length (); field++; /* ptrdiff_t offset_to_top; */ field->set_name ("offset_to_top"); field->set_type (ptrdiff_type); field->set_loc_bitpos (offset * TARGET_CHAR_BIT); - offset += TYPE_LENGTH (field->type ()); + offset += field->type ()->length (); field++; /* void *type_info; */ field->set_name ("type_info"); field->set_type (void_ptr_type); field->set_loc_bitpos (offset * TARGET_CHAR_BIT); - offset += TYPE_LENGTH (field->type ()); + offset += field->type ()->length (); field++; /* void (*virtual_functions[0]) (); */ field->set_name ("virtual_functions"); field->set_type (lookup_array_range_type (ptr_to_void_fn_type, 0, -1)); field->set_loc_bitpos (offset * TARGET_CHAR_BIT); - offset += TYPE_LENGTH (field->type ()); + offset += field->type ()->length (); field++; /* We assumed in the allocation above that there were four fields. */ @@ -371,8 +371,8 @@ gnuv3_rtti_type (struct value *value, if (full_p) *full_p = (- offset_to_top == value_embedded_offset (value) - && (TYPE_LENGTH (value_enclosing_type (value)) - >= TYPE_LENGTH (run_time_type))); + && (value_enclosing_type (value)->length () + >= run_time_type->length ())); if (top_p) *top_p = - offset_to_top; return run_time_type; @@ -500,9 +500,9 @@ gnuv3_baseclass_offset (struct type *type, int index, error (_("Expected a negative vbase offset (old compiler?)")); cur_base_offset = cur_base_offset + vtable_address_point_offset (gdbarch); - if ((- cur_base_offset) % TYPE_LENGTH (ptr_type) != 0) + if ((- cur_base_offset) % ptr_type->length () != 0) error (_("Misaligned vbase offset.")); - cur_base_offset = cur_base_offset / ((int) TYPE_LENGTH (ptr_type)); + cur_base_offset = cur_base_offset / ((int) ptr_type->length ()); vtable = gnuv3_get_vtable (gdbarch, type, address + embedded_offset); gdb_assert (vtable != NULL); @@ -556,7 +556,7 @@ gnuv3_find_method_in (struct type *domain, CORE_ADDR voffset, basetype = domain->field (i).type (); /* Recurse with a modified adjustment. We don't need to adjust voffset. */ - if (adjustment >= pos && adjustment < pos + TYPE_LENGTH (basetype)) + if (adjustment >= pos && adjustment < pos + basetype->length ()) return gnuv3_find_method_in (basetype, voffset, adjustment - pos); } @@ -586,10 +586,10 @@ gnuv3_decode_method_ptr (struct gdbarch *gdbarch, interpretations and choose the right one later on. */ ptr_value = extract_typed_address (contents, funcptr_type); voffset = extract_signed_integer (contents, - TYPE_LENGTH (funcptr_type), byte_order); - contents += TYPE_LENGTH (funcptr_type); + funcptr_type->length (), byte_order); + contents += funcptr_type->length (); adjustment = extract_signed_integer (contents, - TYPE_LENGTH (offset_type), byte_order); + offset_type->length (), byte_order); if (!gdbarch_vbit_in_delta (gdbarch)) { @@ -639,7 +639,7 @@ gnuv3_print_method_ptr (const gdb_byte *contents, /* It's a virtual table offset, maybe in this class. Search for a field with the correct vtable offset. First convert it to an index, as used in TYPE_FN_FIELD_VOFFSET. */ - voffset = ptr_value / TYPE_LENGTH (vtable_ptrdiff_type (gdbarch)); + voffset = ptr_value / vtable_ptrdiff_type (gdbarch)->length (); physname = gnuv3_find_method_in (self_type, voffset, adjustment); @@ -693,7 +693,7 @@ gnuv3_print_method_ptr (const gdb_byte *contents, static int gnuv3_method_ptr_size (struct type *type) { - return 2 * TYPE_LENGTH (builtin_type (type->arch ())->builtin_data_ptr); + return 2 * builtin_type (type->arch ())->builtin_data_ptr->length (); } /* GNU v3 implementation of cplus_make_method_ptr. */ @@ -703,7 +703,7 @@ gnuv3_make_method_ptr (struct type *type, gdb_byte *contents, CORE_ADDR value, int is_virtual) { struct gdbarch *gdbarch = type->arch (); - int size = TYPE_LENGTH (builtin_type (gdbarch)->builtin_data_ptr); + int size = builtin_type (gdbarch)->builtin_data_ptr->length (); enum bfd_endian byte_order = type_byte_order (type); /* FIXME drow/2006-12-24: The adjustment of "this" is currently @@ -775,7 +775,7 @@ gnuv3_method_ptr_to_value (struct value **this_p, struct value *method_ptr) { LONGEST voffset; - voffset = ptr_value / TYPE_LENGTH (vtable_ptrdiff_type (gdbarch)); + voffset = ptr_value / vtable_ptrdiff_type (gdbarch)->length (); return gnuv3_get_virtual_fn (gdbarch, value_ind (*this_p), method_type, voffset); } @@ -1040,14 +1040,14 @@ build_std_type_info_type (struct gdbarch *arch) field->set_name ("_vptr.type_info"); field->set_type (void_ptr_type); field->set_loc_bitpos (offset * TARGET_CHAR_BIT); - offset += TYPE_LENGTH (field->type ()); + offset += field->type ()->length (); field++; /* The name. */ field->set_name ("__name"); field->set_type (char_ptr_type); field->set_loc_bitpos (offset * TARGET_CHAR_BIT); - offset += TYPE_LENGTH (field->type ()); + offset += field->type ()->length (); field++; gdb_assert (field == (field_list + 2)); diff --git a/gdb/go-exp.y b/gdb/go-exp.y index f786ec2..f9ae3ea 100644 --- a/gdb/go-exp.y +++ b/gdb/go-exp.y @@ -475,7 +475,7 @@ exp : SIZEOF_KEYWORD '(' type ')' %prec UNARY = parse_type (pstate)->builtin_unsigned_int; $3 = check_typedef ($3); pstate->push_new - (size_type, (LONGEST) TYPE_LENGTH ($3)); + (size_type, (LONGEST) $3->length ()); } ; diff --git a/gdb/go-lang.c b/gdb/go-lang.c index 92d7e60..599a311 100644 --- a/gdb/go-lang.c +++ b/gdb/go-lang.c @@ -91,7 +91,7 @@ gccgo_string_p (struct type *type) target_type = check_typedef (target_type); if (target_type->code () == TYPE_CODE_INT - && TYPE_LENGTH (target_type) == 1 + && target_type->length () == 1 && strcmp (target_type->name (), "uint8") == 0) return 1; } diff --git a/gdb/guile/scm-math.c b/gdb/guile/scm-math.c index 914bb5f..022863d 100644 --- a/gdb/guile/scm-math.c +++ b/gdb/guile/scm-math.c @@ -586,7 +586,7 @@ vlscm_integer_fits_p (SCM obj, struct type *type) if (type->is_unsigned ()) { /* If scm_is_unsigned_integer can't work with this type, just punt. */ - if (TYPE_LENGTH (type) > sizeof (uintmax_t)) + if (type->length () > sizeof (uintmax_t)) return 0; ULONGEST max = get_unsigned_type_max (type); @@ -597,7 +597,7 @@ vlscm_integer_fits_p (SCM obj, struct type *type) LONGEST min, max; /* If scm_is_signed_integer can't work with this type, just punt. */ - if (TYPE_LENGTH (type) > sizeof (intmax_t)) + if (type->length () > sizeof (intmax_t)) return 0; get_signed_type_minmax (type, &min, &max); return scm_is_signed_integer (obj, min, max); @@ -681,7 +681,7 @@ vlscm_convert_bytevector (SCM bv, struct type *type, SCM type_scm, make_vector_type (type); } type = check_typedef (type); - if (TYPE_LENGTH (type) != length) + if (type->length () != length) { *except_scmp = gdbscm_make_out_of_range_error (func_name, arg_pos, type_scm, diff --git a/gdb/guile/scm-pretty-print.c b/gdb/guile/scm-pretty-print.c index e2bc198..5e6bb12 100644 --- a/gdb/guile/scm-pretty-print.c +++ b/gdb/guile/scm-pretty-print.c @@ -969,7 +969,7 @@ gdbscm_apply_val_pretty_printer (const struct extension_language_defn *extlang, value_fetch_lazy (value); /* No pretty-printer support for unavailable values. */ - if (!value_bytes_available (value, 0, TYPE_LENGTH (type))) + if (!value_bytes_available (value, 0, type->length ())) return EXT_LANG_RC_NOP; if (!gdb_scheme_initialized) diff --git a/gdb/guile/scm-type.c b/gdb/guile/scm-type.c index 8914307..68a5b91 100644 --- a/gdb/guile/scm-type.c +++ b/gdb/guile/scm-type.c @@ -633,7 +633,7 @@ gdbscm_type_sizeof (SCM self) /* Ignore exceptions. */ - return scm_from_long (TYPE_LENGTH (type)); + return scm_from_long (type->length ()); } /* (type-strip-typedefs ) -> diff --git a/gdb/guile/scm-value.c b/gdb/guile/scm-value.c index 4417c2d..0107a4b 100644 --- a/gdb/guile/scm-value.c +++ b/gdb/guile/scm-value.c @@ -827,7 +827,7 @@ gdbscm_value_to_bytevector (SCM self) try { type = check_typedef (type); - length = TYPE_LENGTH (type); + length = type->length (); contents = value_contents (value).data (); } catch (const gdb_exception &except) @@ -1104,7 +1104,7 @@ gdbscm_value_to_string (SCM self, SCM rest) gdbscm_dynwind_xfree (buffer_contents); result = scm_from_stringn ((const char *) buffer_contents, - length * TYPE_LENGTH (char_type), + length * char_type->length (), (encoding != NULL && *encoding != '\0' ? encoding : la_encoding), diff --git a/gdb/h8300-tdep.c b/gdb/h8300-tdep.c index d453fce..0bf1dab 100644 --- a/gdb/h8300-tdep.c +++ b/gdb/h8300-tdep.c @@ -632,8 +632,7 @@ h8300_push_dummy_call (struct gdbarch *gdbarch, struct value *function, /* Now make sure there's space on the stack for the arguments. We may over-allocate a little here, but that won't hurt anything. */ for (argument = 0; argument < nargs; argument++) - stack_alloc += align_up (TYPE_LENGTH (value_type (args[argument])), - wordsize); + stack_alloc += align_up (value_type (args[argument])->length (), wordsize); sp -= stack_alloc; /* Now load as many arguments as possible into registers, and push @@ -647,7 +646,7 @@ h8300_push_dummy_call (struct gdbarch *gdbarch, struct value *function, for (argument = 0; argument < nargs; argument++) { struct type *type = value_type (args[argument]); - int len = TYPE_LENGTH (type); + int len = type->length (); char *contents = (char *) value_contents (args[argument]).data (); /* Pad the argument appropriately. */ @@ -725,7 +724,7 @@ h8300_extract_return_value (struct type *type, struct regcache *regcache, { struct gdbarch *gdbarch = regcache->arch (); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); - int len = TYPE_LENGTH (type); + int len = type->length (); ULONGEST c, addr; switch (len) @@ -764,13 +763,13 @@ h8300h_extract_return_value (struct type *type, struct regcache *regcache, enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); ULONGEST c; - switch (TYPE_LENGTH (type)) + switch (type->length ()) { case 1: case 2: case 4: regcache_cooked_read_unsigned (regcache, E_RET0_REGNUM, &c); - store_unsigned_integer (valbuf, TYPE_LENGTH (type), byte_order, c); + store_unsigned_integer (valbuf, type->length (), byte_order, c); break; case 8: /* long long is now 8 bytes. */ if (type->code () == TYPE_CODE_INT) @@ -797,9 +796,9 @@ h8300_use_struct_convention (struct type *value_type) if (value_type->code () == TYPE_CODE_STRUCT || value_type->code () == TYPE_CODE_UNION) return 1; - return !(TYPE_LENGTH (value_type) == 1 - || TYPE_LENGTH (value_type) == 2 - || TYPE_LENGTH (value_type) == 4); + return !(value_type->length () == 1 + || value_type->length () == 2 + || value_type->length () == 4); } static int @@ -810,10 +809,10 @@ h8300h_use_struct_convention (struct type *value_type) if (value_type->code () == TYPE_CODE_STRUCT || value_type->code () == TYPE_CODE_UNION) return 1; - return !(TYPE_LENGTH (value_type) == 1 - || TYPE_LENGTH (value_type) == 2 - || TYPE_LENGTH (value_type) == 4 - || (TYPE_LENGTH (value_type) == 8 + return !(value_type->length () == 1 + || value_type->length () == 2 + || value_type->length () == 4 + || (value_type->length () == 8 && value_type->code () == TYPE_CODE_INT)); } @@ -829,15 +828,15 @@ h8300_store_return_value (struct type *type, struct regcache *regcache, enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); ULONGEST val; - switch (TYPE_LENGTH (type)) + switch (type->length ()) { case 1: case 2: /* short... */ - val = extract_unsigned_integer (valbuf, TYPE_LENGTH (type), byte_order); + val = extract_unsigned_integer (valbuf, type->length (), byte_order); regcache_cooked_write_unsigned (regcache, E_RET0_REGNUM, val); break; case 4: /* long, float */ - val = extract_unsigned_integer (valbuf, TYPE_LENGTH (type), byte_order); + val = extract_unsigned_integer (valbuf, type->length (), byte_order); regcache_cooked_write_unsigned (regcache, E_RET0_REGNUM, (val >> 16) & 0xffff); regcache_cooked_write_unsigned (regcache, E_RET1_REGNUM, val & 0xffff); @@ -858,16 +857,16 @@ h8300h_store_return_value (struct type *type, struct regcache *regcache, enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); ULONGEST val; - switch (TYPE_LENGTH (type)) + switch (type->length ()) { case 1: case 2: case 4: /* long, float */ - val = extract_unsigned_integer (valbuf, TYPE_LENGTH (type), byte_order); + val = extract_unsigned_integer (valbuf, type->length (), byte_order); regcache_cooked_write_unsigned (regcache, E_RET0_REGNUM, val); break; case 8: - val = extract_unsigned_integer (valbuf, TYPE_LENGTH (type), byte_order); + val = extract_unsigned_integer (valbuf, type->length (), byte_order); regcache_cooked_write_unsigned (regcache, E_RET0_REGNUM, (val >> 32) & 0xffffffff); regcache_cooked_write_unsigned (regcache, E_RET1_REGNUM, @@ -902,7 +901,7 @@ h8300h_return_value (struct gdbarch *gdbarch, struct value *function, ULONGEST addr; regcache_raw_read_unsigned (regcache, E_R0_REGNUM, &addr); - read_memory (addr, readbuf, TYPE_LENGTH (type)); + read_memory (addr, readbuf, type->length ()); } return RETURN_VALUE_ABI_RETURNS_ADDRESS; diff --git a/gdb/hppa-tdep.c b/gdb/hppa-tdep.c index 9e50e04..b9e3cec 100644 --- a/gdb/hppa-tdep.c +++ b/gdb/hppa-tdep.c @@ -741,15 +741,15 @@ hppa32_push_dummy_call (struct gdbarch *gdbarch, struct value *function, gdb_byte param_val[8]; int param_len; memset (param_val, 0, sizeof param_val); - if (TYPE_LENGTH (type) > 8) + if (type->length () > 8) { /* Large parameter, pass by reference. Store the value in "struct" area and then pass its address. */ param_len = 4; - struct_ptr += align_up (TYPE_LENGTH (type), 8); + struct_ptr += align_up (type->length (), 8); if (write_pass) write_memory (struct_end - struct_ptr, - value_contents (arg).data (), TYPE_LENGTH (type)); + value_contents (arg).data (), type->length ()); store_unsigned_integer (param_val, 4, byte_order, struct_end - struct_ptr); } @@ -758,7 +758,7 @@ hppa32_push_dummy_call (struct gdbarch *gdbarch, struct value *function, { /* Integer value store, right aligned. "unpack_long" takes care of any sign-extension problems. */ - param_len = align_up (TYPE_LENGTH (type), 4); + param_len = align_up (type->length (), 4); store_unsigned_integer (param_val, param_len, byte_order, unpack_long (type, value_contents (arg).data ())); @@ -766,16 +766,16 @@ hppa32_push_dummy_call (struct gdbarch *gdbarch, struct value *function, else if (type->code () == TYPE_CODE_FLT) { /* Floating point value store, right aligned. */ - param_len = align_up (TYPE_LENGTH (type), 4); + param_len = align_up (type->length (), 4); memcpy (param_val, value_contents (arg).data (), param_len); } else { - param_len = align_up (TYPE_LENGTH (type), 4); + param_len = align_up (type->length (), 4); /* Small struct value are stored right-aligned. */ - memcpy (param_val + param_len - TYPE_LENGTH (type), - value_contents (arg).data (), TYPE_LENGTH (type)); + memcpy (param_val + param_len - type->length (), + value_contents (arg).data (), type->length ()); /* Structures of size 5, 6 and 7 bytes are special in that the higher-ordered word is stored in the lower-ordered @@ -874,13 +874,13 @@ hppa64_integral_or_pointer_p (const struct type *type) case TYPE_CODE_ENUM: case TYPE_CODE_RANGE: { - int len = TYPE_LENGTH (type); + int len = type->length (); return (len == 1 || len == 2 || len == 4 || len == 8); } case TYPE_CODE_PTR: case TYPE_CODE_REF: case TYPE_CODE_RVALUE_REF: - return (TYPE_LENGTH (type) == 8); + return (type->length () == 8); default: break; } @@ -897,7 +897,7 @@ hppa64_floating_p (const struct type *type) { case TYPE_CODE_FLT: { - int len = TYPE_LENGTH (type); + int len = type->length (); return (len == 4 || len == 8 || len == 16); } default: @@ -970,7 +970,7 @@ hppa64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, { struct value *arg = args[i]; struct type *type = value_type (arg); - int len = TYPE_LENGTH (type); + int len = type->length (); const bfd_byte *valbuf; bfd_byte fptrbuf[8]; int regnum; @@ -1057,7 +1057,7 @@ hppa64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, codeptr = unpack_long (type, value_contents (arg).data ()); fptr = hppa64_convert_code_addr_to_fptr (gdbarch, codeptr); - store_unsigned_integer (fptrbuf, TYPE_LENGTH (type), byte_order, + store_unsigned_integer (fptrbuf, type->length (), byte_order, fptr); valbuf = fptrbuf; } @@ -1125,13 +1125,13 @@ hppa32_return_value (struct gdbarch *gdbarch, struct value *function, struct type *type, struct regcache *regcache, gdb_byte *readbuf, const gdb_byte *writebuf) { - if (TYPE_LENGTH (type) <= 2 * 4) + if (type->length () <= 2 * 4) { /* The value always lives in the right hand end of the register (or register pair)? */ int b; int reg = type->code () == TYPE_CODE_FLT ? HPPA_FP4_REGNUM : 28; - int part = TYPE_LENGTH (type) % 4; + int part = type->length () % 4; /* The left hand register contains only part of the value, transfer that first so that the rest can be xfered as entire 4-byte registers. */ @@ -1144,7 +1144,7 @@ hppa32_return_value (struct gdbarch *gdbarch, struct value *function, reg++; } /* Now transfer the remaining register values. */ - for (b = part; b < TYPE_LENGTH (type); b += 4) + for (b = part; b < type->length (); b += 4) { if (readbuf != NULL) regcache->cooked_read (reg, readbuf + b); @@ -1163,7 +1163,7 @@ hppa64_return_value (struct gdbarch *gdbarch, struct value *function, struct type *type, struct regcache *regcache, gdb_byte *readbuf, const gdb_byte *writebuf) { - int len = TYPE_LENGTH (type); + int len = type->length (); int regnum, offset; if (len > 16) diff --git a/gdb/i386-darwin-tdep.c b/gdb/i386-darwin-tdep.c index 5e7929b..f562406 100644 --- a/gdb/i386-darwin-tdep.c +++ b/gdb/i386-darwin-tdep.c @@ -110,7 +110,7 @@ static int i386_m128_p (struct type *type) { return (type->code () == TYPE_CODE_ARRAY && type->is_vector () - && TYPE_LENGTH (type) == 16); + && type->length () == 16); } /* Return the alignment for TYPE when passed as an argument. */ @@ -125,7 +125,7 @@ i386_darwin_arg_type_alignment (struct type *type) 7. [...] The caller aligns 128-bit vectors in the parameter area to 16-byte boundaries. */ if (type->code () == TYPE_CODE_ARRAY && type->is_vector ()) - return TYPE_LENGTH (type); + return type->length (); /* 4. The caller places all the fields of structures (or unions) with no vector elements in the parameter area. These structures are 4-byte aligned. @@ -201,7 +201,7 @@ i386_darwin_push_dummy_call (struct gdbarch *gdbarch, struct value *function, if (write_pass) write_memory (sp + args_space, value_contents_all (args[i]).data (), - TYPE_LENGTH (arg_type)); + arg_type->length ()); /* The System V ABI says that: @@ -210,7 +210,7 @@ i386_darwin_push_dummy_call (struct gdbarch *gdbarch, struct value *function, depending on the size of the argument." This makes sure the stack stays word-aligned. */ - args_space += align_up (TYPE_LENGTH (arg_type), 4); + args_space += align_up (arg_type->length (), 4); } } diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index abb2826..a2f0017 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -2644,7 +2644,7 @@ i386_16_byte_align_p (struct type *type) type = check_typedef (type); if ((type->code () == TYPE_CODE_DECFLOAT || (type->code () == TYPE_CODE_ARRAY && type->is_vector ())) - && TYPE_LENGTH (type) == 16) + && type->length () == 16) return 1; if (type->code () == TYPE_CODE_ARRAY) return i386_16_byte_align_p (type->target_type ()); @@ -2725,7 +2725,7 @@ i386_thiscall_push_dummy_call (struct gdbarch *gdbarch, struct value *function, for (i = thiscall ? 1 : 0; i < nargs; i++) { - int len = TYPE_LENGTH (value_enclosing_type (args[i])); + int len = value_enclosing_type (args[i])->length (); if (write_pass) { @@ -2862,7 +2862,7 @@ i386_extract_return_value (struct gdbarch *gdbarch, struct type *type, struct regcache *regcache, gdb_byte *valbuf) { i386_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); - int len = TYPE_LENGTH (type); + int len = type->length (); gdb_byte buf[I386_MAX_REGISTER_SIZE]; /* _Float16 and _Float16 _Complex values are returned via xmm0. */ @@ -2920,7 +2920,7 @@ i386_store_return_value (struct gdbarch *gdbarch, struct type *type, struct regcache *regcache, const gdb_byte *valbuf) { i386_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); - int len = TYPE_LENGTH (type); + int len = type->length (); if (type->code () == TYPE_CODE_FLT) { @@ -3000,7 +3000,7 @@ i386_reg_struct_return_p (struct gdbarch *gdbarch, struct type *type) { i386_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); enum type_code code = type->code (); - int len = TYPE_LENGTH (type); + int len = type->length (); gdb_assert (code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION @@ -3041,10 +3041,10 @@ i386_return_value (struct gdbarch *gdbarch, struct value *function, || code == TYPE_CODE_ARRAY) && !i386_reg_struct_return_p (gdbarch, type)) /* Complex double and long double uses the struct return convention. */ - || (code == TYPE_CODE_COMPLEX && TYPE_LENGTH (type) == 16) - || (code == TYPE_CODE_COMPLEX && TYPE_LENGTH (type) == 24) + || (code == TYPE_CODE_COMPLEX && type->length () == 16) + || (code == TYPE_CODE_COMPLEX && type->length () == 24) /* 128-bit decimal float uses the struct return convention. */ - || (code == TYPE_CODE_DECFLOAT && TYPE_LENGTH (type) == 16)) + || (code == TYPE_CODE_DECFLOAT && type->length () == 16)) { /* The System V ABI says that: @@ -3068,7 +3068,7 @@ i386_return_value (struct gdbarch *gdbarch, struct value *function, ULONGEST addr; regcache_raw_read_unsigned (regcache, I386_EAX_REGNUM, &addr); - read_memory (addr, readbuf, TYPE_LENGTH (type)); + read_memory (addr, readbuf, type->length ()); } return RETURN_VALUE_ABI_RETURNS_ADDRESS; @@ -3382,7 +3382,7 @@ i386_pseudo_register_read_into_value (struct gdbarch *gdbarch, status = regcache->raw_read (fpnum, raw_buf); if (status != REG_VALID) mark_value_bytes_unavailable (result_value, 0, - TYPE_LENGTH (value_type (result_value))); + value_type (result_value)->length ()); else memcpy (buf, raw_buf, register_size (gdbarch, regnum)); } @@ -3402,7 +3402,7 @@ i386_pseudo_register_read_into_value (struct gdbarch *gdbarch, { enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ()); LONGEST upper, lower; - int size = TYPE_LENGTH (builtin_type (gdbarch)->builtin_data_ptr); + int size = builtin_type (gdbarch)->builtin_data_ptr->length (); lower = extract_unsigned_integer (raw_buf, 8, byte_order); upper = extract_unsigned_integer (raw_buf + 8, 8, byte_order); @@ -3519,7 +3519,7 @@ i386_pseudo_register_read_into_value (struct gdbarch *gdbarch, status = regcache->raw_read (gpnum, raw_buf); if (status != REG_VALID) mark_value_bytes_unavailable (result_value, 0, - TYPE_LENGTH (value_type (result_value))); + value_type (result_value)->length ()); else memcpy (buf, raw_buf, 2); } @@ -3532,7 +3532,7 @@ i386_pseudo_register_read_into_value (struct gdbarch *gdbarch, status = regcache->raw_read (gpnum % 4, raw_buf); if (status != REG_VALID) mark_value_bytes_unavailable (result_value, 0, - TYPE_LENGTH (value_type (result_value))); + value_type (result_value)->length ()); else if (gpnum >= 4) memcpy (buf, raw_buf + 1, 1); else @@ -3583,7 +3583,7 @@ i386_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache, if (i386_bnd_regnum_p (gdbarch, regnum)) { ULONGEST upper, lower; - int size = TYPE_LENGTH (builtin_type (gdbarch)->builtin_data_ptr); + int size = builtin_type (gdbarch)->builtin_data_ptr->length (); enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ()); /* New values from input value. */ @@ -3799,7 +3799,7 @@ static int i386_convert_register_p (struct gdbarch *gdbarch, int regnum, struct type *type) { - int len = TYPE_LENGTH (type); + int len = type->length (); /* Values may be spread across multiple registers. Most debugging formats aren't expressive enough to specify the locations, so @@ -3832,7 +3832,7 @@ i386_register_to_value (struct frame_info *frame, int regnum, int *optimizedp, int *unavailablep) { struct gdbarch *gdbarch = get_frame_arch (frame); - int len = TYPE_LENGTH (type); + int len = type->length (); if (i386_fp_regnum_p (gdbarch, regnum)) return i387_register_to_value (frame, regnum, type, to, @@ -3870,7 +3870,7 @@ static void i386_value_to_register (struct frame_info *frame, int regnum, struct type *type, const gdb_byte *from) { - int len = TYPE_LENGTH (type); + int len = type->length (); if (i386_fp_regnum_p (get_frame_arch (frame), regnum)) { @@ -4443,7 +4443,7 @@ i386_stap_adjust_register (struct gdbarch *gdbarch, struct stap_parse_info *p, specified by the "[-]N@" prefix, and it is one of the registers that we know has an extended variant available, then use the extended version of the register instead. */ - if (register_size (gdbarch, regnum) < TYPE_LENGTH (p->arg_type) + if (register_size (gdbarch, regnum) < p->arg_type->length () && reg_assoc.find (regname) != reg_assoc.end ()) return "e" + regname; @@ -8427,12 +8427,12 @@ i386_type_align (struct gdbarch *gdbarch, struct type *type) { if ((type->code () == TYPE_CODE_INT || type->code () == TYPE_CODE_FLT) - && TYPE_LENGTH (type) > 4) + && type->length () > 4) return 4; /* Handle x86's funny long double. */ if (type->code () == TYPE_CODE_FLT - && gdbarch_long_double_bit (gdbarch) == TYPE_LENGTH (type) * 8) + && gdbarch_long_double_bit (gdbarch) == type->length () * 8) return 4; } @@ -9006,7 +9006,7 @@ i386_mpx_info_bounds (const char *args, int from_tty) for (i = 0; i < 4; i++) bt_entry[i] = read_memory_typed_address (bt_entry_addr - + i * TYPE_LENGTH (data_ptr_type), + + i * data_ptr_type->length (), data_ptr_type); i386_mpx_print_bounds (bt_entry); @@ -9053,15 +9053,15 @@ i386_mpx_set_bounds (const char *args, int from_tty) bt_entry_addr = i386_mpx_get_bt_entry (addr, bd_base); for (i = 0; i < 2; i++) bt_entry[i] = read_memory_typed_address (bt_entry_addr - + i * TYPE_LENGTH (data_ptr_type), + + i * data_ptr_type->length (), data_ptr_type); bt_entry[0] = (uint64_t) lower; bt_entry[1] = ~(uint64_t) upper; for (i = 0; i < 2; i++) write_memory_unsigned_integer (bt_entry_addr - + i * TYPE_LENGTH (data_ptr_type), - TYPE_LENGTH (data_ptr_type), byte_order, + + i * data_ptr_type->length (), + data_ptr_type->length (), byte_order, bt_entry[i]); } diff --git a/gdb/ia64-tdep.c b/gdb/ia64-tdep.c index a4b59d9..0b448e9 100644 --- a/gdb/ia64-tdep.c +++ b/gdb/ia64-tdep.c @@ -3168,12 +3168,12 @@ ia64_use_struct_convention (struct type *type) case. */ float_elt_type = is_float_or_hfa_type (type); if (float_elt_type != NULL - && TYPE_LENGTH (type) / TYPE_LENGTH (float_elt_type) <= 8) + && type->length () / float_elt_type->length () <= 8) return 0; /* Other structs of length 32 or less are returned in r8-r11. Don't use the struct convention for those either. */ - return TYPE_LENGTH (type) > 32; + return type->length () > 32; } /* Return non-zero if TYPE is a structure or union type. */ @@ -3198,18 +3198,18 @@ ia64_extract_return_value (struct type *type, struct regcache *regcache, gdb_byte from[IA64_FP_REGISTER_SIZE]; int offset = 0; int regnum = IA64_FR8_REGNUM; - int n = TYPE_LENGTH (type) / TYPE_LENGTH (float_elt_type); + int n = type->length () / float_elt_type->length (); while (n-- > 0) { regcache->cooked_read (regnum, from); target_float_convert (from, ia64_ext_type (gdbarch), valbuf + offset, float_elt_type); - offset += TYPE_LENGTH (float_elt_type); + offset += float_elt_type->length (); regnum++; } } - else if (!ia64_struct_type_p (type) && TYPE_LENGTH (type) < 8) + else if (!ia64_struct_type_p (type) && type->length () < 8) { /* This is an integral value, and its size is less than 8 bytes. These values are LSB-aligned, so extract the relevant bytes, @@ -3222,16 +3222,16 @@ ia64_extract_return_value (struct type *type, struct regcache *regcache, ULONGEST val; regcache_cooked_read_unsigned (regcache, IA64_GR8_REGNUM, &val); - store_unsigned_integer (valbuf, TYPE_LENGTH (type), byte_order, val); + store_unsigned_integer (valbuf, type->length (), byte_order, val); } else { ULONGEST val; int offset = 0; int regnum = IA64_GR8_REGNUM; - int reglen = TYPE_LENGTH (register_type (gdbarch, IA64_GR8_REGNUM)); - int n = TYPE_LENGTH (type) / reglen; - int m = TYPE_LENGTH (type) % reglen; + int reglen = register_type (gdbarch, IA64_GR8_REGNUM)->length (); + int n = type->length () / reglen; + int m = type->length () % reglen; while (n-- > 0) { @@ -3263,14 +3263,14 @@ ia64_store_return_value (struct type *type, struct regcache *regcache, gdb_byte to[IA64_FP_REGISTER_SIZE]; int offset = 0; int regnum = IA64_FR8_REGNUM; - int n = TYPE_LENGTH (type) / TYPE_LENGTH (float_elt_type); + int n = type->length () / float_elt_type->length (); while (n-- > 0) { target_float_convert (valbuf + offset, float_elt_type, to, ia64_ext_type (gdbarch)); regcache->cooked_write (regnum, to); - offset += TYPE_LENGTH (float_elt_type); + offset += float_elt_type->length (); regnum++; } } @@ -3278,9 +3278,9 @@ ia64_store_return_value (struct type *type, struct regcache *regcache, { int offset = 0; int regnum = IA64_GR8_REGNUM; - int reglen = TYPE_LENGTH (register_type (gdbarch, IA64_GR8_REGNUM)); - int n = TYPE_LENGTH (type) / reglen; - int m = TYPE_LENGTH (type) % reglen; + int reglen = register_type (gdbarch, IA64_GR8_REGNUM)->length (); + int n = type->length () / reglen; + int m = type->length () % reglen; while (n-- > 0) { @@ -3332,7 +3332,7 @@ is_float_or_hfa_type_recurse (struct type *t, struct type **etp) { case TYPE_CODE_FLT: if (*etp) - return TYPE_LENGTH (*etp) == TYPE_LENGTH (t); + return (*etp)->length () == t->length (); else { *etp = t; @@ -3387,7 +3387,7 @@ slot_alignment_is_next_even (struct type *t) { case TYPE_CODE_INT: case TYPE_CODE_FLT: - if (TYPE_LENGTH (t) > 8) + if (t->length () > 8) return 1; else return 0; @@ -3699,7 +3699,7 @@ ia64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, { arg = args[argno]; type = check_typedef (value_type (arg)); - len = TYPE_LENGTH (type); + len = type->length (); if ((nslots & 1) && slot_alignment_is_next_even (type)) nslots++; @@ -3742,7 +3742,7 @@ ia64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, arg = args[argno]; type = check_typedef (value_type (arg)); - len = TYPE_LENGTH (type); + len = type->length (); /* Special handling for function parameters. */ if (len == 8 @@ -3817,7 +3817,7 @@ ia64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, if (float_elt_type != NULL) { argoffset = 0; - len = TYPE_LENGTH (type); + len = type->length (); while (len > 0 && floatreg < IA64_FR16_REGNUM) { gdb_byte to[IA64_FP_REGISTER_SIZE]; @@ -3826,8 +3826,8 @@ ia64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, ia64_ext_type (gdbarch)); regcache->cooked_write (floatreg, to); floatreg++; - argoffset += TYPE_LENGTH (float_elt_type); - len -= TYPE_LENGTH (float_elt_type); + argoffset += float_elt_type->length (); + len -= float_elt_type->length (); } } } diff --git a/gdb/infcall.c b/gdb/infcall.c index 471e9cc..3485219 100644 --- a/gdb/infcall.c +++ b/gdb/infcall.c @@ -194,21 +194,21 @@ value_arg_coerce (struct gdbarch *gdbarch, struct value *arg, /* If we don't have a prototype, coerce to integer type if necessary. */ if (!is_prototyped) { - if (TYPE_LENGTH (type) < TYPE_LENGTH (builtin->builtin_int)) + if (type->length () < builtin->builtin_int->length ()) type = builtin->builtin_int; } /* Currently all target ABIs require at least the width of an integer type for an argument. We may have to conditionalize the following type coercion for future targets. */ - if (TYPE_LENGTH (type) < TYPE_LENGTH (builtin->builtin_int)) + if (type->length () < builtin->builtin_int->length ()) type = builtin->builtin_int; break; case TYPE_CODE_FLT: if (!is_prototyped && coerce_float_to_double_p) { - if (TYPE_LENGTH (type) < TYPE_LENGTH (builtin->builtin_double)) + if (type->length () < builtin->builtin_double->length ()) type = builtin->builtin_double; - else if (TYPE_LENGTH (type) > TYPE_LENGTH (builtin->builtin_double)) + else if (type->length () > builtin->builtin_double->length ()) type = builtin->builtin_long_double; } break; @@ -307,7 +307,7 @@ find_function_addr (struct value *function, { /* Handle the case of functions lacking debugging info. Their values are characters since their addresses are char. */ - if (TYPE_LENGTH (ftype) == 1) + if (ftype->length () == 1) funaddr = value_as_address (value_addr (function)); else { @@ -452,7 +452,7 @@ get_call_return_value (struct call_return_meta_info *ri) retval = allocate_value (ri->value_type); read_value_memory (retval, 0, 1, ri->struct_addr, value_contents_raw (retval).data (), - TYPE_LENGTH (ri->value_type)); + ri->value_type->length ()); } } else @@ -681,7 +681,7 @@ reserve_stack_space (const type *values_type, CORE_ADDR &sp) { /* Stack grows downward. Align STRUCT_ADDR and SP after making space. */ - sp -= TYPE_LENGTH (values_type); + sp -= values_type->length (); if (gdbarch_frame_align_p (gdbarch)) sp = gdbarch_frame_align (gdbarch, sp); addr = sp; @@ -693,7 +693,7 @@ reserve_stack_space (const type *values_type, CORE_ADDR &sp) if (gdbarch_frame_align_p (gdbarch)) sp = gdbarch_frame_align (gdbarch, sp); addr = sp; - sp += TYPE_LENGTH (values_type); + sp += values_type->length (); if (gdbarch_frame_align_p (gdbarch)) sp = gdbarch_frame_align (gdbarch, sp); } @@ -926,7 +926,7 @@ call_function_by_hand_dummy (struct value *function, else { gdb_assert (sp <= lastval_addr); - sp = lastval_addr + TYPE_LENGTH (value_type (lastval)); + sp = lastval_addr + value_type (lastval)->length (); } if (gdbarch_frame_align_p (gdbarch)) @@ -1083,7 +1083,7 @@ call_function_by_hand_dummy (struct value *function, if (info.trivially_copy_constructible) { - int length = TYPE_LENGTH (param_type); + int length = param_type->length (); write_memory (addr, value_contents (args[i]).data (), length); } else diff --git a/gdb/infcmd.c b/gdb/infcmd.c index a6c5518..b788f45 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -2151,7 +2151,7 @@ default_print_one_register_info (struct ui_file *file, { pad_to_column (format_stream, value_column_2); format_stream.puts ("(raw "); - print_hex_chars (&format_stream, valaddr, TYPE_LENGTH (regtype), + print_hex_chars (&format_stream, valaddr, regtype->length (), byte_order, true); format_stream.putc (')'); } diff --git a/gdb/infrun.c b/gdb/infrun.c index 033699b..1957e80 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -9177,9 +9177,9 @@ siginfo_value_read (struct value *v) NULL, value_contents_all_raw (v).data (), value_offset (v), - TYPE_LENGTH (value_type (v))); + value_type (v)->length ()); - if (transferred != TYPE_LENGTH (value_type (v))) + if (transferred != value_type (v)->length ()) error (_("Unable to read siginfo")); } @@ -9200,9 +9200,9 @@ siginfo_value_write (struct value *v, struct value *fromval) NULL, value_contents_all_raw (fromval).data (), value_offset (v), - TYPE_LENGTH (value_type (fromval))); + value_type (fromval)->length ()); - if (transferred != TYPE_LENGTH (value_type (fromval))) + if (transferred != value_type (fromval)->length ()) error (_("Unable to write siginfo")); } @@ -9256,7 +9256,7 @@ public: if (gdbarch_get_siginfo_type_p (gdbarch)) { struct type *type = gdbarch_get_siginfo_type (gdbarch); - size_t len = TYPE_LENGTH (type); + size_t len = type->length (); siginfo_data.reset ((gdb_byte *) xmalloc (len)); @@ -9298,7 +9298,7 @@ public: /* Errors ignored. */ target_write (current_inferior ()->top_target (), TARGET_OBJECT_SIGNAL_INFO, NULL, - m_siginfo_data.get (), 0, TYPE_LENGTH (type)); + m_siginfo_data.get (), 0, type->length ()); } /* The inferior can be gone if the user types "print exit(0)" @@ -9320,7 +9320,7 @@ private: struct gdbarch *m_siginfo_gdbarch = nullptr; /* The inferior format depends on SIGINFO_GDBARCH and it has a length of - TYPE_LENGTH (gdbarch_get_siginfo_type ()). For different gdbarch the + gdbarch_get_siginfo_type ()->length (). For different gdbarch the content would be invalid. */ gdb::unique_xmalloc_ptr m_siginfo_data; }; diff --git a/gdb/iq2000-tdep.c b/gdb/iq2000-tdep.c index 3852195..236362c 100644 --- a/gdb/iq2000-tdep.c +++ b/gdb/iq2000-tdep.c @@ -91,7 +91,7 @@ iq2000_pointer_to_address (struct gdbarch *gdbarch, enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); enum type_code target = type->target_type ()->code (); CORE_ADDR addr - = extract_unsigned_integer (buf, TYPE_LENGTH (type), byte_order); + = extract_unsigned_integer (buf, type->length (), byte_order); if (target == TYPE_CODE_FUNC || target == TYPE_CODE_METHOD @@ -113,7 +113,7 @@ iq2000_address_to_pointer (struct gdbarch *gdbarch, if (target == TYPE_CODE_FUNC || target == TYPE_CODE_METHOD) addr = insn_ptr_from_addr (addr); - store_unsigned_integer (buf, TYPE_LENGTH (type), byte_order, addr); + store_unsigned_integer (buf, type->length (), byte_order, addr); } /* Real register methods: */ @@ -482,7 +482,7 @@ static void iq2000_store_return_value (struct type *type, struct regcache *regcache, const void *valbuf) { - int len = TYPE_LENGTH (type); + int len = type->length (); int regno = E_FN_RETURN_REGNUM; while (len > 0) @@ -507,7 +507,7 @@ iq2000_use_struct_convention (struct type *type) { return ((type->code () == TYPE_CODE_STRUCT) || (type->code () == TYPE_CODE_UNION)) - && TYPE_LENGTH (type) > 8; + && type->length () > 8; } /* Function: extract_return_value @@ -528,7 +528,7 @@ iq2000_extract_return_value (struct type *type, struct regcache *regcache, returned in a register, and if larger than 8 bytes, it is returned in a stack location which is pointed to by the same register. */ - int len = TYPE_LENGTH (type); + int len = type->length (); if (len <= (2 * 4)) { @@ -556,7 +556,7 @@ iq2000_extract_return_value (struct type *type, struct regcache *regcache, ULONGEST return_buffer; regcache_cooked_read_unsigned (regcache, E_FN_RETURN_REGNUM, &return_buffer); - read_memory (return_buffer, valbuf, TYPE_LENGTH (type)); + read_memory (return_buffer, valbuf, type->length ()); } } @@ -610,7 +610,7 @@ iq2000_pass_8bytetype_by_address (struct type *type) /* Get field type. */ ftype = type->field (0).type (); /* The field type must have size 8, otherwise pass by address. */ - if (TYPE_LENGTH (ftype) != 8) + if (ftype->length () != 8) return 1; /* Skip typedefs of field type. */ while (ftype->code () == TYPE_CODE_TYPEDEF) @@ -645,7 +645,7 @@ iq2000_push_dummy_call (struct gdbarch *gdbarch, struct value *function, i++) { type = value_type (args[i]); - typelen = TYPE_LENGTH (type); + typelen = type->length (); if (typelen <= 4) { /* Scalars of up to 4 bytes, @@ -711,7 +711,7 @@ iq2000_push_dummy_call (struct gdbarch *gdbarch, struct value *function, for (i = 0; i < nargs; i++) { type = value_type (args[i]); - typelen = TYPE_LENGTH (type); + typelen = type->length (); val = value_contents (args[i]).data (); if (typelen <= 4) { diff --git a/gdb/jit.c b/gdb/jit.c index 6d8acc4..d2d8cea 100644 --- a/gdb/jit.c +++ b/gdb/jit.c @@ -265,7 +265,7 @@ jit_read_descriptor (gdbarch *gdbarch, /* Figure out how big the descriptor is on the remote and how to read it. */ ptr_type = builtin_type (gdbarch)->builtin_data_ptr; - ptr_size = TYPE_LENGTH (ptr_type); + ptr_size = ptr_type->length (); desc_size = 8 + 2 * ptr_size; /* Two 32-bit ints and two pointers. */ desc_buf = (gdb_byte *) alloca (desc_size); @@ -305,7 +305,7 @@ jit_read_code_entry (struct gdbarch *gdbarch, /* Figure out how big the entry is on the remote and how to read it. */ ptr_type = builtin_type (gdbarch)->builtin_data_ptr; - ptr_size = TYPE_LENGTH (ptr_type); + ptr_size = ptr_type->length (); /* Figure out where the uint64_t value will be. */ align_bytes = type_align (builtin_type (gdbarch)->builtin_uint64); diff --git a/gdb/linux-record.c b/gdb/linux-record.c index a500bc9..78f6a9a6 100644 --- a/gdb/linux-record.c +++ b/gdb/linux-record.c @@ -84,7 +84,7 @@ #define RECORD_Q_XGETQUOTA (('3' << 8) + 3) #define OUTPUT_REG(val, num) phex_nz ((val), \ - TYPE_LENGTH (gdbarch_register_type (regcache->arch (), (num)))) + gdbarch_register_type (regcache->arch (), (num))->length ()) /* Record a memory area of length LEN pointed to by register REGNUM. */ diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c index 590dd35..85fad70 100644 --- a/gdb/linux-tdep.c +++ b/gdb/linux-tdep.c @@ -293,19 +293,19 @@ linux_get_siginfo_type_with_fields (struct gdbarch *gdbarch, /* __pid_t */ pid_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF, - TYPE_LENGTH (int_type) * TARGET_CHAR_BIT, "__pid_t"); + int_type->length () * TARGET_CHAR_BIT, "__pid_t"); pid_type->set_target_type (int_type); pid_type->set_target_is_stub (true); /* __uid_t */ uid_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF, - TYPE_LENGTH (uint_type) * TARGET_CHAR_BIT, "__uid_t"); + uint_type->length () * TARGET_CHAR_BIT, "__uid_t"); uid_type->set_target_type (uint_type); uid_type->set_target_is_stub (true); /* __clock_t */ clock_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF, - TYPE_LENGTH (long_type) * TARGET_CHAR_BIT, + long_type->length () * TARGET_CHAR_BIT, "__clock_t"); clock_type->set_target_type (long_type); clock_type->set_target_is_stub (true); @@ -394,7 +394,7 @@ linux_get_siginfo_type_with_fields (struct gdbarch *gdbarch, append_composite_type_field (siginfo_type, "si_code", int_type); append_composite_type_field_aligned (siginfo_type, "_sifields", sifields_type, - TYPE_LENGTH (long_type)); + long_type->length ()); linux_gdbarch_data->siginfo_type = siginfo_type; @@ -1715,11 +1715,11 @@ linux_make_mappings_callback (ULONGEST vaddr, ULONGEST size, ++map_data->file_count; pack_long (buf, map_data->long_type, vaddr); - obstack_grow (map_data->data_obstack, buf, TYPE_LENGTH (map_data->long_type)); + obstack_grow (map_data->data_obstack, buf, map_data->long_type->length ()); pack_long (buf, map_data->long_type, vaddr + size); - obstack_grow (map_data->data_obstack, buf, TYPE_LENGTH (map_data->long_type)); + obstack_grow (map_data->data_obstack, buf, map_data->long_type->length ()); pack_long (buf, map_data->long_type, offset); - obstack_grow (map_data->data_obstack, buf, TYPE_LENGTH (map_data->long_type)); + obstack_grow (map_data->data_obstack, buf, map_data->long_type->length ()); obstack_grow_str0 (map_data->filename_obstack, filename); @@ -1748,11 +1748,11 @@ linux_make_mappings_corefile_notes (struct gdbarch *gdbarch, bfd *obfd, mapping_data.long_type = long_type; /* Reserve space for the count. */ - obstack_blank (&data_obstack, TYPE_LENGTH (long_type)); + obstack_blank (&data_obstack, long_type->length ()); /* We always write the page size as 1 since we have no good way to determine the correct value. */ pack_long (buf, long_type, 1); - obstack_grow (&data_obstack, buf, TYPE_LENGTH (long_type)); + obstack_grow (&data_obstack, buf, long_type->length ()); linux_find_memory_regions_full (gdbarch, dump_note_entry_p, @@ -1794,12 +1794,12 @@ linux_get_siginfo_data (thread_info *thread, struct gdbarch *gdbarch) siginfo_type = gdbarch_get_siginfo_type (gdbarch); - gdb::byte_vector buf (TYPE_LENGTH (siginfo_type)); + gdb::byte_vector buf (siginfo_type->length ()); bytes_read = target_read (current_inferior ()->top_target (), TARGET_OBJECT_SIGNAL_INFO, NULL, - buf.data (), 0, TYPE_LENGTH (siginfo_type)); - if (bytes_read != TYPE_LENGTH (siginfo_type)) + buf.data (), 0, siginfo_type->length ()); + if (bytes_read != siginfo_type->length ()) buf.clear (); return buf; diff --git a/gdb/lm32-tdep.c b/gdb/lm32-tdep.c index af32251..9565d0a 100644 --- a/gdb/lm32-tdep.c +++ b/gdb/lm32-tdep.c @@ -252,7 +252,7 @@ lm32_push_dummy_call (struct gdbarch *gdbarch, struct value *function, case TYPE_CODE_CHAR: case TYPE_CODE_RANGE: case TYPE_CODE_ENUM: - if (TYPE_LENGTH (arg_type) < 4) + if (arg_type->length () < 4) { arg_type = builtin_type (gdbarch)->builtin_int32; arg = value_cast (arg_type, arg); @@ -263,7 +263,7 @@ lm32_push_dummy_call (struct gdbarch *gdbarch, struct value *function, /* FIXME: Handle structures. */ contents = (gdb_byte *) value_contents (arg).data (); - val = extract_unsigned_integer (contents, TYPE_LENGTH (arg_type), + val = extract_unsigned_integer (contents, arg_type->length (), byte_order); /* First num_arg_regs parameters are passed by registers, @@ -272,7 +272,7 @@ lm32_push_dummy_call (struct gdbarch *gdbarch, struct value *function, regcache_cooked_write_unsigned (regcache, first_arg_reg + i, val); else { - write_memory_unsigned_integer (sp, TYPE_LENGTH (arg_type), byte_order, + write_memory_unsigned_integer (sp, arg_type->length (), byte_order, val); sp -= 4; } @@ -298,13 +298,13 @@ lm32_extract_return_value (struct type *type, struct regcache *regcache, if (type->code () != TYPE_CODE_STRUCT && type->code () != TYPE_CODE_UNION - && type->code () != TYPE_CODE_ARRAY && TYPE_LENGTH (type) <= 4) + && type->code () != TYPE_CODE_ARRAY && type->length () <= 4) { /* Return value is returned in a single register. */ regcache_cooked_read_unsigned (regcache, SIM_LM32_R1_REGNUM, &l); - store_unsigned_integer (valbuf, TYPE_LENGTH (type), byte_order, l); + store_unsigned_integer (valbuf, type->length (), byte_order, l); } - else if ((type->code () == TYPE_CODE_INT) && (TYPE_LENGTH (type) == 8)) + else if ((type->code () == TYPE_CODE_INT) && (type->length () == 8)) { /* 64-bit values are returned in a register pair. */ regcache_cooked_read_unsigned (regcache, SIM_LM32_R1_REGNUM, &l); @@ -318,7 +318,7 @@ lm32_extract_return_value (struct type *type, struct regcache *regcache, in memory. FIXME: Unless they are only 2 regs?. */ regcache_cooked_read_unsigned (regcache, SIM_LM32_R1_REGNUM, &l); return_buffer = l; - read_memory (return_buffer, valbuf, TYPE_LENGTH (type)); + read_memory (return_buffer, valbuf, type->length ()); } } @@ -331,7 +331,7 @@ lm32_store_return_value (struct type *type, struct regcache *regcache, struct gdbarch *gdbarch = regcache->arch (); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); ULONGEST val; - int len = TYPE_LENGTH (type); + int len = type->length (); if (len <= 4) { @@ -359,7 +359,7 @@ lm32_return_value (struct gdbarch *gdbarch, struct value *function, if (code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION - || code == TYPE_CODE_ARRAY || TYPE_LENGTH (valtype) > 8) + || code == TYPE_CODE_ARRAY || valtype->length () > 8) return RETURN_VALUE_STRUCT_CONVENTION; if (readbuf) diff --git a/gdb/loongarch-tdep.c b/gdb/loongarch-tdep.c index 09af715..94677fb 100644 --- a/gdb/loongarch-tdep.c +++ b/gdb/loongarch-tdep.c @@ -567,7 +567,7 @@ loongarch_push_dummy_call (struct gdbarch *gdbarch, struct value *arg = args[i]; const gdb_byte *val = value_contents (arg).data (); struct type *type = check_typedef (value_type (arg)); - size_t len = TYPE_LENGTH (type); + size_t len = type->length (); int align = type_align (type); enum type_code code = type->code (); struct type *func_type = check_typedef (value_type (function)); @@ -1027,7 +1027,7 @@ loongarch_push_dummy_call (struct gdbarch *gdbarch, case TYPE_CODE_COMPLEX: { struct type *target_type = check_typedef (type->target_type ()); - size_t target_len = TYPE_LENGTH (target_type); + size_t target_len = target_type->length (); if (target_len < regsize) { @@ -1143,7 +1143,7 @@ loongarch_return_value (struct gdbarch *gdbarch, struct value *function, { int regsize = register_size (gdbarch, 0); enum type_code code = type->code (); - size_t len = TYPE_LENGTH (type); + size_t len = type->length (); unsigned int fixed_point_members; unsigned int floating_point_members; bool first_member_is_fixed_point; diff --git a/gdb/m2-exp.y b/gdb/m2-exp.y index d3e917b..566266f 100644 --- a/gdb/m2-exp.y +++ b/gdb/m2-exp.y @@ -480,7 +480,7 @@ exp : SIZE '(' type ')' %prec UNARY { pstate->push_new (parse_m2_type (pstate)->builtin_int, - TYPE_LENGTH ($3)); + $3->length ()); } ; diff --git a/gdb/m2-lang.h b/gdb/m2-lang.h index ed79cc8..249fdf7 100644 --- a/gdb/m2-lang.h +++ b/gdb/m2-lang.h @@ -118,12 +118,12 @@ public: { type = check_typedef (type); if (type->code () == TYPE_CODE_ARRAY - && TYPE_LENGTH (type) > 0 - && TYPE_LENGTH (type->target_type ()) > 0) + && type->length () > 0 + && type->target_type ()->length () > 0) { struct type *elttype = check_typedef (type->target_type ()); - if (TYPE_LENGTH (elttype) == 1 + if (elttype->length () == 1 && (elttype->code () == TYPE_CODE_INT || elttype->code () == TYPE_CODE_CHAR)) return true; diff --git a/gdb/m2-typeprint.c b/gdb/m2-typeprint.c index f6d937f..67afddd 100644 --- a/gdb/m2-typeprint.c +++ b/gdb/m2-typeprint.c @@ -225,7 +225,7 @@ static void m2_array (struct type *type, struct ui_file *stream, int show, int level, const struct type_print_options *flags) { gdb_printf (stream, "ARRAY ["); - if (TYPE_LENGTH (type->target_type ()) > 0 + if (type->target_type ()->length () > 0 && type->bounds ()->high.kind () != PROP_UNDEFINED) { if (type->index_type () != 0) @@ -235,8 +235,8 @@ static void m2_array (struct type *type, struct ui_file *stream, m2_print_bounds (type->index_type (), stream, show, -1, 1); } else - gdb_puts (pulongest ((TYPE_LENGTH (type) - / TYPE_LENGTH (type->target_type ()))), + gdb_puts (pulongest ((type->length () + / type->target_type ()->length ())), stream); } gdb_printf (stream, "] OF "); @@ -379,11 +379,11 @@ m2_get_discrete_bounds (struct type *type, LONGEST *lowp, LONGEST *highp) switch (type->code ()) { case TYPE_CODE_CHAR: - if (TYPE_LENGTH (type) < sizeof (LONGEST)) + if (type->length () < sizeof (LONGEST)) { if (!type->is_unsigned ()) { - *lowp = -(1 << (TYPE_LENGTH (type) * TARGET_CHAR_BIT - 1)); + *lowp = -(1 << (type->length () * TARGET_CHAR_BIT - 1)); *highp = -*lowp - 1; return 0; } diff --git a/gdb/m2-valprint.c b/gdb/m2-valprint.c index 3fb7d42..b58e43f 100644 --- a/gdb/m2-valprint.c +++ b/gdb/m2-valprint.c @@ -207,7 +207,7 @@ print_unpacked_pointer (struct type *type, /* For a pointer to char or unsigned char, also print the string pointed to, unless pointer is null. */ - if (TYPE_LENGTH (elttype) == 1 + if (elttype->length () == 1 && elttype->code () == TYPE_CODE_INT && (options->format == 0 || options->format == 's') && addr != 0) @@ -262,10 +262,10 @@ m2_print_array_contents (struct value *val, { struct type *type = check_typedef (value_type (val)); - if (TYPE_LENGTH (type) > 0) + if (type->length () > 0) { /* For an array of chars, print with string syntax. */ - if (TYPE_LENGTH (type) == 1 && + if (type->length () == 1 && ((type->code () == TYPE_CODE_INT) || ((current_language->la_language == language_m2) && (type->code () == TYPE_CODE_CHAR))) @@ -312,12 +312,12 @@ m2_language::value_print_inner (struct value *val, struct ui_file *stream, switch (type->code ()) { case TYPE_CODE_ARRAY: - if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (type->target_type ()) > 0) + if (type->length () > 0 && type->target_type ()->length () > 0) { elttype = check_typedef (type->target_type ()); - len = TYPE_LENGTH (type) / TYPE_LENGTH (elttype); + len = type->length () / elttype->length (); /* For an array of chars, print with string syntax. */ - if (TYPE_LENGTH (elttype) == 1 && + if (elttype->length () == 1 && ((elttype->code () == TYPE_CODE_INT) || ((current_language->la_language == language_m2) && (elttype->code () == TYPE_CODE_CHAR))) @@ -443,7 +443,7 @@ m2_language::value_print_inner (struct value *val, struct ui_file *stream, break; case TYPE_CODE_RANGE: - if (TYPE_LENGTH (type) == TYPE_LENGTH (type->target_type ())) + if (type->length () == type->target_type ()->length ()) { struct value *v = value_cast (type->target_type (), val); value_print_inner (v, stream, recurse, options); diff --git a/gdb/m32c-tdep.c b/gdb/m32c-tdep.c index 89a73c8..0765968 100644 --- a/gdb/m32c-tdep.c +++ b/gdb/m32c-tdep.c @@ -409,10 +409,10 @@ static void m32c_find_part (struct m32c_reg *reg, int *offset_p, int *len_p) { /* The length of the containing register, of which REG is one part. */ - int containing_len = TYPE_LENGTH (reg->rx->type); + int containing_len = reg->rx->type->length (); /* The length of one "element" in our imaginary array. */ - int elt_len = TYPE_LENGTH (reg->type); + int elt_len = reg->type->length (); /* The offset of REG's "element" from the least significant end of the containing register. */ @@ -429,7 +429,7 @@ m32c_find_part (struct m32c_reg *reg, int *offset_p, int *len_p) /* Flip the offset around if we're big-endian. */ if (gdbarch_byte_order (reg->arch) == BFD_ENDIAN_BIG) - elt_offset = TYPE_LENGTH (reg->rx->type) - elt_offset - elt_len; + elt_offset = reg->rx->type->length () - elt_offset - elt_len; *offset_p = elt_offset; *len_p = elt_len; @@ -445,7 +445,7 @@ m32c_part_read (struct m32c_reg *reg, readable_regcache *cache, gdb_byte *buf) { int offset, len; - memset (buf, 0, TYPE_LENGTH (reg->type)); + memset (buf, 0, reg->type->length ()); m32c_find_part (reg, &offset, &len); return cache->cooked_read_part (reg->rx->num, offset, len, buf); } @@ -474,11 +474,11 @@ m32c_part_write (struct m32c_reg *reg, struct regcache *cache, static enum register_status m32c_cat_read (struct m32c_reg *reg, readable_regcache *cache, gdb_byte *buf) { - int high_bytes = TYPE_LENGTH (reg->rx->type); - int low_bytes = TYPE_LENGTH (reg->ry->type); + int high_bytes = reg->rx->type->length (); + int low_bytes = reg->ry->type->length (); enum register_status status; - gdb_assert (TYPE_LENGTH (reg->type) == high_bytes + low_bytes); + gdb_assert (reg->type->length () == high_bytes + low_bytes); if (gdbarch_byte_order (reg->arch) == BFD_ENDIAN_BIG) { @@ -503,10 +503,10 @@ static enum register_status m32c_cat_write (struct m32c_reg *reg, struct regcache *cache, const gdb_byte *buf) { - int high_bytes = TYPE_LENGTH (reg->rx->type); - int low_bytes = TYPE_LENGTH (reg->ry->type); + int high_bytes = reg->rx->type->length (); + int low_bytes = reg->ry->type->length (); - gdb_assert (TYPE_LENGTH (reg->type) == high_bytes + low_bytes); + gdb_assert (reg->type->length () == high_bytes + low_bytes); if (gdbarch_byte_order (reg->arch) == BFD_ENDIAN_BIG) { @@ -531,7 +531,7 @@ m32c_r3r2r1r0_read (struct m32c_reg *reg, readable_regcache *cache, gdb_byte *bu { gdbarch *arch = reg->arch; m32c_gdbarch_tdep *tdep = gdbarch_tdep (arch); - int len = TYPE_LENGTH (tdep->r0->type); + int len = tdep->r0->type->length (); enum register_status status; if (gdbarch_byte_order (reg->arch) == BFD_ENDIAN_BIG) @@ -568,7 +568,7 @@ m32c_r3r2r1r0_write (struct m32c_reg *reg, struct regcache *cache, { gdbarch *arch = reg->arch; m32c_gdbarch_tdep *tdep = gdbarch_tdep (arch); - int len = TYPE_LENGTH (tdep->r0->type); + int len = tdep->r0->type->length (); if (gdbarch_byte_order (reg->arch) == BFD_ENDIAN_BIG) { @@ -2052,7 +2052,7 @@ m32c_push_dummy_call (struct gdbarch *gdbarch, struct value *function, subsequent arguments are allocated to registers. */ if (return_method == return_method_struct) { - int ptr_len = TYPE_LENGTH (tdep->ptr_voyd); + int ptr_len = tdep->ptr_voyd->length (); sp -= ptr_len; write_memory_unsigned_integer (sp, ptr_len, byte_order, struct_addr); } @@ -2063,7 +2063,7 @@ m32c_push_dummy_call (struct gdbarch *gdbarch, struct value *function, struct value *arg = args[i]; const gdb_byte *arg_bits = value_contents (arg).data (); struct type *arg_type = value_type (arg); - ULONGEST arg_size = TYPE_LENGTH (arg_type); + ULONGEST arg_size = arg_type->length (); /* Can it go in r1 or r1l (for m16c) or r0 or r0l (for m32c)? */ if (i == 0 @@ -2181,7 +2181,7 @@ m32c_return_value (struct gdbarch *gdbarch, m32c_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); enum return_value_convention conv; - ULONGEST valtype_len = TYPE_LENGTH (valtype); + ULONGEST valtype_len = valtype->length (); if (m32c_return_by_passed_buf (valtype)) conv = RETURN_VALUE_STRUCT_CONVENTION; @@ -2198,7 +2198,7 @@ m32c_return_value (struct gdbarch *gdbarch, gdb_assert (valtype_len <= 8); /* Anything that fits in r0 is returned there. */ - if (valtype_len <= TYPE_LENGTH (tdep->r0->type)) + if (valtype_len <= tdep->r0->type->length ()) { ULONGEST u; regcache_cooked_read_unsigned (regcache, tdep->r0->num, &u); @@ -2230,7 +2230,7 @@ m32c_return_value (struct gdbarch *gdbarch, gdb_assert (valtype_len <= 8); /* Anything that fits in r0 is returned there. */ - if (valtype_len <= TYPE_LENGTH (tdep->r0->type)) + if (valtype_len <= tdep->r0->type->length ()) { ULONGEST u = extract_unsigned_integer (writebuf, valtype_len, byte_order); @@ -2477,7 +2477,7 @@ m32c_m16c_address_to_pointer (struct gdbarch *gdbarch, } } - store_unsigned_integer (buf, TYPE_LENGTH (type), byte_order, addr); + store_unsigned_integer (buf, type->length (), byte_order, addr); } @@ -2491,7 +2491,7 @@ m32c_m16c_pointer_to_address (struct gdbarch *gdbarch, gdb_assert (type->code () == TYPE_CODE_PTR || TYPE_IS_REFERENCE (type)); - ptr = extract_unsigned_integer (buf, TYPE_LENGTH (type), byte_order); + ptr = extract_unsigned_integer (buf, type->length (), byte_order); target_code = type->target_type ()->code (); diff --git a/gdb/m32r-tdep.c b/gdb/m32r-tdep.c index 7edbd50..4c2ecd3 100644 --- a/gdb/m32r-tdep.c +++ b/gdb/m32r-tdep.c @@ -247,7 +247,7 @@ m32r_store_return_value (struct type *type, struct regcache *regcache, struct gdbarch *gdbarch = regcache->arch (); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); CORE_ADDR regval; - int len = TYPE_LENGTH (type); + int len = type->length (); regval = extract_unsigned_integer (valbuf, len > 4 ? 4 : len, byte_order); regcache_cooked_write_unsigned (regcache, RET1_REGNUM, regval); @@ -685,14 +685,14 @@ m32r_push_dummy_call (struct gdbarch *gdbarch, struct value *function, /* Now make sure there's space on the stack. */ for (argnum = 0, stack_alloc = 0; argnum < nargs; argnum++) - stack_alloc += ((TYPE_LENGTH (value_type (args[argnum])) + 3) & ~3); + stack_alloc += ((value_type (args[argnum])->length () + 3) & ~3); sp -= stack_alloc; /* Make room on stack for args. */ for (argnum = 0, stack_offset = 0; argnum < nargs; argnum++) { type = value_type (args[argnum]); typecode = type->code (); - len = TYPE_LENGTH (type); + len = type->length (); memset (valbuf, 0, sizeof (valbuf)); @@ -758,7 +758,7 @@ m32r_extract_return_value (struct type *type, struct regcache *regcache, { struct gdbarch *gdbarch = regcache->arch (); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); - int len = TYPE_LENGTH (type); + int len = type->length (); ULONGEST tmp; /* By using store_unsigned_integer we avoid having to do @@ -780,7 +780,7 @@ m32r_return_value (struct gdbarch *gdbarch, struct value *function, struct type *valtype, struct regcache *regcache, gdb_byte *readbuf, const gdb_byte *writebuf) { - if (TYPE_LENGTH (valtype) > 8) + if (valtype->length () > 8) return RETURN_VALUE_STRUCT_CONVENTION; else { diff --git a/gdb/m68hc11-tdep.c b/gdb/m68hc11-tdep.c index 53b7752..f22f818 100644 --- a/gdb/m68hc11-tdep.c +++ b/gdb/m68hc11-tdep.c @@ -1176,16 +1176,16 @@ m68hc11_push_dummy_call (struct gdbarch *gdbarch, struct value *function, type = value_type (args[0]); /* First argument is passed in D and X registers. */ - if (TYPE_LENGTH (type) <= 4) + if (type->length () <= 4) { ULONGEST v; v = extract_unsigned_integer (value_contents (args[0]).data (), - TYPE_LENGTH (type), byte_order); + type->length (), byte_order); first_stack_argnum = 1; regcache_cooked_write_unsigned (regcache, HARD_D_REGNUM, v); - if (TYPE_LENGTH (type) > 2) + if (type->length () > 2) { v >>= 16; regcache_cooked_write_unsigned (regcache, HARD_X_REGNUM, v); @@ -1197,7 +1197,7 @@ m68hc11_push_dummy_call (struct gdbarch *gdbarch, struct value *function, { type = value_type (args[argnum]); - if (TYPE_LENGTH (type) & 1) + if (type->length () & 1) { static gdb_byte zero = 0; @@ -1205,8 +1205,8 @@ m68hc11_push_dummy_call (struct gdbarch *gdbarch, struct value *function, write_memory (sp, &zero, 1); } val = value_contents (args[argnum]).data (); - sp -= TYPE_LENGTH (type); - write_memory (sp, val, TYPE_LENGTH (type)); + sp -= type->length (); + write_memory (sp, val, type->length ()); } /* Store return address. */ @@ -1255,7 +1255,7 @@ m68hc11_store_return_value (struct type *type, struct regcache *regcache, { int len; - len = TYPE_LENGTH (type); + len = type->length (); /* First argument is passed in D and X registers. */ if (len <= 2) @@ -1280,7 +1280,7 @@ m68hc11_extract_return_value (struct type *type, struct regcache *regcache, gdb_byte buf[M68HC11_REG_SIZE]; regcache->raw_read (HARD_D_REGNUM, buf); - switch (TYPE_LENGTH (type)) + switch (type->length ()) { case 1: memcpy (valbuf, buf + 1, 1); @@ -1315,7 +1315,7 @@ m68hc11_return_value (struct gdbarch *gdbarch, struct value *function, if (valtype->code () == TYPE_CODE_STRUCT || valtype->code () == TYPE_CODE_UNION || valtype->code () == TYPE_CODE_ARRAY - || TYPE_LENGTH (valtype) > 4) + || valtype->length () > 4) return RETURN_VALUE_STRUCT_CONVENTION; else { diff --git a/gdb/m68k-bsd-tdep.c b/gdb/m68k-bsd-tdep.c index 2614c22..b4d991c 100644 --- a/gdb/m68k-bsd-tdep.c +++ b/gdb/m68k-bsd-tdep.c @@ -41,7 +41,7 @@ int m68kbsd_fpreg_offset (struct gdbarch *gdbarch, int regnum) { - int fp_len = TYPE_LENGTH (gdbarch_register_type (gdbarch, regnum)); + int fp_len = gdbarch_register_type (gdbarch, regnum)->length (); if (regnum >= M68K_FPC_REGNUM) return 8 * fp_len + (regnum - M68K_FPC_REGNUM) * 4; diff --git a/gdb/m68k-tdep.c b/gdb/m68k-tdep.c index 4f96c78..f16e1d3 100644 --- a/gdb/m68k-tdep.c +++ b/gdb/m68k-tdep.c @@ -294,7 +294,7 @@ static void m68k_extract_return_value (struct type *type, struct regcache *regcache, gdb_byte *valbuf) { - int len = TYPE_LENGTH (type); + int len = type->length (); gdb_byte buf[M68K_MAX_REGISTER_SIZE]; if (type->code () == TYPE_CODE_PTR && len == 4) @@ -343,7 +343,7 @@ static void m68k_store_return_value (struct type *type, struct regcache *regcache, const gdb_byte *valbuf) { - int len = TYPE_LENGTH (type); + int len = type->length (); if (type->code () == TYPE_CODE_PTR && len == 4) { @@ -393,7 +393,7 @@ m68k_reg_struct_return_p (struct gdbarch *gdbarch, struct type *type) { m68k_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); enum type_code code = type->code (); - int len = TYPE_LENGTH (type); + int len = type->length (); gdb_assert (code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION || code == TYPE_CODE_COMPLEX || code == TYPE_CODE_ARRAY); @@ -438,7 +438,7 @@ m68k_return_value (struct gdbarch *gdbarch, struct value *function, if (((code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION || code == TYPE_CODE_COMPLEX || code == TYPE_CODE_ARRAY) && !m68k_reg_struct_return_p (gdbarch, type)) - || (code == TYPE_CODE_FLT && TYPE_LENGTH (type) == 12)) + || (code == TYPE_CODE_FLT && type->length () == 12)) { /* The default on m68k is to return structures in static memory. Consequently a function must return the address where we can @@ -449,7 +449,7 @@ m68k_return_value (struct gdbarch *gdbarch, struct value *function, ULONGEST addr; regcache_raw_read_unsigned (regcache, M68K_D0_REGNUM, &addr); - read_memory (addr, readbuf, TYPE_LENGTH (type)); + read_memory (addr, readbuf, type->length ()); } return RETURN_VALUE_ABI_RETURNS_ADDRESS; @@ -487,7 +487,7 @@ m68k_svr4_return_value (struct gdbarch *gdbarch, struct value *function, /* GCC may return a `long double' in memory too. */ || (!tdep->float_return && code == TYPE_CODE_FLT - && TYPE_LENGTH (type) == 12)) + && type->length () == 12)) { /* The System V ABI says that: @@ -509,7 +509,7 @@ m68k_svr4_return_value (struct gdbarch *gdbarch, struct value *function, regcache_raw_read_unsigned (regcache, tdep->pointer_result_regnum, &addr); - read_memory (addr, readbuf, TYPE_LENGTH (type)); + read_memory (addr, readbuf, type->length ()); } return RETURN_VALUE_ABI_RETURNS_ADDRESS; @@ -550,7 +550,7 @@ m68k_push_dummy_call (struct gdbarch *gdbarch, struct value *function, for (i = nargs - 1; i >= 0; i--) { struct type *value_type = value_enclosing_type (args[i]); - int len = TYPE_LENGTH (value_type); + int len = value_type->length (); int container_len = (len + 3) & ~3; int offset; diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index 56710cf..c547e23 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -1041,8 +1041,8 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend, are hopefully rare enough. Alpha cc -migrate has a sh.value field of zero, we adjust that too. */ - if (TYPE_LENGTH (t) == t->num_fields () - || TYPE_LENGTH (t) == 0) + if (t->length () == t->num_fields () + || t->length () == 0) t->set_length (gdbarch_int_bit (gdbarch) / HOST_CHAR_BIT); for (ext_tsym = ext_sh + external_sym_size; ; @@ -1869,7 +1869,7 @@ upgrade_type (int fd, struct type **tpp, int tq, union aux_ext *ax, int bigend, dbx seems to ignore it too. */ /* TYPE_TARGET_STUB now takes care of the zero TYPE_LENGTH problem. */ - if (TYPE_LENGTH (*tpp) == 0) + if ((*tpp)->length () == 0) t->set_target_is_stub (true); *tpp = t; diff --git a/gdb/mep-tdep.c b/gdb/mep-tdep.c index 66b7656..555eb5e 100644 --- a/gdb/mep-tdep.c +++ b/gdb/mep-tdep.c @@ -1131,8 +1131,8 @@ mep_pseudo_cr32_read (struct gdbarch *gdbarch, int rawnum = mep_pseudo_to_raw[cookednum]; gdb_byte buf64[8]; - gdb_assert (TYPE_LENGTH (register_type (gdbarch, rawnum)) == sizeof (buf64)); - gdb_assert (TYPE_LENGTH (register_type (gdbarch, cookednum)) == 4); + gdb_assert (register_type (gdbarch, rawnum)->length () == sizeof (buf64)); + gdb_assert (register_type (gdbarch, cookednum)->length () == 4); status = regcache->raw_read (rawnum, buf64); if (status == REG_VALID) { @@ -1217,8 +1217,8 @@ mep_pseudo_cr32_write (struct gdbarch *gdbarch, int rawnum = mep_pseudo_to_raw[cookednum]; gdb_byte buf64[8]; - gdb_assert (TYPE_LENGTH (register_type (gdbarch, rawnum)) == sizeof (buf64)); - gdb_assert (TYPE_LENGTH (register_type (gdbarch, cookednum)) == 4); + gdb_assert (register_type (gdbarch, rawnum)->length () == sizeof (buf64)); + gdb_assert (register_type (gdbarch, cookednum)->length () == 4); /* Slow, but legible. */ store_unsigned_integer (buf64, 8, byte_order, extract_unsigned_integer (buf, 4, byte_order)); @@ -2075,7 +2075,7 @@ static const struct frame_unwind mep_frame_unwind = { static int mep_use_struct_convention (struct type *type) { - return (TYPE_LENGTH (type) > MEP_GPR_SIZE); + return (type->length () > MEP_GPR_SIZE); } @@ -2094,15 +2094,15 @@ mep_extract_return_value (struct gdbarch *arch, /* Return values > MEP_GPR_SIZE bytes are returned in memory, pointed to by R0. */ - gdb_assert (TYPE_LENGTH (type) <= MEP_GPR_SIZE); + gdb_assert (type->length () <= MEP_GPR_SIZE); if (byte_order == BFD_ENDIAN_BIG) - offset = MEP_GPR_SIZE - TYPE_LENGTH (type); + offset = MEP_GPR_SIZE - type->length (); else offset = 0; /* Return values that do fit in a single register are returned in R0. */ - regcache->cooked_read_part (MEP_R0_REGNUM, offset, TYPE_LENGTH (type), + regcache->cooked_read_part (MEP_R0_REGNUM, offset, type->length (), valbuf); } @@ -2116,7 +2116,7 @@ mep_store_return_value (struct gdbarch *arch, int byte_order = gdbarch_byte_order (arch); /* Values that fit in a single register go in R0. */ - if (TYPE_LENGTH (type) <= MEP_GPR_SIZE) + if (type->length () <= MEP_GPR_SIZE) { /* Values that don't occupy a full register appear at the least significant end of the value. This is the offset to where the @@ -2124,11 +2124,11 @@ mep_store_return_value (struct gdbarch *arch, int offset; if (byte_order == BFD_ENDIAN_BIG) - offset = MEP_GPR_SIZE - TYPE_LENGTH (type); + offset = MEP_GPR_SIZE - type->length (); else offset = 0; - regcache->cooked_write_part (MEP_R0_REGNUM, offset, TYPE_LENGTH (type), + regcache->cooked_write_part (MEP_R0_REGNUM, offset, type->length (), valbuf); } @@ -2156,7 +2156,7 @@ mep_return_value (struct gdbarch *gdbarch, struct value *function, returned in R0. Fetch R0's value and then read the memory at that address. */ regcache_raw_read_unsigned (regcache, MEP_R0_REGNUM, &addr); - read_memory (addr, readbuf, TYPE_LENGTH (type)); + read_memory (addr, readbuf, type->length ()); } if (writebuf) { @@ -2228,7 +2228,7 @@ push_large_arguments (CORE_ADDR sp, int argc, struct value **argv, for (i = 0; i < argc; i++) { - unsigned arg_len = TYPE_LENGTH (value_type (argv[i])); + unsigned arg_len = value_type (argv[i])->length (); if (arg_len > MEP_GPR_SIZE) { @@ -2288,9 +2288,9 @@ mep_push_dummy_call (struct gdbarch *gdbarch, struct value *function, ULONGEST value; /* Arguments that fit in a GPR get expanded to fill the GPR. */ - if (TYPE_LENGTH (value_type (argv[i])) <= MEP_GPR_SIZE) + if (value_type (argv[i])->length () <= MEP_GPR_SIZE) value = extract_unsigned_integer (value_contents (argv[i]).data (), - TYPE_LENGTH (value_type (argv[i])), + value_type (argv[i])->length (), byte_order); /* Arguments too large to fit in a GPR get copied to the stack, diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c index 0fe204d..70c51e6 100644 --- a/gdb/mi/mi-cmd-stack.c +++ b/gdb/mi/mi-cmd-stack.c @@ -508,7 +508,7 @@ list_arg_or_local (const struct frame_arg *arg, enum what_to_list what, || (val_print_scalar_type_p (value_type (arg->val)) && !value_bytes_available (arg->val, value_embedded_offset (arg->val), - TYPE_LENGTH (value_type (arg->val)))))) + value_type (arg->val)->length ())))) return; gdb::optional tuple_emitter; diff --git a/gdb/microblaze-tdep.c b/gdb/microblaze-tdep.c index 3525453..ad8d0fd 100644 --- a/gdb/microblaze-tdep.c +++ b/gdb/microblaze-tdep.c @@ -516,7 +516,7 @@ microblaze_extract_return_value (struct type *type, struct regcache *regcache, gdb_byte buf[8]; /* Copy the return value (starting) in RETVAL_REGNUM to VALBUF. */ - switch (TYPE_LENGTH (type)) + switch (type->length ()) { case 1: /* return last byte in the register. */ regcache->cooked_read (MICROBLAZE_RETVAL_REGNUM, buf); @@ -530,7 +530,7 @@ microblaze_extract_return_value (struct type *type, struct regcache *regcache, case 8: regcache->cooked_read (MICROBLAZE_RETVAL_REGNUM, buf); regcache->cooked_read (MICROBLAZE_RETVAL_REGNUM + 1, buf+4); - memcpy (valbuf, buf, TYPE_LENGTH (type)); + memcpy (valbuf, buf, type->length ()); return; default: internal_error (__FILE__, __LINE__, @@ -552,7 +552,7 @@ static void microblaze_store_return_value (struct type *type, struct regcache *regcache, const gdb_byte *valbuf) { - int len = TYPE_LENGTH (type); + int len = type->length (); gdb_byte buf[8]; memset (buf, 0, sizeof(buf)); @@ -588,7 +588,7 @@ microblaze_return_value (struct gdbarch *gdbarch, struct value *function, static int microblaze_stabs_argument_has_addr (struct gdbarch *gdbarch, struct type *type) { - return (TYPE_LENGTH (type) == 16); + return (type->length () == 16); } diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c index 9827026..14f5c3e 100644 --- a/gdb/mips-tdep.c +++ b/gdb/mips-tdep.c @@ -916,7 +916,7 @@ mips_convert_register_float_case_p (struct gdbarch *gdbarch, int regnum, return (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG && register_size (gdbarch, regnum) == 4 && mips_float_register_p (gdbarch, regnum) - && type->code () == TYPE_CODE_FLT && TYPE_LENGTH (type) == 8); + && type->code () == TYPE_CODE_FLT && type->length () == 8); } /* This predicate tests for the case of a value of less than 8 @@ -930,7 +930,7 @@ mips_convert_register_gpreg_case_p (struct gdbarch *gdbarch, int regnum, return (register_size (gdbarch, regnum) == 8 && regnum % num_regs > 0 && regnum % num_regs < 32 - && TYPE_LENGTH (type) < 8); + && type->length () < 8); } static int @@ -965,7 +965,7 @@ mips_register_to_value (struct frame_info *frame, int regnum, } else if (mips_convert_register_gpreg_case_p (gdbarch, regnum, type)) { - size_t len = TYPE_LENGTH (type); + size_t len = type->length (); CORE_ADDR offset; offset = gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG ? 8 - len : 0; @@ -997,7 +997,7 @@ mips_value_to_register (struct frame_info *frame, int regnum, else if (mips_convert_register_gpreg_case_p (gdbarch, regnum, type)) { gdb_byte fill[8]; - size_t len = TYPE_LENGTH (type); + size_t len = type->length (); /* Sign extend values, irrespective of type, that are stored to a 64-bit general purpose register. (32-bit unsigned values @@ -1103,7 +1103,7 @@ mips_pseudo_register_type (struct gdbarch *gdbarch, int regnum) /* Absent registers are still absent. */ rawtype = gdbarch_register_type (gdbarch, rawnum); - if (TYPE_LENGTH (rawtype) == 0) + if (rawtype->length () == 0) return rawtype; /* Present the floating point registers however the hardware did; @@ -1121,7 +1121,7 @@ mips_pseudo_register_type (struct gdbarch *gdbarch, int regnum) /* Use pointer types for registers if we can. For n32 we can not, since we do not have a 64-bit pointer type. */ if (mips_abi_regsize (gdbarch) - == TYPE_LENGTH (builtin_type (gdbarch)->builtin_data_ptr)) + == builtin_type (gdbarch)->builtin_data_ptr->length()) { if (rawnum == MIPS_SP_REGNUM || rawnum == mips_regnum (gdbarch)->badvaddr) @@ -1130,7 +1130,7 @@ mips_pseudo_register_type (struct gdbarch *gdbarch, int regnum) return builtin_type (gdbarch)->builtin_func_ptr; } - if (mips_abi_regsize (gdbarch) == 4 && TYPE_LENGTH (rawtype) == 8 + if (mips_abi_regsize (gdbarch) == 4 && rawtype->length () == 8 && ((rawnum >= MIPS_ZERO_REGNUM && rawnum <= MIPS_PS_REGNUM) || rawnum == mips_regnum (gdbarch)->lo || rawnum == mips_regnum (gdbarch)->hi @@ -4453,7 +4453,7 @@ mips_type_needs_double_align (struct type *type) { enum type_code typecode = type->code (); - if (typecode == TYPE_CODE_FLT && TYPE_LENGTH (type) == 8) + if (typecode == TYPE_CODE_FLT && type->length () == 8) return 1; else if (typecode == TYPE_CODE_STRUCT) { @@ -4558,7 +4558,8 @@ mips_eabi_push_dummy_call (struct gdbarch *gdbarch, struct value *function, than necessary for EABI, because the first few arguments are passed in registers, but that's OK. */ for (argnum = 0; argnum < nargs; argnum++) - arg_space += align_up (TYPE_LENGTH (value_type (args[argnum])), abi_regsize); + arg_space += align_up (value_type (args[argnum])->length (), + abi_regsize); sp -= align_up (arg_space, 16); if (mips_debug) @@ -4593,7 +4594,7 @@ mips_eabi_push_dummy_call (struct gdbarch *gdbarch, struct value *function, gdb_byte ref_valbuf[MAX_MIPS_ABI_REGSIZE]; struct value *arg = args[argnum]; struct type *arg_type = check_typedef (value_type (arg)); - int len = TYPE_LENGTH (arg_type); + int len = arg_type->length (); enum type_code typecode = arg_type->code (); if (mips_debug) @@ -4727,7 +4728,7 @@ mips_eabi_push_dummy_call (struct gdbarch *gdbarch, struct value *function, longword_offset = abi_regsize - len; else if ((typecode == TYPE_CODE_STRUCT || typecode == TYPE_CODE_UNION) - && TYPE_LENGTH (arg_type) < abi_regsize) + && arg_type->length () < abi_regsize) longword_offset = abi_regsize - len; } @@ -4808,7 +4809,7 @@ mips_eabi_return_value (struct gdbarch *gdbarch, struct value *function, int fp_return_type = 0; int offset, regnum, xfer; - if (TYPE_LENGTH (type) > 2 * mips_abi_regsize (gdbarch)) + if (type->length () > 2 * mips_abi_regsize (gdbarch)) return RETURN_VALUE_STRUCT_CONVENTION; /* Floating point type? */ @@ -4845,12 +4846,12 @@ mips_eabi_return_value (struct gdbarch *gdbarch, struct value *function, regnum = MIPS_V0_REGNUM; } for (offset = 0; - offset < TYPE_LENGTH (type); + offset < type->length (); offset += mips_abi_regsize (gdbarch), regnum++) { xfer = mips_abi_regsize (gdbarch); - if (offset + xfer > TYPE_LENGTH (type)) - xfer = TYPE_LENGTH (type) - offset; + if (offset + xfer > type->length ()) + xfer = type->length () - offset; mips_xfer_register (gdbarch, regcache, gdbarch_num_regs (gdbarch) + regnum, xfer, gdbarch_byte_order (gdbarch), readbuf, writebuf, @@ -4879,7 +4880,7 @@ mips_n32n64_fp_arg_chunk_p (struct gdbarch *gdbarch, struct type *arg_type, if (mips_get_fpu_type (gdbarch) != MIPS_FPU_DOUBLE) return 0; - if (TYPE_LENGTH (arg_type) < offset + MIPS64_REGSIZE) + if (arg_type->length () < offset + MIPS64_REGSIZE) return 0; for (i = 0; i < arg_type->num_fields (); i++) @@ -4901,12 +4902,12 @@ mips_n32n64_fp_arg_chunk_p (struct gdbarch *gdbarch, struct type *arg_type, /* If this field is entirely before the requested offset, go on to the next one. */ - if (pos + TYPE_LENGTH (field_type) <= offset) + if (pos + field_type->length () <= offset) continue; /* If this is our special aligned double, we can stop. */ if (field_type->code () == TYPE_CODE_FLT - && TYPE_LENGTH (field_type) == MIPS64_REGSIZE) + && field_type->length () == MIPS64_REGSIZE) return 1; /* This field starts at or before the requested offset, and @@ -4951,7 +4952,8 @@ mips_n32n64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, /* Now make space on the stack for the args. */ for (argnum = 0; argnum < nargs; argnum++) - arg_space += align_up (TYPE_LENGTH (value_type (args[argnum])), MIPS64_REGSIZE); + arg_space += align_up (value_type (args[argnum])->length (), + MIPS64_REGSIZE); sp -= align_up (arg_space, 16); if (mips_debug) @@ -4983,7 +4985,7 @@ mips_n32n64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, const gdb_byte *val; struct value *arg = args[argnum]; struct type *arg_type = check_typedef (value_type (arg)); - int len = TYPE_LENGTH (arg_type); + int len = arg_type->length (); enum type_code typecode = arg_type->code (); if (mips_debug) @@ -5153,7 +5155,7 @@ mips_n32n64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, regcache_cooked_write_unsigned (regcache, argreg, regval); if (mips_n32n64_fp_arg_chunk_p (gdbarch, arg_type, - TYPE_LENGTH (arg_type) - len)) + arg_type->length () - len)) { if (mips_debug) gdb_printf (gdb_stdlog, " - fpreg=%d val=%s", @@ -5230,10 +5232,10 @@ mips_n32n64_return_value (struct gdbarch *gdbarch, struct value *function, ($f0) and complex type function ($f0 has the real part, $f2 has the imaginary part.) */ - if (TYPE_LENGTH (type) > 2 * MIPS64_REGSIZE) + if (type->length () > 2 * MIPS64_REGSIZE) return RETURN_VALUE_STRUCT_CONVENTION; else if ((type->code () == TYPE_CODE_COMPLEX - || (type->code () == TYPE_CODE_FLT && TYPE_LENGTH (type) == 16)) + || (type->code () == TYPE_CODE_FLT && type->length () == 16)) && tdep->mips_fpu_type != MIPS_FPU_NONE) { /* A complex value of up to 128 bits in width as well as a 128-bit @@ -5246,15 +5248,15 @@ mips_n32n64_return_value (struct gdbarch *gdbarch, struct value *function, mips_xfer_register (gdbarch, regcache, (gdbarch_num_regs (gdbarch) + mips_regnum (gdbarch)->fp0), - TYPE_LENGTH (type) / 2, gdbarch_byte_order (gdbarch), + type->length () / 2, gdbarch_byte_order (gdbarch), readbuf, writebuf, 0); mips_xfer_register (gdbarch, regcache, (gdbarch_num_regs (gdbarch) + mips_regnum (gdbarch)->fp0 + 2), - TYPE_LENGTH (type) / 2, gdbarch_byte_order (gdbarch), - readbuf ? readbuf + TYPE_LENGTH (type) / 2 : readbuf, + type->length () / 2, gdbarch_byte_order (gdbarch), + readbuf ? readbuf + type->length () / 2 : readbuf, (writebuf - ? writebuf + TYPE_LENGTH (type) / 2 : writebuf), 0); + ? writebuf + type->length () / 2 : writebuf), 0); return RETURN_VALUE_REGISTER_CONVENTION; } else if (type->code () == TYPE_CODE_FLT @@ -5266,7 +5268,7 @@ mips_n32n64_return_value (struct gdbarch *gdbarch, struct value *function, mips_xfer_register (gdbarch, regcache, (gdbarch_num_regs (gdbarch) + mips_regnum (gdbarch)->fp0), - TYPE_LENGTH (type), + type->length (), gdbarch_byte_order (gdbarch), readbuf, writebuf, 0); return RETURN_VALUE_REGISTER_CONVENTION; @@ -5297,7 +5299,7 @@ mips_n32n64_return_value (struct gdbarch *gdbarch, struct value *function, if (mips_debug) gdb_printf (gdb_stderr, "Return float struct+%d\n", offset); - if (TYPE_LENGTH (type->field (field).type ()) == 16) + if (type->field (field).type ()->length () == 16) { /* A 16-byte long double field goes in two consecutive registers. */ @@ -5315,7 +5317,7 @@ mips_n32n64_return_value (struct gdbarch *gdbarch, struct value *function, else mips_xfer_register (gdbarch, regcache, gdbarch_num_regs (gdbarch) + regnum, - TYPE_LENGTH (type->field (field).type ()), + type->field (field).type ()->length (), gdbarch_byte_order (gdbarch), readbuf, writebuf, offset); } @@ -5331,12 +5333,12 @@ mips_n32n64_return_value (struct gdbarch *gdbarch, struct value *function, int offset; int regnum; for (offset = 0, regnum = MIPS_V0_REGNUM; - offset < TYPE_LENGTH (type); + offset < type->length (); offset += register_size (gdbarch, regnum), regnum++) { int xfer = register_size (gdbarch, regnum); - if (offset + xfer > TYPE_LENGTH (type)) - xfer = TYPE_LENGTH (type) - offset; + if (offset + xfer > type->length ()) + xfer = type->length () - offset; if (mips_debug) gdb_printf (gdb_stderr, "Return struct+%d:%d in $%d\n", offset, xfer, regnum); @@ -5354,12 +5356,12 @@ mips_n32n64_return_value (struct gdbarch *gdbarch, struct value *function, int offset; int regnum; for (offset = 0, regnum = MIPS_V0_REGNUM; - offset < TYPE_LENGTH (type); + offset < type->length (); offset += register_size (gdbarch, regnum), regnum++) { int xfer = register_size (gdbarch, regnum); - if (offset + xfer > TYPE_LENGTH (type)) - xfer = TYPE_LENGTH (type) - offset; + if (offset + xfer > type->length ()) + xfer = type->length () - offset; if (mips_debug) gdb_printf (gdb_stderr, "Return scalar+%d:%d in $%d\n", offset, xfer, regnum); @@ -5429,7 +5431,7 @@ mips_o32_push_dummy_call (struct gdbarch *gdbarch, struct value *function, if (mips_type_needs_double_align (arg_type)) arg_space = align_up (arg_space, MIPS32_REGSIZE * 2); /* Allocate space on the stack. */ - arg_space += align_up (TYPE_LENGTH (arg_type), MIPS32_REGSIZE); + arg_space += align_up (arg_type->length (), MIPS32_REGSIZE); } sp -= align_up (arg_space, 16); @@ -5463,7 +5465,7 @@ mips_o32_push_dummy_call (struct gdbarch *gdbarch, struct value *function, const gdb_byte *val; struct value *arg = args[argnum]; struct type *arg_type = check_typedef (value_type (arg)); - int len = TYPE_LENGTH (arg_type); + int len = arg_type->length (); enum type_code typecode = arg_type->code (); if (mips_debug) @@ -5713,7 +5715,7 @@ mips_o32_return_value (struct gdbarch *gdbarch, struct value *function, || type->code () == TYPE_CODE_ARRAY) return RETURN_VALUE_STRUCT_CONVENTION; else if (type->code () == TYPE_CODE_FLT - && TYPE_LENGTH (type) == 4 && tdep->mips_fpu_type != MIPS_FPU_NONE) + && type->length () == 4 && tdep->mips_fpu_type != MIPS_FPU_NONE) { /* A single-precision floating-point value. If reading in or copying, then we get it from/put it to FP0 for standard MIPS code or GPR2 @@ -5738,19 +5740,19 @@ mips_o32_return_value (struct gdbarch *gdbarch, struct value *function, mips_xfer_register (gdbarch, regcache, (gdbarch_num_regs (gdbarch) + mips_regnum (gdbarch)->fp0), - TYPE_LENGTH (type), + type->length (), gdbarch_byte_order (gdbarch), readbuf, writebuf, 0); if (fval_reg != mips_fval_fpr) mips_xfer_register (gdbarch, regcache, gdbarch_num_regs (gdbarch) + 2, - TYPE_LENGTH (type), + type->length (), gdbarch_byte_order (gdbarch), readbuf, writebuf, 0); return RETURN_VALUE_REGISTER_CONVENTION; } else if (type->code () == TYPE_CODE_FLT - && TYPE_LENGTH (type) == 8 && tdep->mips_fpu_type != MIPS_FPU_NONE) + && type->length () == 8 && tdep->mips_fpu_type != MIPS_FPU_NONE) { /* A double-precision floating-point value. If reading in or copying, then we get it from/put it to FP1 and FP0 for standard MIPS code or @@ -5867,12 +5869,12 @@ mips_o32_return_value (struct gdbarch *gdbarch, struct value *function, int offset; int regnum; for (offset = 0, regnum = MIPS_V0_REGNUM; - offset < TYPE_LENGTH (type); + offset < type->length (); offset += register_size (gdbarch, regnum), regnum++) { int xfer = register_size (gdbarch, regnum); - if (offset + xfer > TYPE_LENGTH (type)) - xfer = TYPE_LENGTH (type) - offset; + if (offset + xfer > type->length ()) + xfer = type->length () - offset; if (mips_debug) gdb_printf (gdb_stderr, "Return struct+%d:%d in $%d\n", offset, xfer, regnum); @@ -5891,12 +5893,12 @@ mips_o32_return_value (struct gdbarch *gdbarch, struct value *function, int offset; int regnum; for (offset = 0, regnum = MIPS_V0_REGNUM; - offset < TYPE_LENGTH (type); + offset < type->length (); offset += MIPS32_REGSIZE, regnum++) { int xfer = MIPS32_REGSIZE; - if (offset + xfer > TYPE_LENGTH (type)) - xfer = TYPE_LENGTH (type) - offset; + if (offset + xfer > type->length ()) + xfer = type->length () - offset; if (mips_debug) gdb_printf (gdb_stderr, "Return scalar+%d:%d in $%d\n", offset, xfer, regnum); @@ -5950,7 +5952,7 @@ mips_o64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, struct type *arg_type = check_typedef (value_type (args[argnum])); /* Allocate space on the stack. */ - arg_space += align_up (TYPE_LENGTH (arg_type), MIPS64_REGSIZE); + arg_space += align_up (arg_type->length (), MIPS64_REGSIZE); } sp -= align_up (arg_space, 16); @@ -5984,7 +5986,7 @@ mips_o64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, const gdb_byte *val; struct value *arg = args[argnum]; struct type *arg_type = check_typedef (value_type (arg)); - int len = TYPE_LENGTH (arg_type); + int len = arg_type->length (); enum type_code typecode = arg_type->code (); if (mips_debug) @@ -6182,13 +6184,13 @@ mips_o64_return_value (struct gdbarch *gdbarch, struct value *function, mips_xfer_register (gdbarch, regcache, (gdbarch_num_regs (gdbarch) + mips_regnum (gdbarch)->fp0), - TYPE_LENGTH (type), + type->length (), gdbarch_byte_order (gdbarch), readbuf, writebuf, 0); if (fval_reg != mips_fval_fpr) mips_xfer_register (gdbarch, regcache, gdbarch_num_regs (gdbarch) + 2, - TYPE_LENGTH (type), + type->length (), gdbarch_byte_order (gdbarch), readbuf, writebuf, 0); return RETURN_VALUE_REGISTER_CONVENTION; @@ -6200,12 +6202,12 @@ mips_o64_return_value (struct gdbarch *gdbarch, struct value *function, int offset; int regnum; for (offset = 0, regnum = MIPS_V0_REGNUM; - offset < TYPE_LENGTH (type); + offset < type->length (); offset += MIPS64_REGSIZE, regnum++) { int xfer = MIPS64_REGSIZE; - if (offset + xfer > TYPE_LENGTH (type)) - xfer = TYPE_LENGTH (type) - offset; + if (offset + xfer > type->length ()) + xfer = type->length () - offset; if (mips_debug) gdb_printf (gdb_stderr, "Return scalar+%d:%d in $%d\n", offset, xfer, regnum); @@ -7968,7 +7970,7 @@ mips_integer_to_address (struct gdbarch *gdbarch, struct type *type, const gdb_byte *buf) { enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); - return extract_signed_integer (buf, TYPE_LENGTH (type), byte_order); + return extract_signed_integer (buf, type->length (), byte_order); } /* Dummy virtual frame pointer method. This is no more or less accurate diff --git a/gdb/mn10300-tdep.c b/gdb/mn10300-tdep.c index 22511d8..9f690a4 100644 --- a/gdb/mn10300-tdep.c +++ b/gdb/mn10300-tdep.c @@ -100,10 +100,10 @@ mn10300_type_align (struct type *type) case TYPE_CODE_PTR: case TYPE_CODE_REF: case TYPE_CODE_RVALUE_REF: - return TYPE_LENGTH (type); + return type->length (); case TYPE_CODE_COMPLEX: - return TYPE_LENGTH (type) / 2; + return type->length () / 2; case TYPE_CODE_STRUCT: case TYPE_CODE_UNION: @@ -134,7 +134,7 @@ mn10300_use_struct_convention (struct type *type) { /* Structures bigger than a pair of words can't be returned in registers. */ - if (TYPE_LENGTH (type) > 8) + if (type->length () > 8) return 1; switch (type->code ()) @@ -171,7 +171,7 @@ static void mn10300_store_return_value (struct gdbarch *gdbarch, struct type *type, struct regcache *regcache, const gdb_byte *valbuf) { - int len = TYPE_LENGTH (type); + int len = type->length (); int reg, regsz; if (type->code () == TYPE_CODE_PTR) @@ -199,7 +199,7 @@ mn10300_extract_return_value (struct gdbarch *gdbarch, struct type *type, struct regcache *regcache, void *valbuf) { gdb_byte buf[MN10300_MAX_REGISTER_SIZE]; - int len = TYPE_LENGTH (type); + int len = type->length (); int reg, regsz; if (type->code () == TYPE_CODE_PTR) @@ -1185,7 +1185,7 @@ mn10300_push_dummy_call (struct gdbarch *gdbarch, regs_used = (return_method == return_method_struct) ? 1 : 0; for (len = 0, argnum = 0; argnum < nargs; argnum++) { - arg_len = (TYPE_LENGTH (value_type (args[argnum])) + 3) & ~3; + arg_len = (value_type (args[argnum])->length () + 3) & ~3; while (regs_used < 2 && arg_len > 0) { regs_used++; @@ -1210,7 +1210,7 @@ mn10300_push_dummy_call (struct gdbarch *gdbarch, { /* FIXME what about structs? Unions? */ if (value_type (*args)->code () == TYPE_CODE_STRUCT - && TYPE_LENGTH (value_type (*args)) > 8) + && value_type (*args)->length () > 8) { /* Change to pointer-to-type. */ arg_len = push_size; @@ -1221,7 +1221,7 @@ mn10300_push_dummy_call (struct gdbarch *gdbarch, } else { - arg_len = TYPE_LENGTH (value_type (*args)); + arg_len = value_type (*args)->length (); val = value_contents (*args).data (); } diff --git a/gdb/moxie-tdep.c b/gdb/moxie-tdep.c index 77e1c33..c11cb0f 100644 --- a/gdb/moxie-tdep.c +++ b/gdb/moxie-tdep.c @@ -111,7 +111,7 @@ moxie_store_return_value (struct type *type, struct regcache *regcache, struct gdbarch *gdbarch = regcache->arch (); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); CORE_ADDR regval; - int len = TYPE_LENGTH (type); + int len = type->length (); /* Things always get returned in RET1_REGNUM, RET2_REGNUM. */ regval = extract_unsigned_integer (valbuf, len > 4 ? 4 : len, byte_order); @@ -457,7 +457,7 @@ moxie_extract_return_value (struct type *type, struct regcache *regcache, { struct gdbarch *gdbarch = regcache->arch (); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); - int len = TYPE_LENGTH (type); + int len = type->length (); ULONGEST tmp; /* By using store_unsigned_integer we avoid having to do @@ -481,7 +481,7 @@ moxie_return_value (struct gdbarch *gdbarch, struct value *function, struct type *valtype, struct regcache *regcache, gdb_byte *readbuf, const gdb_byte *writebuf) { - if (TYPE_LENGTH (valtype) > 8) + if (valtype->length () > 8) return RETURN_VALUE_STRUCT_CONVENTION; else { diff --git a/gdb/msp430-tdep.c b/gdb/msp430-tdep.c index 67800a2..2abc7cf 100644 --- a/gdb/msp430-tdep.c +++ b/gdb/msp430-tdep.c @@ -569,11 +569,11 @@ msp430_return_value (struct gdbarch *gdbarch, gdb_byte *readbuf, const gdb_byte *writebuf) { enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); - LONGEST valtype_len = TYPE_LENGTH (valtype); + LONGEST valtype_len = valtype->length (); msp430_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); int code_model = tdep->code_model; - if (TYPE_LENGTH (valtype) > 8 + if (valtype->length () > 8 || valtype->code () == TYPE_CODE_STRUCT || valtype->code () == TYPE_CODE_UNION) return RETURN_VALUE_STRUCT_CONVENTION; @@ -689,7 +689,7 @@ msp430_push_dummy_call (struct gdbarch *gdbarch, struct value *function, struct value *arg = args[i]; const gdb_byte *arg_bits = value_contents_all (arg).data (); struct type *arg_type = check_typedef (value_type (arg)); - ULONGEST arg_size = TYPE_LENGTH (arg_type); + ULONGEST arg_size = arg_type->length (); int offset; int current_arg_on_stack; gdb_byte struct_addr_buf[4]; diff --git a/gdb/nds32-tdep.c b/gdb/nds32-tdep.c index 5b55523..23e9ada 100644 --- a/gdb/nds32-tdep.c +++ b/gdb/nds32-tdep.c @@ -1453,7 +1453,7 @@ nds32_push_dummy_call (struct gdbarch *gdbarch, struct value *function, if (align == 0) continue; - sp -= TYPE_LENGTH (type); + sp -= type->length (); sp = align_down (sp, align); } @@ -1471,7 +1471,7 @@ nds32_push_dummy_call (struct gdbarch *gdbarch, struct value *function, type = value_type (args[i]); calling_use_fpr = nds32_check_calling_use_fpr (type); - len = TYPE_LENGTH (type); + len = type->length (); align = type_align (type); val = value_contents (args[i]).data (); @@ -1658,7 +1658,7 @@ nds32_extract_return_value (struct gdbarch *gdbarch, struct type *type, int len; calling_use_fpr = nds32_check_calling_use_fpr (type); - len = TYPE_LENGTH (type); + len = type->length (); if (abi_use_fpr && calling_use_fpr) { @@ -1748,7 +1748,7 @@ nds32_store_return_value (struct gdbarch *gdbarch, struct type *type, int len; calling_use_fpr = nds32_check_calling_use_fpr (type); - len = TYPE_LENGTH (type); + len = type->length (); if (abi_use_fpr && calling_use_fpr) { @@ -1809,7 +1809,7 @@ nds32_return_value (struct gdbarch *gdbarch, struct value *func_type, struct type *type, struct regcache *regcache, gdb_byte *readbuf, const gdb_byte *writebuf) { - if (TYPE_LENGTH (type) > 8) + if (type->length () > 8) { return RETURN_VALUE_STRUCT_CONVENTION; } diff --git a/gdb/netbsd-tdep.c b/gdb/netbsd-tdep.c index 49382ea..80d1322 100644 --- a/gdb/netbsd-tdep.c +++ b/gdb/netbsd-tdep.c @@ -410,27 +410,27 @@ nbsd_get_siginfo_type (struct gdbarch *gdbarch) type *uint32_type = builtin_type (gdbarch)->builtin_uint32; type *uint64_type = builtin_type (gdbarch)->builtin_uint64; - bool lp64 = TYPE_LENGTH (void_ptr_type) == 8; + bool lp64 = void_ptr_type->length () == 8; size_t char_bits = gdbarch_addressable_memory_unit_size (gdbarch) * 8; /* pid_t */ type *pid_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF, - TYPE_LENGTH (int32_type) * char_bits, "pid_t"); + int32_type->length () * char_bits, "pid_t"); pid_type->set_target_type (int32_type); /* uid_t */ type *uid_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF, - TYPE_LENGTH (uint32_type) * char_bits, "uid_t"); + uint32_type->length () * char_bits, "uid_t"); uid_type->set_target_type (uint32_type); /* clock_t */ type *clock_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF, - TYPE_LENGTH (int_type) * char_bits, "clock_t"); + int_type->length () * char_bits, "clock_t"); clock_type->set_target_type (int_type); /* lwpid_t */ type *lwpid_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF, - TYPE_LENGTH (int32_type) * char_bits, + int32_type->length () * char_bits, "lwpid_t"); lwpid_type->set_target_type (int32_type); diff --git a/gdb/nios2-tdep.c b/gdb/nios2-tdep.c index 0bad229b..ca03b95 100644 --- a/gdb/nios2-tdep.c +++ b/gdb/nios2-tdep.c @@ -205,7 +205,7 @@ static void nios2_extract_return_value (struct gdbarch *gdbarch, struct type *valtype, struct regcache *regcache, gdb_byte *valbuf) { - int len = TYPE_LENGTH (valtype); + int len = valtype->length (); /* Return values of up to 8 bytes are returned in $r2 $r3. */ if (len <= register_size (gdbarch, NIOS2_R2_REGNUM)) @@ -226,7 +226,7 @@ static void nios2_store_return_value (struct gdbarch *gdbarch, struct type *valtype, struct regcache *regcache, const gdb_byte *valbuf) { - int len = TYPE_LENGTH (valtype); + int len = valtype->length (); /* Return values of up to 8 bytes are returned in $r2 $r3. */ if (len <= register_size (gdbarch, NIOS2_R2_REGNUM)) @@ -1786,7 +1786,7 @@ nios2_return_value (struct gdbarch *gdbarch, struct value *function, struct type *type, struct regcache *regcache, gdb_byte *readbuf, const gdb_byte *writebuf) { - if (TYPE_LENGTH (type) > 8) + if (type->length () > 8) return RETURN_VALUE_STRUCT_CONVENTION; if (readbuf) @@ -1818,7 +1818,7 @@ nios2_push_dummy_call (struct gdbarch *gdbarch, struct value *function, /* Now make space on the stack for the args. */ for (argnum = 0; argnum < nargs; argnum++) - arg_space += align_up (TYPE_LENGTH (value_type (args[argnum])), 4); + arg_space += align_up (value_type (args[argnum])->length (), 4); sp -= arg_space; /* Initialize the register pointer. */ @@ -1837,7 +1837,7 @@ nios2_push_dummy_call (struct gdbarch *gdbarch, struct value *function, const gdb_byte *val; struct value *arg = args[argnum]; struct type *arg_type = check_typedef (value_type (arg)); - int len = TYPE_LENGTH (arg_type); + int len = arg_type->length (); val = value_contents (arg).data (); @@ -2255,7 +2255,7 @@ nios2_type_align (struct gdbarch *gdbarch, struct type *type) case TYPE_CODE_METHODPTR: case TYPE_CODE_MEMBERPTR: type = check_typedef (type); - return std::min (4, TYPE_LENGTH (type)); + return std::min (4, type->length ()); default: return 0; } diff --git a/gdb/objfiles.c b/gdb/objfiles.c index 31c27e9..09aba0f 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -1354,7 +1354,7 @@ objfile_int_type (struct objfile *of, int size_in_bytes, bool unsigned_p) int_type = (unsigned_p \ ? objfile_type (of)->builtin_unsigned_ ## F \ : objfile_type (of)->builtin_ ## F); \ - if (int_type != NULL && TYPE_LENGTH (int_type) == size_in_bytes) \ + if (int_type != NULL && int_type->length () == size_in_bytes) \ return int_type TRY_TYPE (char); diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c index 5bd3edb..c88b3fe 100644 --- a/gdb/opencl-lang.c +++ b/gdb/opencl-lang.c @@ -55,8 +55,8 @@ lookup_opencl_vector_type (struct gdbarch *gdbarch, enum type_code code, && get_array_bounds (type, &lowb, &highb) && type->target_type ()->code () == code && type->target_type ()->is_unsigned () == flag_unsigned - && TYPE_LENGTH (type->target_type ()) == el_length - && TYPE_LENGTH (type) == length + && type->target_type ()->length () == el_length + && type->length () == length && highb - lowb + 1 == n); }; const struct language_defn *lang = language_def (language_opencl); @@ -123,7 +123,7 @@ lval_func_read (struct value *v) struct type *type = check_typedef (value_type (v)); struct type *eltype = check_typedef (value_type (c->val))->target_type (); LONGEST offset = value_offset (v); - LONGEST elsize = TYPE_LENGTH (eltype); + LONGEST elsize = eltype->length (); int n, i, j = 0; LONGEST lowb = 0; LONGEST highb = 0; @@ -152,7 +152,7 @@ lval_func_write (struct value *v, struct value *fromval) struct type *type = check_typedef (value_type (v)); struct type *eltype = check_typedef (value_type (c->val))->target_type (); LONGEST offset = value_offset (v); - LONGEST elsize = TYPE_LENGTH (eltype); + LONGEST elsize = eltype->length (); int n, i, j = 0; LONGEST lowb = 0; LONGEST highb = 0; @@ -198,7 +198,7 @@ lval_func_check_synthetic_pointer (const struct value *v, struct lval_closure *c = (struct lval_closure *) value_computed_closure (v); /* Size of the target type in bits. */ int elsize = - TYPE_LENGTH (check_typedef (value_type (c->val))->target_type ()) * 8; + check_typedef (value_type (c->val))->target_type ()->length () * 8; int startrest = offset % elsize; int start = offset / elsize; int endrest = (offset + length) % elsize; @@ -289,7 +289,7 @@ create_value (struct gdbarch *gdbarch, struct value *val, enum noside noside, resulting type is a vector as well. */ struct type *dst_type = lookup_opencl_vector_type (gdbarch, elm_type->code (), - TYPE_LENGTH (elm_type), + elm_type->length (), elm_type->is_unsigned (), n); if (dst_type == NULL) @@ -316,10 +316,10 @@ create_value (struct gdbarch *gdbarch, struct value *val, enum noside noside, /* Copy src val contents into the destination value. */ for (i = 0; i < n; i++) memcpy (value_contents_writeable (ret).data () - + (i * TYPE_LENGTH (elm_type)), + + (i * elm_type->length ()), value_contents (val).data () - + (indices[i] * TYPE_LENGTH (elm_type)), - TYPE_LENGTH (elm_type)); + + (indices[i] * elm_type->length ()), + elm_type->length ()); } } } @@ -463,7 +463,7 @@ opencl_logical_not (struct type *expect_type, struct expression *exp, /* Determine the resulting type of the operation and allocate the value. */ rettype = lookup_opencl_vector_type (exp->gdbarch, TYPE_CODE_INT, - TYPE_LENGTH (eltype), 0, + eltype->length (), 0, highb - lowb + 1); ret = allocate_value (rettype); @@ -474,8 +474,8 @@ opencl_logical_not (struct type *expect_type, struct expression *exp, set) if the value of its operand compares equal to 0. */ int tmp = value_logical_not (value_subscript (arg, i)) ? -1 : 0; memset ((value_contents_writeable (ret).data () - + i * TYPE_LENGTH (eltype)), - tmp, TYPE_LENGTH (eltype)); + + i * eltype->length ()), + tmp, eltype->length ()); } } else @@ -556,14 +556,14 @@ vector_relop (struct expression *exp, struct value *val1, struct value *val2, /* Check whether the vector types are compatible. */ if (eltype1->code () != eltype2->code () - || TYPE_LENGTH (eltype1) != TYPE_LENGTH (eltype2) + || eltype1->length () != eltype2->length () || eltype1->is_unsigned () != eltype2->is_unsigned () || lowb1 != lowb2 || highb1 != highb2) error (_("Cannot perform operation on vectors with different types")); /* Determine the resulting type of the operation and allocate the value. */ rettype = lookup_opencl_vector_type (exp->gdbarch, TYPE_CODE_INT, - TYPE_LENGTH (eltype1), 0, + eltype1->length (), 0, highb1 - lowb1 + 1); ret = allocate_value (rettype); @@ -575,8 +575,8 @@ vector_relop (struct expression *exp, struct value *val1, struct value *val2, int tmp = scalar_relop (value_subscript (val1, i), value_subscript (val2, i), op) ? -1 : 0; memset ((value_contents_writeable (ret).data () - + i * TYPE_LENGTH (eltype1)), - tmp, TYPE_LENGTH (eltype1)); + + i * eltype1->length ()), + tmp, eltype1->length ()); } return ret; @@ -820,7 +820,7 @@ Cannot perform conditional operation on incompatible types")); /* Throw an error if the types of arg2 or arg3 are incompatible. */ if (eltype2->code () != eltype3->code () - || TYPE_LENGTH (eltype2) != TYPE_LENGTH (eltype3) + || eltype2->length () != eltype3->length () || eltype2->is_unsigned () != eltype3->is_unsigned () || lowb2 != lowb3 || highb2 != highb3) error (_("\ @@ -839,8 +839,8 @@ Cannot perform conditional operation on vectors with different sizes")); tmp = value_logical_not (value_subscript (arg1, i)) ? value_subscript (arg3, i) : value_subscript (arg2, i); memcpy (value_contents_writeable (ret).data () + - i * TYPE_LENGTH (eltype2), value_contents_all (tmp).data (), - TYPE_LENGTH (eltype2)); + i * eltype2->length (), value_contents_all (tmp).data (), + eltype2->length ()); } return ret; @@ -899,7 +899,7 @@ public: tmp->set_name (OCL_STRING(TYPE ## 2)); \ tmp = add (init_vector_type (ELEMENT_TYPE, 3)); \ tmp->set_name (OCL_STRING(TYPE ## 3)); \ - tmp->set_length (4 * TYPE_LENGTH (ELEMENT_TYPE)); \ + tmp->set_length (4 * (ELEMENT_TYPE)->length ()); \ tmp = add (init_vector_type (ELEMENT_TYPE, 4)); \ tmp->set_name (OCL_STRING(TYPE ## 4)); \ tmp = add (init_vector_type (ELEMENT_TYPE, 8)); \ diff --git a/gdb/or1k-tdep.c b/gdb/or1k-tdep.c index 360a7cb..9ff9e83 100644 --- a/gdb/or1k-tdep.c +++ b/gdb/or1k-tdep.c @@ -247,7 +247,7 @@ or1k_return_value (struct gdbarch *gdbarch, struct value *functype, { enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); enum type_code rv_type = valtype->code (); - unsigned int rv_size = TYPE_LENGTH (valtype); + unsigned int rv_size = valtype->length (); or1k_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); int bpw = tdep->bytes_per_word; @@ -663,7 +663,7 @@ or1k_push_dummy_call (struct gdbarch *gdbarch, struct value *function, struct value *arg = args[argnum]; struct type *arg_type = check_typedef (value_type (arg)); - int len = TYPE_LENGTH (arg_type); + int len = arg_type->length (); enum type_code typecode = arg_type->code (); if (func_type->has_varargs () && argnum >= func_type->num_fields ()) @@ -753,7 +753,7 @@ or1k_push_dummy_call (struct gdbarch *gdbarch, struct value *function, { struct value *arg = args[argnum]; struct type *arg_type = check_typedef (value_type (arg)); - int len = TYPE_LENGTH (arg_type); + int len = arg_type->length (); enum type_code typecode = arg_type->code (); if ((TYPE_CODE_STRUCT == typecode) || (TYPE_CODE_UNION == typecode) @@ -785,7 +785,7 @@ or1k_push_dummy_call (struct gdbarch *gdbarch, struct value *function, struct value *arg = args[argnum]; struct type *arg_type = check_typedef (value_type (arg)); - int len = TYPE_LENGTH (arg_type); + int len = arg_type->length (); enum type_code typecode = arg_type->code (); /* The EABI passes structures that do not fit in a register by reference. In all other cases, pass the structure by value. */ diff --git a/gdb/p-exp.y b/gdb/p-exp.y index eed41dc..9af297e 100644 --- a/gdb/p-exp.y +++ b/gdb/p-exp.y @@ -553,7 +553,7 @@ exp : SIZEOF '(' type ')' %prec UNARY $3 = check_typedef ($3); pstate->push_new (parse_type (pstate)->builtin_int, - TYPE_LENGTH ($3)); } + $3->length ()); } ; exp : SIZEOF '(' exp ')' %prec UNARY diff --git a/gdb/p-lang.c b/gdb/p-lang.c index 87590c9..613127e 100644 --- a/gdb/p-lang.c +++ b/gdb/p-lang.c @@ -104,7 +104,7 @@ pascal_is_string_type (struct type *type,int *length_pos, int *length_size, if (length_pos) *length_pos = type->field (0).loc_bitpos () / TARGET_CHAR_BIT; if (length_size) - *length_size = TYPE_LENGTH (type->field (0).type ()); + *length_size = type->field (0).type ()->length (); if (string_pos) *string_pos = type->field (1).loc_bitpos () / TARGET_CHAR_BIT; if (char_type) @@ -124,7 +124,7 @@ pascal_is_string_type (struct type *type,int *length_pos, int *length_size, if (length_pos) *length_pos = type->field (1).loc_bitpos () / TARGET_CHAR_BIT; if (length_size) - *length_size = TYPE_LENGTH (type->field (1).type ()); + *length_size = type->field (1).type ()->length (); if (string_pos) *string_pos = type->field (2).loc_bitpos () / TARGET_CHAR_BIT; /* FIXME: how can I detect wide chars in GPC ?? */ @@ -237,7 +237,7 @@ pascal_language::printstr (struct ui_file *stream, struct type *elttype, /* Preserve ELTTYPE's original type, just set its LENGTH. */ check_typedef (elttype); - width = TYPE_LENGTH (elttype); + width = elttype->length (); /* If the string was not truncated due to `set print elements', and the last byte of it is a null, we don't print that, in traditional C diff --git a/gdb/p-typeprint.c b/gdb/p-typeprint.c index f83c883..b6c6d59 100644 --- a/gdb/p-typeprint.c +++ b/gdb/p-typeprint.c @@ -237,7 +237,7 @@ pascal_language::type_print_varspec_prefix (struct type *type, if (passed_a_ptr) gdb_printf (stream, "("); gdb_printf (stream, "array "); - if (TYPE_LENGTH (type->target_type ()) > 0 + if (type->target_type ()->length () > 0 && type->bounds ()->high.kind () != PROP_UNDEFINED) gdb_printf (stream, "[%s..%s] ", plongest (type->bounds ()->low.const_val ()), diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c index 2118a37..2786a8e 100644 --- a/gdb/p-valprint.c +++ b/gdb/p-valprint.c @@ -92,7 +92,7 @@ pascal_language::value_print_inner (struct value *val, { len = high_bound - low_bound + 1; elttype = check_typedef (type->target_type ()); - eltlen = TYPE_LENGTH (elttype); + eltlen = elttype->length (); /* If 's' format is used, try to print out as string. If no format is given, print as string if element type is of TYPE_CODE_CHAR and element size is 1,2 or 4. */ @@ -157,7 +157,7 @@ pascal_language::value_print_inner (struct value *val, -fvtable_thunks. (Otherwise, look under TYPE_CODE_STRUCT.) */ /* Extract the address, assume that it is unsigned. */ addr = extract_unsigned_integer (valaddr, - TYPE_LENGTH (type), byte_order); + type->length (), byte_order); print_address_demangle (options, gdbarch, addr, stream, demangle); break; } @@ -182,10 +182,10 @@ pascal_language::value_print_inner (struct value *val, /* For a pointer to char or unsigned char, also print the string pointed to, unless pointer is null. */ - if (((TYPE_LENGTH (elttype) == 1 + if (((elttype->length () == 1 && (elttype->code () == TYPE_CODE_INT || elttype->code () == TYPE_CODE_CHAR)) - || ((TYPE_LENGTH (elttype) == 2 || TYPE_LENGTH (elttype) == 4) + || ((elttype->length () == 2 || elttype->length () == 4) && elttype->code () == TYPE_CODE_CHAR)) && (options->format == 0 || options->format == 's') && addr != 0) @@ -307,7 +307,7 @@ pascal_language::value_print_inner (struct value *val, (options, gdbarch, extract_unsigned_integer (valaddr + type->field (VTBL_FNADDR_OFFSET).loc_bitpos () / 8, - TYPE_LENGTH (type->field (VTBL_FNADDR_OFFSET).type ()), + type->field (VTBL_FNADDR_OFFSET).type ()->length (), byte_order), stream, demangle); } @@ -345,12 +345,12 @@ pascal_language::value_print_inner (struct value *val, int bound_info = (get_discrete_bounds (range, &low_bound, &high_bound) ? 0 : -1); - if (low_bound == 0 && high_bound == -1 && TYPE_LENGTH (type) > 0) + if (low_bound == 0 && high_bound == -1 && type->length () > 0) { /* If we know the size of the set type, we can figure out the maximum value. */ bound_info = 0; - high_bound = TYPE_LENGTH (type) * TARGET_CHAR_BIT - 1; + high_bound = type->length () * TARGET_CHAR_BIT - 1; range->bounds ()->high.set_const_val (high_bound); } maybe_bad_bstring: @@ -743,13 +743,13 @@ pascal_object_print_value (struct value *val, struct ui_file *stream, user program. Make sure that it still points to a valid memory location. */ - if (boffset < 0 || boffset >= TYPE_LENGTH (type)) + if (boffset < 0 || boffset >= type->length ()) { CORE_ADDR address= value_address (val); - gdb::byte_vector buf (TYPE_LENGTH (baseclass)); + gdb::byte_vector buf (baseclass->length ()); if (target_read_memory (address + boffset, buf.data (), - TYPE_LENGTH (baseclass)) != 0) + baseclass->length ()) != 0) skip = 1; base_value = value_from_contents_and_address (baseclass, buf.data (), diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c index de4158c..b089fcc 100644 --- a/gdb/ppc-linux-nat.c +++ b/gdb/ppc-linux-nat.c @@ -2519,7 +2519,7 @@ ppc_linux_nat_target::check_condition (CORE_ADDR watch_addr, /* DATA_VALUE is the constant in RIGHT_VAL, but actually has the same type as the memory region referenced by LEFT_VAL. */ - *len = TYPE_LENGTH (check_typedef (value_type (left_val))); + *len = check_typedef (value_type (left_val))->length (); } else if (num_accesses_left == 0 && num_accesses_right == 1 && VALUE_LVAL (right_val) == lval_memory @@ -2529,7 +2529,7 @@ ppc_linux_nat_target::check_condition (CORE_ADDR watch_addr, /* DATA_VALUE is the constant in LEFT_VAL, but actually has the same type as the memory region referenced by RIGHT_VAL. */ - *len = TYPE_LENGTH (check_typedef (value_type (right_val))); + *len = check_typedef (value_type (right_val))->length (); } else return 0; diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c index ed154fd..96eb931 100644 --- a/gdb/ppc-linux-tdep.c +++ b/gdb/ppc-linux-tdep.c @@ -253,7 +253,7 @@ ppc_linux_return_value (struct gdbarch *gdbarch, struct value *function, { if ((valtype->code () == TYPE_CODE_STRUCT || valtype->code () == TYPE_CODE_UNION) - && !((TYPE_LENGTH (valtype) == 16 || TYPE_LENGTH (valtype) == 8) + && !((valtype->length () == 16 || valtype->length () == 8) && valtype->is_vector ())) return RETURN_VALUE_STRUCT_CONVENTION; else diff --git a/gdb/ppc-netbsd-tdep.c b/gdb/ppc-netbsd-tdep.c index d8dc494..0156333 100644 --- a/gdb/ppc-netbsd-tdep.c +++ b/gdb/ppc-netbsd-tdep.c @@ -77,12 +77,12 @@ ppcnbsd_return_value (struct gdbarch *gdbarch, struct value *function, #if 0 if ((valtype->code () == TYPE_CODE_STRUCT || valtype->code () == TYPE_CODE_UNION) - && !((TYPE_LENGTH (valtype) == 16 || TYPE_LENGTH (valtype) == 8) + && !((valtype->length () == 16 || valtype->length () == 8) && valtype->is_vector ()) - && !(TYPE_LENGTH (valtype) == 1 - || TYPE_LENGTH (valtype) == 2 - || TYPE_LENGTH (valtype) == 4 - || TYPE_LENGTH (valtype) == 8)) + && !(valtype->length () == 1 + || valtype->length () == 2 + || valtype->length () == 4 + || valtype->length () == 8)) return RETURN_VALUE_STRUCT_CONVENTION; else #endif diff --git a/gdb/ppc-sysv-tdep.c b/gdb/ppc-sysv-tdep.c index 76f29d6..f57c261 100644 --- a/gdb/ppc-sysv-tdep.c +++ b/gdb/ppc-sysv-tdep.c @@ -121,7 +121,7 @@ ppc_sysv_abi_push_dummy_call (struct gdbarch *gdbarch, struct value *function, { struct value *arg = args[argno]; struct type *type = check_typedef (value_type (arg)); - int len = TYPE_LENGTH (type); + int len = type->length (); const bfd_byte *val = value_contents (arg).data (); if (type->code () == TYPE_CODE_FLT && len <= 8 @@ -275,7 +275,7 @@ ppc_sysv_abi_push_dummy_call (struct gdbarch *gdbarch, struct value *function, /* 32-bit decimal floats are right aligned in the doubleword. */ - if (TYPE_LENGTH (type) == 4) + if (type->length () == 4) { memcpy (regval + 4, val, 4); p = regval; @@ -341,11 +341,11 @@ ppc_sysv_abi_push_dummy_call (struct gdbarch *gdbarch, struct value *function, /* OpenCL vectors shorter than 16 bytes are passed as if a series of independent scalars. */ struct type *eltype = check_typedef (type->target_type ()); - int i, nelt = TYPE_LENGTH (type) / TYPE_LENGTH (eltype); + int i, nelt = type->length () / eltype->length (); for (i = 0; i < nelt; i++) { - const gdb_byte *elval = val + i * TYPE_LENGTH (eltype); + const gdb_byte *elval = val + i * eltype->length (); if (eltype->code () == TYPE_CODE_FLT && !tdep->soft_float) { @@ -371,7 +371,7 @@ ppc_sysv_abi_push_dummy_call (struct gdbarch *gdbarch, struct value *function, argoffset += len; } } - else if (TYPE_LENGTH (eltype) == 8) + else if (eltype->length () == 8) { if (greg > 9) { @@ -380,7 +380,7 @@ ppc_sysv_abi_push_dummy_call (struct gdbarch *gdbarch, struct value *function, argoffset = align_up (argoffset, 8); if (write_pass) write_memory (sp + argoffset, elval, - TYPE_LENGTH (eltype)); + eltype->length ()); argoffset += 8; } else @@ -607,7 +607,7 @@ get_decimal_float_return_value (struct gdbarch *gdbarch, struct type *valtype, gdb_assert (valtype->code () == TYPE_CODE_DECFLOAT); /* 32-bit and 64-bit decimal floats in f1. */ - if (TYPE_LENGTH (valtype) <= 8) + if (valtype->length () <= 8) { if (writebuf != NULL) { @@ -615,7 +615,7 @@ get_decimal_float_return_value (struct gdbarch *gdbarch, struct type *valtype, const gdb_byte *p; /* 32-bit decimal float is right aligned in the doubleword. */ - if (TYPE_LENGTH (valtype) == 4) + if (valtype->length () == 4) { memcpy (regval + 4, writebuf, 4); p = regval; @@ -630,12 +630,12 @@ get_decimal_float_return_value (struct gdbarch *gdbarch, struct type *valtype, regcache->cooked_read (tdep->ppc_fp0_regnum + 1, readbuf); /* Left align 32-bit decimal float. */ - if (TYPE_LENGTH (valtype) == 4) + if (valtype->length () == 4) memcpy (readbuf, readbuf + 4, 4); } } /* 128-bit decimal floats in f2,f3. */ - else if (TYPE_LENGTH (valtype) == 16) + else if (valtype->length () == 16) { if (writebuf != NULL || readbuf != NULL) { @@ -687,7 +687,7 @@ do_ppc_sysv_return_value (struct gdbarch *gdbarch, struct type *func_type, gdb_assert (tdep->wordsize == 4); if (type->code () == TYPE_CODE_FLT - && TYPE_LENGTH (type) <= 8 + && type->length () <= 8 && !tdep->soft_float) { if (readbuf) @@ -712,7 +712,7 @@ do_ppc_sysv_return_value (struct gdbarch *gdbarch, struct type *func_type, return RETURN_VALUE_REGISTER_CONVENTION; } if (type->code () == TYPE_CODE_FLT - && TYPE_LENGTH (type) == 16 + && type->length () == 16 && !tdep->soft_float && (gdbarch_long_double_format (gdbarch) == floatformats_ibm_long_double)) @@ -730,7 +730,7 @@ do_ppc_sysv_return_value (struct gdbarch *gdbarch, struct type *func_type, } return RETURN_VALUE_REGISTER_CONVENTION; } - if (TYPE_LENGTH (type) == 16 + if (type->length () == 16 && ((type->code () == TYPE_CODE_FLT && (gdbarch_long_double_format (gdbarch) == floatformats_ibm_long_double)) @@ -754,9 +754,9 @@ do_ppc_sysv_return_value (struct gdbarch *gdbarch, struct type *func_type, } return RETURN_VALUE_REGISTER_CONVENTION; } - if ((type->code () == TYPE_CODE_INT && TYPE_LENGTH (type) == 8) - || (type->code () == TYPE_CODE_FLT && TYPE_LENGTH (type) == 8) - || (type->code () == TYPE_CODE_DECFLOAT && TYPE_LENGTH (type) == 8 + if ((type->code () == TYPE_CODE_INT && type->length () == 8) + || (type->code () == TYPE_CODE_FLT && type->length () == 8) + || (type->code () == TYPE_CODE_DECFLOAT && type->length () == 8 && tdep->soft_float)) { if (readbuf) @@ -784,7 +784,7 @@ do_ppc_sysv_return_value (struct gdbarch *gdbarch, struct type *func_type, || type->code () == TYPE_CODE_PTR || TYPE_IS_REFERENCE (type) || type->code () == TYPE_CODE_ENUM) - && TYPE_LENGTH (type) <= tdep->wordsize) + && type->length () <= tdep->wordsize) { if (readbuf) { @@ -794,7 +794,7 @@ do_ppc_sysv_return_value (struct gdbarch *gdbarch, struct type *func_type, ULONGEST regval; regcache_cooked_read_unsigned (regcache, tdep->ppc_gp0_regnum + 3, ®val); - store_unsigned_integer (readbuf, TYPE_LENGTH (type), byte_order, + store_unsigned_integer (readbuf, type->length (), byte_order, regval); } if (writebuf) @@ -810,15 +810,15 @@ do_ppc_sysv_return_value (struct gdbarch *gdbarch, struct type *func_type, scalars in f1..f2 or r3..r10. */ if (type->code () == TYPE_CODE_ARRAY && type->is_vector () - && TYPE_LENGTH (type) < 16 + && type->length () < 16 && opencl_abi) { struct type *eltype = check_typedef (type->target_type ()); - int i, nelt = TYPE_LENGTH (type) / TYPE_LENGTH (eltype); + int i, nelt = type->length () / eltype->length (); for (i = 0; i < nelt; i++) { - int offset = i * TYPE_LENGTH (eltype); + int offset = i * eltype->length (); if (eltype->code () == TYPE_CODE_FLT) { @@ -853,7 +853,7 @@ do_ppc_sysv_return_value (struct gdbarch *gdbarch, struct type *func_type, { regcache_cooked_read_unsigned (regcache, regnum, ®val); store_unsigned_integer (readbuf + offset, - TYPE_LENGTH (eltype), byte_order, + eltype->length (), byte_order, regval); } } @@ -864,10 +864,10 @@ do_ppc_sysv_return_value (struct gdbarch *gdbarch, struct type *func_type, /* OpenCL vectors >= 16 bytes are returned in v2..v9. */ if (type->code () == TYPE_CODE_ARRAY && type->is_vector () - && TYPE_LENGTH (type) >= 16 + && type->length () >= 16 && opencl_abi) { - int n_regs = TYPE_LENGTH (type) / 16; + int n_regs = type->length () / 16; int i; for (i = 0; i < n_regs; i++) @@ -883,7 +883,7 @@ do_ppc_sysv_return_value (struct gdbarch *gdbarch, struct type *func_type, return RETURN_VALUE_REGISTER_CONVENTION; } - if (TYPE_LENGTH (type) == 16 + if (type->length () == 16 && type->code () == TYPE_CODE_ARRAY && type->is_vector () && tdep->vector_abi == POWERPC_VEC_ALTIVEC) @@ -900,7 +900,7 @@ do_ppc_sysv_return_value (struct gdbarch *gdbarch, struct type *func_type, } return RETURN_VALUE_REGISTER_CONVENTION; } - if (TYPE_LENGTH (type) == 16 + if (type->length () == 16 && type->code () == TYPE_CODE_ARRAY && type->is_vector () && tdep->vector_abi == POWERPC_VEC_GENERIC) @@ -924,7 +924,7 @@ do_ppc_sysv_return_value (struct gdbarch *gdbarch, struct type *func_type, } return RETURN_VALUE_REGISTER_CONVENTION; } - if (TYPE_LENGTH (type) == 8 + if (type->length () == 8 && type->code () == TYPE_CODE_ARRAY && type->is_vector () && tdep->vector_abi == POWERPC_VEC_SPE) @@ -940,13 +940,13 @@ do_ppc_sysv_return_value (struct gdbarch *gdbarch, struct type *func_type, regcache->cooked_write (tdep->ppc_ev0_regnum + 3, writebuf); return RETURN_VALUE_REGISTER_CONVENTION; } - if (broken_gcc && TYPE_LENGTH (type) <= 8) + if (broken_gcc && type->length () <= 8) { /* GCC screwed up for structures or unions whose size is less than or equal to 8 bytes.. Instead of left-aligning, it right-aligns the data into the buffer formed by r3, r4. */ gdb_byte regvals[PPC_MAX_REGISTER_SIZE * 2]; - int len = TYPE_LENGTH (type); + int len = type->length (); int offset = (2 * tdep->wordsize - len) % tdep->wordsize; if (readbuf) @@ -971,7 +971,7 @@ do_ppc_sysv_return_value (struct gdbarch *gdbarch, struct type *func_type, return RETURN_VALUE_REGISTER_CONVENTION; } - if (TYPE_LENGTH (type) <= 8) + if (type->length () <= 8) { if (readbuf) { @@ -981,10 +981,10 @@ do_ppc_sysv_return_value (struct gdbarch *gdbarch, struct type *func_type, gdb_byte regvals[PPC_MAX_REGISTER_SIZE * 2]; regcache->cooked_read (tdep->ppc_gp0_regnum + 3, regvals + 0 * tdep->wordsize); - if (TYPE_LENGTH (type) > tdep->wordsize) + if (type->length () > tdep->wordsize) regcache->cooked_read (tdep->ppc_gp0_regnum + 4, regvals + 1 * tdep->wordsize); - memcpy (readbuf, regvals, TYPE_LENGTH (type)); + memcpy (readbuf, regvals, type->length ()); } if (writebuf) { @@ -993,10 +993,10 @@ do_ppc_sysv_return_value (struct gdbarch *gdbarch, struct type *func_type, two "words" into r3/r4. */ gdb_byte regvals[PPC_MAX_REGISTER_SIZE * 2]; memset (regvals, 0, sizeof regvals); - memcpy (regvals, writebuf, TYPE_LENGTH (type)); + memcpy (regvals, writebuf, type->length ()); regcache->cooked_write (tdep->ppc_gp0_regnum + 3, regvals + 0 * tdep->wordsize); - if (TYPE_LENGTH (type) > tdep->wordsize) + if (type->length () > tdep->wordsize) regcache->cooked_write (tdep->ppc_gp0_regnum + 4, regvals + 1 * tdep->wordsize); } @@ -1088,7 +1088,7 @@ ppc64_aggregate_candidate (struct type *type, if (!*field_type) *field_type = type; if ((*field_type)->code () == type->code () - && TYPE_LENGTH (*field_type) == TYPE_LENGTH (type)) + && (*field_type)->length () == type->length ()) return 1; break; @@ -1100,7 +1100,7 @@ ppc64_aggregate_candidate (struct type *type, if (!*field_type) *field_type = type; if ((*field_type)->code () == type->code () - && TYPE_LENGTH (*field_type) == TYPE_LENGTH (type)) + && (*field_type)->length () == type->length ()) return 2; } break; @@ -1111,7 +1111,7 @@ ppc64_aggregate_candidate (struct type *type, if (!*field_type) *field_type = type; if ((*field_type)->code () == type->code () - && TYPE_LENGTH (*field_type) == TYPE_LENGTH (type)) + && (*field_type)->length () == type->length ()) return 1; } else @@ -1129,8 +1129,8 @@ ppc64_aggregate_candidate (struct type *type, /* There must be no padding. */ if (count == 0) - return TYPE_LENGTH (type) == 0 ? 0 : -1; - else if (TYPE_LENGTH (type) != count * TYPE_LENGTH (*field_type)) + return type->length () == 0 ? 0 : -1; + else if (type->length () != count * (*field_type)->length ()) return -1; return count; @@ -1163,8 +1163,8 @@ ppc64_aggregate_candidate (struct type *type, /* There must be no padding. */ if (count == 0) - return TYPE_LENGTH (type) == 0 ? 0 : -1; - else if (TYPE_LENGTH (type) != count * TYPE_LENGTH (*field_type)) + return type->length () == 0 ? 0 : -1; + else if (type->length () != count * (*field_type)->length ()) return -1; return count; @@ -1209,7 +1209,7 @@ ppc64_elfv2_abi_homogeneous_aggregate (struct type *type, else if (field_type->code () == TYPE_CODE_FLT || field_type->code () == TYPE_CODE_DECFLOAT) - n_regs = (TYPE_LENGTH (field_type) + 7) >> 3; + n_regs = (field_type->length () + 7) >> 3; else n_regs = 1; @@ -1339,7 +1339,7 @@ ppc64_sysv_abi_push_freg (struct gdbarch *gdbarch, if (tdep->soft_float) return; - if (TYPE_LENGTH (type) <= 8 + if (type->length () <= 8 && type->code () == TYPE_CODE_FLT) { /* Floats and doubles go in f1 .. f13. 32-bit floats are converted @@ -1356,7 +1356,7 @@ ppc64_sysv_abi_push_freg (struct gdbarch *gdbarch, argpos->freg++; } - else if (TYPE_LENGTH (type) <= 8 + else if (type->length () <= 8 && type->code () == TYPE_CODE_DECFLOAT) { /* Floats and doubles go in f1 .. f13. 32-bit decimal floats are @@ -1367,15 +1367,15 @@ ppc64_sysv_abi_push_freg (struct gdbarch *gdbarch, int offset = 0; if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG) - offset = 8 - TYPE_LENGTH (type); + offset = 8 - type->length (); argpos->regcache->cooked_write_part (regnum, offset, - TYPE_LENGTH (type), val); + type->length (), val); } argpos->freg++; } - else if (TYPE_LENGTH (type) == 16 + else if (type->length () == 16 && type->code () == TYPE_CODE_FLT && (gdbarch_long_double_format (gdbarch) == floatformats_ibm_long_double)) @@ -1392,7 +1392,7 @@ ppc64_sysv_abi_push_freg (struct gdbarch *gdbarch, argpos->freg += 2; } - else if (TYPE_LENGTH (type) == 16 + else if (type->length () == 16 && type->code () == TYPE_CODE_DECFLOAT) { /* 128-bit decimal floating-point values are stored in and even/odd @@ -1439,39 +1439,39 @@ ppc64_sysv_abi_push_param (struct gdbarch *gdbarch, ppc_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); if (type->code () == TYPE_CODE_FLT - && TYPE_LENGTH (type) == 16 + && type->length () == 16 && (gdbarch_long_double_format (gdbarch) == floatformats_ieee_quad)) { /* IEEE FLOAT128, args in vector registers. */ - ppc64_sysv_abi_push_val (gdbarch, val, TYPE_LENGTH (type), 16, argpos); + ppc64_sysv_abi_push_val (gdbarch, val, type->length (), 16, argpos); ppc64_sysv_abi_push_vreg (gdbarch, val, argpos); } else if (type->code () == TYPE_CODE_FLT || type->code () == TYPE_CODE_DECFLOAT) { /* Floating-point scalars are passed in floating-point registers. */ - ppc64_sysv_abi_push_val (gdbarch, val, TYPE_LENGTH (type), 0, argpos); + ppc64_sysv_abi_push_val (gdbarch, val, type->length (), 0, argpos); ppc64_sysv_abi_push_freg (gdbarch, type, val, argpos); } else if (type->code () == TYPE_CODE_ARRAY && type->is_vector () && tdep->vector_abi == POWERPC_VEC_ALTIVEC - && TYPE_LENGTH (type) == 16) + && type->length () == 16) { /* AltiVec vectors are passed aligned, and in vector registers. */ - ppc64_sysv_abi_push_val (gdbarch, val, TYPE_LENGTH (type), 16, argpos); + ppc64_sysv_abi_push_val (gdbarch, val, type->length (), 16, argpos); ppc64_sysv_abi_push_vreg (gdbarch, val, argpos); } else if (type->code () == TYPE_CODE_ARRAY && type->is_vector () - && TYPE_LENGTH (type) >= 16) + && type->length () >= 16) { /* Non-Altivec vectors are passed by reference. */ /* Copy value onto the stack ... */ CORE_ADDR addr = align_up (argpos->refparam, 16); if (argpos->regcache) - write_memory (addr, val, TYPE_LENGTH (type)); - argpos->refparam = align_up (addr + TYPE_LENGTH (type), tdep->wordsize); + write_memory (addr, val, type->length ()); + argpos->refparam = align_up (addr + type->length (), tdep->wordsize); /* ... and pass a pointer to the copy as parameter. */ ppc64_sysv_abi_push_integer (gdbarch, addr, argpos); @@ -1482,7 +1482,7 @@ ppc64_sysv_abi_push_param (struct gdbarch *gdbarch, || type->code () == TYPE_CODE_CHAR || type->code () == TYPE_CODE_PTR || TYPE_IS_REFERENCE (type)) - && TYPE_LENGTH (type) <= tdep->wordsize) + && type->length () <= tdep->wordsize) { ULONGEST word = 0; @@ -1532,7 +1532,7 @@ ppc64_sysv_abi_push_param (struct gdbarch *gdbarch, if (type->code () == TYPE_CODE_FLT) { /* Handle the case of 128-bit floats for both IEEE and IBM long double formats. */ - if (TYPE_LENGTH (type) == 16 + if (type->length () == 16 && (gdbarch_long_double_format (gdbarch) == floatformats_ieee_quad)) { @@ -1555,10 +1555,10 @@ ppc64_sysv_abi_push_param (struct gdbarch *gdbarch, gdbarch)) for (i = 0; i < nelt; i++) { - const gdb_byte *elval = val + i * TYPE_LENGTH (eltype); + const gdb_byte *elval = val + i * eltype->length (); if (eltype->code () == TYPE_CODE_FLT - && TYPE_LENGTH (eltype) == 16 + && eltype->length () == 16 && (gdbarch_long_double_format (gdbarch) == floatformats_ieee_quad)) /* IEEE FLOAT128, args in vector registers. */ @@ -1574,7 +1574,7 @@ ppc64_sysv_abi_push_param (struct gdbarch *gdbarch, else if (eltype->code () == TYPE_CODE_ARRAY && eltype->is_vector () && tdep->vector_abi == POWERPC_VEC_ALTIVEC - && TYPE_LENGTH (eltype) == 16) + && eltype->length () == 16) { ppc64_sysv_abi_push_vreg (gdbarch, elval, argpos); align = 16; @@ -1582,7 +1582,7 @@ ppc64_sysv_abi_push_param (struct gdbarch *gdbarch, } } - ppc64_sysv_abi_push_val (gdbarch, val, TYPE_LENGTH (type), align, argpos); + ppc64_sysv_abi_push_val (gdbarch, val, type->length (), align, argpos); } } @@ -1699,7 +1699,7 @@ ppc64_sysv_abi_push_dummy_call (struct gdbarch *gdbarch, ppc64_sysv_abi_push_param (gdbarch, eltype, val, &argpos); ppc64_sysv_abi_push_param (gdbarch, eltype, - val + TYPE_LENGTH (eltype), &argpos); + val + eltype->length (), &argpos); } else if (type->code () == TYPE_CODE_ARRAY && type->is_vector () && opencl_abi) @@ -1710,15 +1710,15 @@ ppc64_sysv_abi_push_dummy_call (struct gdbarch *gdbarch, struct type *eltype; int i, nelt; - if (TYPE_LENGTH (type) < 16) + if (type->length () < 16) eltype = check_typedef (type->target_type ()); else eltype = register_type (gdbarch, tdep->ppc_vr0_regnum); - nelt = TYPE_LENGTH (type) / TYPE_LENGTH (eltype); + nelt = type->length () / eltype->length (); for (i = 0; i < nelt; i++) { - const gdb_byte *elval = val + i * TYPE_LENGTH (eltype); + const gdb_byte *elval = val + i * eltype->length (); ppc64_sysv_abi_push_param (gdbarch, eltype, elval, &argpos); } @@ -1805,7 +1805,7 @@ ppc64_sysv_abi_return_value_base (struct gdbarch *gdbarch, struct type *valtype, || valtype->code () == TYPE_CODE_BOOL || valtype->code () == TYPE_CODE_RANGE || is_fixed_point_type (valtype)) - && TYPE_LENGTH (valtype) <= 8) + && valtype->length () <= 8) { int regnum = tdep->ppc_gp0_regnum + 3 + index; @@ -1819,7 +1819,7 @@ ppc64_sysv_abi_return_value_base (struct gdbarch *gdbarch, struct type *valtype, gdb_mpz unscaled; unscaled.read (gdb::make_array_view (writebuf, - TYPE_LENGTH (valtype)), + valtype->length ()), type_byte_order (valtype), valtype->is_unsigned ()); return_val = unscaled.as_integer (); @@ -1837,7 +1837,7 @@ ppc64_sysv_abi_return_value_base (struct gdbarch *gdbarch, struct type *valtype, ULONGEST regval; regcache_cooked_read_unsigned (regcache, regnum, ®val); - store_unsigned_integer (readbuf, TYPE_LENGTH (valtype), + store_unsigned_integer (readbuf, valtype->length (), gdbarch_byte_order (gdbarch), regval); } return 1; @@ -1845,7 +1845,7 @@ ppc64_sysv_abi_return_value_base (struct gdbarch *gdbarch, struct type *valtype, /* Floats and doubles go in f1 .. f13. 32-bit floats are converted to double first. */ - if (TYPE_LENGTH (valtype) <= 8 + if (valtype->length () <= 8 && valtype->code () == TYPE_CODE_FLT) { int regnum = tdep->ppc_fp0_regnum + 1 + index; @@ -1867,26 +1867,26 @@ ppc64_sysv_abi_return_value_base (struct gdbarch *gdbarch, struct type *valtype, /* Floats and doubles go in f1 .. f13. 32-bit decimal floats are placed in the least significant word. */ - if (TYPE_LENGTH (valtype) <= 8 + if (valtype->length () <= 8 && valtype->code () == TYPE_CODE_DECFLOAT) { int regnum = tdep->ppc_fp0_regnum + 1 + index; int offset = 0; if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG) - offset = 8 - TYPE_LENGTH (valtype); + offset = 8 - valtype->length (); if (writebuf != NULL) - regcache->cooked_write_part (regnum, offset, TYPE_LENGTH (valtype), + regcache->cooked_write_part (regnum, offset, valtype->length (), writebuf); if (readbuf != NULL) - regcache->cooked_read_part (regnum, offset, TYPE_LENGTH (valtype), + regcache->cooked_read_part (regnum, offset, valtype->length (), readbuf); return 1; } /* IBM long double stored in two consecutive FPRs. */ - if (TYPE_LENGTH (valtype) == 16 + if (valtype->length () == 16 && valtype->code () == TYPE_CODE_FLT && (gdbarch_long_double_format (gdbarch) == floatformats_ibm_long_double)) @@ -1908,7 +1908,7 @@ ppc64_sysv_abi_return_value_base (struct gdbarch *gdbarch, struct type *valtype, /* 128-bit decimal floating-point values are stored in an even/odd pair of FPRs, with the even FPR holding the most significant half. */ - if (TYPE_LENGTH (valtype) == 16 + if (valtype->length () == 16 && valtype->code () == TYPE_CODE_DECFLOAT) { int regnum = tdep->ppc_fp0_regnum + 2 + 2 * index; @@ -1931,7 +1931,7 @@ ppc64_sysv_abi_return_value_base (struct gdbarch *gdbarch, struct type *valtype, /* AltiVec vectors are returned in VRs starting at v2. IEEE FLOAT 128-bit are stored in vector register. */ - if (TYPE_LENGTH (valtype) == 16 + if (valtype->length () == 16 && ((valtype->code () == TYPE_CODE_ARRAY && valtype->is_vector () && tdep->vector_abi == POWERPC_VEC_ALTIVEC) @@ -1949,20 +1949,20 @@ ppc64_sysv_abi_return_value_base (struct gdbarch *gdbarch, struct type *valtype, } /* Short vectors are returned in GPRs starting at r3. */ - if (TYPE_LENGTH (valtype) <= 8 + if (valtype->length () <= 8 && valtype->code () == TYPE_CODE_ARRAY && valtype->is_vector ()) { int regnum = tdep->ppc_gp0_regnum + 3 + index; int offset = 0; if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG) - offset = 8 - TYPE_LENGTH (valtype); + offset = 8 - valtype->length (); if (writebuf != NULL) - regcache->cooked_write_part (regnum, offset, TYPE_LENGTH (valtype), + regcache->cooked_write_part (regnum, offset, valtype->length (), writebuf); if (readbuf != NULL) - regcache->cooked_read_part (regnum, offset, TYPE_LENGTH (valtype), + regcache->cooked_read_part (regnum, offset, valtype->length (), readbuf); return 1; } @@ -2008,9 +2008,9 @@ ppc64_sysv_abi_return_value (struct gdbarch *gdbarch, struct value *function, gdb_assert (ok); if (readbuf) - readbuf += TYPE_LENGTH (eltype); + readbuf += eltype->length (); if (writebuf) - writebuf += TYPE_LENGTH (eltype); + writebuf += eltype->length (); } return RETURN_VALUE_REGISTER_CONVENTION; } @@ -2021,12 +2021,12 @@ ppc64_sysv_abi_return_value (struct gdbarch *gdbarch, struct value *function, if (valtype->code () == TYPE_CODE_ARRAY && valtype->is_vector () && opencl_abi) { - if (TYPE_LENGTH (valtype) < 16) + if (valtype->length () < 16) eltype = check_typedef (valtype->target_type ()); else eltype = register_type (gdbarch, tdep->ppc_vr0_regnum); - nelt = TYPE_LENGTH (valtype) / TYPE_LENGTH (eltype); + nelt = valtype->length () / eltype->length (); for (int i = 0; i < nelt; i++) { ok = ppc64_sysv_abi_return_value_base (gdbarch, eltype, regcache, @@ -2034,9 +2034,9 @@ ppc64_sysv_abi_return_value (struct gdbarch *gdbarch, struct value *function, gdb_assert (ok); if (readbuf) - readbuf += TYPE_LENGTH (eltype); + readbuf += eltype->length (); if (writebuf) - writebuf += TYPE_LENGTH (eltype); + writebuf += eltype->length (); } return RETURN_VALUE_REGISTER_CONVENTION; } @@ -2056,18 +2056,18 @@ ppc64_sysv_abi_return_value (struct gdbarch *gdbarch, struct value *function, /* Small character arrays are returned, right justified, in r3. */ if (valtype->code () == TYPE_CODE_ARRAY && !valtype->is_vector () - && TYPE_LENGTH (valtype) <= 8 + && valtype->length () <= 8 && valtype->target_type ()->code () == TYPE_CODE_INT - && TYPE_LENGTH (valtype->target_type ()) == 1) + && valtype->target_type ()->length () == 1) { int regnum = tdep->ppc_gp0_regnum + 3; - int offset = (register_size (gdbarch, regnum) - TYPE_LENGTH (valtype)); + int offset = (register_size (gdbarch, regnum) - valtype->length ()); if (writebuf != NULL) - regcache->cooked_write_part (regnum, offset, TYPE_LENGTH (valtype), + regcache->cooked_write_part (regnum, offset, valtype->length (), writebuf); if (readbuf != NULL) - regcache->cooked_read_part (regnum, offset, TYPE_LENGTH (valtype), + regcache->cooked_read_part (regnum, offset, valtype->length (), readbuf); return RETURN_VALUE_REGISTER_CONVENTION; } @@ -2082,7 +2082,7 @@ ppc64_sysv_abi_return_value (struct gdbarch *gdbarch, struct value *function, || (eltype->code () == TYPE_CODE_ARRAY && eltype->is_vector () && tdep->vector_abi == POWERPC_VEC_ALTIVEC - && TYPE_LENGTH (eltype) == 16))) + && eltype->length () == 16))) { for (int i = 0; i < nelt; i++) { @@ -2091,9 +2091,9 @@ ppc64_sysv_abi_return_value (struct gdbarch *gdbarch, struct value *function, gdb_assert (ok); if (readbuf) - readbuf += TYPE_LENGTH (eltype); + readbuf += eltype->length (); if (writebuf) - writebuf += TYPE_LENGTH (eltype); + writebuf += eltype->length (); } return RETURN_VALUE_REGISTER_CONVENTION; @@ -2102,13 +2102,13 @@ ppc64_sysv_abi_return_value (struct gdbarch *gdbarch, struct value *function, /* In the ELFv2 ABI, aggregate types of up to 16 bytes are returned in registers r3:r4. */ if (tdep->elf_abi == POWERPC_ELF_V2 - && TYPE_LENGTH (valtype) <= 16 + && valtype->length () <= 16 && (valtype->code () == TYPE_CODE_STRUCT || valtype->code () == TYPE_CODE_UNION || (valtype->code () == TYPE_CODE_ARRAY && !valtype->is_vector ()))) { - int n_regs = ((TYPE_LENGTH (valtype) + tdep->wordsize - 1) + int n_regs = ((valtype->length () + tdep->wordsize - 1) / tdep->wordsize); for (int i = 0; i < n_regs; i++) @@ -2116,7 +2116,7 @@ ppc64_sysv_abi_return_value (struct gdbarch *gdbarch, struct value *function, gdb_byte regval[PPC_MAX_REGISTER_SIZE]; int regnum = tdep->ppc_gp0_regnum + 3 + i; int offset = i * tdep->wordsize; - int len = TYPE_LENGTH (valtype) - offset; + int len = valtype->length () - offset; if (len > tdep->wordsize) len = tdep->wordsize; diff --git a/gdb/printcmd.c b/gdb/printcmd.c index ce3dd38..55f92ba 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -295,7 +295,7 @@ print_formatted (struct value *val, int size, struct ui_file *stream) { struct type *type = check_typedef (value_type (val)); - int len = TYPE_LENGTH (type); + int len = type->length (); if (VALUE_LVAL (val) == lval_memory) next_address = value_address (val) + len; @@ -349,11 +349,11 @@ float_type_from_length (struct type *type) struct gdbarch *gdbarch = type->arch (); const struct builtin_type *builtin = builtin_type (gdbarch); - if (TYPE_LENGTH (type) == TYPE_LENGTH (builtin->builtin_float)) + if (type->length () == builtin->builtin_float->length ()) type = builtin->builtin_float; - else if (TYPE_LENGTH (type) == TYPE_LENGTH (builtin->builtin_double)) + else if (type->length () == builtin->builtin_double->length ()) type = builtin->builtin_double; - else if (TYPE_LENGTH (type) == TYPE_LENGTH (builtin->builtin_long_double)) + else if (type->length () == builtin->builtin_long_double->length ()) type = builtin->builtin_long_double; return type; @@ -369,7 +369,7 @@ print_scalar_formatted (const gdb_byte *valaddr, struct type *type, int size, struct ui_file *stream) { struct gdbarch *gdbarch = type->arch (); - unsigned int len = TYPE_LENGTH (type); + unsigned int len = type->length (); enum bfd_endian byte_order = type_byte_order (type); /* String printing should go through val_print_scalar_formatted. */ @@ -377,7 +377,7 @@ print_scalar_formatted (const gdb_byte *valaddr, struct type *type, /* If the value is a pointer, and pointers and addresses are not the same, then at this point, the value's length (in target bytes) is - gdbarch_addr_bit/TARGET_CHAR_BIT, not TYPE_LENGTH (type). */ + gdbarch_addr_bit/TARGET_CHAR_BIT, not type->length (). */ if (type->code () == TYPE_CODE_PTR) len = gdbarch_addr_bit (gdbarch) / TARGET_CHAR_BIT; @@ -387,8 +387,8 @@ print_scalar_formatted (const gdb_byte *valaddr, struct type *type, if (options->format != 'c' && (options->format != 'd' || type->is_unsigned ())) { - if (len < TYPE_LENGTH (type) && byte_order == BFD_ENDIAN_BIG) - valaddr += TYPE_LENGTH (type) - len; + if (len < type->length () && byte_order == BFD_ENDIAN_BIG) + valaddr += type->length () - len; } /* Allow LEN == 0, and in this case, don't assume that VALADDR is @@ -444,8 +444,8 @@ print_scalar_formatted (const gdb_byte *valaddr, struct type *type, || type->bit_size_differs_p ()) { val_long.emplace (unpack_long (type, valaddr)); - converted_bytes.resize (TYPE_LENGTH (type)); - store_signed_integer (converted_bytes.data (), TYPE_LENGTH (type), + converted_bytes.resize (type->length ()); + store_signed_integer (converted_bytes.data (), type->length (), byte_order, *val_long); valaddr = converted_bytes.data (); } @@ -1088,19 +1088,19 @@ do_examine (struct format_data fmt, struct gdbarch *gdbarch, CORE_ADDR addr) else if (format == 's') { next_address = find_string_backward (gdbarch, addr, count, - TYPE_LENGTH (val_type), + val_type->length (), &opts, &count); } else { - next_address = addr - count * TYPE_LENGTH (val_type); + next_address = addr - count * val_type->length (); } /* The following call to print_formatted updates next_address in every iteration. In backward case, we store the start address here and update next_address with it before exiting the function. */ addr_rewound = (format == 's' - ? next_address - TYPE_LENGTH (val_type) + ? next_address - val_type->length () : next_address); need_to_update_next_address = 1; } @@ -2433,7 +2433,7 @@ printf_c_string (struct ui_file *stream, const char *format, && VALUE_LVAL (value) == lval_internalvar && c_is_string_type_p (value_type (value))) { - size_t len = TYPE_LENGTH (value_type (value)); + size_t len = value_type (value)->length (); /* Copy the internal var value to TEM_STR and append a terminating null character. This protects against corrupted C-style strings that lack @@ -2500,13 +2500,13 @@ printf_wide_c_string (struct ui_file *stream, const char *format, struct gdbarch *gdbarch = value_type (value)->arch (); struct type *wctype = lookup_typename (current_language, "wchar_t", NULL, 0); - int wcwidth = TYPE_LENGTH (wctype); + int wcwidth = wctype->length (); if (VALUE_LVAL (value) == lval_internalvar && c_is_string_type_p (value_type (value))) { str = value_contents (value).data (); - len = TYPE_LENGTH (value_type (value)); + len = value_type (value)->length (); } else { @@ -2779,7 +2779,7 @@ ui_printf (const char *arg, struct ui_file *stream) const gdb_byte *bytes; valtype = value_type (val_args[i]); - if (TYPE_LENGTH (valtype) != TYPE_LENGTH (wctype) + if (valtype->length () != wctype->length () || valtype->code () != TYPE_CODE_INT) error (_("expected wchar_t argument for %%lc")); @@ -2789,8 +2789,8 @@ ui_printf (const char *arg, struct ui_file *stream) convert_between_encodings (target_wide_charset (gdbarch), host_charset (), - bytes, TYPE_LENGTH (valtype), - TYPE_LENGTH (valtype), + bytes, valtype->length (), + valtype->length (), &output, translit_char); obstack_grow_str0 (&output, ""); diff --git a/gdb/procfs.c b/gdb/procfs.c index ffb4d18..c571562 100644 --- a/gdb/procfs.c +++ b/gdb/procfs.c @@ -1522,7 +1522,7 @@ procfs_address_to_host_pointer (CORE_ADDR addr) struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr; void *ptr; - gdb_assert (sizeof (ptr) == TYPE_LENGTH (ptr_type)); + gdb_assert (sizeof (ptr) == ptr_type->length ()); gdbarch_address_to_pointer (target_gdbarch (), ptr_type, (gdb_byte *) &ptr, addr); return ptr; @@ -3020,7 +3020,7 @@ procfs_target::can_use_hw_breakpoint (enum bptype type, int cnt, int othertype) different. */ struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr; - if (sizeof (void *) != TYPE_LENGTH (ptr_type)) + if (sizeof (void *) != ptr_type->length ()) return 0; /* Other tests here??? */ diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c index 6ea384e..0066ae6 100644 --- a/gdb/python/py-inferior.c +++ b/gdb/python/py-inferior.c @@ -746,7 +746,7 @@ infpy_thread_from_thread_handle (PyObject *self, PyObject *args, PyObject *kw) { struct value *val = value_object_to_value (handle_obj); bytes = value_contents_all (val).data (); - bytes_len = TYPE_LENGTH (value_type (val)); + bytes_len = value_type (val)->length (); } else { diff --git a/gdb/python/py-prettyprint.c b/gdb/python/py-prettyprint.c index 1f8dd26..9276807 100644 --- a/gdb/python/py-prettyprint.c +++ b/gdb/python/py-prettyprint.c @@ -582,7 +582,7 @@ gdbpy_apply_val_pretty_printer (const struct extension_language_defn *extlang, value_fetch_lazy (value); /* No pretty-printer support for unavailable values. */ - if (!value_bytes_available (value, 0, TYPE_LENGTH (type))) + if (!value_bytes_available (value, 0, type->length ())) return EXT_LANG_RC_NOP; if (!gdb_python_initialized) diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c index 3d7d2f6..3e558de 100644 --- a/gdb/python/py-type.c +++ b/gdb/python/py-type.c @@ -771,7 +771,7 @@ typy_get_sizeof (PyObject *self, void *closure) if (size_varies) Py_RETURN_NONE; - return gdb_py_object_from_longest (TYPE_LENGTH (type)).release (); + return gdb_py_object_from_longest (type->length ()).release (); } /* Return the alignment of the type represented by SELF, in bytes. */ diff --git a/gdb/python/py-unwind.c b/gdb/python/py-unwind.c index dcb1d7a..0a1b460 100644 --- a/gdb/python/py-unwind.c +++ b/gdb/python/py-unwind.c @@ -292,13 +292,13 @@ unwind_infopy_add_saved_register (PyObject *self, PyObject *args) return NULL; } data_size = register_size (pending_frame->gdbarch, regnum); - if (data_size != TYPE_LENGTH (value_type (value))) + if (data_size != value_type (value)->length ()) { PyErr_Format ( PyExc_ValueError, "The value of the register returned by the Python " "sniffer has unexpected size: %u instead of %u.", - (unsigned) TYPE_LENGTH (value_type (value)), + (unsigned) value_type (value)->length (), (unsigned) data_size); return NULL; } @@ -620,7 +620,7 @@ pyuw_sniffer (const struct frame_unwind *self, struct frame_info *this_frame, /* `value' validation was done before, just assert. */ gdb_assert (value != NULL); - gdb_assert (data_size == TYPE_LENGTH (value_type (value))); + gdb_assert (data_size == value_type (value)->length ()); cached_frame->reg[i].data = (gdb_byte *) xmalloc (data_size); memcpy (cached_frame->reg[i].data, diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c index cb3346c..92a1530 100644 --- a/gdb/python/py-value.c +++ b/gdb/python/py-value.c @@ -158,7 +158,7 @@ convert_buffer_and_type_to_value (PyObject *obj, struct type *type) return nullptr; } - if (TYPE_LENGTH (type) > py_buf.len) + if (type->length () > py_buf.len) { PyErr_SetString (PyExc_ValueError, _("Size of type is larger than that of buffer object.")); @@ -597,7 +597,7 @@ valpy_string (PyObject *self, PyObject *args, PyObject *kw) encoding = (user_encoding && *user_encoding) ? user_encoding : la_encoding; return PyUnicode_Decode ((const char *) buffer.get (), - length * TYPE_LENGTH (char_type), + length * char_type->length (), encoding, errors); } diff --git a/gdb/ravenscar-thread.c b/gdb/ravenscar-thread.c index fd4bf45..215e52f 100644 --- a/gdb/ravenscar-thread.c +++ b/gdb/ravenscar-thread.c @@ -388,7 +388,7 @@ get_running_thread_id (int cpu) if (!object_msym.minsym) return 0; - object_size = TYPE_LENGTH (builtin_type_void_data_ptr); + object_size = builtin_type_void_data_ptr->length (); object_addr = (object_msym.value_address () + (cpu - 1) * object_size); buf_size = object_size; diff --git a/gdb/regcache.c b/gdb/regcache.c index a22a839..b0e92dd 100644 --- a/gdb/regcache.c +++ b/gdb/regcache.c @@ -118,7 +118,7 @@ init_regcache_descr (struct gdbarch *gdbarch) = GDBARCH_OBSTACK_CALLOC (gdbarch, descr->nr_cooked_registers, long); for (i = 0; i < gdbarch_num_regs (gdbarch); i++) { - descr->sizeof_register[i] = TYPE_LENGTH (descr->register_type[i]); + descr->sizeof_register[i] = descr->register_type[i]->length (); descr->register_offset[i] = offset; offset += descr->sizeof_register[i]; } @@ -127,7 +127,7 @@ init_regcache_descr (struct gdbarch *gdbarch) for (; i < descr->nr_cooked_registers; i++) { - descr->sizeof_register[i] = TYPE_LENGTH (descr->register_type[i]); + descr->sizeof_register[i] = descr->register_type[i]->length (); descr->register_offset[i] = offset; offset += descr->sizeof_register[i]; } @@ -755,7 +755,7 @@ readable_regcache::cooked_read_value (int regnum) if (cooked_read (regnum, value_contents_raw (result).data ()) == REG_UNAVAILABLE) mark_value_bytes_unavailable (result, 0, - TYPE_LENGTH (value_type (result))); + value_type (result)->length ()); return result; } diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c index e74ea03..e419b97 100644 --- a/gdb/riscv-tdep.c +++ b/gdb/riscv-tdep.c @@ -1066,7 +1066,7 @@ riscv_register_type (struct gdbarch *gdbarch, int regnum) int flen = riscv_isa_flen (gdbarch); if (flen == 8 && type->code () == TYPE_CODE_FLT - && TYPE_LENGTH (type) == flen + && type->length () == flen && (strcmp (type->name (), "builtin_type_ieee_double") == 0 || strcmp (type->name (), "double") == 0)) type = riscv_fpreg_d_type (gdbarch); @@ -1079,7 +1079,7 @@ riscv_register_type (struct gdbarch *gdbarch, int regnum) || regnum == RISCV_GP_REGNUM || regnum == RISCV_TP_REGNUM) && type->code () == TYPE_CODE_INT - && TYPE_LENGTH (type) == xlen) + && type->length () == xlen) { /* This spots the case where some interesting registers are defined as simple integers of the expected size, we force these registers @@ -1154,7 +1154,7 @@ riscv_print_one_register_info (struct gdbarch *gdbarch, if (print_raw_format) { gdb_printf (file, "\t(raw "); - print_hex_chars (file, valaddr, TYPE_LENGTH (regtype), byte_order, + print_hex_chars (file, valaddr, regtype->length (), byte_order, true); gdb_printf (file, ")"); } @@ -2243,7 +2243,7 @@ riscv_type_align (gdbarch *gdbarch, type *type) { type = check_typedef (type); if (type->code () == TYPE_CODE_ARRAY && type->is_vector ()) - return std::min (TYPE_LENGTH (type), (ULONGEST) BIGGEST_ALIGNMENT); + return std::min (type->length (), (ULONGEST) BIGGEST_ALIGNMENT); /* Anything else will be aligned by the generic code. */ return 0; @@ -2729,12 +2729,12 @@ riscv_call_arg_struct (struct riscv_arg_info *ainfo, except we use the type of the complex field instead of the type from AINFO, and the first location might be at a non-zero offset. */ - if (TYPE_LENGTH (sinfo.field_type (0)) <= (2 * cinfo->flen) + if (sinfo.field_type (0)->length () <= (2 * cinfo->flen) && riscv_arg_regs_available (&cinfo->float_regs) >= 2 && !ainfo->is_unnamed) { bool result; - int len = TYPE_LENGTH (sinfo.field_type (0)) / 2; + int len = sinfo.field_type (0)->length () / 2; int offset = sinfo.field_offset (0); result = riscv_assign_reg_location (&ainfo->argloc[0], @@ -2759,13 +2759,13 @@ riscv_call_arg_struct (struct riscv_arg_info *ainfo, except we use the type of the first scalar field instead of the type from AINFO. Also the location might be at a non-zero offset. */ - if (TYPE_LENGTH (sinfo.field_type (0)) > cinfo->flen + if (sinfo.field_type (0)->length () > cinfo->flen || ainfo->is_unnamed) riscv_call_arg_scalar_int (ainfo, cinfo); else { int offset = sinfo.field_offset (0); - int len = TYPE_LENGTH (sinfo.field_type (0)); + int len = sinfo.field_type (0)->length (); if (!riscv_assign_reg_location (&ainfo->argloc[0], &cinfo->float_regs, @@ -2777,21 +2777,21 @@ riscv_call_arg_struct (struct riscv_arg_info *ainfo, if (sinfo.number_of_fields () == 2 && sinfo.field_type(0)->code () == TYPE_CODE_FLT - && TYPE_LENGTH (sinfo.field_type (0)) <= cinfo->flen + && sinfo.field_type (0)->length () <= cinfo->flen && sinfo.field_type(1)->code () == TYPE_CODE_FLT - && TYPE_LENGTH (sinfo.field_type (1)) <= cinfo->flen + && sinfo.field_type (1)->length () <= cinfo->flen && riscv_arg_regs_available (&cinfo->float_regs) >= 2) { - int len0 = TYPE_LENGTH (sinfo.field_type (0)); + int len0 = sinfo.field_type (0)->length (); int offset = sinfo.field_offset (0); if (!riscv_assign_reg_location (&ainfo->argloc[0], &cinfo->float_regs, len0, offset)) error (_("failed during argument setup")); - int len1 = TYPE_LENGTH (sinfo.field_type (1)); + int len1 = sinfo.field_type (1)->length (); offset = sinfo.field_offset (1); - gdb_assert (len1 <= (TYPE_LENGTH (ainfo->type) - - TYPE_LENGTH (sinfo.field_type (0)))); + gdb_assert (len1 <= (ainfo->type->length () + - sinfo.field_type (0)->length ())); if (!riscv_assign_reg_location (&ainfo->argloc[1], &cinfo->float_regs, @@ -2803,17 +2803,17 @@ riscv_call_arg_struct (struct riscv_arg_info *ainfo, if (sinfo.number_of_fields () == 2 && riscv_arg_regs_available (&cinfo->int_regs) >= 1 && (sinfo.field_type(0)->code () == TYPE_CODE_FLT - && TYPE_LENGTH (sinfo.field_type (0)) <= cinfo->flen + && sinfo.field_type (0)->length () <= cinfo->flen && is_integral_type (sinfo.field_type (1)) - && TYPE_LENGTH (sinfo.field_type (1)) <= cinfo->xlen)) + && sinfo.field_type (1)->length () <= cinfo->xlen)) { - int len0 = TYPE_LENGTH (sinfo.field_type (0)); + int len0 = sinfo.field_type (0)->length (); int offset = sinfo.field_offset (0); if (!riscv_assign_reg_location (&ainfo->argloc[0], &cinfo->float_regs, len0, offset)) error (_("failed during argument setup")); - int len1 = TYPE_LENGTH (sinfo.field_type (1)); + int len1 = sinfo.field_type (1)->length (); offset = sinfo.field_offset (1); gdb_assert (len1 <= cinfo->xlen); if (!riscv_assign_reg_location (&ainfo->argloc[1], @@ -2825,12 +2825,12 @@ riscv_call_arg_struct (struct riscv_arg_info *ainfo, if (sinfo.number_of_fields () == 2 && riscv_arg_regs_available (&cinfo->int_regs) >= 1 && (is_integral_type (sinfo.field_type (0)) - && TYPE_LENGTH (sinfo.field_type (0)) <= cinfo->xlen + && sinfo.field_type (0)->length () <= cinfo->xlen && sinfo.field_type(1)->code () == TYPE_CODE_FLT - && TYPE_LENGTH (sinfo.field_type (1)) <= cinfo->flen)) + && sinfo.field_type (1)->length () <= cinfo->flen)) { - int len0 = TYPE_LENGTH (sinfo.field_type (0)); - int len1 = TYPE_LENGTH (sinfo.field_type (1)); + int len0 = sinfo.field_type (0)->length (); + int len1 = sinfo.field_type (1)->length (); gdb_assert (len0 <= cinfo->xlen); gdb_assert (len1 <= cinfo->flen); @@ -2872,7 +2872,7 @@ riscv_arg_location (struct gdbarch *gdbarch, struct type *type, bool is_unnamed) { ainfo->type = type; - ainfo->length = TYPE_LENGTH (ainfo->type); + ainfo->length = ainfo->type->length (); ainfo->align = type_align (ainfo->type); ainfo->is_unnamed = is_unnamed; ainfo->contents = nullptr; @@ -3273,7 +3273,7 @@ riscv_return_value (struct gdbarch *gdbarch, gdb_mpz unscaled; unscaled.read (gdb::make_array_view (writebuf, - TYPE_LENGTH (arg_type)), + arg_type->length ()), type_byte_order (arg_type), arg_type->is_unsigned ()); abi_val = allocate_value (info.type); @@ -3294,7 +3294,7 @@ riscv_return_value (struct gdbarch *gdbarch, old_readbuf = readbuf; readbuf = value_contents_raw (abi_val).data (); } - arg_len = TYPE_LENGTH (info.type); + arg_len = info.type->length (); switch (info.argloc[0].loc_type) { @@ -3409,7 +3409,7 @@ riscv_return_value (struct gdbarch *gdbarch, else arg_val = value_cast (arg_type, abi_val); memcpy (old_readbuf, value_contents_raw (arg_val).data (), - TYPE_LENGTH (arg_type)); + arg_type->length ()); } } diff --git a/gdb/rl78-tdep.c b/gdb/rl78-tdep.c index 6df6401..1ce0435 100644 --- a/gdb/rl78-tdep.c +++ b/gdb/rl78-tdep.c @@ -1034,7 +1034,7 @@ rl78_address_to_pointer (struct gdbarch *gdbarch, { enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); - store_unsigned_integer (buf, TYPE_LENGTH (type), byte_order, + store_unsigned_integer (buf, type->length (), byte_order, addr & 0xffffff); } @@ -1046,13 +1046,13 @@ rl78_pointer_to_address (struct gdbarch *gdbarch, { enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); CORE_ADDR addr - = extract_unsigned_integer (buf, TYPE_LENGTH (type), byte_order); + = extract_unsigned_integer (buf, type->length (), byte_order); /* Is it a code address? */ if (type->target_type ()->code () == TYPE_CODE_FUNC || type->target_type ()->code () == TYPE_CODE_METHOD || TYPE_CODE_SPACE (type->target_type ()) - || TYPE_LENGTH (type) == 4) + || type->length () == 4) return rl78_make_instruction_address (addr); else return rl78_make_data_address (addr); @@ -1247,7 +1247,7 @@ rl78_return_value (struct gdbarch *gdbarch, gdb_byte *readbuf, const gdb_byte *writebuf) { enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); - ULONGEST valtype_len = TYPE_LENGTH (valtype); + ULONGEST valtype_len = valtype->length (); rl78_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); int is_g10 = tdep->elf_flags & E_FLAG_RL78_G10; @@ -1342,7 +1342,7 @@ rl78_push_dummy_call (struct gdbarch *gdbarch, struct value *function, for (i = nargs - 1; i >= 0; i--) { struct type *value_type = value_enclosing_type (args[i]); - int len = TYPE_LENGTH (value_type); + int len = value_type->length (); int container_len = (len + 1) & ~1; sp -= container_len; diff --git a/gdb/rs6000-aix-tdep.c b/gdb/rs6000-aix-tdep.c index 86270c8..1a6bb50 100644 --- a/gdb/rs6000-aix-tdep.c +++ b/gdb/rs6000-aix-tdep.c @@ -351,7 +351,7 @@ rs6000_push_dummy_call (struct gdbarch *gdbarch, struct value *function, arg = args[argno]; type = check_typedef (value_type (arg)); - len = TYPE_LENGTH (type); + len = type->length (); if (type->code () == TYPE_CODE_FLT) { @@ -439,7 +439,7 @@ ran_out_of_registers_for_arguments: for (; jj < nargs; ++jj) { struct value *val = args[jj]; - space += ((TYPE_LENGTH (value_type (val))) + 3) & -4; + space += ((value_type (val)->length ()) + 3) & -4; } /* Add location required for the rest of the parameters. */ @@ -473,7 +473,7 @@ ran_out_of_registers_for_arguments: arg = args[argno]; type = check_typedef (value_type (arg)); - len = TYPE_LENGTH (type); + len = type->length (); /* Float types should be passed in fpr's, as well as in the @@ -533,7 +533,7 @@ rs6000_return_value (struct gdbarch *gdbarch, struct value *function, /* AltiVec extension: Functions that declare a vector data type as a return value place that return value in VR2. */ if (valtype->code () == TYPE_CODE_ARRAY && valtype->is_vector () - && TYPE_LENGTH (valtype) == 16) + && valtype->length () == 16) { if (readbuf) regcache->cooked_read (tdep->ppc_vr0_regnum + 2, readbuf); @@ -558,7 +558,7 @@ rs6000_return_value (struct gdbarch *gdbarch, struct value *function, complex*8 and complex*16 are returned in FPR1:FPR2, and complex*32 is returned in FPR1:FPR4. */ if (valtype->code () == TYPE_CODE_FLT - && (TYPE_LENGTH (valtype) == 4 || TYPE_LENGTH (valtype) == 8)) + && (valtype->length () == 4 || valtype->length () == 8)) { struct type *regtype = register_type (gdbarch, tdep->ppc_fp0_regnum); gdb_byte regval[8]; @@ -585,7 +585,7 @@ rs6000_return_value (struct gdbarch *gdbarch, struct value *function, lengths less than or equal to 32 bits, must be returned right justified in GPR3 with signed values sign extended and unsigned values zero extended, as necessary. */ - if (TYPE_LENGTH (valtype) <= tdep->wordsize) + if (valtype->length () <= tdep->wordsize) { if (readbuf) { @@ -594,7 +594,7 @@ rs6000_return_value (struct gdbarch *gdbarch, struct value *function, /* For reading we don't have to worry about sign extension. */ regcache_cooked_read_unsigned (regcache, tdep->ppc_gp0_regnum + 3, ®val); - store_unsigned_integer (readbuf, TYPE_LENGTH (valtype), byte_order, + store_unsigned_integer (readbuf, valtype->length (), byte_order, regval); } if (writebuf) @@ -611,7 +611,7 @@ rs6000_return_value (struct gdbarch *gdbarch, struct value *function, /* Eight-byte non-floating-point scalar values must be returned in GPR3:GPR4. */ - if (TYPE_LENGTH (valtype) == 8) + if (valtype->length () == 8) { gdb_assert (valtype->code () != TYPE_CODE_FLT); gdb_assert (tdep->wordsize == 4); diff --git a/gdb/rs6000-lynx178-tdep.c b/gdb/rs6000-lynx178-tdep.c index dc13dd3..c234a93 100644 --- a/gdb/rs6000-lynx178-tdep.c +++ b/gdb/rs6000-lynx178-tdep.c @@ -94,7 +94,7 @@ rs6000_lynx178_push_dummy_call (struct gdbarch *gdbarch, arg = args[argno]; type = check_typedef (value_type (arg)); - len = TYPE_LENGTH (type); + len = type->length (); if (type->code () == TYPE_CODE_FLT) { @@ -184,7 +184,7 @@ ran_out_of_registers_for_arguments: { struct value *val = args[jj]; - space += align_up (TYPE_LENGTH (value_type (val)), 4); + space += align_up (value_type (val)->length (), 4); } /* Add location required for the rest of the parameters. */ @@ -218,7 +218,7 @@ ran_out_of_registers_for_arguments: arg = args[argno]; type = check_typedef (value_type (arg)); - len = TYPE_LENGTH (type); + len = type->length (); /* Float types should be passed in fpr's, as well as in the @@ -276,7 +276,7 @@ rs6000_lynx178_return_value (struct gdbarch *gdbarch, struct value *function, /* AltiVec extension: Functions that declare a vector data type as a return value place that return value in VR2. */ if (valtype->code () == TYPE_CODE_ARRAY && valtype->is_vector () - && TYPE_LENGTH (valtype) == 16) + && valtype->length () == 16) { if (readbuf) regcache->cooked_read (tdep->ppc_vr0_regnum + 2, readbuf); @@ -301,7 +301,7 @@ rs6000_lynx178_return_value (struct gdbarch *gdbarch, struct value *function, complex*8 and complex*16 are returned in FPR1:FPR2, and complex*32 is returned in FPR1:FPR4. */ if (valtype->code () == TYPE_CODE_FLT - && (TYPE_LENGTH (valtype) == 4 || TYPE_LENGTH (valtype) == 8)) + && (valtype->length () == 4 || valtype->length () == 8)) { struct type *regtype = register_type (gdbarch, tdep->ppc_fp0_regnum); gdb_byte regval[8]; @@ -328,7 +328,7 @@ rs6000_lynx178_return_value (struct gdbarch *gdbarch, struct value *function, lengths less than or equal to 32 bits, must be returned right justified in GPR3 with signed values sign extended and unsigned values zero extended, as necessary. */ - if (TYPE_LENGTH (valtype) <= tdep->wordsize) + if (valtype->length () <= tdep->wordsize) { if (readbuf) { @@ -337,7 +337,7 @@ rs6000_lynx178_return_value (struct gdbarch *gdbarch, struct value *function, /* For reading we don't have to worry about sign extension. */ regcache_cooked_read_unsigned (regcache, tdep->ppc_gp0_regnum + 3, ®val); - store_unsigned_integer (readbuf, TYPE_LENGTH (valtype), byte_order, + store_unsigned_integer (readbuf, valtype->length (), byte_order, regval); } if (writebuf) @@ -354,7 +354,7 @@ rs6000_lynx178_return_value (struct gdbarch *gdbarch, struct value *function, /* Eight-byte non-floating-point scalar values must be returned in GPR3:GPR4. */ - if (TYPE_LENGTH (valtype) == 8) + if (valtype->length () == 8) { gdb_assert (valtype->code () != TYPE_CODE_FLT); gdb_assert (tdep->wordsize == 4); diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c index cccc887..87b2faa 100644 --- a/gdb/rs6000-tdep.c +++ b/gdb/rs6000-tdep.c @@ -2665,8 +2665,8 @@ rs6000_convert_register_p (struct gdbarch *gdbarch, int regnum, && regnum >= tdep->ppc_fp0_regnum && regnum < tdep->ppc_fp0_regnum + ppc_num_fprs && type->code () == TYPE_CODE_FLT - && TYPE_LENGTH (type) - != TYPE_LENGTH (builtin_type (gdbarch)->builtin_double)); + && (type->length () + != builtin_type (gdbarch)->builtin_double->length ())); } static int diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index a48996e..5539884 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -224,7 +224,7 @@ rust_u8_type_p (struct type *type) { return (type->code () == TYPE_CODE_INT && type->is_unsigned () - && TYPE_LENGTH (type) == 1); + && type->length () == 1); } /* Return true if TYPE is a Rust character type. */ @@ -233,7 +233,7 @@ static bool rust_chartype_p (struct type *type) { return (type->code () == TYPE_CODE_CHAR - && TYPE_LENGTH (type) == 4 + && type->length () == 4 && type->is_unsigned ()); } @@ -456,7 +456,7 @@ rust_language::print_enum (struct value *val, struct ui_file *stream, gdb_assert (rust_enum_p (type)); gdb::array_view view (value_contents_for_printing (val).data (), - TYPE_LENGTH (value_type (val))); + value_type (val)->length ()); type = resolve_dynamic_type (type, view, value_address (val)); if (rust_empty_enum_p (type)) @@ -564,7 +564,7 @@ rust_language::value_print_inner case TYPE_CODE_INT: /* Recognize the unit type. */ - if (type->is_unsigned () && TYPE_LENGTH (type) == 0 + if (type->is_unsigned () && type->length () == 0 && type->name () != NULL && strcmp (type->name (), "()") == 0) { gdb_puts ("()", stream); @@ -961,7 +961,7 @@ rust_composite_type (struct type *original, struct field *field = &result->field (i); field->set_loc_bitpos (bitpos); - bitpos += TYPE_LENGTH (type1) * TARGET_CHAR_BIT; + bitpos += type1->length () * TARGET_CHAR_BIT; field->set_name (field1); field->set_type (type1); @@ -990,7 +990,7 @@ rust_composite_type (struct type *original, if (i > 0) result->set_length (result->field (i - 1).loc_bitpos () / TARGET_CHAR_BIT - + TYPE_LENGTH (result->field (i - 1).type ())); + + result->field (i - 1).type ()->length ()); return result; } @@ -1071,7 +1071,7 @@ rust_range (struct type *expect_type, struct expression *exp, if (noside == EVAL_AVOID_SIDE_EFFECTS) return value_zero (range_type, lval_memory); - addrval = value_allocate_space_in_inferior (TYPE_LENGTH (range_type)); + addrval = value_allocate_space_in_inferior (range_type->length ()); addr = value_as_long (addrval); result = value_at_lazy (range_type, addr); @@ -1273,7 +1273,7 @@ rust_subscript (struct type *expect_type, struct expression *exp, slice = rust_slice_type (new_name, value_type (result), usize); - addrval = value_allocate_space_in_inferior (TYPE_LENGTH (slice)); + addrval = value_allocate_space_in_inferior (slice->length ()); addr = value_as_long (addrval); tem = value_at_lazy (slice, addr); @@ -1485,7 +1485,7 @@ rust_aggregate_operation::evaluate (struct type *expect_type, if (noside == EVAL_NORMAL) { - addrval = value_allocate_space_in_inferior (TYPE_LENGTH (type)); + addrval = value_allocate_space_in_inferior (type->length ()); addr = value_as_long (addrval); result = value_at_lazy (type, addr); } @@ -1606,7 +1606,7 @@ rust_language::language_arch_info (struct gdbarch *gdbarch, add (arch_integer_type (gdbarch, 64, 0, "i64")); add (arch_integer_type (gdbarch, 64, 1, "u64")); - unsigned int length = 8 * TYPE_LENGTH (builtin->builtin_data_ptr); + unsigned int length = 8 * builtin->builtin_data_ptr->length (); add (arch_integer_type (gdbarch, length, 0, "isize")); struct type *usize_type = add (arch_integer_type (gdbarch, length, 1, "usize")); diff --git a/gdb/rx-tdep.c b/gdb/rx-tdep.c index 62a9ac4..faca81a 100644 --- a/gdb/rx-tdep.c +++ b/gdb/rx-tdep.c @@ -712,8 +712,8 @@ rx_push_dummy_call (struct gdbarch *gdbarch, struct value *function, gdb_assert (return_type->code () == TYPE_CODE_STRUCT || func_type->code () == TYPE_CODE_UNION); - if (TYPE_LENGTH (return_type) > 16 - || TYPE_LENGTH (return_type) % 4 != 0) + if (return_type->length () > 16 + || return_type->length () % 4 != 0) { if (write_pass) regcache_cooked_write_unsigned (regcache, RX_R15_REGNUM, @@ -727,7 +727,7 @@ rx_push_dummy_call (struct gdbarch *gdbarch, struct value *function, struct value *arg = args[i]; const gdb_byte *arg_bits = value_contents_all (arg).data (); struct type *arg_type = check_typedef (value_type (arg)); - ULONGEST arg_size = TYPE_LENGTH (arg_type); + ULONGEST arg_size = arg_type->length (); if (i == 0 && struct_addr != 0 && return_method != return_method_struct @@ -803,7 +803,7 @@ rx_push_dummy_call (struct gdbarch *gdbarch, struct value *function, { struct type *p_arg_type = func_type->field (i).type (); - p_arg_size = TYPE_LENGTH (p_arg_type); + p_arg_size = p_arg_type->length (); } sp_off = align_up (sp_off, p_arg_size); @@ -874,12 +874,12 @@ rx_return_value (struct gdbarch *gdbarch, gdb_byte *readbuf, const gdb_byte *writebuf) { enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); - ULONGEST valtype_len = TYPE_LENGTH (valtype); + ULONGEST valtype_len = valtype->length (); - if (TYPE_LENGTH (valtype) > 16 + if (valtype->length () > 16 || ((valtype->code () == TYPE_CODE_STRUCT || valtype->code () == TYPE_CODE_UNION) - && TYPE_LENGTH (valtype) % 4 != 0)) + && valtype->length () % 4 != 0)) return RETURN_VALUE_STRUCT_CONVENTION; if (readbuf) diff --git a/gdb/s12z-tdep.c b/gdb/s12z-tdep.c index 5e49c61..c447547 100644 --- a/gdb/s12z-tdep.c +++ b/gdb/s12z-tdep.c @@ -557,7 +557,7 @@ s12z_extract_return_value (struct type *type, struct regcache *regcache, { int reg = -1; - switch (TYPE_LENGTH (type)) + switch (type->length ()) { case 0: /* Nothing to do */ return; @@ -594,7 +594,7 @@ s12z_return_value (struct gdbarch *gdbarch, struct value *function, if (type->code () == TYPE_CODE_STRUCT || type->code () == TYPE_CODE_UNION || type->code () == TYPE_CODE_ARRAY - || TYPE_LENGTH (type) > 4) + || type->length () > 4) return RETURN_VALUE_STRUCT_CONVENTION; if (readbuf) diff --git a/gdb/s390-tdep.c b/gdb/s390-tdep.c index 2b28394..9f76b94 100644 --- a/gdb/s390-tdep.c +++ b/gdb/s390-tdep.c @@ -62,7 +62,7 @@ s390_type_align (gdbarch *gdbarch, struct type *t) { t = check_typedef (t); - if (TYPE_LENGTH (t) > 8) + if (t->length () > 8) { switch (t->code ()) { @@ -1237,7 +1237,7 @@ s390_value_from_register (struct gdbarch *gdbarch, struct type *type, check_typedef (type); if ((regnum >= S390_F0_REGNUM && regnum <= S390_F15_REGNUM - && TYPE_LENGTH (type) < 8) + && type->length () < 8) || regnum_is_vxr_full (tdep, regnum) || (regnum >= S390_V16_REGNUM && regnum <= S390_V31_REGNUM)) set_value_offset (value, 0); @@ -1649,7 +1649,7 @@ s390_effective_inner_type (struct type *type, unsigned int min_size) if (inner == NULL) break; inner = check_typedef (inner); - if (TYPE_LENGTH (inner) < min_size) + if (inner->length () < min_size) break; type = inner; } @@ -1665,7 +1665,7 @@ s390_function_arg_float (struct type *type) { /* Note that long double as well as complex types are intentionally excluded. */ - if (TYPE_LENGTH (type) > 8) + if (type->length () > 8) return 0; /* A struct containing just a float or double is passed like a float @@ -1681,11 +1681,11 @@ s390_function_arg_float (struct type *type) static int s390_function_arg_vector (struct type *type) { - if (TYPE_LENGTH (type) > 16) + if (type->length () > 16) return 0; /* Structs containing just a vector are passed like a vector. */ - type = s390_effective_inner_type (type, TYPE_LENGTH (type)); + type = s390_effective_inner_type (type, type->length ()); return type->code () == TYPE_CODE_ARRAY && type->is_vector (); } @@ -1707,7 +1707,7 @@ s390_function_arg_integer (struct type *type) { enum type_code code = type->code (); - if (TYPE_LENGTH (type) > 8) + if (type->length () > 8) return 0; if (code == TYPE_CODE_INT @@ -1720,7 +1720,7 @@ s390_function_arg_integer (struct type *type) return 1; return ((code == TYPE_CODE_UNION || code == TYPE_CODE_STRUCT) - && is_power_of_two (TYPE_LENGTH (type))); + && is_power_of_two (type->length ())); } /* Argument passing state: Internal data structure passed to helper @@ -1750,7 +1750,7 @@ s390_handle_arg (struct s390_arg_state *as, struct value *arg, enum bfd_endian byte_order, int is_unnamed) { struct type *type = check_typedef (value_type (arg)); - unsigned int length = TYPE_LENGTH (type); + unsigned int length = type->length (); int write_mode = as->regcache != NULL; if (s390_function_arg_float (type)) @@ -2012,7 +2012,7 @@ s390_register_return_value (struct gdbarch *gdbarch, struct type *type, { enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); int word_size = gdbarch_ptr_bit (gdbarch) / 8; - int length = TYPE_LENGTH (type); + int length = type->length (); int code = type->code (); if (code == TYPE_CODE_FLT || code == TYPE_CODE_DECFLOAT) @@ -2086,13 +2086,13 @@ s390_return_value (struct gdbarch *gdbarch, struct value *function, { s390_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); rvc = (tdep->vector_abi == S390_VECTOR_ABI_128 - && TYPE_LENGTH (type) <= 16 && type->is_vector ()) + && type->length () <= 16 && type->is_vector ()) ? RETURN_VALUE_REGISTER_CONVENTION : RETURN_VALUE_STRUCT_CONVENTION; break; } default: - rvc = TYPE_LENGTH (type) <= 8 + rvc = type->length () <= 8 ? RETURN_VALUE_REGISTER_CONVENTION : RETURN_VALUE_STRUCT_CONVENTION; } @@ -2203,7 +2203,7 @@ s390_unwind_pseudo_register (struct frame_info *this_frame, int regnum) { LONGEST pswa = value_as_long (val); - if (TYPE_LENGTH (type) == 4) + if (type->length () == 4) return value_from_pointer (type, pswa & 0x7fffffff); else return value_from_pointer (type, pswa); @@ -2220,7 +2220,7 @@ s390_unwind_pseudo_register (struct frame_info *this_frame, int regnum) { LONGEST pswm = value_as_long (val); - if (TYPE_LENGTH (type) == 4) + if (type->length () == 4) return value_from_longest (type, (pswm >> 12) & 3); else return value_from_longest (type, (pswm >> 44) & 3); diff --git a/gdb/sh-tdep.c b/gdb/sh-tdep.c index 8ed1a42..f6b7df5 100644 --- a/gdb/sh-tdep.c +++ b/gdb/sh-tdep.c @@ -812,7 +812,7 @@ sh_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) static int sh_use_struct_convention (int renesas_abi, struct type *type) { - int len = TYPE_LENGTH (type); + int len = type->length (); int nelem = type->num_fields (); /* The Renesas ABI returns aggregate types always on stack. */ @@ -832,13 +832,13 @@ sh_use_struct_convention (int renesas_abi, struct type *type) /* If the first field in the aggregate has the same length as the entire aggregate type, the type is returned in registers. */ - if (TYPE_LENGTH (type->field (0).type ()) == len) + if (type->field (0).type ()->length () == len) return 0; /* If the size of the aggregate is 8 bytes and the first field is of size 4 bytes its alignment is equal to long long's alignment, so it's returned in registers. */ - if (len == 8 && TYPE_LENGTH (type->field (0).type ()) == 4) + if (len == 8 && type->field (0).type ()->length () == 4) return 0; /* Otherwise use struct convention. */ @@ -849,7 +849,7 @@ static int sh_use_struct_convention_nofpu (int renesas_abi, struct type *type) { /* The Renesas ABI returns long longs/doubles etc. always on stack. */ - if (renesas_abi && type->num_fields () == 0 && TYPE_LENGTH (type) >= 8) + if (renesas_abi && type->num_fields () == 0 && type->length () >= 8) return 1; return sh_use_struct_convention (renesas_abi, type); } @@ -937,7 +937,7 @@ sh_stack_allocsize (int nargs, struct value **args) { int stack_alloc = 0; while (nargs-- > 0) - stack_alloc += ((TYPE_LENGTH (value_type (args[nargs])) + 3) & ~3); + stack_alloc += ((value_type (args[nargs])->length () + 3) & ~3); return stack_alloc; } @@ -1101,7 +1101,7 @@ sh_push_dummy_call_fpu (struct gdbarch *gdbarch, for (argnum = 0; argnum < nargs; argnum++) { type = value_type (args[argnum]); - len = TYPE_LENGTH (type); + len = type->length (); val = sh_justify_value_in_reg (gdbarch, args[argnum], len); /* Some decisions have to be made how various types are handled. @@ -1150,7 +1150,7 @@ sh_push_dummy_call_fpu (struct gdbarch *gdbarch, and then proceeds as normal by writing the second 32 bits into the next register. */ if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_LITTLE - && TYPE_LENGTH (type) == 2 * reg_size) + && type->length () == 2 * reg_size) { regcache_cooked_write_unsigned (regcache, flt_argreg + 1, regval); @@ -1239,7 +1239,7 @@ sh_push_dummy_call_nofpu (struct gdbarch *gdbarch, for (argnum = 0; argnum < nargs; argnum++) { type = value_type (args[argnum]); - len = TYPE_LENGTH (type); + len = type->length (); val = sh_justify_value_in_reg (gdbarch, args[argnum], len); /* Some decisions have to be made how various types are handled. @@ -1312,7 +1312,7 @@ sh_extract_return_value_nofpu (struct type *type, struct regcache *regcache, { struct gdbarch *gdbarch = regcache->arch (); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); - int len = TYPE_LENGTH (type); + int len = type->length (); if (len <= 4) { @@ -1338,7 +1338,7 @@ sh_extract_return_value_fpu (struct type *type, struct regcache *regcache, struct gdbarch *gdbarch = regcache->arch (); if (sh_treat_as_flt_p (type)) { - int len = TYPE_LENGTH (type); + int len = type->length (); int i, regnum = gdbarch_fp0_regnum (gdbarch); for (i = 0; i < len; i += 4) if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_LITTLE) @@ -1364,7 +1364,7 @@ sh_store_return_value_nofpu (struct type *type, struct regcache *regcache, struct gdbarch *gdbarch = regcache->arch (); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); ULONGEST val; - int len = TYPE_LENGTH (type); + int len = type->length (); if (len <= 4) { @@ -1386,7 +1386,7 @@ sh_store_return_value_fpu (struct type *type, struct regcache *regcache, struct gdbarch *gdbarch = regcache->arch (); if (sh_treat_as_flt_p (type)) { - int len = TYPE_LENGTH (type); + int len = type->length (); int i, regnum = gdbarch_fp0_regnum (gdbarch); for (i = 0; i < len; i += 4) if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_LITTLE) diff --git a/gdb/solib-darwin.c b/gdb/solib-darwin.c index 4eca080..6f622dc 100644 --- a/gdb/solib-darwin.c +++ b/gdb/solib-darwin.c @@ -124,7 +124,7 @@ darwin_load_image_infos (struct darwin_info *info) /* The structure has 4 fields: version (4 bytes), count (4 bytes), info (pointer) and notifier (pointer). */ - len = 4 + 4 + 2 * TYPE_LENGTH (ptr_type); + len = 4 + 4 + 2 * ptr_type->length (); gdb_assert (len <= sizeof (buf)); memset (&info->all_image, 0, sizeof (info->all_image)); @@ -140,7 +140,7 @@ darwin_load_image_infos (struct darwin_info *info) info->all_image.count = extract_unsigned_integer (buf + 4, 4, byte_order); info->all_image.info = extract_typed_address (buf + 8, ptr_type); info->all_image.notifier = extract_typed_address - (buf + 8 + TYPE_LENGTH (ptr_type), ptr_type); + (buf + 8 + ptr_type->length (), ptr_type); } /* Link map info to include in an allocated so_list entry. */ @@ -227,7 +227,7 @@ darwin_current_sos (void) { struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr; enum bfd_endian byte_order = type_byte_order (ptr_type); - int ptr_len = TYPE_LENGTH (ptr_type); + int ptr_len = ptr_type->length (); unsigned int image_info_size; struct so_list *head = NULL; struct so_list *tail = NULL; @@ -339,7 +339,7 @@ static CORE_ADDR darwin_read_exec_load_addr_from_dyld (struct darwin_info *info) { struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr; - int ptr_len = TYPE_LENGTH (ptr_type); + int ptr_len = ptr_type->length (); unsigned int image_info_size = ptr_len * 3; int i; @@ -487,12 +487,12 @@ darwin_solib_read_all_image_info_addr (struct darwin_info *info) struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr; /* Sanity check. */ - if (TYPE_LENGTH (ptr_type) > sizeof (buf)) + if (ptr_type->length () > sizeof (buf)) return; len = target_read (current_inferior ()->top_target (), TARGET_OBJECT_DARWIN_DYLD_INFO, - NULL, buf, 0, TYPE_LENGTH (ptr_type)); + NULL, buf, 0, ptr_type->length ()); if (len <= 0) return; diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c index bab76e2..a6a9ec5 100644 --- a/gdb/solib-svr4.c +++ b/gdb/solib-svr4.c @@ -672,7 +672,7 @@ elf_locate_base (void) { struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr; gdb_byte *pbuf; - int pbuf_size = TYPE_LENGTH (ptr_type); + int pbuf_size = ptr_type->length (); pbuf = (gdb_byte *) alloca (pbuf_size); /* DT_MIPS_RLD_MAP contains a pointer to the address @@ -692,7 +692,7 @@ elf_locate_base (void) { struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr; gdb_byte *pbuf; - int pbuf_size = TYPE_LENGTH (ptr_type); + int pbuf_size = ptr_type->length (); pbuf = (gdb_byte *) alloca (pbuf_size); /* DT_MIPS_RLD_MAP_REL contains an offset from the address of the @@ -868,7 +868,7 @@ open_symbol_file_object (int from_tty) CORE_ADDR lm, l_name; struct link_map_offsets *lmo = svr4_fetch_link_map_offsets (); struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr; - int l_name_size = TYPE_LENGTH (ptr_type); + int l_name_size = ptr_type->length (); gdb::byte_vector l_name_buf (l_name_size); struct svr4_info *info = get_svr4_info (current_program_space); symfile_add_flags add_flags = 0; diff --git a/gdb/sparc-tdep.c b/gdb/sparc-tdep.c index e7fb040..5f1d9ef 100644 --- a/gdb/sparc-tdep.c +++ b/gdb/sparc-tdep.c @@ -208,7 +208,7 @@ sparc_fetch_wcookie (struct gdbarch *gdbarch) static int sparc_integral_or_pointer_p (const struct type *type) { - int len = TYPE_LENGTH (type); + int len = type->length (); switch (type->code ()) { @@ -242,7 +242,7 @@ sparc_floating_p (const struct type *type) { case TYPE_CODE_FLT: { - int len = TYPE_LENGTH (type); + int len = type->length (); return (len == 4 || len == 8 || len == 16); } default: @@ -261,7 +261,7 @@ sparc_complex_floating_p (const struct type *type) { case TYPE_CODE_COMPLEX: { - int len = TYPE_LENGTH (type); + int len = type->length (); return (len == 8 || len == 16 || len == 32); } default: @@ -306,14 +306,14 @@ sparc_structure_return_p (const struct type *type) return true; /* Integer vectors are returned by memory if the vector size is greater than 8 bytes long. */ - return (TYPE_LENGTH (type) > 8); + return (type->length () > 8); } if (sparc_floating_p (type)) { /* Floating point types are passed by register for size 4 and 8 bytes, and by memory for size 16 bytes. */ - return (TYPE_LENGTH (type) == 16); + return (type->length () == 16); } /* Other than that, only aggregates of all sizes get returned by @@ -334,13 +334,13 @@ sparc_arg_by_memory_p (const struct type *type) return true; /* Integer vectors are passed by memory if the vector size is greater than 8 bytes long. */ - return (TYPE_LENGTH (type) > 8); + return (type->length () > 8); } /* Floats are passed by register for size 4 and 8 bytes, and by memory for size 16 bytes. */ if (sparc_floating_p (type)) - return (TYPE_LENGTH (type) == 16); + return (type->length () == 16); /* Complex floats and aggregates of all sizes are passed by memory. */ if (sparc_complex_floating_p (type) || sparc_structure_or_union_p (type)) @@ -603,7 +603,7 @@ sparc32_push_dummy_code (struct gdbarch *gdbarch, CORE_ADDR sp, /* This is an UNIMP instruction. */ store_unsigned_integer (buf, 4, byte_order, - TYPE_LENGTH (value_type) & 0x1fff); + value_type->length () & 0x1fff); write_memory (sp - 8, buf, 4); return sp - 8; } @@ -627,7 +627,7 @@ sparc32_store_arguments (struct regcache *regcache, int nargs, for (i = 0; i < nargs; i++) { struct type *type = value_type (args[i]); - int len = TYPE_LENGTH (type); + int len = type->length (); if (sparc_arg_by_memory_p (type)) { @@ -671,7 +671,7 @@ sparc32_store_arguments (struct regcache *regcache, int nargs, { const bfd_byte *valbuf = value_contents (args[i]).data (); struct type *type = value_type (args[i]); - int len = TYPE_LENGTH (type); + int len = type->length (); gdb_byte buf[4]; if (len < 4) @@ -1236,7 +1236,7 @@ sparc32_struct_return_from_sym (struct symbol *sym) { type = check_typedef (type->target_type ()); if (sparc_structure_or_union_p (type) - || (sparc_floating_p (type) && TYPE_LENGTH (type) == 16)) + || (sparc_floating_p (type) && type->length () == 16)) return 1; } @@ -1399,7 +1399,7 @@ static void sparc32_extract_return_value (struct type *type, struct regcache *regcache, gdb_byte *valbuf) { - int len = TYPE_LENGTH (type); + int len = type->length (); gdb_byte buf[32]; gdb_assert (!sparc_structure_return_p (type)); @@ -1453,7 +1453,7 @@ static void sparc32_store_return_value (struct type *type, struct regcache *regcache, const gdb_byte *valbuf) { - int len = TYPE_LENGTH (type); + int len = type->length (); gdb_byte buf[32]; gdb_assert (!sparc_structure_return_p (type)); @@ -1521,13 +1521,13 @@ sparc32_return_value (struct gdbarch *gdbarch, struct value *function, { regcache_cooked_read_unsigned (regcache, SPARC_SP_REGNUM, &sp); addr = read_memory_unsigned_integer (sp + 64, 4, byte_order); - read_memory (addr, readbuf, TYPE_LENGTH (type)); + read_memory (addr, readbuf, type->length ()); } if (writebuf) { regcache_cooked_read_unsigned (regcache, SPARC_SP_REGNUM, &sp); addr = read_memory_unsigned_integer (sp + 64, 4, byte_order); - write_memory (addr, writebuf, TYPE_LENGTH (type)); + write_memory (addr, writebuf, type->length ()); } return RETURN_VALUE_ABI_PRESERVES_ADDRESS; @@ -1545,7 +1545,7 @@ static int sparc32_stabs_argument_has_addr (struct gdbarch *gdbarch, struct type *type) { return (sparc_structure_or_union_p (type) - || (sparc_floating_p (type) && TYPE_LENGTH (type) == 16) + || (sparc_floating_p (type) && type->length () == 16) || sparc_complex_floating_p (type)); } diff --git a/gdb/sparc64-tdep.c b/gdb/sparc64-tdep.c index 0945083..7b6e991 100644 --- a/gdb/sparc64-tdep.c +++ b/gdb/sparc64-tdep.c @@ -561,7 +561,7 @@ sparc64_integral_or_pointer_p (const struct type *type) case TYPE_CODE_ENUM: case TYPE_CODE_RANGE: { - int len = TYPE_LENGTH (type); + int len = type->length (); gdb_assert (len == 1 || len == 2 || len == 4 || len == 8); } return 1; @@ -569,7 +569,7 @@ sparc64_integral_or_pointer_p (const struct type *type) case TYPE_CODE_REF: case TYPE_CODE_RVALUE_REF: { - int len = TYPE_LENGTH (type); + int len = type->length (); gdb_assert (len == 8); } return 1; @@ -589,7 +589,7 @@ sparc64_floating_p (const struct type *type) { case TYPE_CODE_FLT: { - int len = TYPE_LENGTH (type); + int len = type->length (); gdb_assert (len == 4 || len == 8 || len == 16); } return 1; @@ -609,7 +609,7 @@ sparc64_complex_floating_p (const struct type *type) { case TYPE_CODE_COMPLEX: { - int len = TYPE_LENGTH (type); + int len = type->length (); gdb_assert (len == 8 || len == 16 || len == 32); } return 1; @@ -1180,7 +1180,7 @@ sparc64_16_byte_align_p (struct type *type) if (sparc64_floating_p (t)) return 1; } - if (sparc64_floating_p (type) && TYPE_LENGTH (type) == 16) + if (sparc64_floating_p (type) && type->length () == 16) return 1; if (sparc64_structure_or_union_p (type)) @@ -1210,7 +1210,7 @@ sparc64_store_floating_fields (struct regcache *regcache, struct type *type, const gdb_byte *valbuf, int element, int bitpos) { struct gdbarch *gdbarch = regcache->arch (); - int len = TYPE_LENGTH (type); + int len = type->length (); gdb_assert (element < 16); @@ -1286,7 +1286,7 @@ sparc64_store_floating_fields (struct regcache *regcache, struct type *type, { struct type *subtype = check_typedef (type->field (0).type ()); - if (sparc64_floating_p (subtype) && TYPE_LENGTH (subtype) == 4) + if (sparc64_floating_p (subtype) && subtype->length () == 4) regcache->cooked_write (SPARC_F1_REGNUM, valbuf); } } @@ -1305,7 +1305,7 @@ sparc64_extract_floating_fields (struct regcache *regcache, struct type *type, if (type->code () == TYPE_CODE_ARRAY) { - int len = TYPE_LENGTH (type); + int len = type->length (); int regnum = SPARC_F0_REGNUM + bitpos / 32; valbuf += bitpos / 8; @@ -1321,7 +1321,7 @@ sparc64_extract_floating_fields (struct regcache *regcache, struct type *type, } else if (sparc64_floating_p (type)) { - int len = TYPE_LENGTH (type); + int len = type->length (); int regnum; if (len == 16) @@ -1389,7 +1389,7 @@ sparc64_store_arguments (struct regcache *regcache, int nargs, for (i = 0; i < nargs; i++) { struct type *type = value_type (args[i]); - int len = TYPE_LENGTH (type); + int len = type->length (); if (sparc64_structure_or_union_p (type) || (sparc64_complex_floating_p (type) && len == 32)) @@ -1489,7 +1489,7 @@ sparc64_store_arguments (struct regcache *regcache, int nargs, { const gdb_byte *valbuf = value_contents (args[i]).data (); struct type *type = value_type (args[i]); - int len = TYPE_LENGTH (type); + int len = type->length (); int regnum = -1; gdb_byte buf[16]; @@ -1653,7 +1653,7 @@ static void sparc64_extract_return_value (struct type *type, struct regcache *regcache, gdb_byte *valbuf) { - int len = TYPE_LENGTH (type); + int len = type->length (); gdb_byte buf[32]; int i; @@ -1703,7 +1703,7 @@ static void sparc64_store_return_value (struct type *type, struct regcache *regcache, const gdb_byte *valbuf) { - int len = TYPE_LENGTH (type); + int len = type->length (); gdb_byte buf[16]; int i; @@ -1756,7 +1756,7 @@ sparc64_return_value (struct gdbarch *gdbarch, struct value *function, struct type *type, struct regcache *regcache, gdb_byte *readbuf, const gdb_byte *writebuf) { - if (TYPE_LENGTH (type) > 32) + if (type->length () > 32) return RETURN_VALUE_STRUCT_CONVENTION; if (readbuf) diff --git a/gdb/stabsread.c b/gdb/stabsread.c index af34353..6124435 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -800,7 +800,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type, dbl_type = objfile_type (objfile)->builtin_double; dbl_valu = (gdb_byte *) obstack_alloc (&objfile->objfile_obstack, - TYPE_LENGTH (dbl_type)); + dbl_type->length ()); target_float_from_string (dbl_valu, dbl_type, std::string (p)); @@ -1086,7 +1086,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type, { /* If PCC says a parameter is a short or a char, it is really an int. */ - if (TYPE_LENGTH (sym->type ()) + if (sym->type ()->length () < gdbarch_int_bit (gdbarch) / TARGET_CHAR_BIT && sym->type ()->code () == TYPE_CODE_INT) { @@ -2883,7 +2883,7 @@ read_one_struct_field (struct stab_field_info *fip, const char **pp, FIELD_BITSIZE (fip->list->field) = 0; } if ((FIELD_BITSIZE (fip->list->field) - == TARGET_CHAR_BIT * TYPE_LENGTH (field_type) + == TARGET_CHAR_BIT * field_type->length () || (field_type->code () == TYPE_CODE_ENUM && FIELD_BITSIZE (fip->list->field) == gdbarch_int_bit (gdbarch)) @@ -3384,8 +3384,8 @@ set_length_in_type_chain (struct type *type) while (ntype != type) { - if (TYPE_LENGTH(ntype) == 0) - ntype->set_length (TYPE_LENGTH (type)); + if (ntype->length () == 0) + ntype->set_length (type->length ()); else complain_about_struct_wipeout (ntype); ntype = TYPE_CHAIN (ntype); diff --git a/gdb/stack.c b/gdb/stack.c index 95aeea2..379635e 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -585,7 +585,7 @@ read_frame_arg (const frame_print_options &fp_opts, if (value_lazy (entryval)) value_fetch_lazy (entryval); - if (value_contents_eq (val, 0, entryval, 0, TYPE_LENGTH (type))) + if (value_contents_eq (val, 0, entryval, 0, type->length ())) { /* Initialize it just to avoid a GCC false warning. */ struct value *val_deref = NULL, *entryval_deref; @@ -612,7 +612,7 @@ read_frame_arg (const frame_print_options &fp_opts, if (val != val_deref && value_contents_eq (val_deref, 0, entryval_deref, 0, - TYPE_LENGTH (type_deref))) + type_deref->length ())) val_equal = 1; } catch (const gdb_exception_error &except) @@ -779,7 +779,7 @@ print_frame_args (const frame_print_options &fp_opts, case LOC_REF_ARG: { long current_offset = sym->value_longest (); - int arg_size = TYPE_LENGTH (sym->type ()); + int arg_size = sym->type ()->length (); /* Compute address of next argument by adding the size of this argument and rounding to an int boundary. */ diff --git a/gdb/stap-probe.c b/gdb/stap-probe.c index 2b3eb37..40d646a 100644 --- a/gdb/stap-probe.c +++ b/gdb/stap-probe.c @@ -1482,14 +1482,14 @@ stap_modify_semaphore (CORE_ADDR address, int set, struct gdbarch *gdbarch) ULONGEST value; /* Swallow errors. */ - if (target_read_memory (address, bytes, TYPE_LENGTH (type)) != 0) + if (target_read_memory (address, bytes, type->length ()) != 0) { warning (_("Could not read the value of a SystemTap semaphore.")); return; } enum bfd_endian byte_order = type_byte_order (type); - value = extract_unsigned_integer (bytes, TYPE_LENGTH (type), byte_order); + value = extract_unsigned_integer (bytes, type->length (), byte_order); /* Note that we explicitly don't worry about overflow or underflow. */ if (set) @@ -1497,9 +1497,9 @@ stap_modify_semaphore (CORE_ADDR address, int set, struct gdbarch *gdbarch) else --value; - store_unsigned_integer (bytes, TYPE_LENGTH (type), byte_order, value); + store_unsigned_integer (bytes, type->length (), byte_order, value); - if (target_write_memory (address, bytes, TYPE_LENGTH (type)) != 0) + if (target_write_memory (address, bytes, type->length ()) != 0) warning (_("Could not write the value of a SystemTap semaphore.")); } diff --git a/gdb/symmisc.c b/gdb/symmisc.c index 8508c06..09dd97f 100644 --- a/gdb/symmisc.c +++ b/gdb/symmisc.c @@ -567,8 +567,8 @@ print_symbol (struct gdbarch *gdbarch, struct symbol *symbol, struct type *type = check_typedef (symbol->type ()); gdb_printf (outfile, "const %s hex bytes:", - pulongest (TYPE_LENGTH (type))); - for (i = 0; i < TYPE_LENGTH (type); i++) + pulongest (type->length ())); + for (i = 0; i < type->length (); i++) gdb_printf (outfile, " %02x", (unsigned) symbol->value_bytes ()[i]); } diff --git a/gdb/target-float.c b/gdb/target-float.c index d077ca2..d0bf9ba 100644 --- a/gdb/target-float.c +++ b/gdb/target-float.c @@ -921,7 +921,7 @@ host_float_ops::to_target (const struct type *type, const T *from, gdb_byte *to) const { /* Ensure possible padding bytes in the target buffer are zeroed out. */ - memset (to, 0, TYPE_LENGTH (type)); + memset (to, 0, type->length ()); to_target (floatformat_from_type (type), from, to); } @@ -1499,7 +1499,7 @@ mpfr_float_ops::to_target (const struct type *type, const gdb_mpfr &from, gdb_byte *to) const { /* Ensure possible padding bytes in the target buffer are zeroed out. */ - memset (to, 0, TYPE_LENGTH (type)); + memset (to, 0, type->length ()); to_target (floatformat_from_type (type), from, to); } @@ -1744,7 +1744,7 @@ match_endianness (const gdb_byte *from, const struct type *type, gdb_byte *to) { gdb_assert (type->code () == TYPE_CODE_DECFLOAT); - int len = TYPE_LENGTH (type); + int len = type->length (); int i; #if WORDS_BIGENDIAN @@ -1770,7 +1770,7 @@ set_decnumber_context (decContext *ctx, const struct type *type) { gdb_assert (type->code () == TYPE_CODE_DECFLOAT); - switch (TYPE_LENGTH (type)) + switch (type->length ()) { case 4: decContextDefault (ctx, DEC_INIT_DECIMAL32); @@ -1816,7 +1816,7 @@ decimal_from_number (const decNumber *from, set_decnumber_context (&set, type); - switch (TYPE_LENGTH (type)) + switch (type->length ()) { case 4: decimal32FromNumber ((decimal32 *) dec, from, &set); @@ -1844,7 +1844,7 @@ decimal_to_number (const gdb_byte *addr, const struct type *type, gdb_byte dec[16]; match_endianness (addr, type, dec); - switch (TYPE_LENGTH (type)) + switch (type->length ()) { case 4: decimal32ToNumber ((decimal32 *) dec, to); @@ -1940,7 +1940,7 @@ decimal_float_ops::to_string (const gdb_byte *addr, const struct type *type, std::string result; result.resize (MAX_DECIMAL_STRING); - switch (TYPE_LENGTH (type)) + switch (type->length ()) { case 4: decimal32ToString ((decimal32 *) dec, &result[0]); @@ -1971,7 +1971,7 @@ decimal_float_ops::from_string (gdb_byte *addr, const struct type *type, set_decnumber_context (&set, type); - switch (TYPE_LENGTH (type)) + switch (type->length ()) { case 4: decimal32FromString ((decimal32 *) dec, string.c_str (), &set); @@ -2100,7 +2100,7 @@ decimal_float_ops::compare (const gdb_byte *x, const struct type *type_x, decimal_to_number (y, type_y, &number2); /* Perform the comparison in the larger of the two sizes. */ - type_result = TYPE_LENGTH (type_x) > TYPE_LENGTH (type_y) ? type_x : type_y; + type_result = type_x->length () > type_y->length () ? type_x : type_y; set_decnumber_context (&set, type_result); decNumberCompare (&result, &number1, &number2, &set); @@ -2159,7 +2159,7 @@ target_float_same_format_p (const struct type *type1, return floatformat_from_type (type1) == floatformat_from_type (type2); case TYPE_CODE_DECFLOAT: - return (TYPE_LENGTH (type1) == TYPE_LENGTH (type2) + return (type1->length () == type2->length () && (type_byte_order (type1) == type_byte_order (type2))); @@ -2179,7 +2179,7 @@ target_float_format_length (const struct type *type) return floatformat_totalsize_bytes (floatformat_from_type (type)); case TYPE_CODE_DECFLOAT: - return TYPE_LENGTH (type); + return type->length (); default: gdb_assert_not_reached ("unexpected type code"); @@ -2459,7 +2459,7 @@ target_float_convert (const gdb_byte *from, const struct type *from_type, /* The floating-point formats match, so we simply copy the data, ensuring possible padding bytes in the target buffer are zeroed out. */ - memset (to, 0, TYPE_LENGTH (to_type)); + memset (to, 0, to_type->length ()); memcpy (to, from, target_float_format_length (to_type)); } diff --git a/gdb/tic6x-tdep.c b/gdb/tic6x-tdep.c index df3295e..5dd84f8 100644 --- a/gdb/tic6x-tdep.c +++ b/gdb/tic6x-tdep.c @@ -702,7 +702,7 @@ static void tic6x_extract_return_value (struct type *valtype, struct regcache *regcache, enum bfd_endian byte_order, gdb_byte *valbuf) { - int len = TYPE_LENGTH (valtype); + int len = valtype->length (); /* pointer types are returned in register A4, up to 32-bit types in A4 @@ -746,7 +746,7 @@ static void tic6x_store_return_value (struct type *valtype, struct regcache *regcache, enum bfd_endian byte_order, const gdb_byte *valbuf) { - int len = TYPE_LENGTH (valtype); + int len = valtype->length (); /* return values of up to 8 bytes are returned in A5:A4 */ @@ -792,7 +792,7 @@ tic6x_return_value (struct gdbarch *gdbarch, struct value *function, } } - if (TYPE_LENGTH (type) > 8) + if (type->length () > 8) return RETURN_VALUE_STRUCT_CONVENTION; if (readbuf) @@ -810,7 +810,7 @@ tic6x_return_value (struct gdbarch *gdbarch, struct value *function, static int tic6x_arg_type_alignment (struct type *type) { - int len = TYPE_LENGTH (check_typedef (type)); + int len = check_typedef (type)->length (); enum type_code typecode = check_typedef (type)->code (); if (typecode == TYPE_CODE_STRUCT || typecode == TYPE_CODE_UNION) @@ -898,7 +898,7 @@ tic6x_push_dummy_call (struct gdbarch *gdbarch, struct value *function, /* Now make space on the stack for the args. */ for (argnum = 0; argnum < nargs; argnum++) { - int len = align_up (TYPE_LENGTH (value_type (args[argnum])), 4); + int len = align_up (value_type (args[argnum])->length (), 4); if (argnum >= 10 - argreg) references_offset += len; stack_offset += len; @@ -917,7 +917,7 @@ tic6x_push_dummy_call (struct gdbarch *gdbarch, struct value *function, const gdb_byte *val; struct value *arg = args[argnum]; struct type *arg_type = check_typedef (value_type (arg)); - int len = TYPE_LENGTH (arg_type); + int len = arg_type->length (); enum type_code typecode = arg_type->code (); val = value_contents (arg).data (); diff --git a/gdb/tilegx-tdep.c b/gdb/tilegx-tdep.c index 744aca9..2888251 100644 --- a/gdb/tilegx-tdep.c +++ b/gdb/tilegx-tdep.c @@ -204,7 +204,7 @@ tilegx_use_struct_convention (struct type *type) /* Only scalars which fit in R0 - R9 can be returned in registers. Otherwise, they are returned via a pointer passed in R0. */ return (!tilegx_type_is_scalar (type) - && (TYPE_LENGTH (type) > (1 + TILEGX_R9_REGNUM - TILEGX_R0_REGNUM) + && (type->length () > (1 + TILEGX_R9_REGNUM - TILEGX_R0_REGNUM) * tilegx_reg_size)); } @@ -215,7 +215,7 @@ static void tilegx_extract_return_value (struct type *type, struct regcache *regcache, gdb_byte *valbuf) { - int len = TYPE_LENGTH (type); + int len = type->length (); int i, regnum = TILEGX_R0_REGNUM; for (i = 0; i < len; i += tilegx_reg_size) @@ -230,17 +230,17 @@ static void tilegx_store_return_value (struct type *type, struct regcache *regcache, const void *valbuf) { - if (TYPE_LENGTH (type) < tilegx_reg_size) + if (type->length () < tilegx_reg_size) { /* Add leading zeros to the (little-endian) value. */ gdb_byte buf[tilegx_reg_size] = { 0 }; - memcpy (buf, valbuf, TYPE_LENGTH (type)); + memcpy (buf, valbuf, type->length ()); regcache->raw_write (TILEGX_R0_REGNUM, buf); } else { - int len = TYPE_LENGTH (type); + int len = type->length (); int i, regnum = TILEGX_R0_REGNUM; for (i = 0; i < len; i += tilegx_reg_size) @@ -302,7 +302,7 @@ tilegx_push_dummy_call (struct gdbarch *gdbarch, for (i = 0; i < nargs && argreg <= TILEGX_R9_REGNUM; i++) { const gdb_byte *val; - typelen = TYPE_LENGTH (value_enclosing_type (args[i])); + typelen = value_enclosing_type (args[i])->length (); if (typelen > (TILEGX_R9_REGNUM - argreg + 1) * tilegx_reg_size) break; @@ -329,7 +329,7 @@ tilegx_push_dummy_call (struct gdbarch *gdbarch, { const gdb_byte *contents = value_contents (args[j]).data (); - typelen = TYPE_LENGTH (value_enclosing_type (args[j])); + typelen = value_enclosing_type (args[j])->length (); slacklen = align_up (typelen, 8) - typelen; gdb::byte_vector val (typelen + slacklen); memcpy (val.data (), contents, typelen); diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index dfb62dc..6f01f52 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -922,7 +922,7 @@ collection_list::collect_symbol (struct symbol *sym, bfd_signed_vma offset; int treat_as_expr = 0; - len = TYPE_LENGTH (check_typedef (sym->type ())); + len = check_typedef (sym->type ())->length (); switch (sym->aclass ()) { default: @@ -1387,7 +1387,7 @@ encode_actions_1 (struct command_line *action, check_typedef (type); collect->add_memrange (target_gdbarch (), memrange_absolute, addr, - TYPE_LENGTH (type), + type->length (), tloc->address); collect->append_exp (std::string (exp_start, action_exp)); @@ -2532,7 +2532,7 @@ info_scope_command (const char *args_in, int from_tty) case LOC_CONST_BYTES: gdb_printf ("constant bytes: "); if (sym->type ()) - for (j = 0; j < TYPE_LENGTH (sym->type ()); j++) + for (j = 0; j < sym->type ()->length (); j++) gdb_printf (" %02x", (unsigned) sym->value_bytes ()[j]); break; case LOC_STATIC: @@ -2612,7 +2612,7 @@ info_scope_command (const char *args_in, int from_tty) { struct type *t = check_typedef (sym->type ()); - gdb_printf (", length %s.\n", pulongest (TYPE_LENGTH (t))); + gdb_printf (", length %s.\n", pulongest (t->length ())); } } if (block->function ()) diff --git a/gdb/typeprint.c b/gdb/typeprint.c index ff677b2..7904312 100644 --- a/gdb/typeprint.c +++ b/gdb/typeprint.c @@ -138,13 +138,13 @@ print_offset_data::update (struct type *type, unsigned int field_idx, print their sizes. */ gdb_printf (stream, "/* %6s */", (print_in_hex ? - hex_string_custom (TYPE_LENGTH (ftype), 4) : - pulongest (TYPE_LENGTH (ftype)))); + hex_string_custom (ftype->length (), 4) : + pulongest (ftype->length ()))); return; } unsigned int bitpos = type->field (field_idx).loc_bitpos (); - unsigned int fieldsize_byte = TYPE_LENGTH (ftype); + unsigned int fieldsize_byte = ftype->length (); unsigned int fieldsize_bit = fieldsize_byte * TARGET_CHAR_BIT; maybe_print_hole (stream, bitpos, "hole"); @@ -184,13 +184,13 @@ void print_offset_data::finish (struct type *type, int level, struct ui_file *stream) { - unsigned int bitpos = TYPE_LENGTH (type) * TARGET_CHAR_BIT; + unsigned int bitpos = type->length () * TARGET_CHAR_BIT; maybe_print_hole (stream, bitpos, "padding"); gdb_puts ("\n", stream); print_spaces (level + 4 + print_offset_data::indentation, stream); gdb_printf (stream, "/* total size (bytes): %4s */\n", - pulongest (TYPE_LENGTH (type))); + pulongest (type->length ())); } @@ -694,7 +694,7 @@ print_type_fixed_point (struct type *type, struct ui_file *stream) std::string small_img = type->fixed_point_scaling_factor ().str (); gdb_printf (stream, "%s-byte fixed point (small = %s)", - pulongest (TYPE_LENGTH (type)), small_img.c_str ()); + pulongest (type->length ()), small_img.c_str ()); } /* Dump details of a type specified either directly or indirectly. diff --git a/gdb/v850-tdep.c b/gdb/v850-tdep.c index 73628e1..f27c6ab 100644 --- a/gdb/v850-tdep.c +++ b/gdb/v850-tdep.c @@ -515,14 +515,14 @@ v850_use_struct_convention (struct gdbarch *gdbarch, struct type *type) if (tdep->abi == V850_ABI_RH850) { - if (v850_type_is_scalar (type) && TYPE_LENGTH(type) <= 8) + if (v850_type_is_scalar (type) && type->length () <= 8) return 0; /* Structs are never returned in registers for this ABI. */ return 1; } /* 1. The value is greater than 8 bytes -> returned by copying. */ - if (TYPE_LENGTH (type) > 8) + if (type->length () > 8) return 1; /* 2. The value is a single basic type -> returned in register. */ @@ -537,13 +537,13 @@ v850_use_struct_convention (struct gdbarch *gdbarch, struct type *type) && type->num_fields () == 1) { fld_type = type->field (0).type (); - if (v850_type_is_scalar (fld_type) && TYPE_LENGTH (fld_type) >= 4) + if (v850_type_is_scalar (fld_type) && fld_type->length () >= 4) return 0; if (fld_type->code () == TYPE_CODE_ARRAY) { tgt_type = fld_type->target_type (); - if (v850_type_is_scalar (tgt_type) && TYPE_LENGTH (tgt_type) >= 4) + if (v850_type_is_scalar (tgt_type) && tgt_type->length () >= 4) return 0; } } @@ -553,7 +553,7 @@ v850_use_struct_convention (struct gdbarch *gdbarch, struct type *type) register. */ if (type->code () == TYPE_CODE_STRUCT && v850_type_is_scalar (type->field (0).type ()) - && TYPE_LENGTH (type->field (0).type ()) == 4) + && type->field (0).type ()->length () == 4) { for (i = 1; i < type->num_fields (); ++i) { @@ -561,8 +561,8 @@ v850_use_struct_convention (struct gdbarch *gdbarch, struct type *type) if (fld_type->code () == TYPE_CODE_ARRAY) { tgt_type = fld_type->target_type (); - if (TYPE_LENGTH (tgt_type) > 0 - && TYPE_LENGTH (fld_type) / TYPE_LENGTH (tgt_type) > 2) + if (tgt_type->length () > 0 + && fld_type->length () / tgt_type->length () > 2) return 1; } } @@ -978,7 +978,7 @@ v850_eight_byte_align_p (struct type *type) type = check_typedef (type); if (v850_type_is_scalar (type)) - return (TYPE_LENGTH (type) == 8); + return (type->length () == 8); else { int i; @@ -1039,7 +1039,7 @@ v850_push_dummy_call (struct gdbarch *gdbarch, /* Now make space on the stack for the args. */ for (argnum = 0; argnum < nargs; argnum++) - arg_space += ((TYPE_LENGTH (value_type (args[argnum])) + 3) & ~3); + arg_space += ((value_type (args[argnum])->length () + 3) & ~3); sp -= arg_space + stack_offset; argreg = E_ARG0_REGNUM; @@ -1058,7 +1058,7 @@ v850_push_dummy_call (struct gdbarch *gdbarch, if (!v850_type_is_scalar (value_type (*args)) && tdep->abi == V850_ABI_GCC - && TYPE_LENGTH (value_type (*args)) > E_MAX_RETTYPE_SIZE_IN_REGS) + && value_type (*args)->length () > E_MAX_RETTYPE_SIZE_IN_REGS) { store_unsigned_integer (valbuf, 4, byte_order, value_address (*args)); @@ -1067,7 +1067,7 @@ v850_push_dummy_call (struct gdbarch *gdbarch, } else { - len = TYPE_LENGTH (value_type (*args)); + len = value_type (*args)->length (); val = (gdb_byte *) value_contents (*args).data (); } @@ -1118,7 +1118,7 @@ v850_extract_return_value (struct type *type, struct regcache *regcache, { struct gdbarch *gdbarch = regcache->arch (); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); - int len = TYPE_LENGTH (type); + int len = type->length (); if (len <= v850_reg_size) { @@ -1145,7 +1145,7 @@ v850_store_return_value (struct type *type, struct regcache *regcache, { struct gdbarch *gdbarch = regcache->arch (); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); - int len = TYPE_LENGTH (type); + int len = type->length (); if (len <= v850_reg_size) regcache_cooked_write_unsigned diff --git a/gdb/valarith.c b/gdb/valarith.c index 940d60a..c0e937d 100644 --- a/gdb/valarith.c +++ b/gdb/valarith.c @@ -115,8 +115,8 @@ value_ptrdiff (struct value *arg1, struct value *arg2) gdb_assert (type1->code () == TYPE_CODE_PTR); gdb_assert (type2->code () == TYPE_CODE_PTR); - if (TYPE_LENGTH (check_typedef (type1->target_type ())) - != TYPE_LENGTH (check_typedef (type2->target_type ()))) + if (check_typedef (type1->target_type ())->length () + != check_typedef (type2->target_type ())->length ()) error (_("First argument of `-' is a pointer and " "second argument is neither\n" "an integer nor a pointer of the same type.")); @@ -770,7 +770,7 @@ value_args_as_target_float (struct value *arg1, struct value *arg2, if (is_floating_type (type1)) { *eff_type_x = type1; - memcpy (x, value_contents (arg1).data (), TYPE_LENGTH (type1)); + memcpy (x, value_contents (arg1).data (), type1->length ()); } else if (is_integral_type (type1)) { @@ -789,7 +789,7 @@ value_args_as_target_float (struct value *arg1, struct value *arg2, if (is_floating_type (type2)) { *eff_type_y = type2; - memcpy (y, value_contents (arg2).data (), TYPE_LENGTH (type2)); + memcpy (y, value_contents (arg2).data (), type2->length ()); } else if (is_integral_type (type2)) { @@ -930,7 +930,7 @@ promotion_type (struct type *type1, struct type *type2) result_type = type2; else if (!is_floating_type (type2)) result_type = type1; - else if (TYPE_LENGTH (type2) > TYPE_LENGTH (type1)) + else if (type2->length () > type1->length ()) result_type = type2; else result_type = type1; @@ -938,9 +938,9 @@ promotion_type (struct type *type1, struct type *type2) else { /* Integer types. */ - if (TYPE_LENGTH (type1) > TYPE_LENGTH (type2)) + if (type1->length () > type2->length ()) result_type = type1; - else if (TYPE_LENGTH (type2) > TYPE_LENGTH (type1)) + else if (type2->length () > type1->length ()) result_type = type2; else if (type1->is_unsigned ()) result_type = type1; @@ -1074,7 +1074,7 @@ static int type_length_bits (type *type) { int unit_size = gdbarch_addressable_memory_unit_size (type->arch ()); - return unit_size * 8 * TYPE_LENGTH (type); + return unit_size * 8 * type->length (); } /* Check whether the RHS value of a shift is valid in C/C++ semantics. @@ -1168,8 +1168,8 @@ scalar_binop (struct value *arg1, struct value *arg2, enum exp_opcode op) struct type *eff_type_v1, *eff_type_v2; gdb::byte_vector v1, v2; - v1.resize (TYPE_LENGTH (result_type)); - v2.resize (TYPE_LENGTH (result_type)); + v1.resize (result_type->length ()); + v2.resize (result_type->length ()); value_args_as_target_float (arg1, arg2, v1.data (), &eff_type_v1, @@ -1216,7 +1216,7 @@ scalar_binop (struct value *arg1, struct value *arg2, enum exp_opcode op) val = allocate_value (result_type); store_signed_integer (value_contents_raw (val).data (), - TYPE_LENGTH (result_type), + result_type->length (), type_byte_order (result_type), v); } @@ -1362,7 +1362,7 @@ scalar_binop (struct value *arg1, struct value *arg2, enum exp_opcode op) val = allocate_value (result_type); store_unsigned_integer (value_contents_raw (val).data (), - TYPE_LENGTH (value_type (val)), + value_type (val)->length (), type_byte_order (result_type), v); } @@ -1523,7 +1523,7 @@ scalar_binop (struct value *arg1, struct value *arg2, enum exp_opcode op) val = allocate_value (result_type); store_signed_integer (value_contents_raw (val).data (), - TYPE_LENGTH (value_type (val)), + value_type (val)->length (), type_byte_order (result_type), v); } @@ -1562,13 +1562,13 @@ value_vector_widen (struct value *scalar_value, struct type *vector_type) /* If we reduced the length of the scalar then check we didn't loose any important bits. */ - if (TYPE_LENGTH (eltype) < TYPE_LENGTH (scalar_type) + if (eltype->length () < scalar_type->length () && !value_equal (elval, scalar_value)) error (_("conversion of scalar to vector involves truncation")); value *val = allocate_value (vector_type); gdb::array_view val_contents = value_contents_writeable (val); - int elt_len = TYPE_LENGTH (eltype); + int elt_len = eltype->length (); for (i = 0; i < high_bound - low_bound + 1; i++) /* Duplicate the contents of elval into the destination vector. */ @@ -1605,10 +1605,10 @@ vector_binop (struct value *val1, struct value *val2, enum exp_opcode op) eltype1 = check_typedef (type1->target_type ()); eltype2 = check_typedef (type2->target_type ()); - elsize = TYPE_LENGTH (eltype1); + elsize = eltype1->length (); if (eltype1->code () != eltype2->code () - || elsize != TYPE_LENGTH (eltype2) + || elsize != eltype2->length () || eltype1->is_unsigned () != eltype2->is_unsigned () || low_bound1 != low_bound2 || high_bound1 != high_bound2) error (_("Cannot perform operation on vectors with different types")); @@ -1680,7 +1680,7 @@ value_logical_not (struct value *arg1) if (is_floating_value (arg1)) return target_float_is_zero (value_contents (arg1).data (), type1); - len = TYPE_LENGTH (type1); + len = type1->length (); p = value_contents (arg1).data (); while (--len >= 0) @@ -1698,8 +1698,8 @@ value_logical_not (struct value *arg1) static int value_strcmp (struct value *arg1, struct value *arg2) { - int len1 = TYPE_LENGTH (value_type (arg1)); - int len2 = TYPE_LENGTH (value_type (arg2)); + int len1 = value_type (arg1)->length (); + int len2 = value_type (arg2)->length (); const gdb_byte *s1 = value_contents (arg1).data (); const gdb_byte *s2 = value_contents (arg2).data (); int i, len = len1 < len2 ? len1 : len2; @@ -1754,8 +1754,8 @@ value_equal (struct value *arg1, struct value *arg2) { struct type *eff_type_v1, *eff_type_v2; gdb::byte_vector v1, v2; - v1.resize (std::max (TYPE_LENGTH (type1), TYPE_LENGTH (type2))); - v2.resize (std::max (TYPE_LENGTH (type1), TYPE_LENGTH (type2))); + v1.resize (std::max (type1->length (), type2->length ())); + v2.resize (std::max (type1->length (), type2->length ())); value_args_as_target_float (arg1, arg2, v1.data (), &eff_type_v1, @@ -1773,8 +1773,8 @@ value_equal (struct value *arg1, struct value *arg2) return (CORE_ADDR) value_as_long (arg1) == value_as_address (arg2); else if (code1 == code2 - && ((len = (int) TYPE_LENGTH (type1)) - == (int) TYPE_LENGTH (type2))) + && ((len = (int) type1->length ()) + == (int) type2->length ())) { p1 = value_contents (arg1).data (); p2 = value_contents (arg2).data (); @@ -1806,10 +1806,10 @@ value_equal_contents (struct value *arg1, struct value *arg2) type2 = check_typedef (value_type (arg2)); return (type1->code () == type2->code () - && TYPE_LENGTH (type1) == TYPE_LENGTH (type2) + && type1->length () == type2->length () && memcmp (value_contents (arg1).data (), value_contents (arg2).data (), - TYPE_LENGTH (type1)) == 0); + type1->length ()) == 0); } /* Simulate the C operator < by returning 1 @@ -1842,8 +1842,8 @@ value_less (struct value *arg1, struct value *arg2) { struct type *eff_type_v1, *eff_type_v2; gdb::byte_vector v1, v2; - v1.resize (std::max (TYPE_LENGTH (type1), TYPE_LENGTH (type2))); - v2.resize (std::max (TYPE_LENGTH (type1), TYPE_LENGTH (type2))); + v1.resize (std::max (type1->length (), type2->length ())); + v2.resize (std::max (type1->length (), type2->length ())); value_args_as_target_float (arg1, arg2, v1.data (), &eff_type_v1, @@ -1911,7 +1911,7 @@ value_neg (struct value *arg1) error (_("Could not determine the vector bounds")); gdb::array_view val_contents = value_contents_writeable (val); - int elt_len = TYPE_LENGTH (eltype); + int elt_len = eltype->length (); for (i = 0; i < high_bound - low_bound + 1; i++) { @@ -1956,7 +1956,7 @@ value_complement (struct value *arg1) val = allocate_value (type); gdb::array_view val_contents = value_contents_writeable (val); - int elt_len = TYPE_LENGTH (eltype); + int elt_len = eltype->length (); for (i = 0; i < high_bound - low_bound + 1; i++) { diff --git a/gdb/valops.c b/gdb/valops.c index 064021f..b4866d0 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -473,12 +473,12 @@ value_cast (struct type *type, struct value *arg2) if (code1 == TYPE_CODE_ARRAY) { struct type *element_type = type->target_type (); - unsigned element_length = TYPE_LENGTH (check_typedef (element_type)); + unsigned element_length = check_typedef (element_type)->length (); if (element_length > 0 && type->bounds ()->high.kind () == PROP_UNDEFINED) { struct type *range_type = type->index_type (); - int val_length = TYPE_LENGTH (type2); + int val_length = type2->length (); LONGEST low_bound, high_bound, new_length; if (!get_discrete_bounds (range_type, &low_bound, &high_bound)) @@ -594,7 +594,7 @@ value_cast (struct type *type, struct value *arg2) || code2 == TYPE_CODE_ENUM || code2 == TYPE_CODE_RANGE)) { - /* TYPE_LENGTH (type) is the length of a pointer, but we really + /* type->length () is the length of a pointer, but we really want the length of an address! -- we are really dealing with addresses (i.e., gdb representations) not pointers (i.e., target representations) here. @@ -633,16 +633,16 @@ value_cast (struct type *type, struct value *arg2) } else if (code1 == TYPE_CODE_ARRAY && type->is_vector () && code2 == TYPE_CODE_ARRAY && type2->is_vector () - && TYPE_LENGTH (type) != TYPE_LENGTH (type2)) + && type->length () != type2->length ()) error (_("Cannot convert between vector values of different sizes")); else if (code1 == TYPE_CODE_ARRAY && type->is_vector () && scalar - && TYPE_LENGTH (type) != TYPE_LENGTH (type2)) + && type->length () != type2->length ()) error (_("can only cast scalar to vector of same size")); else if (code1 == TYPE_CODE_VOID) { return value_zero (to_type, not_lval); } - else if (TYPE_LENGTH (type) == TYPE_LENGTH (type2)) + else if (type->length () == type2->length ()) { if (code1 == TYPE_CODE_PTR && code2 == TYPE_CODE_PTR) return value_cast_pointers (to_type, arg2, 0); @@ -745,7 +745,7 @@ dynamic_cast_check_1 (struct type *desired_type, if (class_types_same_p (desired_type, TYPE_BASECLASS (search_type, i))) { if (address + embedded_offset + offset >= arg_addr - && address + embedded_offset + offset < arg_addr + TYPE_LENGTH (arg_type)) + && address + embedded_offset + offset < arg_addr + arg_type->length ()) { ++result_count; if (!*result) @@ -956,7 +956,7 @@ value_one (struct type *type) val = allocate_value (type); gdb::array_view val_contents = value_contents_writeable (val); - int elt_len = TYPE_LENGTH (eltype); + int elt_len = eltype->length (); for (i = 0; i < high_bound - low_bound + 1; i++) { @@ -1154,10 +1154,10 @@ value_assign (struct value *toval, struct value *fromval) containing type (e.g. short or int) then do so. This is safer for volatile bitfields mapped to hardware registers. */ - if (changed_len < TYPE_LENGTH (type) - && TYPE_LENGTH (type) <= (int) sizeof (LONGEST) - && ((LONGEST) changed_addr % TYPE_LENGTH (type)) == 0) - changed_len = TYPE_LENGTH (type); + if (changed_len < type->length () + && type->length () <= (int) sizeof (LONGEST) + && ((LONGEST) changed_addr % type->length ()) == 0) + changed_len = type->length (); if (changed_len > (int) sizeof (LONGEST)) error (_("Can't handle bitfields which " @@ -1473,7 +1473,7 @@ value_coerce_to_target (struct value *val) if (!value_must_coerce_to_target (val)) return val; - length = TYPE_LENGTH (check_typedef (value_type (val))); + length = check_typedef (value_type (val))->length (); addr = allocate_space_in_inferior (length); write_memory (addr, value_contents (val).data (), length); return value_at_lazy (value_type (val), addr); @@ -1547,7 +1547,7 @@ value_addr (struct value *arg1) if (TYPE_IS_REFERENCE (type)) { if (value_bits_synthetic_pointer (arg1, value_embedded_offset (arg1), - TARGET_CHAR_BIT * TYPE_LENGTH (type))) + TARGET_CHAR_BIT * type->length ())) arg1 = coerce_ref (arg1); else { @@ -1736,7 +1736,7 @@ value_cstring (const char *ptr, ssize_t len, struct type *char_type) { struct value *val; int lowbound = current_language->string_lower_bound (); - ssize_t highbound = len / TYPE_LENGTH (char_type); + ssize_t highbound = len / char_type->length (); struct type *stringtype = lookup_array_range_type (char_type, lowbound, highbound + lowbound - 1); @@ -1759,7 +1759,7 @@ value_string (const char *ptr, ssize_t len, struct type *char_type) { struct value *val; int lowbound = current_language->string_lower_bound (); - ssize_t highbound = len / TYPE_LENGTH (char_type); + ssize_t highbound = len / char_type->length (); struct type *stringtype = lookup_string_range_type (char_type, lowbound, highbound + lowbound - 1); @@ -2087,7 +2087,7 @@ struct_field_searcher::search (struct value *arg1, LONGEST offset, boffset += value_embedded_offset (arg1) + offset; if (boffset < 0 - || boffset >= TYPE_LENGTH (value_enclosing_type (arg1))) + || boffset >= value_enclosing_type (arg1)->length ()) { CORE_ADDR base_addr; @@ -2095,7 +2095,7 @@ struct_field_searcher::search (struct value *arg1, LONGEST offset, v2 = value_at_lazy (basetype, base_addr); if (target_read_memory (base_addr, value_contents_raw (v2).data (), - TYPE_LENGTH (value_type (v2))) != 0) + value_type (v2)->length ()) != 0) error (_("virtual baseclass botch")); } else @@ -2266,15 +2266,15 @@ search_struct_method (const char *name, struct value **arg1p, clobbered by the user program. Make sure that it still points to a valid memory location. */ - if (offset < 0 || offset >= TYPE_LENGTH (type)) + if (offset < 0 || offset >= type->length ()) { CORE_ADDR address; - gdb::byte_vector tmp (TYPE_LENGTH (baseclass)); + gdb::byte_vector tmp (baseclass->length ()); address = value_address (*arg1p); if (target_read_memory (address + offset, - tmp.data (), TYPE_LENGTH (baseclass)) != 0) + tmp.data (), baseclass->length ()) != 0) error (_("virtual baseclass botch")); base_val = value_from_contents_and_address (baseclass, @@ -3900,7 +3900,7 @@ value_full_object (struct value *argp, the object's type. In this case it is better to leave the object as-is. */ if (full - && TYPE_LENGTH (real_type) < TYPE_LENGTH (value_enclosing_type (argp))) + && real_type->length () < value_enclosing_type (argp)->length ()) return argp; /* If we have the full object, but for some reason the enclosing @@ -4021,7 +4021,7 @@ value_slice (struct value *array, int lowbound, int length) { struct type *element_type = array_type->target_type (); LONGEST offset - = (lowbound - lowerbound) * TYPE_LENGTH (check_typedef (element_type)); + = (lowbound - lowerbound) * check_typedef (element_type)->length (); slice_type = create_array_type (NULL, element_type, @@ -4058,7 +4058,7 @@ value_literal_complex (struct value *arg1, arg1 = value_cast (real_type, arg1); arg2 = value_cast (real_type, arg2); - int len = TYPE_LENGTH (real_type); + int len = real_type->length (); copy (value_contents (arg1), value_contents_raw (val).slice (0, len)); @@ -4090,7 +4090,7 @@ value_imaginary_part (struct value *value) gdb_assert (type->code () == TYPE_CODE_COMPLEX); return value_from_component (value, ttype, - TYPE_LENGTH (check_typedef (ttype))); + check_typedef (ttype)->length ()); } /* Cast a value into the appropriate complex data type. */ @@ -4105,7 +4105,7 @@ cast_into_complex (struct type *type, struct value *val) struct type *val_real_type = value_type (val)->target_type (); struct value *re_val = allocate_value (val_real_type); struct value *im_val = allocate_value (val_real_type); - int len = TYPE_LENGTH (val_real_type); + int len = val_real_type->length (); copy (value_contents (val).slice (0, len), value_contents_raw (re_val)); diff --git a/gdb/valprint.c b/gdb/valprint.c index a926f32..91a5941 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -354,14 +354,14 @@ valprint_check_validity (struct ui_file *stream, { if (value_bits_any_optimized_out (val, TARGET_CHAR_BIT * embedded_offset, - TARGET_CHAR_BIT * TYPE_LENGTH (type))) + TARGET_CHAR_BIT * type->length ())) { val_print_optimized_out (val, stream); return 0; } if (value_bits_synthetic_pointer (val, TARGET_CHAR_BIT * embedded_offset, - TARGET_CHAR_BIT * TYPE_LENGTH (type))) + TARGET_CHAR_BIT * type->length ())) { const int is_ref = type->code () == TYPE_CODE_REF; int ref_is_addressable = 0; @@ -382,7 +382,7 @@ valprint_check_validity (struct ui_file *stream, return is_ref; } - if (!value_bytes_available (val, embedded_offset, TYPE_LENGTH (type))) + if (!value_bytes_available (val, embedded_offset, type->length ())) { val_print_unavailable (stream); return 0; @@ -459,7 +459,7 @@ generic_val_print_array (struct value *val, struct type *unresolved_elttype = type->target_type (); struct type *elttype = check_typedef (unresolved_elttype); - if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (unresolved_elttype) > 0) + if (type->length () > 0 && unresolved_elttype->length () > 0) { LONGEST low_bound, high_bound; @@ -549,7 +549,7 @@ generic_val_print_ref (struct type *type, const int value_is_synthetic = value_bits_synthetic_pointer (original_value, TARGET_CHAR_BIT * embedded_offset, - TARGET_CHAR_BIT * TYPE_LENGTH (type)); + TARGET_CHAR_BIT * type->length ()); const int must_coerce_ref = ((options->addressprint && value_is_synthetic) || options->deref_ref); const int type_is_defined = elttype->code () != TYPE_CODE_UNDEF; @@ -832,11 +832,11 @@ generic_val_print_fixed_point (struct value *val, struct ui_file *stream, const gdb_byte *valaddr = value_contents_for_printing (val).data (); gdb_mpf f; - f.read_fixed_point (gdb::make_array_view (valaddr, TYPE_LENGTH (type)), + f.read_fixed_point (gdb::make_array_view (valaddr, type->length ()), type_byte_order (type), type->is_unsigned (), type->fixed_point_scaling_factor ()); - const char *fmt = TYPE_LENGTH (type) < 4 ? "%.11Fg" : "%.17Fg"; + const char *fmt = type->length () < 4 ? "%.11Fg" : "%.17Fg"; std::string str = gmp_string_printf (fmt, f.val); gdb_printf (stream, "%s", str.c_str ()); } @@ -1285,9 +1285,9 @@ value_print_scalar_formatted (struct value *val, /* A scalar object that does not have all bits available can't be printed, because all bits contribute to its representation. */ if (value_bits_any_optimized_out (val, 0, - TARGET_CHAR_BIT * TYPE_LENGTH (type))) + TARGET_CHAR_BIT * type->length ())) val_print_optimized_out (val, stream); - else if (!value_bytes_available (val, 0, TYPE_LENGTH (type))) + else if (!value_bytes_available (val, 0, type->length ())) val_print_unavailable (stream); else print_scalar_formatted (valaddr, type, options, size, stream); @@ -2169,10 +2169,10 @@ generic_emit_char (int c, struct type *type, struct ui_file *stream, gdb_byte *c_buf; int need_escape = 0; - c_buf = (gdb_byte *) alloca (TYPE_LENGTH (type)); + c_buf = (gdb_byte *) alloca (type->length ()); pack_long (c_buf, type, c); - wchar_iterator iter (c_buf, TYPE_LENGTH (type), encoding, TYPE_LENGTH (type)); + wchar_iterator iter (c_buf, type->length (), encoding, type->length ()); /* This holds the printable form of the wchar_t data. */ auto_obstack wchar_buf; @@ -2210,14 +2210,14 @@ generic_emit_char (int c, struct type *type, struct ui_file *stream, { for (i = 0; i < num_chars; ++i) print_wchar (chars[i], buf, buflen, - TYPE_LENGTH (type), byte_order, + type->length (), byte_order, &wchar_buf, quoter, &need_escape); } } /* This handles the NUM_CHARS == 0 case as well. */ if (print_escape) - print_wchar (gdb_WEOF, buf, buflen, TYPE_LENGTH (type), + print_wchar (gdb_WEOF, buf, buflen, type->length (), byte_order, &wchar_buf, quoter, &need_escape); } @@ -2487,7 +2487,7 @@ generic_printstr (struct ui_file *stream, struct type *type, { enum bfd_endian byte_order = type_byte_order (type); unsigned int i; - int width = TYPE_LENGTH (type); + int width = type->length (); int finished = 0; struct converted_character *last; @@ -2598,7 +2598,7 @@ val_print_string (struct type *elttype, const char *encoding, gdb::unique_xmalloc_ptr buffer; /* Dynamically growable fetch buffer. */ struct gdbarch *gdbarch = elttype->arch (); enum bfd_endian byte_order = type_byte_order (elttype); - int width = TYPE_LENGTH (elttype); + int width = elttype->length (); /* First we need to figure out the limit on the number of characters we are going to attempt to fetch and print. This is actually pretty simple. If diff --git a/gdb/valprint.h b/gdb/valprint.h index 2e12eaa..39eab1e 100644 --- a/gdb/valprint.h +++ b/gdb/valprint.h @@ -171,7 +171,7 @@ extern void print_function_pointer_address (const struct value_print_options *op If TYPE represents some aggregate type (e.g., a structure), return 1. Otherwise, any of the bytes starting at OFFSET and extending for - TYPE_LENGTH(TYPE) bytes are invalid, print a message to STREAM and + TYPE->length () bytes are invalid, print a message to STREAM and return 0. The checking is done using FUNCS. Otherwise, return 1. */ diff --git a/gdb/value.c b/gdb/value.c index 48db5b0..8ed941f 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -436,7 +436,7 @@ value_entirely_covered_by_range_vector (struct value *value, if (t.offset == 0 && t.length == (TARGET_CHAR_BIT - * TYPE_LENGTH (value_enclosing_type (value)))) + * value_enclosing_type (value)->length ())) return 1; } @@ -858,9 +858,9 @@ value_contents_bits_eq (const struct value *val1, int offset1, /* We shouldn't be trying to compare past the end of the values. */ gdb_assert (offset1 + length - <= TYPE_LENGTH (val1->enclosing_type) * TARGET_CHAR_BIT); + <= val1->enclosing_type->length () * TARGET_CHAR_BIT); gdb_assert (offset2 + length - <= TYPE_LENGTH (val2->enclosing_type) * TARGET_CHAR_BIT); + <= val2->enclosing_type->length () * TARGET_CHAR_BIT); memset (&rp1, 0, sizeof (rp1)); memset (&rp2, 0, sizeof (rp2)); @@ -1010,7 +1010,7 @@ show_max_value_size (struct ui_file *file, int from_tty, static void check_type_length_before_alloc (const struct type *type) { - ULONGEST length = TYPE_LENGTH (type); + ULONGEST length = type->length (); if (max_value_size > -1 && length > max_value_size) { @@ -1032,7 +1032,7 @@ allocate_value_contents (struct value *val) { check_type_length_before_alloc (val->enclosing_type); val->contents.reset - ((gdb_byte *) xzalloc (TYPE_LENGTH (val->enclosing_type))); + ((gdb_byte *) xzalloc (val->enclosing_type->length ())); } } @@ -1087,7 +1087,7 @@ allocate_optimized_out_value (struct type *type) { struct value *retval = allocate_value_lazy (type); - mark_value_bytes_optimized_out (retval, 0, TYPE_LENGTH (type)); + mark_value_bytes_optimized_out (retval, 0, type->length ()); set_value_lazy (retval, 0); return retval; } @@ -1160,7 +1160,7 @@ value_contents_raw (struct value *value) allocate_value_contents (value); - ULONGEST length = TYPE_LENGTH (value_type (value)); + ULONGEST length = value_type (value)->length (); return gdb::make_array_view (value->contents.get () + value->embedded_offset * unit_size, length); } @@ -1170,7 +1170,7 @@ value_contents_all_raw (struct value *value) { allocate_value_contents (value); - ULONGEST length = TYPE_LENGTH (value_enclosing_type (value)); + ULONGEST length = value_enclosing_type (value)->length (); return gdb::make_array_view (value->contents.get (), length); } @@ -1256,7 +1256,7 @@ value_contents_for_printing (struct value *value) if (value->lazy) value_fetch_lazy (value); - ULONGEST length = TYPE_LENGTH (value_enclosing_type (value)); + ULONGEST length = value_enclosing_type (value)->length (); return gdb::make_array_view (value->contents.get (), length); } @@ -1265,7 +1265,7 @@ value_contents_for_printing_const (const struct value *value) { gdb_assert (!value->lazy); - ULONGEST length = TYPE_LENGTH (value_enclosing_type (value)); + ULONGEST length = value_enclosing_type (value)->length (); return gdb::make_array_view (value->contents.get (), length); } @@ -1737,7 +1737,7 @@ value_copy (const value *arg) if (!value_lazy (val) && !value_entirely_optimized_out (val)) { gdb_assert (arg->contents != nullptr); - ULONGEST length = TYPE_LENGTH (value_enclosing_type (arg)); + ULONGEST length = value_enclosing_type (arg)->length (); const auto &arg_view = gdb::make_array_view (arg->contents.get (), length); copy (arg_view, value_contents_all_raw (val)); @@ -1801,7 +1801,7 @@ value_force_lval (struct value *v, CORE_ADDR addr) { gdb_assert (VALUE_LVAL (v) == not_lval); - write_memory (addr, value_contents_raw (v).data (), TYPE_LENGTH (value_type (v))); + write_memory (addr, value_contents_raw (v).data (), value_type (v)->length ()); v->lval = lval_memory; v->location.address = addr; } @@ -2343,7 +2343,7 @@ set_internalvar_component (struct internalvar *var, value_as_long (newval), bitpos, bitsize); else memcpy (addr + offset * unit_size, value_contents (newval).data (), - TYPE_LENGTH (value_type (newval))); + value_type (newval)->length ()); break; default: @@ -2877,7 +2877,7 @@ unpack_long (struct type *type, const gdb_byte *valaddr) enum bfd_endian byte_order = type_byte_order (type); enum type_code code = type->code (); - int len = TYPE_LENGTH (type); + int len = type->length (); int nosign = type->is_unsigned (); switch (code) @@ -3037,12 +3037,12 @@ value_static_field (struct type *type, int fieldno) void set_value_enclosing_type (struct value *val, struct type *new_encl_type) { - if (TYPE_LENGTH (new_encl_type) > TYPE_LENGTH (value_enclosing_type (val))) + if (new_encl_type->length () > value_enclosing_type (val)->length ()) { check_type_length_before_alloc (new_encl_type); val->contents .reset ((gdb_byte *) xrealloc (val->contents.release (), - TYPE_LENGTH (new_encl_type))); + new_encl_type->length ())); } val->enclosing_type = new_encl_type; @@ -3085,12 +3085,12 @@ value_primitive_field (struct value *arg1, LONGEST offset, are sufficiently aligned. */ LONGEST bitpos = arg_type->field (fieldno).loc_bitpos (); - LONGEST container_bitsize = TYPE_LENGTH (type) * 8; + LONGEST container_bitsize = type->length () * 8; v = allocate_value_lazy (type); v->bitsize = TYPE_FIELD_BITSIZE (arg_type, fieldno); if ((bitpos % container_bitsize) + v->bitsize <= container_bitsize - && TYPE_LENGTH (type) <= (int) sizeof (LONGEST)) + && type->length () <= (int) sizeof (LONGEST)) v->bitpos = bitpos % container_bitsize; else v->bitpos = bitpos % 8; @@ -3130,7 +3130,7 @@ value_primitive_field (struct value *arg1, LONGEST offset, { v = allocate_value (value_enclosing_type (arg1)); value_contents_copy_raw (v, 0, arg1, 0, - TYPE_LENGTH (value_enclosing_type (arg1))); + value_enclosing_type (arg1)->length ()); } v->type = type; v->offset = value_offset (arg1); @@ -3263,7 +3263,7 @@ unpack_bits_as_long (struct type *field_type, const gdb_byte *valaddr, bytes_read = ((bitpos % 8) + bitsize + 7) / 8; else { - bytes_read = TYPE_LENGTH (field_type); + bytes_read = field_type->length (); bitsize = 8 * bytes_read; } @@ -3372,14 +3372,14 @@ unpack_value_bitfield (struct value *dest_val, num = unpack_bits_as_long (field_type, valaddr + embedded_offset, bitpos, bitsize); store_signed_integer (value_contents_raw (dest_val).data (), - TYPE_LENGTH (field_type), byte_order, num); + field_type->length (), byte_order, num); } /* Now copy the optimized out / unavailability ranges to the right bits. */ src_bit_offset = embedded_offset * TARGET_CHAR_BIT + bitpos; if (byte_order == BFD_ENDIAN_BIG) - dst_bit_offset = TYPE_LENGTH (field_type) * TARGET_CHAR_BIT - bitsize; + dst_bit_offset = field_type->length () * TARGET_CHAR_BIT - bitsize; else dst_bit_offset = 0; value_ranges_copy_adjusted (dest_val, dst_bit_offset, @@ -3468,7 +3468,7 @@ pack_long (gdb_byte *buf, struct type *type, LONGEST num) LONGEST len; type = check_typedef (type); - len = TYPE_LENGTH (type); + len = type->length (); switch (type->code ()) { @@ -3518,7 +3518,7 @@ pack_unsigned_long (gdb_byte *buf, struct type *type, ULONGEST num) enum bfd_endian byte_order; type = check_typedef (type); - len = TYPE_LENGTH (type); + len = type->length (); byte_order = type_byte_order (type); switch (type->code ()) @@ -3658,7 +3658,7 @@ value_from_contents_and_address (struct type *type, { gdb::array_view view; if (valaddr != nullptr) - view = gdb::make_array_view (valaddr, TYPE_LENGTH (type)); + view = gdb::make_array_view (valaddr, type->length ()); struct type *resolved_type = resolve_dynamic_type (type, view, address); struct type *resolved_type_no_typedef = check_typedef (resolved_type); struct value *v; @@ -3684,7 +3684,7 @@ value_from_contents (struct type *type, const gdb_byte *contents) struct value *result; result = allocate_value (type); - memcpy (value_contents_raw (result).data (), contents, TYPE_LENGTH (type)); + memcpy (value_contents_raw (result).data (), contents, type->length ()); return result; } @@ -3947,7 +3947,7 @@ value_fetch_lazy_memory (struct value *val) CORE_ADDR addr = value_address (val); struct type *type = check_typedef (value_enclosing_type (val)); - if (TYPE_LENGTH (type)) + if (type->length ()) read_value_memory (val, 0, value_stack (val), addr, value_contents_all_raw (val).data (), type_length_units (type)); diff --git a/gdb/value.h b/gdb/value.h index 7e1eec2..52752df 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -550,7 +550,7 @@ extern void mark_value_bits_unavailable (struct value *value, example, to compare a complete object value with itself, including its enclosing type chunk, you'd do: - int len = TYPE_LENGTH (check_typedef (value_enclosing_type (val))); + int len = check_typedef (value_enclosing_type (val))->length (); value_contents_eq (val, 0, val, 0, len); Returns true iff the set of available/valid contents match. diff --git a/gdb/vax-tdep.c b/gdb/vax-tdep.c index 6ad0dda..633575d 100644 --- a/gdb/vax-tdep.c +++ b/gdb/vax-tdep.c @@ -119,7 +119,7 @@ vax_store_arguments (struct regcache *regcache, int nargs, /* Push arguments in reverse order. */ for (i = nargs - 1; i >= 0; i--) { - int len = TYPE_LENGTH (value_enclosing_type (args[i])); + int len = value_enclosing_type (args[i])->length (); sp -= (len + 3) & ~3; count += (len + 3) / 4; @@ -203,7 +203,7 @@ vax_return_value (struct gdbarch *gdbarch, struct value *function, struct type *type, struct regcache *regcache, gdb_byte *readbuf, const gdb_byte *writebuf) { - int len = TYPE_LENGTH (type); + int len = type->length (); gdb_byte buf[8]; if (type->code () == TYPE_CODE_STRUCT diff --git a/gdb/windows-tdep.c b/gdb/windows-tdep.c index c4c76e3..6c74cdb 100644 --- a/gdb/windows-tdep.c +++ b/gdb/windows-tdep.c @@ -244,7 +244,7 @@ windows_get_tlb_type (struct gdbarch *gdbarch) seh_type->set_name (xstrdup ("seh")); seh_ptr_type = arch_type (gdbarch, TYPE_CODE_PTR, - TYPE_LENGTH (void_ptr_type) * TARGET_CHAR_BIT, + void_ptr_type->length () * TARGET_CHAR_BIT, NULL); seh_ptr_type->set_target_type (seh_type); @@ -265,7 +265,7 @@ windows_get_tlb_type (struct gdbarch *gdbarch) append_composite_type_field (peb_ldr_type, "entry_in_progress", void_ptr_type); peb_ldr_ptr_type = arch_type (gdbarch, TYPE_CODE_PTR, - TYPE_LENGTH (void_ptr_type) * TARGET_CHAR_BIT, + void_ptr_type->length () * TARGET_CHAR_BIT, NULL); peb_ldr_ptr_type->set_target_type (peb_ldr_type); @@ -277,7 +277,7 @@ windows_get_tlb_type (struct gdbarch *gdbarch) append_composite_type_field (uni_str_type, "maximum_length", word_type); append_composite_type_field_aligned (uni_str_type, "buffer", wchar_ptr_type, - TYPE_LENGTH (wchar_ptr_type)); + wchar_ptr_type->length ()); /* struct _RTL_USER_PROCESS_PARAMETERS */ rupp_type = arch_composite_type (gdbarch, "rtl_user_process_parameters", @@ -291,7 +291,7 @@ windows_get_tlb_type (struct gdbarch *gdbarch) append_composite_type_field (rupp_type, "console_flags", dword32_type); append_composite_type_field_aligned (rupp_type, "standard_input", void_ptr_type, - TYPE_LENGTH (void_ptr_type)); + void_ptr_type->length ()); append_composite_type_field (rupp_type, "standard_output", void_ptr_type); append_composite_type_field (rupp_type, "standard_error", void_ptr_type); append_composite_type_field (rupp_type, "current_directory", uni_str_type); @@ -312,7 +312,7 @@ windows_get_tlb_type (struct gdbarch *gdbarch) append_composite_type_field (rupp_type, "show_window_flags", dword32_type); append_composite_type_field_aligned (rupp_type, "window_title", uni_str_type, - TYPE_LENGTH (void_ptr_type)); + void_ptr_type->length ()); append_composite_type_field (rupp_type, "desktop_info", uni_str_type); append_composite_type_field (rupp_type, "shell_info", uni_str_type); append_composite_type_field (rupp_type, "runtime_data", uni_str_type); @@ -335,7 +335,7 @@ windows_get_tlb_type (struct gdbarch *gdbarch) append_composite_type_field (peb_type, "process_heap", void_ptr_type); append_composite_type_field (peb_type, "fast_peb_lock", void_ptr_type); peb_ptr_type = arch_type (gdbarch, TYPE_CODE_PTR, - TYPE_LENGTH (void_ptr_type) * TARGET_CHAR_BIT, + void_ptr_type->length () * TARGET_CHAR_BIT, NULL); peb_ptr_type->set_target_type (peb_type); @@ -379,7 +379,7 @@ windows_get_tlb_type (struct gdbarch *gdbarch) append_composite_type_field (tib_type, "last_error_number", dword_ptr_type); tib_ptr_type = arch_type (gdbarch, TYPE_CODE_PTR, - TYPE_LENGTH (void_ptr_type) * TARGET_CHAR_BIT, + void_ptr_type->length () * TARGET_CHAR_BIT, NULL); tib_ptr_type->set_target_type (tib_type); @@ -855,7 +855,7 @@ windows_get_siginfo_type (struct gdbarch *gdbarch) append_composite_type_field (siginfo_type, "NumberParameters", dword_type); /* The 64-bit variant needs some padding. */ append_composite_type_field_aligned (siginfo_type, "", - para_type, TYPE_LENGTH (ulongptr_type)); + para_type, ulongptr_type->length ()); windows_gdbarch_data->siginfo_type = siginfo_type; diff --git a/gdb/xstormy16-tdep.c b/gdb/xstormy16-tdep.c index 97ccad4..1703637 100644 --- a/gdb/xstormy16-tdep.c +++ b/gdb/xstormy16-tdep.c @@ -148,7 +148,7 @@ static int xstormy16_use_struct_convention (struct type *type) { return !xstormy16_type_is_scalar (type) - || TYPE_LENGTH (type) > E_MAX_RETTYPE_SIZE_IN_REGS; + || type->length () > E_MAX_RETTYPE_SIZE_IN_REGS; } /* Function: xstormy16_extract_return_value @@ -159,7 +159,7 @@ static void xstormy16_extract_return_value (struct type *type, struct regcache *regcache, gdb_byte *valbuf) { - int len = TYPE_LENGTH (type); + int len = type->length (); int i, regnum = E_1ST_ARG_REGNUM; for (i = 0; i < len; i += xstormy16_reg_size) @@ -175,7 +175,7 @@ static void xstormy16_store_return_value (struct type *type, struct regcache *regcache, const gdb_byte *valbuf) { - if (TYPE_LENGTH (type) == 1) + if (type->length () == 1) { /* Add leading zeros to the value. */ gdb_byte buf[xstormy16_reg_size]; @@ -185,7 +185,7 @@ xstormy16_store_return_value (struct type *type, struct regcache *regcache, } else { - int len = TYPE_LENGTH (type); + int len = type->length (); int i, regnum = E_1ST_ARG_REGNUM; for (i = 0; i < len; i += xstormy16_reg_size) @@ -252,7 +252,7 @@ xstormy16_push_dummy_call (struct gdbarch *gdbarch, would fit in the remaining unused registers. */ for (i = 0; i < nargs && argreg <= E_LST_ARG_REGNUM; i++) { - typelen = TYPE_LENGTH (value_enclosing_type (args[i])); + typelen = value_enclosing_type (args[i])->length (); if (typelen > E_MAX_RETTYPE_SIZE (argreg)) break; @@ -277,7 +277,7 @@ xstormy16_push_dummy_call (struct gdbarch *gdbarch, { const gdb_byte *bytes = value_contents (args[j]).data (); - typelen = TYPE_LENGTH (value_enclosing_type (args[j])); + typelen = value_enclosing_type (args[j])->length (); slacklen = typelen & 1; gdb::byte_vector val (typelen + slacklen); memcpy (val.data (), bytes, typelen); @@ -612,7 +612,7 @@ xstormy16_pointer_to_address (struct gdbarch *gdbarch, enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); enum type_code target = type->target_type ()->code (); CORE_ADDR addr - = extract_unsigned_integer (buf, TYPE_LENGTH (type), byte_order); + = extract_unsigned_integer (buf, type->length (), byte_order); if (target == TYPE_CODE_FUNC || target == TYPE_CODE_METHOD) { @@ -637,7 +637,7 @@ xstormy16_address_to_pointer (struct gdbarch *gdbarch, if (addr2) addr = addr2; } - store_unsigned_integer (buf, TYPE_LENGTH (type), byte_order, addr); + store_unsigned_integer (buf, type->length (), byte_order, addr); } static struct xstormy16_frame_cache * diff --git a/gdb/xtensa-tdep.c b/gdb/xtensa-tdep.c index f881870..58fdb40 100644 --- a/gdb/xtensa-tdep.c +++ b/gdb/xtensa-tdep.c @@ -1537,7 +1537,7 @@ xtensa_extract_return_value (struct type *type, { struct gdbarch *gdbarch = regcache->arch (); bfd_byte *valbuf = (bfd_byte *) dst; - int len = TYPE_LENGTH (type); + int len = type->length (); ULONGEST pc, wb; int callsize, areg; int offset = 0; @@ -1597,7 +1597,7 @@ xtensa_store_return_value (struct type *type, unsigned int areg; ULONGEST pc, wb; int callsize; - int len = TYPE_LENGTH (type); + int len = type->length (); int offset = 0; DEBUGTRACE ("xtensa_store_return_value (...)\n"); @@ -1613,7 +1613,7 @@ xtensa_store_return_value (struct type *type, if (len > (callsize > 8 ? 8 : 16)) internal_error (__FILE__, __LINE__, _("unimplemented for this length: %s"), - pulongest (TYPE_LENGTH (type))); + pulongest (type->length ())); areg = arreg_number (gdbarch, tdep->a0_base + 2 + callsize, wb); @@ -1651,7 +1651,7 @@ xtensa_return_value (struct gdbarch *gdbarch, int struct_return = ((valtype->code () == TYPE_CODE_STRUCT || valtype->code () == TYPE_CODE_UNION || valtype->code () == TYPE_CODE_ARRAY) - && TYPE_LENGTH (valtype) > 16); + && valtype->length () > 16); if (struct_return) return RETURN_VALUE_STRUCT_CONVENTION; @@ -1723,7 +1723,7 @@ xtensa_push_dummy_call (struct gdbarch *gdbarch, struct type *arg_type = check_typedef (value_type (arg)); gdb_printf (gdb_stdlog, "%2d: %s %3s ", i, host_address_to_string (arg), - pulongest (TYPE_LENGTH (arg_type))); + pulongest (arg_type->length ())); switch (arg_type->code ()) { case TYPE_CODE_INT: @@ -1767,32 +1767,32 @@ xtensa_push_dummy_call (struct gdbarch *gdbarch, case TYPE_CODE_ENUM: /* Cast argument to long if necessary as the mask does it too. */ - if (TYPE_LENGTH (arg_type) - < TYPE_LENGTH (builtin_type (gdbarch)->builtin_long)) + if (arg_type->length () + < builtin_type (gdbarch)->builtin_long->length ()) { arg_type = builtin_type (gdbarch)->builtin_long; arg = value_cast (arg_type, arg); } /* Aligment is equal to the type length for the basic types. */ - info->align = TYPE_LENGTH (arg_type); + info->align = arg_type->length (); break; case TYPE_CODE_FLT: /* Align doubles correctly. */ - if (TYPE_LENGTH (arg_type) - == TYPE_LENGTH (builtin_type (gdbarch)->builtin_double)) - info->align = TYPE_LENGTH (builtin_type (gdbarch)->builtin_double); + if (arg_type->length () + == builtin_type (gdbarch)->builtin_double->length ()) + info->align = builtin_type (gdbarch)->builtin_double->length (); else - info->align = TYPE_LENGTH (builtin_type (gdbarch)->builtin_long); + info->align = builtin_type (gdbarch)->builtin_long->length (); break; case TYPE_CODE_STRUCT: default: - info->align = TYPE_LENGTH (builtin_type (gdbarch)->builtin_long); + info->align = builtin_type (gdbarch)->builtin_long->length (); break; } - info->length = TYPE_LENGTH (arg_type); + info->length = arg_type->length (); info->contents = value_contents (arg).data (); /* Align size and onstack_size. */ diff --git a/gdb/z80-tdep.c b/gdb/z80-tdep.c index 684f083..d30f230 100644 --- a/gdb/z80-tdep.c +++ b/gdb/z80-tdep.c @@ -522,7 +522,7 @@ z80_return_value (struct gdbarch *gdbarch, struct value *function, gdb_byte *readbuf, const gdb_byte *writebuf) { /* Byte are returned in L, word in HL, dword in DEHL. */ - int len = TYPE_LENGTH (valtype); + int len = valtype->length (); if ((valtype->code () == TYPE_CODE_STRUCT || valtype->code () == TYPE_CODE_UNION -- cgit v1.1