diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2021-10-04 20:47:06 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2021-10-25 14:51:44 -0400 |
commit | 50888e42dcd32b30e1144c0aa6d1c1490da45cd9 (patch) | |
tree | 72fad89d67057ecb53f26bac0464542829053e3e | |
parent | d9f82e931394efed68858eb7c7bb5832ad888482 (diff) | |
download | gdb-50888e42dcd32b30e1144c0aa6d1c1490da45cd9.zip gdb-50888e42dcd32b30e1144c0aa6d1c1490da45cd9.tar.gz gdb-50888e42dcd32b30e1144c0aa6d1c1490da45cd9.tar.bz2 |
gdb: change functions returning value contents to use gdb::array_view
The bug fixed by this [1] patch was caused by an out-of-bounds access to
a value's content. The code gets the value's content (just a pointer)
and then indexes it with a non-sensical index.
This made me think of changing functions that return value contents to
return array_views instead of a plain pointer. This has the advantage
that when GDB is built with _GLIBCXX_DEBUG, accesses to the array_view
are checked, making bugs more apparent / easier to find.
This patch changes the return types of these functions, and updates
callers to call .data() on the result, meaning it's not changing
anything in practice. Additional work will be needed (which can be done
little by little) to make callers propagate the use of array_view and
reap the benefits.
[1] https://sourceware.org/pipermail/gdb-patches/2021-September/182306.html
Change-Id: I5151f888f169e1c36abe2cbc57620110673816f3
96 files changed, 453 insertions, 417 deletions
diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c index b122543..abb8be3 100644 --- a/gdb/aarch64-linux-tdep.c +++ b/gdb/aarch64-linux-tdep.c @@ -1621,7 +1621,7 @@ aarch64_linux_set_memtags (struct gdbarch *gdbarch, struct value *address, /* Update the value's content with the tag. */ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); - gdb_byte *srcbuf = value_contents_raw (address); + gdb_byte *srcbuf = value_contents_raw (address).data (); store_unsigned_integer (srcbuf, sizeof (addr), byte_order, addr); } else diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c index 4b5af46..42b8494 100644 --- a/gdb/aarch64-tdep.c +++ b/gdb/aarch64-tdep.c @@ -1593,7 +1593,7 @@ pass_in_x (struct gdbarch *gdbarch, struct regcache *regcache, int len = TYPE_LENGTH (type); enum type_code typecode = type->code (); int regnum = AARCH64_X0_REGNUM + info->ngrn; - const bfd_byte *buf = value_contents (arg); + const bfd_byte *buf = value_contents (arg).data (); info->argnum++; @@ -1663,7 +1663,7 @@ static void pass_on_stack (struct aarch64_call_info *info, struct type *type, struct value *arg) { - const bfd_byte *buf = value_contents (arg); + const bfd_byte *buf = value_contents (arg).data (); int len = TYPE_LENGTH (type); int align; stack_item_t item; @@ -1739,12 +1739,12 @@ pass_in_v_vfp_candidate (struct gdbarch *gdbarch, struct regcache *regcache, { case TYPE_CODE_FLT: return pass_in_v (gdbarch, regcache, info, TYPE_LENGTH (arg_type), - value_contents (arg)); + value_contents (arg).data ()); break; case TYPE_CODE_COMPLEX: { - const bfd_byte *buf = value_contents (arg); + const bfd_byte *buf = value_contents (arg).data (); struct type *target_type = check_typedef (TYPE_TARGET_TYPE (arg_type)); if (!pass_in_v (gdbarch, regcache, info, TYPE_LENGTH (target_type), @@ -1758,7 +1758,7 @@ pass_in_v_vfp_candidate (struct gdbarch *gdbarch, struct regcache *regcache, case TYPE_CODE_ARRAY: if (arg_type->is_vector ()) return pass_in_v (gdbarch, regcache, info, TYPE_LENGTH (arg_type), - value_contents (arg)); + value_contents (arg).data ()); /* fall through. */ case TYPE_CODE_STRUCT: @@ -1900,7 +1900,7 @@ aarch64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, sp = align_down (sp - len, 16); /* Write the real data into the stack. */ - write_memory (sp, value_contents (arg), len); + write_memory (sp, value_contents (arg).data (), len); /* Construct the indirection. */ arg_type = lookup_pointer_type (arg_type); @@ -2682,7 +2682,7 @@ aarch64_pseudo_read_value_1 (struct gdbarch *gdbarch, mark_value_bytes_unavailable (result_value, 0, TYPE_LENGTH (value_type (result_value))); else - memcpy (value_contents_raw (result_value), reg_buf, regsize); + memcpy (value_contents_raw (result_value).data (), reg_buf, regsize); return result_value; } diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 8b9e94e..b0c915f 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -2181,7 +2181,7 @@ decode_constrained_packed_array (struct value *arr) bounds may be variable and were not passed to that function. So, we further resolve the array bounds here and then update the sizes. */ - const gdb_byte *valaddr = value_contents_for_printing (arr); + const gdb_byte *valaddr = value_contents_for_printing (arr).data (); CORE_ADDR address = value_address (arr); gdb::array_view<const gdb_byte> view = gdb::make_array_view (valaddr, TYPE_LENGTH (type)); @@ -2438,7 +2438,7 @@ ada_value_primitive_packed_val (struct value *obj, const gdb_byte *valaddr, if (obj == NULL) src = valaddr + offset; else - src = value_contents (obj) + offset; + src = value_contents (obj).data () + offset; if (is_dynamic_type (type)) { @@ -2488,7 +2488,7 @@ ada_value_primitive_packed_val (struct value *obj, const gdb_byte *valaddr, else { v = allocate_value (type); - src = value_contents (obj) + offset; + src = value_contents (obj).data () + offset; } if (obj != NULL) @@ -2511,7 +2511,7 @@ ada_value_primitive_packed_val (struct value *obj, const gdb_byte *valaddr, } else set_value_bitsize (v, bit_size); - unpacked = value_contents_writeable (v); + unpacked = value_contents_writeable (v).data (); if (bit_size == 0) { @@ -2581,12 +2581,13 @@ ada_value_assign (struct value *toval, struct value *fromval) if (is_big_endian && is_scalar_type (value_type (fromval))) from_offset = from_size - bits; copy_bitwise (buffer, value_bitpos (toval), - value_contents (fromval), from_offset, + value_contents (fromval).data (), from_offset, bits, is_big_endian); write_memory_with_notification (to_addr, buffer, len); val = value_copy (toval); - memcpy (value_contents_raw (val), value_contents (fromval), + memcpy (value_contents_raw (val).data (), + value_contents (fromval).data (), TYPE_LENGTH (type)); deprecated_set_value_type (val, type); @@ -2634,14 +2635,16 @@ value_assign_to_component (struct value *container, struct value *component, = TYPE_LENGTH (value_type (component)) * TARGET_CHAR_BIT - bits; else src_offset = 0; - copy_bitwise (value_contents_writeable (container) + offset_in_container, + copy_bitwise ((value_contents_writeable (container).data () + + offset_in_container), value_bitpos (container) + bit_offset_in_container, - value_contents (val), src_offset, bits, 1); + value_contents (val).data (), src_offset, bits, 1); } else - copy_bitwise (value_contents_writeable (container) + offset_in_container, + copy_bitwise ((value_contents_writeable (container).data () + + offset_in_container), value_bitpos (container) + bit_offset_in_container, - value_contents (val), 0, bits, 0); + value_contents (val).data (), 0, bits, 0); } /* Determine if TYPE is an access to an unconstrained array. */ @@ -4010,7 +4013,7 @@ ensure_lval (struct value *val) VALUE_LVAL (val) = lval_memory; set_value_address (val, addr); - write_memory (addr, value_contents (val), len); + write_memory (addr, value_contents (val).data (), len); } return val; @@ -4181,8 +4184,8 @@ ada_convert_actual (struct value *actual, struct type *formal_type0) actual_type = ada_check_typedef (value_type (actual)); val = allocate_value (actual_type); - memcpy ((char *) value_contents_raw (val), - (char *) value_contents (actual), + memcpy ((char *) value_contents_raw (val).data (), + (char *) value_contents (actual).data (), TYPE_LENGTH (actual_type)); actual = ensure_lval (val); } @@ -4245,11 +4248,13 @@ make_array_descriptor (struct type *type, struct value *arr) for (i = ada_array_arity (ada_check_typedef (value_type (arr))); i > 0; i -= 1) { - modify_field (value_type (bounds), value_contents_writeable (bounds), + modify_field (value_type (bounds), + value_contents_writeable (bounds).data (), ada_array_bound (arr, i, 0), desc_bound_bitpos (bounds_type, i, 0), desc_bound_bitsize (bounds_type, i, 0)); - modify_field (value_type (bounds), value_contents_writeable (bounds), + modify_field (value_type (bounds), + value_contents_writeable (bounds).data (), ada_array_bound (arr, i, 1), desc_bound_bitpos (bounds_type, i, 1), desc_bound_bitsize (bounds_type, i, 1)); @@ -4258,14 +4263,14 @@ make_array_descriptor (struct type *type, struct value *arr) bounds = ensure_lval (bounds); modify_field (value_type (descriptor), - value_contents_writeable (descriptor), + value_contents_writeable (descriptor).data (), value_pointer (ensure_lval (arr), desc_type->field (0).type ()), fat_pntr_data_bitpos (desc_type), fat_pntr_data_bitsize (desc_type)); modify_field (value_type (descriptor), - value_contents_writeable (descriptor), + value_contents_writeable (descriptor).data (), value_pointer (bounds, desc_type->field (1).type ()), fat_pntr_bounds_bitpos (desc_type), @@ -6553,7 +6558,8 @@ ada_value_primitive_field (struct value *arg1, int offset, int fieldno, int bit_pos = TYPE_FIELD_BITPOS (arg_type, fieldno); int bit_size = TYPE_FIELD_BITSIZE (arg_type, fieldno); - return ada_value_primitive_packed_val (arg1, value_contents (arg1), + return ada_value_primitive_packed_val (arg1, + value_contents (arg1).data (), offset + bit_pos / 8, bit_pos % 8, bit_size, type); } @@ -8480,7 +8486,7 @@ ada_to_fixed_value_create (struct type *type0, CORE_ADDR address, /* Our value does not live in memory; it could be a convenience variable, for instance. Create a not_lval value using val0's contents. */ - return value_from_contents (type, value_contents (val0)); + return value_from_contents (type, value_contents (val0).data ()); } return value_from_contents_and_address (type, 0, address); @@ -8916,8 +8922,9 @@ ada_promote_array_of_integrals (struct type *type, struct value *val) { struct value *elt = value_cast (elt_type, value_subscript (val, lo + i)); - memcpy (value_contents_writeable (res) + (i * TYPE_LENGTH (elt_type)), - value_contents_all (elt), TYPE_LENGTH (elt_type)); + memcpy ((value_contents_writeable (res).data () + + (i * TYPE_LENGTH (elt_type))), + value_contents_all (elt).data (), TYPE_LENGTH (elt_type)); } return res; @@ -9033,7 +9040,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), + store_unsigned_integer (value_contents_raw (val).data (), TYPE_LENGTH (value_type (val)), type_byte_order (type1), v); return val; @@ -9065,7 +9072,8 @@ ada_value_equal (struct value *arg1, struct value *arg2) 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) - && memcmp (value_contents (arg1), value_contents (arg2), + && memcmp (value_contents (arg1).data (), + value_contents (arg2).data (), TYPE_LENGTH (arg1_type)) == 0); } return value_equal (arg1, arg2); diff --git a/gdb/ada-tasks.c b/gdb/ada-tasks.c index 9a5bcc6..32fbc14 100644 --- a/gdb/ada-tasks.c +++ b/gdb/ada-tasks.c @@ -401,7 +401,7 @@ iterate_over_live_ada_tasks (ada_task_list_iterator_ftype iterator) static void value_as_string (char *dest, struct value *val, int length) { - memcpy (dest, value_contents (val), length); + memcpy (dest, value_contents (val).data (), length); dest[length] = '\0'; } diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c index e725cd3..17cace0 100644 --- a/gdb/ada-valprint.c +++ b/gdb/ada-valprint.c @@ -747,7 +747,7 @@ ada_value_print_num (struct value *val, struct ui_file *stream, int recurse, const struct value_print_options *options) { struct type *type = ada_check_typedef (value_type (val)); - const gdb_byte *valaddr = value_contents_for_printing (val); + const gdb_byte *valaddr = value_contents_for_printing (val).data (); if (type->code () == TYPE_CODE_RANGE && (TYPE_TARGET_TYPE (type)->code () == TYPE_CODE_ENUM @@ -827,7 +827,7 @@ ada_val_print_enum (struct value *value, struct ui_file *stream, int recurse, } struct type *type = ada_check_typedef (value_type (value)); - const gdb_byte *valaddr = value_contents_for_printing (value); + const gdb_byte *valaddr = value_contents_for_printing (value).data (); int offset_aligned = ada_aligned_value_addr (type, valaddr) - valaddr; len = type->num_fields (); @@ -895,7 +895,7 @@ ada_value_print_array (struct value *val, struct ui_file *stream, int recurse, if (ada_is_string_type (type) && (options->format == 0 || options->format == 's')) { - const gdb_byte *valaddr = value_contents_for_printing (val); + const gdb_byte *valaddr = value_contents_for_printing (val).data (); int offset_aligned = ada_aligned_value_addr (type, valaddr) - valaddr; ada_val_print_string (type, valaddr, offset_aligned, stream, recurse, @@ -910,7 +910,7 @@ ada_value_print_array (struct value *val, struct ui_file *stream, int recurse, val_print_optimized_out (val, stream); else if (TYPE_FIELD_BITSIZE (type, 0) > 0) { - const gdb_byte *valaddr = value_contents_for_printing (val); + const gdb_byte *valaddr = value_contents_for_printing (val).data (); int offset_aligned = ada_aligned_value_addr (type, valaddr) - valaddr; val_print_packed_array_elements (type, valaddr, offset_aligned, stream, recurse, options); @@ -1009,7 +1009,7 @@ ada_value_print_1 (struct value *val, struct ui_file *stream, int recurse, type = value_type (val); struct type *saved_type = type; - const gdb_byte *valaddr = value_contents_for_printing (val); + const gdb_byte *valaddr = value_contents_for_printing (val).data (); CORE_ADDR address = value_address (val); gdb::array_view<const gdb_byte> view = gdb::make_array_view (valaddr, TYPE_LENGTH (type)); diff --git a/gdb/alpha-tdep.c b/gdb/alpha-tdep.c index 7538c56..03935d1 100644 --- a/gdb/alpha-tdep.c +++ b/gdb/alpha-tdep.c @@ -258,7 +258,7 @@ alpha_register_to_value (struct frame_info *frame, int regnum, /* Convert to VALTYPE. */ gdb_assert (TYPE_LENGTH (valtype) == 4); - alpha_sts (gdbarch, out, value_contents_all (value)); + alpha_sts (gdbarch, out, value_contents_all (value).data ()); release_value (value); return 1; @@ -365,7 +365,7 @@ alpha_push_dummy_call (struct gdbarch *gdbarch, struct value *function, sp = (sp & -16) - 16; /* Write the real data into the stack. */ - write_memory (sp, value_contents (arg), 16); + write_memory (sp, value_contents (arg).data (), 16); /* Construct the indirection. */ arg_type = lookup_pointer_type (arg_type); @@ -386,7 +386,7 @@ alpha_push_dummy_call (struct gdbarch *gdbarch, struct value *function, sp = (sp & -16) - 16; /* Write the real data into the stack. */ - write_memory (sp, value_contents (arg), 32); + write_memory (sp, value_contents (arg).data (), 32); /* Construct the indirection. */ arg_type = lookup_pointer_type (arg_type); @@ -400,7 +400,7 @@ alpha_push_dummy_call (struct gdbarch *gdbarch, struct value *function, m_arg->len = TYPE_LENGTH (arg_type); m_arg->offset = accumulate_size; accumulate_size = (accumulate_size + m_arg->len + 7) & ~7; - m_arg->contents = value_contents (arg); + m_arg->contents = value_contents (arg).data (); } /* Determine required argument register loads, loading an argument register diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c index 4776120..e563d36 100644 --- a/gdb/amd64-tdep.c +++ b/gdb/amd64-tdep.c @@ -358,7 +358,7 @@ amd64_pseudo_register_read_value (struct gdbarch *gdbarch, value *result_value = allocate_value (register_type (gdbarch, regnum)); VALUE_LVAL (result_value) = lval_register; VALUE_REGNUM (result_value) = regnum; - gdb_byte *buf = value_contents_raw (result_value); + gdb_byte *buf = value_contents_raw (result_value).data (); if (i386_byte_regnum_p (gdbarch, regnum)) { @@ -977,7 +977,7 @@ if (return_method == return_method_struct) else { /* The argument will be passed in registers. */ - const gdb_byte *valbuf = value_contents (args[i]); + const gdb_byte *valbuf = value_contents (args[i]).data (); gdb_byte buf[8]; gdb_assert (len <= 16); @@ -1029,7 +1029,7 @@ if (return_method == return_method_struct) for (i = 0; i < num_stack_args; i++) { struct type *type = value_type (stack_args[i]); - const gdb_byte *valbuf = value_contents (stack_args[i]); + const gdb_byte *valbuf = value_contents (stack_args[i]).data (); int len = TYPE_LENGTH (type); write_memory (sp + element * 8, valbuf, len); diff --git a/gdb/amd64-windows-tdep.c b/gdb/amd64-windows-tdep.c index fe8a3a0..ed783f6 100644 --- a/gdb/amd64-windows-tdep.c +++ b/gdb/amd64-windows-tdep.c @@ -179,7 +179,7 @@ amd64_windows_adjust_args_passed_by_pointer (struct value **args, if (amd64_windows_passed_by_pointer (value_type (args[i]))) { struct type *type = value_type (args[i]); - const gdb_byte *valbuf = value_contents (args[i]); + const gdb_byte *valbuf = value_contents (args[i]).data (); const int len = TYPE_LENGTH (type); /* Store a copy of that argument on the stack, aligned to @@ -205,7 +205,7 @@ amd64_windows_store_arg_in_reg (struct regcache *regcache, struct value *arg, int regno) { struct type *type = value_type (arg); - const gdb_byte *valbuf = value_contents (arg); + const gdb_byte *valbuf = value_contents (arg).data (); gdb_byte buf[8]; gdb_assert (TYPE_LENGTH (type) <= 8); @@ -295,7 +295,7 @@ amd64_windows_push_arguments (struct regcache *regcache, int nargs, for (i = 0; i < num_stack_args; i++) { struct type *type = value_type (stack_args[i]); - const gdb_byte *valbuf = value_contents (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); diff --git a/gdb/arc-tdep.c b/gdb/arc-tdep.c index b793a18..35874eb 100644 --- a/gdb/arc-tdep.c +++ b/gdb/arc-tdep.c @@ -779,9 +779,10 @@ arc_push_dummy_call (struct gdbarch *gdbarch, struct value *function, unsigned int len = TYPE_LENGTH (value_type (args[i])); unsigned int space = align_up (len, 4); - memcpy (data, value_contents (args[i]), (size_t) len); + memcpy (data, value_contents (args[i]).data (), (size_t) len); arc_debug_printf ("copying arg %d, val 0x%08x, len %d to mem", - i, *((int *) value_contents (args[i])), len); + i, *((int *) value_contents (args[i]).data ()), + len); data += space; } diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index d7493f1..768844d 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -3820,7 +3820,7 @@ arm_push_dummy_call (struct gdbarch *gdbarch, struct value *function, len = TYPE_LENGTH (arg_type); target_type = TYPE_TARGET_TYPE (arg_type); typecode = arg_type->code (); - val = value_contents (args[argnum]); + val = value_contents (args[argnum]).data (); align = type_align (arg_type); /* Round alignment up to a whole number of words. */ diff --git a/gdb/avr-tdep.c b/gdb/avr-tdep.c index 6ef73d5..ea259b9 100644 --- a/gdb/avr-tdep.c +++ b/gdb/avr-tdep.c @@ -1296,7 +1296,7 @@ avr_push_dummy_call (struct gdbarch *gdbarch, struct value *function, int j; struct value *arg = args[i]; struct type *type = check_typedef (value_type (arg)); - const bfd_byte *contents = value_contents (arg); + const bfd_byte *contents = value_contents (arg).data (); int len = TYPE_LENGTH (type); /* Calculate the potential last register needed. diff --git a/gdb/bfin-tdep.c b/gdb/bfin-tdep.c index bdf8ab9..d381f92 100644 --- a/gdb/bfin-tdep.c +++ b/gdb/bfin-tdep.c @@ -530,7 +530,7 @@ bfin_push_dummy_call (struct gdbarch *gdbarch, int container_len = align_up (TYPE_LENGTH (arg_type), 4); sp -= container_len; - write_memory (sp, value_contents (args[i]), container_len); + write_memory (sp, value_contents (args[i]).data (), container_len); } /* Initialize R0, R1, and R2 to the first 3 words of parameters. */ diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index e5f44be..de96f91 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -1695,7 +1695,7 @@ extract_bitfield_from_watchpoint_value (struct watchpoint *w, struct value *val) unpack_value_bitfield (bit_val, w->val_bitpos, w->val_bitsize, - value_contents_for_printing (val), + value_contents_for_printing (val).data (), value_offset (val), val); diff --git a/gdb/c-lang.c b/gdb/c-lang.c index 98250f5..2a7dd4d 100644 --- a/gdb/c-lang.c +++ b/gdb/c-lang.c @@ -302,7 +302,7 @@ c_get_string (struct value *value, gdb::unique_xmalloc_ptr<gdb_byte> *buffer, && (*length < 0 || *length <= fetchlimit)) { int i; - const gdb_byte *contents = value_contents (value); + const gdb_byte *contents = value_contents (value).data (); /* If a length is specified, use that. */ if (*length >= 0) @@ -675,7 +675,7 @@ c_string_operation::evaluate (struct type *expect_type, error (_("Too many array elements")); result = allocate_value (expect_type); - memcpy (value_contents_raw (result), obstack_base (&output), + memcpy (value_contents_raw (result).data (), obstack_base (&output), obstack_object_size (&output)); } else diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c index d3071d1..c491d37 100644 --- a/gdb/c-valprint.c +++ b/gdb/c-valprint.c @@ -237,7 +237,7 @@ c_value_print_array (struct value *val, { struct type *type = check_typedef (value_type (val)); CORE_ADDR address = value_address (val); - const gdb_byte *valaddr = value_contents_for_printing (val); + const gdb_byte *valaddr = value_contents_for_printing (val).data (); struct type *unresolved_elttype = TYPE_TARGET_TYPE (type); struct type *elttype = check_typedef (unresolved_elttype); @@ -333,7 +333,7 @@ c_value_print_ptr (struct value *val, struct ui_file *stream, int recurse, } struct type *type = check_typedef (value_type (val)); - const gdb_byte *valaddr = value_contents_for_printing (val); + const gdb_byte *valaddr = value_contents_for_printing (val).data (); if (options->vtblprint && cp_is_vtbl_ptr_type (type)) { @@ -374,7 +374,7 @@ c_value_print_struct (struct value *val, struct ui_file *stream, int recurse, TYPE_CODE_PTR.) */ int offset = TYPE_FIELD_BITPOS (type, VTBL_FNADDR_OFFSET) / 8; struct type *field_type = type->field (VTBL_FNADDR_OFFSET).type (); - const gdb_byte *valaddr = value_contents_for_printing (val); + const gdb_byte *valaddr = value_contents_for_printing (val).data (); CORE_ADDR addr = extract_typed_address (valaddr + offset, field_type); print_function_pointer_address (options, type->arch (), addr, stream); @@ -405,7 +405,7 @@ c_value_print_int (struct value *val, struct ui_file *stream, intended to be used as an integer or a character, print the character equivalent as well. */ struct type *type = value_type (val); - const gdb_byte *valaddr = value_contents_for_printing (val); + const gdb_byte *valaddr = value_contents_for_printing (val).data (); if (c_textual_element_type (type, options->format)) { fputs_filtered (" ", stream); diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index f8f0133..9b77409 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -2075,7 +2075,7 @@ setting_cmd (const char *fnname, struct cmd_list_element *showlist, && type0->code () != TYPE_CODE_STRING) error (_("First argument of %s must be a string."), fnname); - const char *a0 = (const char *) value_contents (argv[0]); + const char *a0 = (const char *) value_contents (argv[0]).data (); cmd_list_element *cmd = lookup_cmd (&a0, showlist, "", NULL, -1, 0); if (cmd == nullptr || cmd->type != show_cmd) diff --git a/gdb/cli/cli-dump.c b/gdb/cli/cli-dump.c index 6f7688a..cb20708 100644 --- a/gdb/cli/cli-dump.c +++ b/gdb/cli/cli-dump.c @@ -224,7 +224,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), + dump_binary_file (filename.get (), mode, value_contents (val).data (), TYPE_LENGTH (value_type (val))); else { @@ -241,7 +241,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), + value_contents (val).data (), TYPE_LENGTH (value_type (val))); } } diff --git a/gdb/compile/compile-object-load.c b/gdb/compile/compile-object-load.c index f28bf26..6786b42 100644 --- a/gdb/compile/compile-object-load.c +++ b/gdb/compile/compile-object-load.c @@ -585,7 +585,8 @@ store_regs (struct type *regs_type, CORE_ADDR regs_base) error (_("Register \"%s\" is not available."), reg_name); inferior_addr = regs_base + reg_offset; - if (0 != target_write_memory (inferior_addr, value_contents (regval), + if (0 != target_write_memory (inferior_addr, + value_contents (regval).data (), reg_size)) error (_("Cannot write register \"%s\" to inferior memory at %s."), reg_name, paddress (gdbarch, inferior_addr)); diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c index ef7276a..1023728 100644 --- a/gdb/cp-valprint.c +++ b/gdb/cp-valprint.c @@ -189,7 +189,7 @@ cp_print_value_fields (struct value *val, struct ui_file *stream, vptr_fieldno = get_vptr_fieldno (type, &vptr_basetype); for (i = n_baseclasses; i < len; i++) { - const gdb_byte *valaddr = value_contents_for_printing (val); + const gdb_byte *valaddr = value_contents_for_printing (val).data (); /* If requested, skip printing of static fields. */ if (!options->static_field_print @@ -397,7 +397,7 @@ cp_print_value (struct value *val, struct ui_file *stream, = (struct type **) obstack_next_free (&dont_print_vb_obstack); struct obstack tmp_obstack = dont_print_vb_obstack; int i, n_baseclasses = TYPE_N_BASECLASSES (type); - const gdb_byte *valaddr = value_contents_for_printing (val); + const gdb_byte *valaddr = value_contents_for_printing (val).data (); if (dont_print_vb == 0) { @@ -761,7 +761,7 @@ test_print_fields (gdbarch *arch) } value *val = allocate_value (the_struct); - gdb_byte *contents = value_contents_writeable (val); + gdb_byte *contents = value_contents_writeable (val).data (); store_unsigned_integer (contents, TYPE_LENGTH (value_enclosing_type (val)), gdbarch_byte_order (arch), 0xe9); diff --git a/gdb/cris-tdep.c b/gdb/cris-tdep.c index a0ff594..6b5dfc3 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 i; len = TYPE_LENGTH (value_type (args[argnum])); - val = value_contents (args[argnum]); + val = value_contents (args[argnum]).data (); /* How may registers worth of storage do we need for this argument? */ reg_demand = (len / 4) + (len % 4 != 0 ? 1 : 0); diff --git a/gdb/csky-tdep.c b/gdb/csky-tdep.c index 657ba75..8835aba 100644 --- a/gdb/csky-tdep.c +++ b/gdb/csky-tdep.c @@ -362,7 +362,7 @@ csky_push_dummy_call (struct gdbarch *gdbarch, struct value *function, arg_type = check_typedef (value_type (args[argnum])); len = TYPE_LENGTH (arg_type); - val = value_contents (args[argnum]); + val = value_contents (args[argnum]).data (); /* Copy the argument to argument registers or the dummy stack. Large arguments are split between registers and stack. diff --git a/gdb/d-valprint.c b/gdb/d-valprint.c index d46d51b..4b73c96 100644 --- a/gdb/d-valprint.c +++ b/gdb/d-valprint.c @@ -48,7 +48,7 @@ dynamic_array_type (struct type *type, struct type *ptr_type; struct value *ival; int length; - const gdb_byte *valaddr = value_contents_for_printing (val); + const gdb_byte *valaddr = value_contents_for_printing (val).data (); length = unpack_field_as_long (type, valaddr + embedded_offset, 0); diff --git a/gdb/dummy-frame.c b/gdb/dummy-frame.c index ed2c778..bdfd518 100644 --- a/gdb/dummy-frame.c +++ b/gdb/dummy-frame.c @@ -353,8 +353,8 @@ dummy_frame_prev_register (struct frame_info *this_frame, /* Use the regcache_cooked_read() method so that it, on the fly, constructs either a raw or pseudo register from the raw register cache. */ - cache->prev_regcache->cooked_read (regnum, - value_contents_writeable (reg_val)); + cache->prev_regcache->cooked_read + (regnum, value_contents_writeable (reg_val).data ()); return reg_val; } diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c index 0f05f88..6521619 100644 --- a/gdb/dwarf2/expr.c +++ b/gdb/dwarf2/expr.c @@ -169,7 +169,7 @@ rw_pieced_value (value *v, value *from, bool check_optimized) gdb_assert (!check_optimized || from == nullptr); if (from != nullptr) { - from_contents = value_contents (from); + from_contents = value_contents (from).data (); v_contents = nullptr; } else @@ -181,7 +181,7 @@ rw_pieced_value (value *v, value *from, bool check_optimized) if (check_optimized) v_contents = nullptr; else - v_contents = value_contents_raw (v); + v_contents = value_contents_raw (v).data (); from_contents = nullptr; } @@ -394,7 +394,7 @@ rw_pieced_value (value *v, value *from, bool check_optimized) bits_to_skip += p->offset; copy_bitwise (v_contents, offset, - value_contents_all (p->v.value), + value_contents_all (p->v.value).data (), bits_to_skip, this_size_bits, bits_big_endian); } @@ -577,7 +577,7 @@ indirect_pieced_value (value *value) encode address spaces and other things in CORE_ADDR. */ bfd_endian byte_order = gdbarch_byte_order (get_frame_arch (frame)); LONGEST byte_offset - = extract_signed_integer (value_contents (value), + = extract_signed_integer (value_contents (value).data (), TYPE_LENGTH (type), byte_order); byte_offset += piece->v.ptr.offset; @@ -1037,8 +1037,8 @@ dwarf_expr_context::fetch_result (struct type *type, struct type *subobj_type, if (gdbarch_byte_order (arch) == BFD_ENDIAN_BIG) subobj_offset += n - max; - memcpy (value_contents_raw (retval), - value_contents_all (val) + subobj_offset, len); + memcpy (value_contents_raw (retval).data (), + value_contents_all (val).data () + subobj_offset, len); } break; @@ -1050,7 +1050,7 @@ dwarf_expr_context::fetch_result (struct type *type, struct type *subobj_type, invalid_synthetic_pointer (); retval = allocate_value (subobj_type); - bfd_byte *contents = value_contents_raw (retval); + bfd_byte *contents = value_contents_raw (retval).data (); memcpy (contents, this->m_data + subobj_offset, n); } break; @@ -1157,7 +1157,7 @@ dwarf_expr_context::fetch_address (int n) ULONGEST result; dwarf_require_integral (value_type (result_val)); - result = extract_unsigned_integer (value_contents (result_val), + result = extract_unsigned_integer (value_contents (result_val).data (), TYPE_LENGTH (value_type (result_val)), byte_order); @@ -2366,7 +2366,7 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr, else result_val = value_from_contents (type, - value_contents_all (result_val)); + value_contents_all (result_val).data ()); } break; diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c index 0e55993..33f0d99 100644 --- a/gdb/dwarf2/loc.c +++ b/gdb/dwarf2/loc.c @@ -1338,7 +1338,8 @@ value_of_dwarf_reg_entry (struct type *type, struct frame_info *frame, release_value (target_val).release ()); /* Copy the referencing pointer to the new computed value. */ - memcpy (value_contents_raw (val), value_contents_raw (outer_val), + memcpy (value_contents_raw (val).data (), + value_contents_raw (outer_val).data (), TYPE_LENGTH (checked_type)); set_value_lazy (val, 0); diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index e456c37..bd07546 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -10045,7 +10045,7 @@ dwarf2_compute_name (const char *name, else if (bytes != NULL) { v = allocate_value (type); - memcpy (value_contents_writeable (v), bytes, + memcpy (value_contents_writeable (v).data (), bytes, TYPE_LENGTH (type)); } else diff --git a/gdb/elfread.c b/gdb/elfread.c index c4be482..463e091 100644 --- a/gdb/elfread.c +++ b/gdb/elfread.c @@ -1020,7 +1020,7 @@ elf_gnu_ifunc_resolver_return_stop (struct breakpoint *b) value = allocate_value (value_type); gdbarch_return_value (gdbarch, func_func, value_type, regcache, - value_contents_raw (value), NULL); + value_contents_raw (value).data (), NULL); resolved_address = value_as_address (value); resolved_pc = gdbarch_convert_from_func_ptr_addr (gdbarch, resolved_address, current_inferior ()->top_target ()); @@ -2322,12 +2322,12 @@ array_operation::evaluate_struct_tuple (struct value *struct_val, bitsize = TYPE_FIELD_BITSIZE (struct_type, fieldno); bitpos = TYPE_FIELD_BITPOS (struct_type, fieldno); - addr = value_contents_writeable (struct_val) + bitpos / 8; + addr = value_contents_writeable (struct_val).data () + bitpos / 8; if (bitsize) modify_field (struct_type, addr, value_as_long (val), bitpos % 8, bitsize); else - memcpy (addr, value_contents (val), + memcpy (addr, value_contents (val).data (), TYPE_LENGTH (value_type (val))); } @@ -2351,7 +2351,7 @@ array_operation::evaluate (struct type *expect_type, { struct value *rec = allocate_value (expect_type); - memset (value_contents_raw (rec), '\0', TYPE_LENGTH (type)); + memset (value_contents_raw (rec).data (), '\0', TYPE_LENGTH (type)); return evaluate_struct_tuple (rec, exp, noside, nargs); } @@ -2370,7 +2370,7 @@ array_operation::evaluate (struct type *expect_type, high_bound = (TYPE_LENGTH (type) / element_size) - 1; } index = low_bound; - memset (value_contents_raw (array), 0, TYPE_LENGTH (expect_type)); + memset (value_contents_raw (array).data (), 0, TYPE_LENGTH (expect_type)); for (tem = nargs; --nargs >= 0;) { struct value *element; @@ -2382,9 +2382,9 @@ array_operation::evaluate (struct type *expect_type, if (index > high_bound) /* To avoid memory corruption. */ error (_("Too many array elements")); - memcpy (value_contents_raw (array) + memcpy (value_contents_raw (array).data () + (index - low_bound) * element_size, - value_contents (element), + value_contents (element).data (), element_size); index++; } @@ -2395,7 +2395,7 @@ array_operation::evaluate (struct type *expect_type, && type->code () == TYPE_CODE_SET) { struct value *set = allocate_value (expect_type); - gdb_byte *valaddr = value_contents_raw (set); + gdb_byte *valaddr = value_contents_raw (set).data (); struct type *element_type = type->index_type (); struct type *check_type = element_type; LONGEST low_bound, high_bound; diff --git a/gdb/f-lang.c b/gdb/f-lang.c index 16ec9e0..1b5a99c 100644 --- a/gdb/f-lang.c +++ b/gdb/f-lang.c @@ -770,7 +770,7 @@ eval_op_f_abs (struct type *expect_type, struct expression *exp, case TYPE_CODE_FLT: { double d - = fabs (target_float_to_host_double (value_contents (arg1), + = fabs (target_float_to_host_double (value_contents (arg1).data (), value_type (arg1))); return value_from_host_double (type, d); } @@ -800,10 +800,10 @@ eval_op_f_mod (struct type *expect_type, struct expression *exp, case TYPE_CODE_FLT: { double d1 - = target_float_to_host_double (value_contents (arg1), + = target_float_to_host_double (value_contents (arg1).data (), value_type (arg1)); double d2 - = target_float_to_host_double (value_contents (arg2), + = target_float_to_host_double (value_contents (arg2).data (), value_type (arg2)); double d3 = fmod (d1, d2); return value_from_host_double (type, d3); @@ -833,7 +833,7 @@ eval_op_f_ceil (struct type *expect_type, struct expression *exp, if (type->code () != TYPE_CODE_FLT) error (_("argument to CEILING must be of type float")); double val - = target_float_to_host_double (value_contents (arg1), + = target_float_to_host_double (value_contents (arg1).data (), value_type (arg1)); val = ceil (val); return value_from_host_double (type, val); @@ -851,7 +851,7 @@ eval_op_f_floor (struct type *expect_type, struct expression *exp, if (type->code () != TYPE_CODE_FLT) error (_("argument to FLOOR must be of type float")); double val - = target_float_to_host_double (value_contents (arg1), + = target_float_to_host_double (value_contents (arg1).data (), value_type (arg1)); val = floor (val); return value_from_host_double (type, val); @@ -883,10 +883,10 @@ eval_op_f_modulo (struct type *expect_type, struct expression *exp, case TYPE_CODE_FLT: { double a - = target_float_to_host_double (value_contents (arg1), + = target_float_to_host_double (value_contents (arg1).data (), value_type (arg1)); double p - = target_float_to_host_double (value_contents (arg2), + = target_float_to_host_double (value_contents (arg2).data (), value_type (arg2)); double result = fmod (a, p); if (result != 0 && (a < 0.0) != (p < 0.0)) @@ -1384,11 +1384,9 @@ fortran_undetermined::value_subarray (value *array, array = value_at_lazy (array_slice_type, value_address (array) + total_offset); else - array = value_from_contents_and_address (array_slice_type, - (value_contents (array) - + total_offset), - (value_address (array) - + total_offset)); + array = value_from_contents_and_address + (array_slice_type, value_contents (array).data () + total_offset, + value_address (array) + total_offset); } else if (!value_lazy (array)) array = value_from_component (array, array_slice_type, total_offset); @@ -1518,7 +1516,7 @@ fortran_structop_operation::evaluate (struct type *expect_type, struct type *elt_type = value_type (elt); if (is_dynamic_type (elt_type)) { - const gdb_byte *valaddr = value_contents_for_printing (elt); + const gdb_byte *valaddr = value_contents_for_printing (elt).data (); CORE_ADDR address = value_address (elt); gdb::array_view<const gdb_byte> view = gdb::make_array_view (valaddr, TYPE_LENGTH (elt_type)); @@ -1746,10 +1744,9 @@ fortran_argument_convert (struct value *value, bool is_artificial) const int length = TYPE_LENGTH (type); const CORE_ADDR addr = value_as_long (value_allocate_space_in_inferior (length)); - write_memory (addr, value_contents (value), length); - struct value *val - = value_from_contents_and_address (type, value_contents (value), - addr); + write_memory (addr, value_contents (value).data (), length); + struct value *val = value_from_contents_and_address + (type, value_contents (value).data (), addr); return value_addr (val); } else diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c index 27d9a73..7d7130a 100644 --- a/gdb/f-valprint.c +++ b/gdb/f-valprint.c @@ -223,7 +223,7 @@ f_language::value_print_inner (struct value *val, struct ui_file *stream, struct type *elttype; CORE_ADDR addr; int index; - const gdb_byte *valaddr = value_contents_for_printing (val); + const gdb_byte *valaddr = value_contents_for_printing (val).data (); const CORE_ADDR address = value_address (val); switch (type->code ()) diff --git a/gdb/findcmd.c b/gdb/findcmd.c index 44512d2..812c22e 100644 --- a/gdb/findcmd.c +++ b/gdb/findcmd.c @@ -185,7 +185,7 @@ parse_find_args (const char *args, ULONGEST *max_countp, } else { - const gdb_byte *contents = value_contents (v); + const gdb_byte *contents = value_contents (v).data (); pattern_buf.insert (pattern_buf.end (), contents, contents + TYPE_LENGTH (t)); } diff --git a/gdb/findvar.c b/gdb/findvar.c index 56edbdb..d2b7713 100644 --- a/gdb/findvar.c +++ b/gdb/findvar.c @@ -627,7 +627,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), TYPE_LENGTH (type), + store_signed_integer (value_contents_raw (v).data (), TYPE_LENGTH (type), type_byte_order (type), (LONGEST) SYMBOL_VALUE (var)); VALUE_LVAL (v) = not_lval; @@ -641,10 +641,10 @@ language_defn::read_var_value (struct symbol *var, struct objfile *var_objfile = symbol_objfile (var); addr = symbol_overlayed_address (SYMBOL_VALUE_ADDRESS (var), var->obj_section (var_objfile)); - store_typed_address (value_contents_raw (v), type, addr); + store_typed_address (value_contents_raw (v).data (), type, addr); } else - store_typed_address (value_contents_raw (v), type, + store_typed_address (value_contents_raw (v).data (), type, SYMBOL_VALUE_ADDRESS (var)); VALUE_LVAL (v) = not_lval; return v; @@ -656,7 +656,7 @@ language_defn::read_var_value (struct symbol *var, type = resolve_dynamic_type (type, {}, /* Unused address. */ 0); } v = allocate_value (type); - memcpy (value_contents_raw (v), SYMBOL_VALUE_BYTES (var), + memcpy (value_contents_raw (v).data (), SYMBOL_VALUE_BYTES (var), TYPE_LENGTH (type)); VALUE_LVAL (v) = not_lval; return v; @@ -926,7 +926,7 @@ value_from_register (struct type *type, int regnum, struct frame_info *frame) VALUE_NEXT_FRAME_ID (v) = get_frame_id (get_next_frame_sentinel_okay (frame)); VALUE_REGNUM (v) = regnum; ok = gdbarch_register_to_value (gdbarch, frame, regnum, type1, - value_contents_raw (v), &optim, + value_contents_raw (v).data (), &optim, &unavail); if (!ok) diff --git a/gdb/frame-unwind.c b/gdb/frame-unwind.c index 3dc303a..8110278 100644 --- a/gdb/frame-unwind.c +++ b/gdb/frame-unwind.c @@ -300,7 +300,7 @@ frame_unwind_got_constant (struct frame_info *frame, int regnum, struct value *reg_val; reg_val = value_zero (register_type (gdbarch, regnum), not_lval); - store_unsigned_integer (value_contents_writeable (reg_val), + store_unsigned_integer (value_contents_writeable (reg_val).data (), register_size (gdbarch, regnum), byte_order, val); return reg_val; } @@ -312,7 +312,8 @@ frame_unwind_got_bytes (struct frame_info *frame, int regnum, const gdb_byte *bu struct value *reg_val; reg_val = value_zero (register_type (gdbarch, regnum), not_lval); - memcpy (value_contents_raw (reg_val), buf, register_size (gdbarch, regnum)); + memcpy (value_contents_raw (reg_val).data (), buf, + register_size (gdbarch, regnum)); return reg_val; } @@ -328,7 +329,7 @@ frame_unwind_got_address (struct frame_info *frame, int regnum, struct value *reg_val; reg_val = value_zero (register_type (gdbarch, regnum), not_lval); - pack_long (value_contents_writeable (reg_val), + pack_long (value_contents_writeable (reg_val).data (), register_type (gdbarch, regnum), addr); return reg_val; } diff --git a/gdb/frame.c b/gdb/frame.c index 1667325..b121892 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -1156,7 +1156,7 @@ frame_register_unwind (frame_info *next_frame, int regnum, if (bufferp) { if (!*optimizedp && !*unavailablep) - memcpy (bufferp, value_contents_all (value), + memcpy (bufferp, value_contents_all (value).data (), TYPE_LENGTH (value_type (value))); else memset (bufferp, 0, TYPE_LENGTH (value_type (value))); @@ -1261,7 +1261,7 @@ frame_unwind_register_value (frame_info *next_frame, int regnum) else { int i; - const gdb_byte *buf = value_contents (value); + const gdb_byte *buf = value_contents (value).data (); fprintf_unfiltered (&debug_file, " bytes="); fprintf_unfiltered (&debug_file, "["); @@ -1304,7 +1304,7 @@ frame_unwind_register_signed (frame_info *next_frame, int regnum) _("Register %d is not available"), regnum); } - LONGEST r = extract_signed_integer (value_contents_all (value), size, + LONGEST r = extract_signed_integer (value_contents_all (value).data (), size, byte_order); release_value (value); @@ -1338,8 +1338,8 @@ frame_unwind_register_unsigned (frame_info *next_frame, int regnum) _("Register %d is not available"), regnum); } - ULONGEST r = extract_unsigned_integer (value_contents_all (value), size, - byte_order); + ULONGEST r = extract_unsigned_integer (value_contents_all (value).data (), + size, byte_order); release_value (value); return r; @@ -1364,7 +1364,8 @@ read_frame_register_unsigned (frame_info *frame, int regnum, enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); int size = register_size (gdbarch, VALUE_REGNUM (regval)); - *val = extract_unsigned_integer (value_contents (regval), size, byte_order); + *val = extract_unsigned_integer (value_contents (regval).data (), size, + byte_order); return true; } @@ -1496,7 +1497,8 @@ get_frame_register_bytes (frame_info *frame, int regnum, return false; } - memcpy (myaddr, value_contents_all (value) + offset, curr_len); + memcpy (myaddr, value_contents_all (value).data () + offset, + curr_len); release_value (value); } @@ -1546,9 +1548,10 @@ put_frame_register_bytes (struct frame_info *frame, int regnum, regnum); gdb_assert (value != NULL); - memcpy ((char *) value_contents_writeable (value) + offset, myaddr, - curr_len); - put_frame_register (frame, regnum, value_contents_raw (value)); + memcpy ((char *) value_contents_writeable (value).data () + offset, + myaddr, curr_len); + put_frame_register (frame, regnum, + value_contents_raw (value).data ()); release_value (value); } diff --git a/gdb/frv-tdep.c b/gdb/frv-tdep.c index ead4488..e105c27 100644 --- a/gdb/frv-tdep.c +++ b/gdb/frv-tdep.c @@ -1259,7 +1259,7 @@ frv_push_dummy_call (struct gdbarch *gdbarch, struct value *function, /* The FDPIC ABI requires function descriptors to be passed instead of entry points. */ CORE_ADDR addr = extract_unsigned_integer - (value_contents (arg), 4, byte_order); + (value_contents (arg).data (), 4, byte_order); addr = find_func_descr (gdbarch, addr); store_unsigned_integer (valbuf, 4, byte_order, addr); typecode = TYPE_CODE_PTR; @@ -1268,7 +1268,7 @@ frv_push_dummy_call (struct gdbarch *gdbarch, struct value *function, } else { - val = value_contents (arg); + val = value_contents (arg).data (); } while (len > 0) diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index b39d2b7..c947215 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -3878,7 +3878,7 @@ is_unique_ancestor (struct type *base, struct value *val) int offset = -1; return is_unique_ancestor_worker (base, value_type (val), &offset, - value_contents_for_printing (val), + value_contents_for_printing (val).data (), value_embedded_offset (val), value_address (val), val) == 1; } diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c index b82ac59..9311371 100644 --- a/gdb/gnu-v3-abi.c +++ b/gdb/gnu-v3-abi.c @@ -729,7 +729,7 @@ static struct value * gnuv3_method_ptr_to_value (struct value **this_p, struct value *method_ptr) { struct gdbarch *gdbarch; - const gdb_byte *contents = value_contents (method_ptr); + const gdb_byte *contents = value_contents (method_ptr).data (); CORE_ADDR ptr_value; struct type *self_type, *final_type, *method_type; LONGEST adjustment; diff --git a/gdb/go-valprint.c b/gdb/go-valprint.c index e04ea6b..5001e67 100644 --- a/gdb/go-valprint.c +++ b/gdb/go-valprint.c @@ -52,7 +52,7 @@ print_go_string (struct type *type, unpack_value_field_as_pointer. Do this until we can get unpack_value_field_as_pointer. */ LONGEST addr; - const gdb_byte *valaddr = value_contents_for_printing (val); + const gdb_byte *valaddr = value_contents_for_printing (val).data (); if (! unpack_value_field_as_long (type, valaddr, embedded_offset, 0, diff --git a/gdb/guile/scm-value.c b/gdb/guile/scm-value.c index d4d76df..659acf0 100644 --- a/gdb/guile/scm-value.c +++ b/gdb/guile/scm-value.c @@ -828,7 +828,7 @@ gdbscm_value_to_bytevector (SCM self) { type = check_typedef (type); length = TYPE_LENGTH (type); - contents = value_contents (value); + contents = value_contents (value).data (); } catch (const gdb_exception &except) { @@ -978,7 +978,8 @@ gdbscm_value_to_real (SCM self) { if (is_floating_value (value)) { - d = target_float_to_host_double (value_contents (value), type); + d = target_float_to_host_double (value_contents (value).data (), + type); check = value_from_host_double (type, d); } else if (type->is_unsigned ()) diff --git a/gdb/h8300-tdep.c b/gdb/h8300-tdep.c index 7d4495f..7a7da9d 100644 --- a/gdb/h8300-tdep.c +++ b/gdb/h8300-tdep.c @@ -648,7 +648,7 @@ h8300_push_dummy_call (struct gdbarch *gdbarch, struct value *function, { struct type *type = value_type (args[argument]); int len = TYPE_LENGTH (type); - char *contents = (char *) value_contents (args[argument]); + char *contents = (char *) value_contents (args[argument]).data (); /* Pad the argument appropriately. */ int padded_len = align_up (len, wordsize); diff --git a/gdb/hppa-tdep.c b/gdb/hppa-tdep.c index db26195..344022c 100644 --- a/gdb/hppa-tdep.c +++ b/gdb/hppa-tdep.c @@ -758,8 +758,8 @@ hppa32_push_dummy_call (struct gdbarch *gdbarch, struct value *function, param_len = 4; struct_ptr += align_up (TYPE_LENGTH (type), 8); if (write_pass) - write_memory (struct_end - struct_ptr, value_contents (arg), - TYPE_LENGTH (type)); + write_memory (struct_end - struct_ptr, + value_contents (arg).data (), TYPE_LENGTH (type)); store_unsigned_integer (param_val, 4, byte_order, struct_end - struct_ptr); } @@ -769,15 +769,15 @@ 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); - store_unsigned_integer (param_val, param_len, byte_order, - unpack_long (type, - value_contents (arg))); + store_unsigned_integer + (param_val, param_len, byte_order, + unpack_long (type, value_contents (arg).data ())); } else if (type->code () == TYPE_CODE_FLT) { /* Floating point value store, right aligned. */ param_len = align_up (TYPE_LENGTH (type), 4); - memcpy (param_val, value_contents (arg), param_len); + memcpy (param_val, value_contents (arg).data (), param_len); } else { @@ -785,7 +785,7 @@ hppa32_push_dummy_call (struct gdbarch *gdbarch, struct value *function, /* Small struct value are stored right-aligned. */ memcpy (param_val + param_len - TYPE_LENGTH (type), - value_contents (arg), TYPE_LENGTH (type)); + value_contents (arg).data (), TYPE_LENGTH (type)); /* Structures of size 5, 6 and 7 bytes are special in that the higher-ordered word is stored in the lower-ordered @@ -1041,7 +1041,7 @@ hppa64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, the right halves of the floating point registers; the left halves are unused." */ regcache->cooked_write_part (regnum, offset % 8, len, - value_contents (arg)); + value_contents (arg).data ()); } } } @@ -1065,7 +1065,7 @@ hppa64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, { ULONGEST codeptr, fptr; - codeptr = unpack_long (type, value_contents (arg)); + 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, fptr); @@ -1073,7 +1073,7 @@ hppa64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, } else { - valbuf = value_contents (arg); + valbuf = value_contents (arg).data (); } /* Always store the argument in memory. */ @@ -2769,7 +2769,7 @@ hppa_frame_prev_register_helper (struct frame_info *this_frame, trad_frame_get_prev_register (this_frame, saved_regs, HPPA_PCOQ_HEAD_REGNUM); - pc = extract_unsigned_integer (value_contents_all (pcoq_val), + pc = extract_unsigned_integer (value_contents_all (pcoq_val).data (), size, byte_order); return frame_unwind_got_constant (this_frame, regnum, pc + 4); } diff --git a/gdb/i386-darwin-tdep.c b/gdb/i386-darwin-tdep.c index 37b3b59..c038d8b 100644 --- a/gdb/i386-darwin-tdep.c +++ b/gdb/i386-darwin-tdep.c @@ -189,7 +189,7 @@ i386_darwin_push_dummy_call (struct gdbarch *gdbarch, struct value *function, { if (write_pass) { - const gdb_byte *val = value_contents_all (args[i]); + const gdb_byte *val = value_contents_all (args[i]).data (); regcache->raw_write (I387_MM0_REGNUM(tdep) + num_m128, val); } num_m128++; @@ -200,7 +200,7 @@ i386_darwin_push_dummy_call (struct gdbarch *gdbarch, struct value *function, i386_darwin_arg_type_alignment (arg_type)); if (write_pass) write_memory (sp + args_space, - value_contents_all (args[i]), + value_contents_all (args[i]).data (), TYPE_LENGTH (arg_type)); /* The System V ABI says that: diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index a9c4292..23dc39a 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -2729,7 +2729,7 @@ i386_thiscall_push_dummy_call (struct gdbarch *gdbarch, struct value *function, args_space_used = align_up (args_space_used, 16); write_memory (sp + args_space_used, - value_contents_all (args[i]), len); + value_contents_all (args[i]).data (), len); /* The System V ABI says that: "An argument's size is increased, if necessary, to make it a @@ -2773,7 +2773,8 @@ i386_thiscall_push_dummy_call (struct gdbarch *gdbarch, struct value *function, /* The 'this' pointer needs to be in ECX. */ if (thiscall) - regcache->cooked_write (I386_ECX_REGNUM, value_contents_all (args[0])); + regcache->cooked_write (I386_ECX_REGNUM, + value_contents_all (args[0]).data ()); /* MarkK wrote: This "+ 8" is all over the place: (i386_frame_this_id, i386_sigtramp_frame_this_id, @@ -3324,7 +3325,7 @@ i386_pseudo_register_read_into_value (struct gdbarch *gdbarch, { gdb_byte raw_buf[I386_MAX_REGISTER_SIZE]; enum register_status status; - gdb_byte *buf = value_contents_raw (result_value); + gdb_byte *buf = value_contents_raw (result_value).data (); if (i386_mmx_regnum_p (gdbarch, regnum)) { diff --git a/gdb/i387-tdep.c b/gdb/i387-tdep.c index c17c0f3..cb1aa15 100644 --- a/gdb/i387-tdep.c +++ b/gdb/i387-tdep.c @@ -284,7 +284,7 @@ i387_print_float_info (struct gdbarch *gdbarch, struct ui_file *file, if (value_entirely_available (regval)) { - const gdb_byte *raw = value_contents (regval); + const gdb_byte *raw = value_contents (regval).data (); fputs_filtered ("0x", file); for (i = 9; i >= 0; i--) diff --git a/gdb/ia64-tdep.c b/gdb/ia64-tdep.c index aa47b21..b6816cb 100644 --- a/gdb/ia64-tdep.c +++ b/gdb/ia64-tdep.c @@ -1935,7 +1935,7 @@ ia64_frame_prev_register (struct frame_info *this_frame, void **this_cache, that frame by adding the size of output: (sof (size of frame) - sol (size of locals)). */ val = ia64_frame_prev_register (this_frame, this_cache, IA64_CFM_REGNUM); - prev_cfm = extract_unsigned_integer (value_contents_all (val), + prev_cfm = extract_unsigned_integer (value_contents_all (val).data (), 8, byte_order); bsp = rse_address_add (cache->bsp, -(cache->sof)); prev_bsp = @@ -1985,7 +1985,7 @@ ia64_frame_prev_register (struct frame_info *this_frame, void **this_cache, /* Adjust the register number to account for register rotation. */ regnum = VP16_REGNUM + ((regnum - VP16_REGNUM) + rrb_pr) % 48; } - prN = extract_bit_field (value_contents_all (pr_val), + prN = extract_bit_field (value_contents_all (pr_val).data (), regnum - VP0_REGNUM, 1); return frame_unwind_got_constant (this_frame, regnum, prN); } @@ -1996,7 +1996,7 @@ ia64_frame_prev_register (struct frame_info *this_frame, void **this_cache, ULONGEST unatN; unat_val = ia64_frame_prev_register (this_frame, this_cache, IA64_UNAT_REGNUM); - unatN = extract_bit_field (value_contents_all (unat_val), + unatN = extract_bit_field (value_contents_all (unat_val).data (), regnum - IA64_NAT0_REGNUM, 1); return frame_unwind_got_constant (this_frame, regnum, unatN); } @@ -2118,12 +2118,12 @@ ia64_frame_prev_register (struct frame_info *this_frame, void **this_cache, regnum = IA64_GR32_REGNUM + (regnum - V32_REGNUM); reg_val = ia64_frame_prev_register (this_frame, this_cache, IA64_CFM_REGNUM); - prev_cfm = extract_unsigned_integer (value_contents_all (reg_val), - 8, byte_order); + prev_cfm = extract_unsigned_integer + (value_contents_all (reg_val).data (), 8, byte_order); reg_val = ia64_frame_prev_register (this_frame, this_cache, IA64_BSP_REGNUM); - prev_bsp = extract_unsigned_integer (value_contents_all (reg_val), - 8, byte_order); + prev_bsp = extract_unsigned_integer + (value_contents_all (reg_val).data (), 8, byte_order); prev_bof = rse_address_add (prev_bsp, -(prev_cfm & 0x7f)); addr = rse_address_add (prev_bof, (regnum - IA64_GR32_REGNUM)); @@ -2956,7 +2956,7 @@ ia64_libunwind_frame_prev_register (struct frame_info *this_frame, /* Adjust the register number to account for register rotation. */ regnum = VP16_REGNUM + ((regnum - VP16_REGNUM) + rrb_pr) % 48; } - prN_val = extract_bit_field (value_contents_all (val), + prN_val = extract_bit_field (value_contents_all (val).data (), regnum - VP0_REGNUM, 1); return frame_unwind_got_constant (this_frame, regnum, prN_val); } @@ -2965,7 +2965,7 @@ ia64_libunwind_frame_prev_register (struct frame_info *this_frame, { ULONGEST unatN_val; - unatN_val = extract_bit_field (value_contents_all (val), + unatN_val = extract_bit_field (value_contents_all (val).data (), regnum - IA64_NAT0_REGNUM, 1); return frame_unwind_got_constant (this_frame, regnum, unatN_val); } @@ -2980,11 +2980,11 @@ ia64_libunwind_frame_prev_register (struct frame_info *this_frame, register will be if we pop the frame back which is why we might have been called. We know that libunwind will pass us back the beginning of the current frame so we should just add sof to it. */ - prev_bsp = extract_unsigned_integer (value_contents_all (val), + prev_bsp = extract_unsigned_integer (value_contents_all (val).data (), 8, byte_order); cfm_val = libunwind_frame_prev_register (this_frame, this_cache, IA64_CFM_REGNUM); - prev_cfm = extract_unsigned_integer (value_contents_all (cfm_val), + prev_cfm = extract_unsigned_integer (value_contents_all (cfm_val).data (), 8, byte_order); prev_bsp = rse_address_add (prev_bsp, (prev_cfm & 0x7f)); @@ -3067,7 +3067,7 @@ ia64_libunwind_sigtramp_frame_prev_register (struct frame_info *this_frame, method of getting previous registers. */ prev_ip_val = libunwind_frame_prev_register (this_frame, this_cache, IA64_IP_REGNUM); - prev_ip = extract_unsigned_integer (value_contents_all (prev_ip_val), + prev_ip = extract_unsigned_integer (value_contents_all (prev_ip_val).data (), 8, byte_order); if (prev_ip == 0) @@ -3747,8 +3747,8 @@ ia64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, && TYPE_TARGET_TYPE (type)->code () == TYPE_CODE_FUNC) { gdb_byte val_buf[8]; - ULONGEST faddr = extract_unsigned_integer (value_contents (arg), - 8, byte_order); + ULONGEST faddr = extract_unsigned_integer + (value_contents (arg).data (), 8, byte_order); store_unsigned_integer (val_buf, 8, byte_order, find_func_descr (regcache, faddr, &funcdescaddr)); @@ -3780,7 +3780,7 @@ ia64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, This is why we use store_unsigned_integer. */ store_unsigned_integer (val_buf, 8, byte_order, - extract_unsigned_integer (value_contents (arg), len, + extract_unsigned_integer (value_contents (arg).data (), len, byte_order)); } else @@ -3794,7 +3794,7 @@ ia64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, In this case, the data is Byte0-aligned. Happy news, this means that we don't need to differentiate the handling of 8byte blocks and less-than-8bytes blocks. */ - memcpy (val_buf, value_contents (arg) + argoffset, + memcpy (val_buf, value_contents (arg).data () + argoffset, (len > 8) ? 8 : len); } @@ -3818,7 +3818,7 @@ ia64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, while (len > 0 && floatreg < IA64_FR16_REGNUM) { gdb_byte to[IA64_FP_REGISTER_SIZE]; - target_float_convert (value_contents (arg) + argoffset, + target_float_convert (value_contents (arg).data () + argoffset, float_elt_type, to, ia64_ext_type (gdbarch)); regcache->cooked_write (floatreg, to); diff --git a/gdb/infcall.c b/gdb/infcall.c index 40298fb..4416a0c 100644 --- a/gdb/infcall.c +++ b/gdb/infcall.c @@ -451,7 +451,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), + value_contents_raw (retval).data (), TYPE_LENGTH (ri->value_type)); } } @@ -460,7 +460,7 @@ get_call_return_value (struct call_return_meta_info *ri) retval = allocate_value (ri->value_type); gdbarch_return_value (ri->gdbarch, ri->function, ri->value_type, get_current_regcache (), - value_contents_raw (retval), NULL); + value_contents_raw (retval).data (), NULL); if (stack_temporaries && class_or_union_p (ri->value_type)) { /* Values of class type returned in registers are copied onto @@ -1083,7 +1083,7 @@ call_function_by_hand_dummy (struct value *function, if (info.trivially_copy_constructible) { int length = TYPE_LENGTH (param_type); - write_memory (addr, value_contents (args[i]), length); + write_memory (addr, value_contents (args[i]).data (), length); } else { diff --git a/gdb/infcmd.c b/gdb/infcmd.c index 6d3a8b0..302db42 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -1430,7 +1430,7 @@ get_return_value (struct value *function, struct type *value_type) case RETURN_VALUE_ABI_PRESERVES_ADDRESS: value = allocate_value (value_type); gdbarch_return_value (gdbarch, function, value_type, stop_regs, - value_contents_raw (value), NULL); + value_contents_raw (value).data (), NULL); break; case RETURN_VALUE_STRUCT_CONVENTION: value = NULL; @@ -2076,7 +2076,7 @@ default_print_one_register_info (struct ui_file *file, || regtype->code () == TYPE_CODE_DECFLOAT) { struct value_print_options opts; - const gdb_byte *valaddr = value_contents_for_printing (val); + const gdb_byte *valaddr = value_contents_for_printing (val).data (); enum bfd_endian byte_order = type_byte_order (regtype); get_user_print_options (&opts); diff --git a/gdb/infrun.c b/gdb/infrun.c index d97d469..edc0e8f 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -8998,7 +8998,7 @@ siginfo_value_read (struct value *v) target_read (current_inferior ()->top_target (), TARGET_OBJECT_SIGNAL_INFO, NULL, - value_contents_all_raw (v), + value_contents_all_raw (v).data (), value_offset (v), TYPE_LENGTH (value_type (v))); @@ -9021,7 +9021,7 @@ siginfo_value_write (struct value *v, struct value *fromval) transferred = target_write (current_inferior ()->top_target (), TARGET_OBJECT_SIGNAL_INFO, NULL, - value_contents_all_raw (fromval), + value_contents_all_raw (fromval).data (), value_offset (v), TYPE_LENGTH (value_type (fromval))); diff --git a/gdb/iq2000-tdep.c b/gdb/iq2000-tdep.c index 69bc758..806fa76 100644 --- a/gdb/iq2000-tdep.c +++ b/gdb/iq2000-tdep.c @@ -712,7 +712,7 @@ iq2000_push_dummy_call (struct gdbarch *gdbarch, struct value *function, { type = value_type (args[i]); typelen = TYPE_LENGTH (type); - val = value_contents (args[i]); + val = value_contents (args[i]).data (); if (typelen <= 4) { /* Char, short, int, float, pointer, and structs <= four bytes. */ diff --git a/gdb/lm32-tdep.c b/gdb/lm32-tdep.c index 123a1a9..9c5dda3 100644 --- a/gdb/lm32-tdep.c +++ b/gdb/lm32-tdep.c @@ -271,7 +271,7 @@ lm32_push_dummy_call (struct gdbarch *gdbarch, struct value *function, /* FIXME: Handle structures. */ - contents = (gdb_byte *) value_contents (arg); + contents = (gdb_byte *) value_contents (arg).data (); val = extract_unsigned_integer (contents, TYPE_LENGTH (arg_type), byte_order); diff --git a/gdb/m2-valprint.c b/gdb/m2-valprint.c index be21cbb..a3af195 100644 --- a/gdb/m2-valprint.c +++ b/gdb/m2-valprint.c @@ -165,7 +165,7 @@ m2_print_unbounded_array (struct value *value, struct value *val; struct type *type = check_typedef (value_type (value)); - const gdb_byte *valaddr = value_contents_for_printing (value); + const gdb_byte *valaddr = value_contents_for_printing (value).data (); addr = unpack_pointer (type->field (0).type (), (TYPE_FIELD_BITPOS (type, 0) / 8) + @@ -305,7 +305,7 @@ m2_language::value_print_inner (struct value *val, struct ui_file *stream, unsigned len; struct type *elttype; CORE_ADDR addr; - const gdb_byte *valaddr = value_contents_for_printing (val); + const gdb_byte *valaddr = value_contents_for_printing (val).data (); const CORE_ADDR address = value_address (val); struct type *type = check_typedef (value_type (val)); diff --git a/gdb/m32c-tdep.c b/gdb/m32c-tdep.c index 550a63d..3374b00 100644 --- a/gdb/m32c-tdep.c +++ b/gdb/m32c-tdep.c @@ -2043,7 +2043,7 @@ m32c_push_dummy_call (struct gdbarch *gdbarch, struct value *function, for (i = nargs - 1; i >= 0; i--) { struct value *arg = args[i]; - const gdb_byte *arg_bits = value_contents (arg); + const gdb_byte *arg_bits = value_contents (arg).data (); struct type *arg_type = value_type (arg); ULONGEST arg_size = TYPE_LENGTH (arg_type); diff --git a/gdb/m32r-tdep.c b/gdb/m32r-tdep.c index b5839be..48cc42c 100644 --- a/gdb/m32r-tdep.c +++ b/gdb/m32r-tdep.c @@ -710,11 +710,11 @@ m32r_push_dummy_call (struct gdbarch *gdbarch, struct value *function, { /* Value gets right-justified in the register or stack word. */ memcpy (valbuf + (register_size (gdbarch, argreg) - len), - (gdb_byte *) value_contents (args[argnum]), len); + (gdb_byte *) value_contents (args[argnum]).data (), len); val = valbuf; } else - val = (gdb_byte *) value_contents (args[argnum]); + val = (gdb_byte *) value_contents (args[argnum]).data (); while (len > 0) { diff --git a/gdb/m68hc11-tdep.c b/gdb/m68hc11-tdep.c index c141711..bbf7e5d 100644 --- a/gdb/m68hc11-tdep.c +++ b/gdb/m68hc11-tdep.c @@ -1159,7 +1159,7 @@ m68hc11_push_dummy_call (struct gdbarch *gdbarch, struct value *function, { ULONGEST v; - v = extract_unsigned_integer (value_contents (args[0]), + v = extract_unsigned_integer (value_contents (args[0]).data (), TYPE_LENGTH (type), byte_order); first_stack_argnum = 1; @@ -1183,7 +1183,7 @@ m68hc11_push_dummy_call (struct gdbarch *gdbarch, struct value *function, sp--; write_memory (sp, &zero, 1); } - val = value_contents (args[argnum]); + val = value_contents (args[argnum]).data (); sp -= TYPE_LENGTH (type); write_memory (sp, val, TYPE_LENGTH (type)); } diff --git a/gdb/m68k-tdep.c b/gdb/m68k-tdep.c index 7397e62..75fa189 100644 --- a/gdb/m68k-tdep.c +++ b/gdb/m68k-tdep.c @@ -560,7 +560,7 @@ m68k_push_dummy_call (struct gdbarch *gdbarch, struct value *function, else offset = container_len - len; sp -= container_len; - write_memory (sp + offset, value_contents_all (args[i]), len); + write_memory (sp + offset, value_contents_all (args[i]).data (), len); } /* Store struct value address. */ diff --git a/gdb/mep-tdep.c b/gdb/mep-tdep.c index 89fde0a..d48e1f1 100644 --- a/gdb/mep-tdep.c +++ b/gdb/mep-tdep.c @@ -2229,7 +2229,7 @@ push_large_arguments (CORE_ADDR sp, int argc, struct value **argv, /* Reserve space for the copy, and then round the SP down, to make sure it's all aligned properly. */ sp = (sp - arg_len) & -4; - write_memory (sp, value_contents (argv[i]), arg_len); + write_memory (sp, value_contents (argv[i]).data (), arg_len); copy[i] = sp; } } @@ -2283,7 +2283,7 @@ mep_push_dummy_call (struct gdbarch *gdbarch, struct value *function, /* Arguments that fit in a GPR get expanded to fill the GPR. */ if (TYPE_LENGTH (value_type (argv[i])) <= MEP_GPR_SIZE) - value = extract_unsigned_integer (value_contents (argv[i]), + value = extract_unsigned_integer (value_contents (argv[i]).data (), TYPE_LENGTH (value_type (argv[i])), byte_order); diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c index f16cdaa..57295d6 100644 --- a/gdb/mips-tdep.c +++ b/gdb/mips-tdep.c @@ -4585,7 +4585,7 @@ mips_eabi_push_dummy_call (struct gdbarch *gdbarch, struct value *function, fprintf_unfiltered (gdb_stdlog, " push"); } else - val = value_contents (arg); + val = value_contents (arg).data (); /* 32-bit ABIs always start floating point arguments in an even-numbered floating point register. Round the FP register @@ -4960,7 +4960,7 @@ mips_n32n64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, "mips_n32n64_push_dummy_call: %d len=%d type=%d", argnum + 1, len, (int) typecode); - val = value_contents (arg); + val = value_contents (arg).data (); /* A 128-bit long double value requires an even-odd pair of floating-point registers. */ @@ -5427,7 +5427,7 @@ mips_o32_push_dummy_call (struct gdbarch *gdbarch, struct value *function, "mips_o32_push_dummy_call: %d len=%d type=%d", argnum + 1, len, (int) typecode); - val = value_contents (arg); + val = value_contents (arg).data (); /* 32-bit ABIs always start floating point arguments in an even-numbered floating point register. Round the FP register @@ -5949,7 +5949,7 @@ mips_o64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, "mips_o64_push_dummy_call: %d len=%d type=%d", argnum + 1, len, (int) typecode); - val = value_contents (arg); + val = value_contents (arg).data (); /* Floating point arguments passed in registers have to be treated specially. On 32-bit architectures, doubles are @@ -6556,7 +6556,7 @@ print_gp_register_row (struct ui_file *file, struct frame_info *frame, col++; continue; } - raw_buffer = value_contents_all (value); + raw_buffer = value_contents_all (value).data (); /* pad small registers */ for (byte = 0; byte < (mips_abi_regsize (gdbarch) diff --git a/gdb/mn10300-tdep.c b/gdb/mn10300-tdep.c index 2961f2a..7feab0b 100644 --- a/gdb/mn10300-tdep.c +++ b/gdb/mn10300-tdep.c @@ -1222,7 +1222,7 @@ mn10300_push_dummy_call (struct gdbarch *gdbarch, else { arg_len = TYPE_LENGTH (value_type (*args)); - val = value_contents (*args); + val = value_contents (*args).data (); } while (regs_used < 2 && arg_len > 0) diff --git a/gdb/msp430-tdep.c b/gdb/msp430-tdep.c index 06a468c..c1b0c4c 100644 --- a/gdb/msp430-tdep.c +++ b/gdb/msp430-tdep.c @@ -683,7 +683,7 @@ msp430_push_dummy_call (struct gdbarch *gdbarch, struct value *function, for (i = 0; i < nargs; i++) { struct value *arg = args[i]; - const gdb_byte *arg_bits = value_contents_all (arg); + 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); int offset; diff --git a/gdb/nds32-tdep.c b/gdb/nds32-tdep.c index 36f4979..828853e 100644 --- a/gdb/nds32-tdep.c +++ b/gdb/nds32-tdep.c @@ -1481,7 +1481,7 @@ nds32_push_dummy_call (struct gdbarch *gdbarch, struct value *function, calling_use_fpr = nds32_check_calling_use_fpr (type); len = TYPE_LENGTH (type); align = type_align (type); - val = value_contents (args[i]); + val = value_contents (args[i]).data (); /* The size of a composite type larger than 4 bytes will be rounded up to the nearest multiple of 4. */ diff --git a/gdb/nios2-tdep.c b/gdb/nios2-tdep.c index b090680..be5544e 100644 --- a/gdb/nios2-tdep.c +++ b/gdb/nios2-tdep.c @@ -1839,7 +1839,7 @@ nios2_push_dummy_call (struct gdbarch *gdbarch, struct value *function, struct type *arg_type = check_typedef (value_type (arg)); int len = TYPE_LENGTH (arg_type); - val = value_contents (arg); + val = value_contents (arg).data (); /* Copy the argument to general registers or the stack in register-sized pieces. Large arguments are split between diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c index b279674..437f27f 100644 --- a/gdb/opencl-lang.c +++ b/gdb/opencl-lang.c @@ -139,8 +139,8 @@ lval_func_read (struct value *v) gdb_assert (n <= c->n); for (i = offset; i < n; i++) - memcpy (value_contents_raw (v) + j++ * elsize, - value_contents (c->val) + c->indices[i] * elsize, + memcpy (value_contents_raw (v).data () + j++ * elsize, + value_contents (c->val).data () + c->indices[i] * elsize, elsize); } @@ -179,8 +179,8 @@ lval_func_write (struct value *v, struct value *fromval) struct value *from_elm_val = allocate_value (eltype); struct value *to_elm_val = value_subscript (c->val, c->indices[i]); - memcpy (value_contents_writeable (from_elm_val), - value_contents (fromval) + j++ * elsize, + memcpy (value_contents_writeable (from_elm_val).data (), + value_contents (fromval).data () + j++ * elsize, elsize); value_assign (to_elm_val, from_elm_val); } @@ -315,9 +315,9 @@ 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) + memcpy (value_contents_writeable (ret).data () + (i * TYPE_LENGTH (elm_type)), - value_contents (val) + value_contents (val).data () + (indices[i] * TYPE_LENGTH (elm_type)), TYPE_LENGTH (elm_type)); } @@ -473,7 +473,8 @@ opencl_logical_not (struct type *expect_type, struct expression *exp, value of its operand compares unequal to 0, and -1 (i.e. all bits 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) + i * TYPE_LENGTH (eltype), + memset ((value_contents_writeable (ret).data () + + i * TYPE_LENGTH (eltype)), tmp, TYPE_LENGTH (eltype)); } } @@ -573,7 +574,8 @@ vector_relop (struct expression *exp, struct value *val1, struct value *val2, if the specified relation is true. */ int tmp = scalar_relop (value_subscript (val1, i), value_subscript (val2, i), op) ? -1 : 0; - memset (value_contents_writeable (ret) + i * TYPE_LENGTH (eltype1), + memset ((value_contents_writeable (ret).data () + + i * TYPE_LENGTH (eltype1)), tmp, TYPE_LENGTH (eltype1)); } @@ -836,8 +838,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) + - i * TYPE_LENGTH (eltype2), value_contents_all (tmp), + memcpy (value_contents_writeable (ret).data () + + i * TYPE_LENGTH (eltype2), value_contents_all (tmp).data (), TYPE_LENGTH (eltype2)); } diff --git a/gdb/or1k-tdep.c b/gdb/or1k-tdep.c index 91f2157..6b0b62d 100644 --- a/gdb/or1k-tdep.c +++ b/gdb/or1k-tdep.c @@ -655,7 +655,7 @@ or1k_push_dummy_call (struct gdbarch *gdbarch, struct value *function, heap_offset += align_up (len, bpw); valaddr = heap_sp + heap_offset; - write_memory (valaddr, value_contents (arg), len); + write_memory (valaddr, value_contents (arg).data (), len); } /* The ABI passes all structures by reference, so get its @@ -667,7 +667,7 @@ or1k_push_dummy_call (struct gdbarch *gdbarch, struct value *function, else { /* Everything else, we just get the value. */ - val = value_contents (arg); + val = value_contents (arg).data (); } /* Stick the value in a register. */ @@ -767,7 +767,7 @@ or1k_push_dummy_call (struct gdbarch *gdbarch, struct value *function, val = valbuf; } else - val = value_contents (arg); + val = value_contents (arg).data (); while (len > 0) { diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c index 44be498..335d4b8 100644 --- a/gdb/p-valprint.c +++ b/gdb/p-valprint.c @@ -80,7 +80,7 @@ pascal_language::value_print_inner (struct value *val, struct type *char_type; CORE_ADDR addr; int want_space = 0; - const gdb_byte *valaddr = value_contents_for_printing (val); + const gdb_byte *valaddr = value_contents_for_printing (val).data (); switch (type->code ()) { @@ -536,7 +536,7 @@ pascal_object_print_value_fields (struct value *val, struct ui_file *stream, { struct obstack tmp_obstack = dont_print_statmem_obstack; int fields_seen = 0; - const gdb_byte *valaddr = value_contents_for_printing (val); + const gdb_byte *valaddr = value_contents_for_printing (val).data (); if (dont_print_statmem == 0) { diff --git a/gdb/ppc-sysv-tdep.c b/gdb/ppc-sysv-tdep.c index 3abb987..d98af25 100644 --- a/gdb/ppc-sysv-tdep.c +++ b/gdb/ppc-sysv-tdep.c @@ -122,7 +122,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); - const bfd_byte *val = value_contents (arg); + const bfd_byte *val = value_contents (arg).data (); if (type->code () == TYPE_CODE_FLT && len <= 8 && !tdep->soft_float) @@ -1633,7 +1633,7 @@ ppc64_sysv_abi_push_dummy_call (struct gdbarch *gdbarch, { struct value *arg = args[argno]; struct type *type = check_typedef (value_type (arg)); - const bfd_byte *val = value_contents (arg); + const bfd_byte *val = value_contents (arg).data (); if (type->code () == TYPE_CODE_COMPLEX) { diff --git a/gdb/printcmd.c b/gdb/printcmd.c index 2fe3f4b..03abd75 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -2447,7 +2447,7 @@ printf_c_string (struct ui_file *stream, const char *format, null terminated) to be printed without problems. */ gdb_byte *tem_str = (gdb_byte *) alloca (len + 1); - memcpy (tem_str, value_contents (value), len); + memcpy (tem_str, value_contents (value).data (), len); tem_str [len] = 0; str = tem_str; } @@ -2511,7 +2511,7 @@ printf_wide_c_string (struct ui_file *stream, const char *format, if (VALUE_LVAL (value) == lval_internalvar && c_is_string_type_p (value_type (value))) { - str = value_contents (value); + str = value_contents (value).data (); len = TYPE_LENGTH (value_type (value)); } else @@ -2620,14 +2620,15 @@ printf_floating (struct ui_file *stream, const char *format, { param_type = float_type_from_length (param_type); if (param_type != value_type (value)) - value = value_from_contents (param_type, value_contents (value)); + value = value_from_contents (param_type, + value_contents (value).data ()); } value = value_cast (fmt_type, value); /* Convert the value to a string and print it. */ std::string str - = target_float_to_string (value_contents (value), fmt_type, format); + = target_float_to_string (value_contents (value).data (), fmt_type, format); fputs_filtered (str.c_str (), stream); } @@ -2788,7 +2789,7 @@ ui_printf (const char *arg, struct ui_file *stream) || valtype->code () != TYPE_CODE_INT) error (_("expected wchar_t argument for %%lc")); - bytes = value_contents (val_args[i]); + bytes = value_contents (val_args[i]).data (); auto_obstack output; diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c index aec8c0f..3938dd8 100644 --- a/gdb/python/py-inferior.c +++ b/gdb/python/py-inferior.c @@ -689,7 +689,7 @@ infpy_thread_from_thread_handle (PyObject *self, PyObject *args, PyObject *kw) else if (gdbpy_is_value_object (handle_obj)) { struct value *val = value_object_to_value (handle_obj); - bytes = value_contents_all (val); + bytes = value_contents_all (val).data (); bytes_len = TYPE_LENGTH (value_type (val)); } else diff --git a/gdb/python/py-unwind.c b/gdb/python/py-unwind.c index 3d87a19..1669834 100644 --- a/gdb/python/py-unwind.c +++ b/gdb/python/py-unwind.c @@ -133,7 +133,7 @@ pyuw_value_obj_to_pointer (PyObject *pyo_value, CORE_ADDR *addr) if ((value = value_object_to_value (pyo_value)) != NULL) { *addr = unpack_pointer (value_type (value), - value_contents (value)); + value_contents (value).data ()); rc = 1; } } @@ -631,7 +631,8 @@ pyuw_sniffer (const struct frame_unwind *self, struct frame_info *this_frame, gdb_assert (data_size == TYPE_LENGTH (value_type (value))); cached_frame->reg[i].data = (gdb_byte *) xmalloc (data_size); - memcpy (cached_frame->reg[i].data, value_contents (value), data_size); + memcpy (cached_frame->reg[i].data, + value_contents (value).data (), data_size); } } diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c index d45df5f..c843c2c 100644 --- a/gdb/python/py-value.c +++ b/gdb/python/py-value.c @@ -1500,8 +1500,8 @@ valpy_nonzero (PyObject *self) if (is_integral_type (type) || type->code () == TYPE_CODE_PTR) nonzero = !!value_as_long (self_value->value); else if (is_floating_value (self_value->value)) - nonzero = !target_float_is_zero (value_contents (self_value->value), - type); + nonzero = !target_float_is_zero + (value_contents (self_value->value).data (), type); else /* All other values are True. */ nonzero = 1; @@ -1754,7 +1754,7 @@ valpy_float (PyObject *self) type = check_typedef (type); if (type->code () == TYPE_CODE_FLT && is_floating_value (value)) - d = target_float_to_host_double (value_contents (value), type); + d = target_float_to_host_double (value_contents (value).data (), type); else if (type->code () == TYPE_CODE_INT) { /* Note that valpy_long accepts TYPE_CODE_PTR and some diff --git a/gdb/regcache.c b/gdb/regcache.c index 672da05..8457284 100644 --- a/gdb/regcache.c +++ b/gdb/regcache.c @@ -712,7 +712,7 @@ readable_regcache::cooked_read (int regnum, gdb_byte *buf) computed = gdbarch_pseudo_register_read_value (m_descr->gdbarch, this, regnum); if (value_entirely_available (computed)) - memcpy (buf, value_contents_raw (computed), + memcpy (buf, value_contents_raw (computed).data (), m_descr->sizeof_register[regnum]); else { @@ -749,7 +749,7 @@ readable_regcache::cooked_read_value (int regnum) direction than in the other one, even though the value-based API is preferred. */ if (cooked_read (regnum, - value_contents_raw (result)) == REG_UNAVAILABLE) + value_contents_raw (result).data ()) == REG_UNAVAILABLE) mark_value_bytes_unavailable (result, 0, TYPE_LENGTH (value_type (result))); diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c index 4be8902..4b92754 100644 --- a/gdb/riscv-tdep.c +++ b/gdb/riscv-tdep.c @@ -1059,7 +1059,7 @@ riscv_print_one_register_info (struct gdbarch *gdbarch, && regtype->field (2).type ()->code () == TYPE_CODE_FLT)) { struct value_print_options opts; - const gdb_byte *valaddr = value_contents_for_printing (val); + const gdb_byte *valaddr = value_contents_for_printing (val).data (); enum bfd_endian byte_order = type_byte_order (regtype); get_user_print_options (&opts); @@ -2942,7 +2942,7 @@ riscv_push_dummy_call (struct gdbarch *gdbarch, if (info->type != arg_type) arg_value = value_cast (info->type, arg_value); - info->contents = value_contents (arg_value); + info->contents = value_contents (arg_value).data (); } /* Adjust the stack pointer and align it. */ @@ -3137,13 +3137,13 @@ riscv_return_value (struct gdbarch *gdbarch, { struct value *arg_val = value_from_contents (arg_type, writebuf); abi_val = value_cast (info.type, arg_val); - writebuf = value_contents_raw (abi_val); + writebuf = value_contents_raw (abi_val).data (); } else { abi_val = allocate_value (info.type); old_readbuf = readbuf; - readbuf = value_contents_raw (abi_val); + readbuf = value_contents_raw (abi_val).data (); } arg_len = TYPE_LENGTH (info.type); @@ -3241,7 +3241,7 @@ riscv_return_value (struct gdbarch *gdbarch, if (readbuf != nullptr) { struct value *arg_val = value_cast (arg_type, abi_val); - memcpy (old_readbuf, value_contents_raw (arg_val), + memcpy (old_readbuf, value_contents_raw (arg_val).data (), TYPE_LENGTH (arg_type)); } } diff --git a/gdb/rl78-tdep.c b/gdb/rl78-tdep.c index 1c4829f..3b2cf96 100644 --- a/gdb/rl78-tdep.c +++ b/gdb/rl78-tdep.c @@ -1345,7 +1345,7 @@ rl78_push_dummy_call (struct gdbarch *gdbarch, struct value *function, sp -= container_len; write_memory (rl78_make_data_address (sp), - value_contents_all (args[i]), len); + value_contents_all (args[i]).data (), len); } /* Store struct value address. */ diff --git a/gdb/rs6000-aix-tdep.c b/gdb/rs6000-aix-tdep.c index 3717f2b..80e1957 100644 --- a/gdb/rs6000-aix-tdep.c +++ b/gdb/rs6000-aix-tdep.c @@ -364,7 +364,8 @@ rs6000_push_dummy_call (struct gdbarch *gdbarch, struct value *function, gdb_assert (len <= 8); - target_float_convert (value_contents (arg), type, reg_val, reg_type); + target_float_convert (value_contents (arg).data (), type, reg_val, + reg_type); regcache->cooked_write (fp_regnum, reg_val); ++f_argno; } @@ -378,7 +379,7 @@ rs6000_push_dummy_call (struct gdbarch *gdbarch, struct value *function, gdb_byte word[PPC_MAX_REGISTER_SIZE]; memset (word, 0, reg_size); memcpy (word, - ((char *) value_contents (arg)) + argbytes, + ((char *) value_contents (arg).data ()) + argbytes, (len - argbytes) > reg_size ? reg_size : len - argbytes); regcache->cooked_write (tdep->ppc_gp0_regnum + 3 + ii, word); @@ -396,7 +397,7 @@ rs6000_push_dummy_call (struct gdbarch *gdbarch, struct value *function, gdb_byte word[PPC_MAX_REGISTER_SIZE]; memset (word, 0, reg_size); - memcpy (word, value_contents (arg), len); + memcpy (word, value_contents (arg).data (), len); regcache->cooked_write (tdep->ppc_gp0_regnum + 3 +ii, word); } ++argno; @@ -457,7 +458,7 @@ ran_out_of_registers_for_arguments: if (argbytes) { write_memory (sp + 24 + (ii * 4), - value_contents (arg) + argbytes, + value_contents (arg).data () + argbytes, len - argbytes); ++argno; ii += ((len - argbytes + 3) & -4) / 4; @@ -480,11 +481,11 @@ ran_out_of_registers_for_arguments: gdb_assert (len <= 8); regcache->cooked_write (tdep->ppc_fp0_regnum + 1 + f_argno, - value_contents (arg)); + value_contents (arg).data ()); ++f_argno; } - write_memory (sp + 24 + (ii * 4), value_contents (arg), len); + write_memory (sp + 24 + (ii * 4), value_contents (arg).data (), len); ii += ((len + 3) & -4) / 4; } } diff --git a/gdb/rs6000-lynx178-tdep.c b/gdb/rs6000-lynx178-tdep.c index 5fa28d4..21f1baf 100644 --- a/gdb/rs6000-lynx178-tdep.c +++ b/gdb/rs6000-lynx178-tdep.c @@ -111,7 +111,8 @@ rs6000_lynx178_push_dummy_call (struct gdbarch *gdbarch, gdb_assert (len <= 8); - target_float_convert (value_contents (arg), type, reg_val, reg_type); + target_float_convert (value_contents (arg).data (), type, reg_val, + reg_type); regcache->cooked_write (fp_regnum, reg_val); ++f_argno; } @@ -125,7 +126,7 @@ rs6000_lynx178_push_dummy_call (struct gdbarch *gdbarch, gdb_byte word[PPC_MAX_REGISTER_SIZE]; memset (word, 0, reg_size); memcpy (word, - ((char *) value_contents (arg)) + argbytes, + ((char *) value_contents (arg).data ()) + argbytes, (len - argbytes) > reg_size ? reg_size : len - argbytes); regcache->cooked_write (tdep->ppc_gp0_regnum + 3 + ii, word); @@ -143,7 +144,7 @@ rs6000_lynx178_push_dummy_call (struct gdbarch *gdbarch, gdb_byte word[PPC_MAX_REGISTER_SIZE]; memset (word, 0, reg_size); - memcpy (word, value_contents (arg), len); + memcpy (word, value_contents (arg).data (), len); regcache->cooked_write (tdep->ppc_gp0_regnum + 3 +ii, word); } ++argno; @@ -205,7 +206,7 @@ ran_out_of_registers_for_arguments: if (argbytes) { write_memory (sp + 24 + (ii * 4), - value_contents (arg) + argbytes, + value_contents (arg).data () + argbytes, len - argbytes); ++argno; ii += align_up (len - argbytes, 4) / 4; @@ -228,11 +229,11 @@ ran_out_of_registers_for_arguments: gdb_assert (len <= 8); regcache->cooked_write (tdep->ppc_fp0_regnum + 1 + f_argno, - value_contents (arg)); + value_contents (arg).data ()); ++f_argno; } - write_memory (sp + 24 + (ii * 4), value_contents (arg), len); + write_memory (sp + 24 + (ii * 4), value_contents (arg).data (), len); ii += align_up (len, 4) / 4; } } diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index 3c6a358..1da758f 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -415,8 +415,9 @@ rust_language::print_enum (struct value *val, struct ui_file *stream, opts.deref_ref = 0; gdb_assert (rust_enum_p (type)); - gdb::array_view<const gdb_byte> view (value_contents_for_printing (val), - TYPE_LENGTH (value_type (val))); + gdb::array_view<const gdb_byte> view + (value_contents_for_printing (val).data (), + TYPE_LENGTH (value_type (val))); type = resolve_dynamic_type (type, view, value_address (val)); if (rust_empty_enum_p (type)) @@ -558,7 +559,7 @@ rust_language::value_print_inner encoding. */ fputs_filtered ("b", stream); printstr (stream, TYPE_TARGET_TYPE (type), - value_contents_for_printing (val), + value_contents_for_printing (val).data (), high_bound - low_bound + 1, "ASCII", 0, &opts); } break; @@ -1316,7 +1317,7 @@ eval_op_rust_struct_anon (struct type *expect_type, struct expression *exp, if (rust_enum_p (type)) { - gdb::array_view<const gdb_byte> view (value_contents (lhs), + gdb::array_view<const gdb_byte> view (value_contents (lhs).data (), TYPE_LENGTH (type)); type = resolve_dynamic_type (type, view, value_address (lhs)); @@ -1379,7 +1380,7 @@ eval_op_rust_structop (struct type *expect_type, struct expression *exp, struct type *type = value_type (lhs); if (type->code () == TYPE_CODE_STRUCT && rust_enum_p (type)) { - gdb::array_view<const gdb_byte> view (value_contents (lhs), + gdb::array_view<const gdb_byte> view (value_contents (lhs).data (), TYPE_LENGTH (type)); type = resolve_dynamic_type (type, view, value_address (lhs)); diff --git a/gdb/rx-tdep.c b/gdb/rx-tdep.c index 6715e73..2d20aed 100644 --- a/gdb/rx-tdep.c +++ b/gdb/rx-tdep.c @@ -518,9 +518,9 @@ rx_frame_prev_register (struct frame_info *this_frame, void **this_cache, psw_val = rx_frame_prev_register (this_frame, this_cache, RX_PSW_REGNUM); - psw = extract_unsigned_integer (value_contents_all (psw_val), 4, - gdbarch_byte_order ( - get_frame_arch (this_frame))); + psw = extract_unsigned_integer + (value_contents_all (psw_val).data (), 4, + gdbarch_byte_order (get_frame_arch (this_frame))); if ((psw & 0x20000 /* U bit */) != 0) return rx_frame_prev_register (this_frame, this_cache, @@ -724,7 +724,7 @@ rx_push_dummy_call (struct gdbarch *gdbarch, struct value *function, for (i = 0; i < nargs; i++) { struct value *arg = args[i]; - const gdb_byte *arg_bits = value_contents_all (arg); + 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); diff --git a/gdb/s390-tdep.c b/gdb/s390-tdep.c index d3bb2ba..0a4a574 100644 --- a/gdb/s390-tdep.c +++ b/gdb/s390-tdep.c @@ -1764,7 +1764,7 @@ s390_handle_arg (struct s390_arg_state *as, struct value *arg, it occupies the leftmost bits. */ if (write_mode) as->regcache->cooked_write_part (S390_F0_REGNUM + as->fr, 0, length, - value_contents (arg)); + value_contents (arg).data ()); as->fr += 2; } else @@ -1773,7 +1773,7 @@ s390_handle_arg (struct s390_arg_state *as, struct value *arg, it occupies the rightmost bits. */ as->argp = align_up (as->argp + length, word_size); if (write_mode) - write_memory (as->argp - length, value_contents (arg), + write_memory (as->argp - length, value_contents (arg).data (), length); } } @@ -1788,13 +1788,13 @@ s390_handle_arg (struct s390_arg_state *as, struct value *arg, if (write_mode) as->regcache->cooked_write_part (regnum, 0, length, - value_contents (arg)); + value_contents (arg).data ()); as->vr++; } else { if (write_mode) - write_memory (as->argp, value_contents (arg), length); + write_memory (as->argp, value_contents (arg).data (), length); as->argp = align_up (as->argp + length, word_size); } } @@ -1809,9 +1809,9 @@ s390_handle_arg (struct s390_arg_state *as, struct value *arg, memory word and sign- or zero-extend to full word size. This also applies to a struct or union. */ val = type->is_unsigned () - ? extract_unsigned_integer (value_contents (arg), + ? extract_unsigned_integer (value_contents (arg).data (), length, byte_order) - : extract_signed_integer (value_contents (arg), + : extract_signed_integer (value_contents (arg).data (), length, byte_order); } @@ -1838,9 +1838,10 @@ s390_handle_arg (struct s390_arg_state *as, struct value *arg, if (write_mode) { as->regcache->cooked_write (S390_R0_REGNUM + as->gr, - value_contents (arg)); - as->regcache->cooked_write (S390_R0_REGNUM + as->gr + 1, - value_contents (arg) + word_size); + value_contents (arg).data ()); + as->regcache->cooked_write + (S390_R0_REGNUM + as->gr + 1, + value_contents (arg).data () + word_size); } as->gr += 2; } @@ -1851,7 +1852,7 @@ s390_handle_arg (struct s390_arg_state *as, struct value *arg, as->gr = 7; if (write_mode) - write_memory (as->argp, value_contents (arg), length); + write_memory (as->argp, value_contents (arg).data (), length); as->argp += length; } } @@ -1862,7 +1863,7 @@ s390_handle_arg (struct s390_arg_state *as, struct value *arg, alignment as a conservative assumption. */ as->copy = align_down (as->copy - length, 8); if (write_mode) - write_memory (as->copy, value_contents (arg), length); + write_memory (as->copy, value_contents (arg).data (), length); if (as->gr <= 6) { diff --git a/gdb/score-tdep.c b/gdb/score-tdep.c index 91d79f4..12c9287 100644 --- a/gdb/score-tdep.c +++ b/gdb/score-tdep.c @@ -530,7 +530,7 @@ score_push_dummy_call (struct gdbarch *gdbarch, struct value *function, struct value *arg = args[argnum]; struct type *arg_type = check_typedef (value_type (arg)); enum type_code typecode = arg_type->code (); - const gdb_byte *val = value_contents (arg); + const gdb_byte *val = value_contents (arg).data (); int downward_offset = 0; int arg_last_part_p = 0; diff --git a/gdb/sh-tdep.c b/gdb/sh-tdep.c index bfb220a..04431df 100644 --- a/gdb/sh-tdep.c +++ b/gdb/sh-tdep.c @@ -923,12 +923,12 @@ sh_justify_value_in_reg (struct gdbarch *gdbarch, struct value *val, int len) { /* value gets right-justified in the register or stack word. */ if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG) - memcpy (valbuf + (4 - len), value_contents (val), len); + memcpy (valbuf + (4 - len), value_contents (val).data (), len); else - memcpy (valbuf, value_contents (val), len); + memcpy (valbuf, value_contents (val).data (), len); return valbuf; } - return value_contents (val); + return value_contents (val).data (); } /* Helper function to eval number of bytes to allocate on stack. */ diff --git a/gdb/sparc-tdep.c b/gdb/sparc-tdep.c index 1b42068..7302929 100644 --- a/gdb/sparc-tdep.c +++ b/gdb/sparc-tdep.c @@ -642,7 +642,7 @@ sparc32_store_arguments (struct regcache *regcache, int nargs, correct, and wasting a few bytes shouldn't be a problem. */ sp &= ~0x7; - write_memory (sp, value_contents (args[i]), len); + write_memory (sp, value_contents (args[i]).data (), len); args[i] = value_from_pointer (lookup_pointer_type (type), sp); num_elements++; } @@ -673,7 +673,7 @@ sparc32_store_arguments (struct regcache *regcache, int nargs, for (i = 0; i < nargs; i++) { - const bfd_byte *valbuf = value_contents (args[i]); + const bfd_byte *valbuf = value_contents (args[i]).data (); struct type *type = value_type (args[i]); int len = TYPE_LENGTH (type); gdb_byte buf[4]; diff --git a/gdb/sparc64-tdep.c b/gdb/sparc64-tdep.c index 3464411..4a1b864 100644 --- a/gdb/sparc64-tdep.c +++ b/gdb/sparc64-tdep.c @@ -1418,7 +1418,7 @@ sparc64_store_arguments (struct regcache *regcache, int nargs, a problem. */ sp &= ~0xf; - write_memory (sp, value_contents (args[i]), len); + write_memory (sp, value_contents (args[i]).data (), len); args[i] = value_from_pointer (lookup_pointer_type (type), sp); num_elements++; } @@ -1487,7 +1487,7 @@ sparc64_store_arguments (struct regcache *regcache, int nargs, for (i = 0; i < nargs; i++) { - const gdb_byte *valbuf = value_contents (args[i]); + const gdb_byte *valbuf = value_contents (args[i]).data (); struct type *type = value_type (args[i]); int len = TYPE_LENGTH (type); int regnum = -1; diff --git a/gdb/stack.c b/gdb/stack.c index bedadb0..66517cf 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -1716,8 +1716,8 @@ info_frame_command_core (struct frame_info *fi, bool selected_frame_p) enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); int sp_size = register_size (gdbarch, sp_regnum); - sp = extract_unsigned_integer (value_contents_all (value), - sp_size, byte_order); + sp = extract_unsigned_integer + (value_contents_all (value).data (), sp_size, byte_order); printf_filtered (" Previous frame's sp is "); fputs_filtered (paddress (gdbarch, sp), gdb_stdout); @@ -2842,7 +2842,7 @@ return_command (const char *retval_exp, int from_tty) && rv_conv != RETURN_VALUE_ABI_RETURNS_ADDRESS); gdbarch_return_value (cache_arch, function, return_type, get_current_regcache (), NULL /*read*/, - value_contents (return_value) /*write*/); + value_contents (return_value).data () /*write*/); } /* If we are at the end of a call dummy now, pop the dummy frame diff --git a/gdb/std-regs.c b/gdb/std-regs.c index 9d1cd13..5cf01c3 100644 --- a/gdb/std-regs.c +++ b/gdb/std-regs.c @@ -44,7 +44,7 @@ value_of_builtin_frame_fp_reg (struct frame_info *frame, const void *baton) { struct type *data_ptr_type = builtin_type (gdbarch)->builtin_data_ptr; struct value *val = allocate_value (data_ptr_type); - gdb_byte *buf = value_contents_raw (val); + gdb_byte *buf = value_contents_raw (val).data (); gdbarch_address_to_pointer (gdbarch, data_ptr_type, buf, get_frame_base_address (frame)); @@ -63,7 +63,7 @@ value_of_builtin_frame_pc_reg (struct frame_info *frame, const void *baton) { struct type *func_ptr_type = builtin_type (gdbarch)->builtin_func_ptr; struct value *val = allocate_value (func_ptr_type); - gdb_byte *buf = value_contents_raw (val); + gdb_byte *buf = value_contents_raw (val).data (); gdbarch_address_to_pointer (gdbarch, func_ptr_type, buf, get_frame_pc (frame)); diff --git a/gdb/tic6x-tdep.c b/gdb/tic6x-tdep.c index fb18b79..afa034c 100644 --- a/gdb/tic6x-tdep.c +++ b/gdb/tic6x-tdep.c @@ -919,7 +919,7 @@ tic6x_push_dummy_call (struct gdbarch *gdbarch, struct value *function, int len = TYPE_LENGTH (arg_type); enum type_code typecode = arg_type->code (); - val = value_contents (arg); + val = value_contents (arg).data (); /* Copy the argument to general registers or the stack in register-sized pieces. */ diff --git a/gdb/tilegx-tdep.c b/gdb/tilegx-tdep.c index 9451ff5..5a00537 100644 --- a/gdb/tilegx-tdep.c +++ b/gdb/tilegx-tdep.c @@ -308,7 +308,7 @@ tilegx_push_dummy_call (struct gdbarch *gdbarch, break; /* Put argument into registers wordwise. */ - val = value_contents (args[i]); + val = value_contents (args[i]).data (); for (j = 0; j < typelen; j += tilegx_reg_size) { /* ISSUE: Why special handling for "typelen = 4x + 1"? @@ -327,7 +327,7 @@ tilegx_push_dummy_call (struct gdbarch *gdbarch, the stack, word aligned. */ for (j = nargs - 1; j >= i; j--) { - const gdb_byte *contents = value_contents (args[j]); + const gdb_byte *contents = value_contents (args[j]).data (); typelen = TYPE_LENGTH (value_enclosing_type (args[j])); slacklen = align_up (typelen, 8) - typelen; diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index df5013e4..042fcc7 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -3820,7 +3820,7 @@ sdata_make_value (struct gdbarch *gdbarch, struct internalvar *var, type = init_vector_type (builtin_type (gdbarch)->builtin_true_char, buf->size ()); v = allocate_value (type); - memcpy (value_contents_raw (v), buf->data (), buf->size ()); + memcpy (value_contents_raw (v).data (), buf->data (), buf->size ()); return v; } else diff --git a/gdb/v850-tdep.c b/gdb/v850-tdep.c index 8f25198..f829f4d 100644 --- a/gdb/v850-tdep.c +++ b/gdb/v850-tdep.c @@ -1065,7 +1065,7 @@ v850_push_dummy_call (struct gdbarch *gdbarch, else { len = TYPE_LENGTH (value_type (*args)); - val = (gdb_byte *) value_contents (*args); + val = (gdb_byte *) value_contents (*args).data (); } if (gdbarch_tdep (gdbarch)->eight_byte_align diff --git a/gdb/valarith.c b/gdb/valarith.c index 07472ef..140ef44 100644 --- a/gdb/valarith.c +++ b/gdb/valarith.c @@ -716,7 +716,7 @@ value_concat (struct value *arg1, struct value *arg2) char_type = type2; inchar = (char) unpack_long (type2, - value_contents (inval2)); + value_contents (inval2).data ()); for (idx = 0; idx < count; idx++) { ptr[idx] = inchar; @@ -727,10 +727,8 @@ value_concat (struct value *arg1, struct value *arg2) char_type = TYPE_TARGET_TYPE (type2); for (idx = 0; idx < count; idx++) - { - memcpy (&ptr[idx * inval2len], value_contents (inval2), - inval2len); - } + memcpy (&ptr[idx * inval2len], value_contents (inval2).data (), + inval2len); } outval = value_string (ptr.data (), count * inval2len, char_type); } @@ -759,22 +757,22 @@ value_concat (struct value *arg1, struct value *arg2) { char_type = type1; - ptr[0] = (char) unpack_long (type1, value_contents (inval1)); + ptr[0] = (char) unpack_long (type1, value_contents (inval1).data ()); } else { char_type = TYPE_TARGET_TYPE (type1); - memcpy (ptr.data (), value_contents (inval1), inval1len); + memcpy (ptr.data (), value_contents (inval1).data (), inval1len); } if (type2->code () == TYPE_CODE_CHAR) { ptr[inval1len] = - (char) unpack_long (type2, value_contents (inval2)); + (char) unpack_long (type2, value_contents (inval2).data ()); } else { - memcpy (&ptr[inval1len], value_contents (inval2), inval2len); + memcpy (&ptr[inval1len], value_contents (inval2).data (), inval2len); } outval = value_string (ptr.data (), inval1len + inval2len, char_type); } @@ -855,7 +853,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), TYPE_LENGTH (type1)); + memcpy (x, value_contents (arg1).data (), TYPE_LENGTH (type1)); } else if (is_integral_type (type1)) { @@ -874,7 +872,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), TYPE_LENGTH (type2)); + memcpy (y, value_contents (arg2).data (), TYPE_LENGTH (type2)); } else if (is_integral_type (type2)) { @@ -929,11 +927,11 @@ fixed_point_binop (struct value *arg1, struct value *arg2, enum exp_opcode op) type2 = type1; } - v1.read_fixed_point (gdb::make_array_view (value_contents (arg1), + v1.read_fixed_point (gdb::make_array_view (value_contents (arg1).data (), TYPE_LENGTH (type1)), type_byte_order (type1), type1->is_unsigned (), type1->fixed_point_scaling_factor ()); - v2.read_fixed_point (gdb::make_array_view (value_contents (arg2), + v2.read_fixed_point (gdb::make_array_view (value_contents (arg2).data (), TYPE_LENGTH (type2)), type_byte_order (type2), type2->is_unsigned (), type2->fixed_point_scaling_factor ()); @@ -944,7 +942,7 @@ fixed_point_binop (struct value *arg1, struct value *arg2, enum exp_opcode op) value *fp_val = allocate_value (type1); fp.write_fixed_point - (gdb::make_array_view (value_contents_raw (fp_val), + (gdb::make_array_view (value_contents_raw (fp_val).data (), TYPE_LENGTH (type1)), type_byte_order (type1), type1->is_unsigned (), @@ -1204,7 +1202,7 @@ scalar_binop (struct value *arg1, struct value *arg2, enum exp_opcode op) v2.data (), &eff_type_v2); target_float_binop (op, v1.data (), eff_type_v1, v2.data (), eff_type_v2, - value_contents_raw (val), result_type); + value_contents_raw (val).data (), result_type); } else if (type1->code () == TYPE_CODE_BOOL || type2->code () == TYPE_CODE_BOOL) @@ -1243,7 +1241,7 @@ scalar_binop (struct value *arg1, struct value *arg2, enum exp_opcode op) result_type = type1; val = allocate_value (result_type); - store_signed_integer (value_contents_raw (val), + store_signed_integer (value_contents_raw (val).data (), TYPE_LENGTH (result_type), type_byte_order (result_type), v); @@ -1383,7 +1381,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), + store_unsigned_integer (value_contents_raw (val).data (), TYPE_LENGTH (value_type (val)), type_byte_order (result_type), v); @@ -1512,7 +1510,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), + store_signed_integer (value_contents_raw (val).data (), TYPE_LENGTH (value_type (val)), type_byte_order (result_type), v); @@ -1559,8 +1557,8 @@ value_vector_widen (struct value *scalar_value, struct type *vector_type) val = allocate_value (vector_type); for (i = 0; i < high_bound - low_bound + 1; i++) /* Duplicate the contents of elval into the destination vector. */ - memcpy (value_contents_writeable (val) + (i * TYPE_LENGTH (eltype)), - value_contents_all (elval), TYPE_LENGTH (eltype)); + memcpy (value_contents_writeable (val).data () + (i * TYPE_LENGTH (eltype)), + value_contents_all (elval).data (), TYPE_LENGTH (eltype)); return val; } @@ -1607,8 +1605,8 @@ vector_binop (struct value *val1, struct value *val2, enum exp_opcode op) { tmp = value_binop (value_subscript (val1, i), value_subscript (val2, i), op); - memcpy (value_contents_writeable (val) + i * elsize, - value_contents_all (tmp), + memcpy (value_contents_writeable (val).data () + i * elsize, + value_contents_all (tmp).data (), elsize); } value_free_to_mark (mark); @@ -1666,10 +1664,10 @@ value_logical_not (struct value *arg1) type1 = check_typedef (value_type (arg1)); if (is_floating_value (arg1)) - return target_float_is_zero (value_contents (arg1), type1); + return target_float_is_zero (value_contents (arg1).data (), type1); len = TYPE_LENGTH (type1); - p = value_contents (arg1); + p = value_contents (arg1).data (); while (--len >= 0) { @@ -1688,8 +1686,8 @@ value_strcmp (struct value *arg1, struct value *arg2) { int len1 = TYPE_LENGTH (value_type (arg1)); int len2 = TYPE_LENGTH (value_type (arg2)); - const gdb_byte *s1 = value_contents (arg1); - const gdb_byte *s2 = value_contents (arg2); + const gdb_byte *s1 = value_contents (arg1).data (); + const gdb_byte *s2 = value_contents (arg2).data (); int i, len = len1 < len2 ? len1 : len2; for (i = 0; i < len; i++) @@ -1764,8 +1762,8 @@ value_equal (struct value *arg1, struct value *arg2) && ((len = (int) TYPE_LENGTH (type1)) == (int) TYPE_LENGTH (type2))) { - p1 = value_contents (arg1); - p2 = value_contents (arg2); + p1 = value_contents (arg1).data (); + p2 = value_contents (arg2).data (); while (--len >= 0) { if (*p1++ != *p2++) @@ -1795,7 +1793,8 @@ value_equal_contents (struct value *arg1, struct value *arg2) return (type1->code () == type2->code () && TYPE_LENGTH (type1) == TYPE_LENGTH (type2) - && memcmp (value_contents (arg1), value_contents (arg2), + && memcmp (value_contents (arg1).data (), + value_contents (arg2).data (), TYPE_LENGTH (type1)) == 0); } @@ -1870,7 +1869,7 @@ value_pos (struct value *arg1) if (is_integral_type (type) || is_floating_value (arg1) || (type->code () == TYPE_CODE_ARRAY && type->is_vector ()) || type->code () == TYPE_CODE_COMPLEX) - return value_from_contents (type, value_contents (arg1)); + return value_from_contents (type, value_contents (arg1).data ()); else error (_("Argument to positive operation not a number.")); } @@ -1900,8 +1899,9 @@ value_neg (struct value *arg1) for (i = 0; i < high_bound - low_bound + 1; i++) { tmp = value_neg (value_subscript (arg1, i)); - memcpy (value_contents_writeable (val) + i * TYPE_LENGTH (eltype), - value_contents_all (tmp), TYPE_LENGTH (eltype)); + memcpy ((value_contents_writeable (val).data () + + i * TYPE_LENGTH (eltype)), + value_contents_all (tmp).data (), TYPE_LENGTH (eltype)); } return val; } @@ -1943,8 +1943,9 @@ value_complement (struct value *arg1) for (i = 0; i < high_bound - low_bound + 1; i++) { tmp = value_complement (value_subscript (arg1, i)); - memcpy (value_contents_writeable (val) + i * TYPE_LENGTH (eltype), - value_contents_all (tmp), TYPE_LENGTH (eltype)); + memcpy ((value_contents_writeable (val).data () + + i * TYPE_LENGTH (eltype)), + value_contents_all (tmp).data (), TYPE_LENGTH (eltype)); } } else if (type->code () == TYPE_CODE_COMPLEX) @@ -2005,7 +2006,7 @@ value_in (struct value *element, struct value *set) && eltype->code () != TYPE_CODE_ENUM && eltype->code () != TYPE_CODE_BOOL) error (_("First argument of 'IN' has wrong type")); - member = value_bit_index (settype, value_contents (set), + member = value_bit_index (settype, value_contents (set).data (), value_as_long (element)); if (member < 0) error (_("First argument of 'IN' not in range")); diff --git a/gdb/valops.c b/gdb/valops.c index f65479b..4847f93 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -341,7 +341,7 @@ value_to_gdb_mpq (struct value *value) gdb_mpq result; if (is_floating_type (type)) { - double d = target_float_to_host_double (value_contents (value), + double d = target_float_to_host_double (value_contents (value).data (), type); mpq_set_d (result.val, d); } @@ -351,7 +351,7 @@ value_to_gdb_mpq (struct value *value) || is_fixed_point_type (type)); gdb_mpz vz; - vz.read (gdb::make_array_view (value_contents (value), + vz.read (gdb::make_array_view (value_contents (value).data (), TYPE_LENGTH (type)), type_byte_order (type), type->is_unsigned ()); mpq_set_z (result.val, vz.val); @@ -392,7 +392,7 @@ value_cast_to_fixed_point (struct type *to_type, struct value *from_val) /* Finally, create the result value, and pack the unscaled value in it. */ struct value *result = allocate_value (to_type); - unscaled.write (gdb::make_array_view (value_contents_raw (result), + unscaled.write (gdb::make_array_view (value_contents_raw (result).data (), TYPE_LENGTH (to_type)), type_byte_order (to_type), to_type->is_unsigned ()); @@ -546,8 +546,8 @@ value_cast (struct type *type, struct value *arg2) if (is_floating_value (arg2)) { struct value *v = allocate_value (to_type); - target_float_convert (value_contents (arg2), type2, - value_contents_raw (v), type); + target_float_convert (value_contents (arg2).data (), type2, + value_contents_raw (v).data (), type); return v; } else if (is_fixed_point_type (type2)) @@ -555,12 +555,13 @@ value_cast (struct type *type, struct value *arg2) gdb_mpq fp_val; fp_val.read_fixed_point - (gdb::make_array_view (value_contents (arg2), TYPE_LENGTH (type2)), + (gdb::make_array_view (value_contents (arg2).data (), + TYPE_LENGTH (type2)), type_byte_order (type2), type2->is_unsigned (), type2->fixed_point_scaling_factor ()); struct value *v = allocate_value (to_type); - target_float_from_host_double (value_contents_raw (v), + target_float_from_host_double (value_contents_raw (v).data (), to_type, mpq_get_d (fp_val.val)); return v; } @@ -586,7 +587,7 @@ value_cast (struct type *type, struct value *arg2) bits. */ if (code2 == TYPE_CODE_PTR) longest = extract_unsigned_integer - (value_contents (arg2), TYPE_LENGTH (type2), + (value_contents (arg2).data (), TYPE_LENGTH (type2), type_byte_order (type2)); else longest = value_as_long (arg2); @@ -623,7 +624,8 @@ value_cast (struct type *type, struct value *arg2) { struct value *result = allocate_value (to_type); - cplus_make_method_ptr (to_type, value_contents_writeable (result), 0, 0); + cplus_make_method_ptr (to_type, + value_contents_writeable (result).data (), 0, 0); return result; } else if (code1 == TYPE_CODE_MEMBERPTR && code2 == TYPE_CODE_INT @@ -904,7 +906,7 @@ value_dynamic_cast (struct type *type, struct value *arg) return tem; result = NULL; if (dynamic_cast_check_1 (TYPE_TARGET_TYPE (resolved_type), - value_contents_for_printing (tem), + value_contents_for_printing (tem).data (), value_embedded_offset (tem), value_address (tem), tem, rtti_type, addr, @@ -920,7 +922,7 @@ value_dynamic_cast (struct type *type, struct value *arg) result = NULL; if (is_public_ancestor (arg_type, rtti_type) && dynamic_cast_check_2 (TYPE_TARGET_TYPE (resolved_type), - value_contents_for_printing (tem), + value_contents_for_printing (tem).data (), value_embedded_offset (tem), value_address (tem), tem, rtti_type, &result) == 1) @@ -961,8 +963,9 @@ value_one (struct type *type) for (i = 0; i < high_bound - low_bound + 1; i++) { tmp = value_one (eltype); - memcpy (value_contents_writeable (val) + i * TYPE_LENGTH (eltype), - value_contents_all (tmp), TYPE_LENGTH (eltype)); + memcpy ((value_contents_writeable (val).data () + + i * TYPE_LENGTH (eltype)), + value_contents_all (tmp).data (), TYPE_LENGTH (eltype)); } } else @@ -1173,7 +1176,7 @@ value_assign (struct value *toval, struct value *fromval) { changed_addr = value_address (toval); changed_len = type_length_units (type); - dest_buffer = value_contents (fromval); + dest_buffer = value_contents (fromval).data (); } write_memory_with_notification (changed_addr, dest_buffer, changed_len); @@ -1249,12 +1252,12 @@ value_assign (struct value *toval, struct value *fromval) format. */ gdbarch_value_to_register (gdbarch, frame, VALUE_REGNUM (toval), type, - value_contents (fromval)); + value_contents (fromval).data ()); } else { gdb::array_view<const gdb_byte> contents - = gdb::make_array_view (value_contents (fromval), + = gdb::make_array_view (value_contents (fromval).data (), TYPE_LENGTH (type)); put_frame_register_bytes (frame, value_reg, value_offset (toval), @@ -1339,7 +1342,7 @@ value_assign (struct value *toval, struct value *fromval) implies the returned value is not lazy, even if TOVAL was. */ val = value_copy (toval); set_value_lazy (val, 0); - memcpy (value_contents_raw (val), value_contents (fromval), + memcpy (value_contents_raw (val).data (), value_contents (fromval).data (), TYPE_LENGTH (type)); /* We copy over the enclosing type and pointed-to offset from FROMVAL @@ -1373,7 +1376,7 @@ value_repeat (struct value *arg1, int count) set_value_address (val, value_address (arg1)); read_value_memory (val, 0, value_stack (val), value_address (val), - value_contents_all_raw (val), + value_contents_all_raw (val).data (), type_length_units (value_enclosing_type (val))); return val; @@ -1481,7 +1484,7 @@ value_coerce_to_target (struct value *val) length = TYPE_LENGTH (check_typedef (value_type (val))); addr = allocate_space_in_inferior (length); - write_memory (addr, value_contents (val), length); + write_memory (addr, value_contents (val).data (), length); return value_at_lazy (value_type (val), addr); } @@ -1747,7 +1750,7 @@ value_cstring (const char *ptr, ssize_t len, struct type *char_type) = lookup_array_range_type (char_type, lowbound, highbound + lowbound - 1); val = allocate_value (stringtype); - memcpy (value_contents_raw (val), ptr, len); + memcpy (value_contents_raw (val).data (), ptr, len); return val; } @@ -1770,7 +1773,7 @@ value_string (const char *ptr, ssize_t len, struct type *char_type) = lookup_string_range_type (char_type, lowbound, highbound + lowbound - 1); val = allocate_value (stringtype); - memcpy (value_contents_raw (val), ptr, len); + memcpy (value_contents_raw (val).data (), ptr, len); return val; } @@ -2054,7 +2057,7 @@ struct_field_searcher::search (struct value *arg1, LONGEST offset, struct value *v2; boffset = baseclass_offset (type, i, - value_contents_for_printing (arg1), + value_contents_for_printing (arg1).data (), value_embedded_offset (arg1) + offset, value_address (arg1), arg1); @@ -2072,7 +2075,7 @@ struct_field_searcher::search (struct value *arg1, LONGEST offset, base_addr = value_address (arg1) + boffset; v2 = value_at_lazy (basetype, base_addr); if (target_read_memory (base_addr, - value_contents_raw (v2), + value_contents_raw (v2).data (), TYPE_LENGTH (value_type (v2))) != 0) error (_("virtual baseclass botch")); } @@ -2258,13 +2261,13 @@ search_struct_method (const char *name, struct value **arg1p, base_val = value_from_contents_and_address (baseclass, tmp.data (), address + offset); - base_valaddr = value_contents_for_printing (base_val); + base_valaddr = value_contents_for_printing (base_val).data (); this_offset = 0; } else { base_val = *arg1p; - base_valaddr = value_contents_for_printing (*arg1p); + base_valaddr = value_contents_for_printing (*arg1p).data (); this_offset = offset; } @@ -2520,7 +2523,7 @@ find_method_list (struct value **argp, const char *method, if (BASETYPE_VIA_VIRTUAL (type, i)) { base_offset = baseclass_offset (type, i, - value_contents_for_printing (*argp), + value_contents_for_printing (*argp).data (), value_offset (*argp) + offset, value_address (*argp), *argp); } @@ -3448,7 +3451,7 @@ get_baseclass_offset (struct type *vt, struct type *cls, { if (BASETYPE_VIA_VIRTUAL (vt, i)) { - const gdb_byte *adr = value_contents_for_printing (v); + const gdb_byte *adr = value_contents_for_printing (v).data (); *boffs = baseclass_offset (vt, i, adr, value_offset (v), value_as_long (v), v); *isvirt = true; @@ -3462,7 +3465,7 @@ get_baseclass_offset (struct type *vt, struct type *cls, { if (*isvirt == false) /* Add non-virtual base offset. */ { - const gdb_byte *adr = value_contents_for_printing (v); + const gdb_byte *adr = value_contents_for_printing (v).data (); *boffs += baseclass_offset (vt, i, adr, value_offset (v), value_as_long (v), v); } @@ -3659,7 +3662,7 @@ value_struct_elt_for_reference (struct type *domain, int offset, result = allocate_value (lookup_methodptr_type (TYPE_FN_FIELD_TYPE (f, j))); cplus_make_method_ptr (value_type (result), - value_contents_writeable (result), + value_contents_writeable (result).data (), TYPE_FN_FIELD_VOFFSET (f, j), 1); } else if (noside == EVAL_AVOID_SIDE_EFFECTS) @@ -3684,7 +3687,7 @@ value_struct_elt_for_reference (struct type *domain, int offset, { result = allocate_value (lookup_methodptr_type (TYPE_FN_FIELD_TYPE (f, j))); cplus_make_method_ptr (value_type (result), - value_contents_writeable (result), + value_contents_writeable (result).data (), value_address (v), 0); } } @@ -4027,10 +4030,10 @@ value_literal_complex (struct value *arg1, arg1 = value_cast (real_type, arg1); arg2 = value_cast (real_type, arg2); - memcpy (value_contents_raw (val), - value_contents (arg1), TYPE_LENGTH (real_type)); - memcpy (value_contents_raw (val) + TYPE_LENGTH (real_type), - value_contents (arg2), TYPE_LENGTH (real_type)); + memcpy (value_contents_raw (val).data (), + value_contents (arg1).data (), TYPE_LENGTH (real_type)); + memcpy (value_contents_raw (val).data () + TYPE_LENGTH (real_type), + value_contents (arg2).data (), TYPE_LENGTH (real_type)); return val; } @@ -4072,10 +4075,10 @@ cast_into_complex (struct type *type, struct value *val) struct value *re_val = allocate_value (val_real_type); struct value *im_val = allocate_value (val_real_type); - memcpy (value_contents_raw (re_val), - value_contents (val), TYPE_LENGTH (val_real_type)); - memcpy (value_contents_raw (im_val), - value_contents (val) + TYPE_LENGTH (val_real_type), + memcpy (value_contents_raw (re_val).data (), + value_contents (val).data (), TYPE_LENGTH (val_real_type)); + memcpy (value_contents_raw (im_val).data (), + value_contents (val).data () + TYPE_LENGTH (val_real_type), TYPE_LENGTH (val_real_type)); return value_literal_complex (re_val, im_val, type); diff --git a/gdb/valprint.c b/gdb/valprint.c index 485b5b9..6eb3db2 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -484,7 +484,7 @@ generic_value_print_ptr (struct value *val, struct ui_file *stream, { struct type *type = check_typedef (value_type (val)); struct type *elttype = check_typedef (TYPE_TARGET_TYPE (type)); - const gdb_byte *valaddr = value_contents_for_printing (val); + const gdb_byte *valaddr = value_contents_for_printing (val).data (); CORE_ADDR addr = unpack_pointer (type, valaddr); print_unpacked_pointer (type, elttype, addr, stream, options); @@ -520,7 +520,7 @@ get_value_addr_contents (struct value *deref_val) gdb_assert (deref_val != NULL); if (value_lval_const (deref_val) == lval_memory) - return value_contents_for_printing_const (value_addr (deref_val)); + return value_contents_for_printing_const (value_addr (deref_val)).data (); else { /* We have a non-addressable value, such as a DW_AT_const_value. */ @@ -545,7 +545,7 @@ generic_val_print_ref (struct type *type, const int must_coerce_ref = ((options->addressprint && value_is_synthetic) || options->deref_ref); const int type_is_defined = elttype->code () != TYPE_CODE_UNDEF; - const gdb_byte *valaddr = value_contents_for_printing (original_value); + const gdb_byte *valaddr = value_contents_for_printing (original_value).data (); if (must_coerce_ref && type_is_defined) { @@ -693,7 +693,7 @@ generic_val_print_enum (struct type *type, gdb_assert (!options->format); - const gdb_byte *valaddr = value_contents_for_printing (original_value); + const gdb_byte *valaddr = value_contents_for_printing (original_value).data (); val = unpack_long (type, valaddr + embedded_offset * unit_size); @@ -740,7 +740,7 @@ generic_value_print_bool } else { - const gdb_byte *valaddr = value_contents_for_printing (value); + const gdb_byte *valaddr = value_contents_for_printing (value).data (); struct type *type = check_typedef (value_type (value)); LONGEST val = unpack_long (type, valaddr); if (val == 0) @@ -783,7 +783,7 @@ generic_value_print_char (struct value *value, struct ui_file *stream, { struct type *unresolved_type = value_type (value); struct type *type = check_typedef (unresolved_type); - const gdb_byte *valaddr = value_contents_for_printing (value); + const gdb_byte *valaddr = value_contents_for_printing (value).data (); LONGEST val = unpack_long (type, valaddr); if (type->is_unsigned ()) @@ -804,7 +804,7 @@ generic_val_print_float (struct type *type, struct ui_file *stream, { gdb_assert (!options->format); - const gdb_byte *valaddr = value_contents_for_printing (original_value); + const gdb_byte *valaddr = value_contents_for_printing (original_value).data (); print_floating (valaddr, type, stream); } @@ -821,7 +821,7 @@ generic_val_print_fixed_point (struct value *val, struct ui_file *stream, { struct type *type = value_type (val); - const gdb_byte *valaddr = value_contents_for_printing (val); + 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)), @@ -867,7 +867,7 @@ generic_value_print_memberptr /* Member pointers are essentially specific to C++, and so if we encounter one, we should print it according to C++ rules. */ struct type *type = check_typedef (value_type (val)); - const gdb_byte *valaddr = value_contents_for_printing (val); + const gdb_byte *valaddr = value_contents_for_printing (val).data (); cp_print_class_member (valaddr, type, stream, "&"); } else @@ -977,7 +977,7 @@ generic_value_print (struct value *val, struct ui_file *stream, int recurse, break; case TYPE_CODE_METHODPTR: - cplus_print_method_ptr (value_contents_for_printing (val), type, + cplus_print_method_ptr (value_contents_for_printing (val).data (), type, stream); break; @@ -1193,7 +1193,7 @@ static void val_print_type_code_flags (struct type *type, struct value *original_value, int embedded_offset, struct ui_file *stream) { - const gdb_byte *valaddr = (value_contents_for_printing (original_value) + const gdb_byte *valaddr = (value_contents_for_printing (original_value).data () + embedded_offset); ULONGEST val = unpack_long (type, valaddr); int field, nfields = type->num_fields (); @@ -1267,7 +1267,7 @@ value_print_scalar_formatted (struct value *val, /* value_contents_for_printing fetches all VAL's contents. They are needed to check whether VAL is optimized-out or unavailable below. */ - const gdb_byte *valaddr = value_contents_for_printing (val); + const gdb_byte *valaddr = value_contents_for_printing (val).data (); /* A scalar object that does not have all bits available can't be printed, because all bits contribute to its representation. */ @@ -3155,7 +3155,7 @@ test_print_flags (gdbarch *arch) append_flags_type_field (flags_type, 5, 3, field_type, "C"); value *val = allocate_value (flags_type); - gdb_byte *contents = value_contents_writeable (val); + gdb_byte *contents = value_contents_writeable (val).data (); store_unsigned_integer (contents, 4, gdbarch_byte_order (arch), 0xaa); string_file out; diff --git a/gdb/value.c b/gdb/value.c index bb2adae..42ce804 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -1146,21 +1146,25 @@ set_value_parent (struct value *value, struct value *parent) value->parent = value_ref_ptr::new_reference (parent); } -gdb_byte * +gdb::array_view<gdb_byte> value_contents_raw (struct value *value) { struct gdbarch *arch = get_value_arch (value); int unit_size = gdbarch_addressable_memory_unit_size (arch); allocate_value_contents (value); - return value->contents.get () + value->embedded_offset * unit_size; + + ULONGEST length = TYPE_LENGTH (value_type (value)); + return {value->contents.get () + value->embedded_offset * unit_size, length}; } -gdb_byte * +gdb::array_view<gdb_byte> value_contents_all_raw (struct value *value) { allocate_value_contents (value); - return value->contents.get (); + + ULONGEST length = TYPE_LENGTH (value_type (value)); + return {value->contents.get (), length}; } struct type * @@ -1238,25 +1242,29 @@ require_available (const struct value *value) throw_error (NOT_AVAILABLE_ERROR, _("value is not available")); } -const gdb_byte * +gdb::array_view<const gdb_byte> value_contents_for_printing (struct value *value) { if (value->lazy) value_fetch_lazy (value); - return value->contents.get (); + + ULONGEST length = TYPE_LENGTH (value_type (value)); + return {value->contents.get (), length}; } -const gdb_byte * +gdb::array_view<const gdb_byte> value_contents_for_printing_const (const struct value *value) { gdb_assert (!value->lazy); - return value->contents.get (); + + ULONGEST length = TYPE_LENGTH (value_type (value)); + return {value->contents.get (), length}; } -const gdb_byte * +gdb::array_view<const gdb_byte> value_contents_all (struct value *value) { - const gdb_byte *result = value_contents_for_printing (value); + gdb::array_view<const gdb_byte> result = value_contents_for_printing (value); require_not_optimized_out (value); require_available (value); return result; @@ -1334,8 +1342,8 @@ value_contents_copy_raw (struct value *dst, LONGEST dst_offset, TARGET_CHAR_BIT * length)); /* Copy the data. */ - memcpy (value_contents_all_raw (dst) + dst_offset * unit_size, - value_contents_all_raw (src) + src_offset * unit_size, + memcpy (value_contents_all_raw (dst).data () + dst_offset * unit_size, + value_contents_all_raw (src).data () + src_offset * unit_size, length * unit_size); /* Copy the meta-data, adjusted. */ @@ -1392,16 +1400,16 @@ set_value_stack (struct value *value, int val) value->stack = val; } -const gdb_byte * +gdb::array_view<const gdb_byte> value_contents (struct value *value) { - const gdb_byte *result = value_contents_writeable (value); + gdb::array_view<const gdb_byte> result = value_contents_writeable (value); require_not_optimized_out (value); require_available (value); return result; } -gdb_byte * +gdb::array_view<gdb_byte> value_contents_writeable (struct value *value) { if (value->lazy) @@ -1713,7 +1721,8 @@ value_copy (struct value *arg) val->initialized = arg->initialized; if (!value_lazy (val)) { - memcpy (value_contents_all_raw (val), value_contents_all_raw (arg), + memcpy (value_contents_all_raw (val).data (), + value_contents_all_raw (arg).data (), TYPE_LENGTH (value_enclosing_type (arg))); } @@ -1761,7 +1770,8 @@ value_non_lval (struct value *arg) struct type *enc_type = value_enclosing_type (arg); struct value *val = allocate_value (enc_type); - memcpy (value_contents_all_raw (val), value_contents_all (arg), + memcpy (value_contents_all_raw (val).data (), + value_contents_all (arg).data (), TYPE_LENGTH (enc_type)); val->type = arg->type; set_value_embedded_offset (val, value_embedded_offset (arg)); @@ -1778,7 +1788,7 @@ value_force_lval (struct value *v, CORE_ADDR addr) { gdb_assert (VALUE_LVAL (v) == not_lval); - write_memory (addr, value_contents_raw (v), TYPE_LENGTH (value_type (v))); + write_memory (addr, value_contents_raw (v).data (), TYPE_LENGTH (value_type (v))); v->lval = lval_memory; v->location.address = addr; } @@ -2303,7 +2313,7 @@ set_internalvar_component (struct internalvar *var, switch (var->kind) { case INTERNALVAR_VALUE: - addr = value_contents_writeable (var->u.value); + addr = value_contents_writeable (var->u.value).data (); arch = get_value_arch (var->u.value); unit_size = gdbarch_addressable_memory_unit_size (arch); @@ -2311,7 +2321,7 @@ set_internalvar_component (struct internalvar *var, modify_field (value_type (var->u.value), addr + offset, value_as_long (newval), bitpos, bitsize); else - memcpy (addr + offset * unit_size, value_contents (newval), + memcpy (addr + offset * unit_size, value_contents (newval).data (), TYPE_LENGTH (value_type (newval))); break; @@ -2695,7 +2705,7 @@ value_as_long (struct value *val) in disassemble_command). It also dereferences references, which I suspect is the most logical thing to do. */ val = coerce_array (val); - return unpack_long (value_type (val), value_contents (val)); + return unpack_long (value_type (val), value_contents (val).data ()); } /* Extract a value as a C pointer. Does not deallocate the value. @@ -2798,9 +2808,9 @@ value_as_address (struct value *val) if (!value_type (val)->is_pointer_or_reference () && gdbarch_integer_to_address_p (gdbarch)) return gdbarch_integer_to_address (gdbarch, value_type (val), - value_contents (val)); + value_contents (val).data ()); - return unpack_long (value_type (val), value_contents (val)); + return unpack_long (value_type (val), value_contents (val).data ()); #endif } @@ -2924,7 +2934,7 @@ is_floating_value (struct value *val) if (is_floating_type (type)) { - if (!target_float_is_valid (value_contents (val), type)) + if (!target_float_is_valid (value_contents (val).data (), type)) error (_("Invalid floating value found in program.")); return true; } @@ -3066,7 +3076,7 @@ value_primitive_field (struct value *arg1, LONGEST offset, for references to ordinary fields of unavailable values. */ if (BASETYPE_VIA_VIRTUAL (arg_type, fieldno)) boffset = baseclass_offset (arg_type, fieldno, - value_contents (arg1), + value_contents (arg1).data (), value_embedded_offset (arg1), value_address (arg1), arg1); @@ -3325,7 +3335,7 @@ 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), + store_signed_integer (value_contents_raw (dest_val).data (), TYPE_LENGTH (field_type), byte_order, num); } @@ -3532,7 +3542,7 @@ value_from_longest (struct type *type, LONGEST num) { struct value *val = allocate_value (type); - pack_long (value_contents_raw (val), type, num); + pack_long (value_contents_raw (val).data (), type, num); return val; } @@ -3544,7 +3554,7 @@ value_from_ulongest (struct type *type, ULONGEST num) { struct value *val = allocate_value (type); - pack_unsigned_long (value_contents_raw (val), type, num); + pack_unsigned_long (value_contents_raw (val).data (), type, num); return val; } @@ -3558,7 +3568,7 @@ value_from_pointer (struct type *type, CORE_ADDR addr) { struct value *val = allocate_value (type); - store_typed_address (value_contents_raw (val), + store_typed_address (value_contents_raw (val).data (), check_typedef (type), addr); return val; } @@ -3572,7 +3582,7 @@ value_from_host_double (struct type *type, double d) { struct value *value = allocate_value (type); gdb_assert (type->code () == TYPE_CODE_FLT); - target_float_from_host_double (value_contents_raw (value), + target_float_from_host_double (value_contents_raw (value).data (), value_type (value), d); return value; } @@ -3638,7 +3648,7 @@ value_from_contents (struct type *type, const gdb_byte *contents) struct value *result; result = allocate_value (type); - memcpy (value_contents_raw (result), contents, TYPE_LENGTH (type)); + memcpy (value_contents_raw (result).data (), contents, TYPE_LENGTH (type)); return result; } @@ -3790,7 +3800,7 @@ coerce_ref (struct value *arg) enc_type = check_typedef (value_enclosing_type (arg)); enc_type = TYPE_TARGET_TYPE (enc_type); - CORE_ADDR addr = unpack_pointer (value_type (arg), value_contents (arg)); + CORE_ADDR addr = unpack_pointer (value_type (arg), value_contents (arg).data ()); retval = value_at_lazy (enc_type, addr); enc_type = value_type (retval); return readjust_indirect_value_type (retval, enc_type, value_type_arg_tmp, @@ -3887,7 +3897,7 @@ value_fetch_lazy_bitfield (struct value *val) value_fetch_lazy (parent); unpack_value_bitfield (val, value_bitpos (val), value_bitsize (val), - value_contents_for_printing (parent), + value_contents_for_printing (parent).data (), value_offset (val), parent); } @@ -3903,7 +3913,7 @@ value_fetch_lazy_memory (struct value *val) if (TYPE_LENGTH (type)) read_value_memory (val, 0, value_stack (val), - addr, value_contents_all_raw (val), + addr, value_contents_all_raw (val).data (), type_length_units (type)); } @@ -3999,7 +4009,7 @@ value_fetch_lazy_register (struct value *val) else { int i; - const gdb_byte *buf = value_contents (new_val); + const gdb_byte *buf = value_contents (new_val).data (); if (VALUE_LVAL (new_val) == lval_register) fprintf_unfiltered (&debug_file, " register=%d", diff --git a/gdb/value.h b/gdb/value.h index 4501237..aa10564 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -360,7 +360,7 @@ extern void error_value_optimized_out (void); get to the real subobject, if the value happens to represent something embedded in a larger run-time object. */ -extern gdb_byte *value_contents_raw (struct value *); +extern gdb::array_view<gdb_byte> value_contents_raw (struct value *); /* Actual contents of the value. For use of this value; setting it uses the stuff above. Not valid if lazy is nonzero. Target @@ -368,24 +368,24 @@ extern gdb_byte *value_contents_raw (struct value *); value. Note that a value therefore extends beyond what is declared here. */ -extern const gdb_byte *value_contents (struct value *); -extern gdb_byte *value_contents_writeable (struct value *); +extern gdb::array_view<const gdb_byte> value_contents (struct value *); +extern gdb::array_view<gdb_byte> value_contents_writeable (struct value *); /* The ALL variants of the above two macros do not adjust the returned pointer by the embedded_offset value. */ -extern gdb_byte *value_contents_all_raw (struct value *); -extern const gdb_byte *value_contents_all (struct value *); +extern gdb::array_view<gdb_byte> value_contents_all_raw (struct value *); +extern gdb::array_view<const gdb_byte> value_contents_all (struct value *); /* Like value_contents_all, but does not require that the returned bits be valid. This should only be used in situations where you plan to check the validity manually. */ -extern const gdb_byte *value_contents_for_printing (struct value *value); +extern gdb::array_view<const gdb_byte> value_contents_for_printing (struct value *value); /* Like value_contents_for_printing, but accepts a constant value pointer. Unlike value_contents_for_printing however, the pointed value must _not_ be lazy. */ -extern const gdb_byte * +extern gdb::array_view<const gdb_byte> value_contents_for_printing_const (const struct value *value); extern void value_fetch_lazy (struct value *val); diff --git a/gdb/vax-tdep.c b/gdb/vax-tdep.c index 249b0bf..70bed6a 100644 --- a/gdb/vax-tdep.c +++ b/gdb/vax-tdep.c @@ -123,7 +123,7 @@ vax_store_arguments (struct regcache *regcache, int nargs, sp -= (len + 3) & ~3; count += (len + 3) / 4; - write_memory (sp, value_contents_all (args[i]), len); + write_memory (sp, value_contents_all (args[i]).data (), len); } /* Push argument count. */ diff --git a/gdb/windows-tdep.c b/gdb/windows-tdep.c index f6005a3..891c48a 100644 --- a/gdb/windows-tdep.c +++ b/gdb/windows-tdep.c @@ -408,7 +408,7 @@ tlb_value_read (struct value *val) if (!target_get_tib_address (inferior_ptid, &tlb)) error (_("Unable to read tlb")); - store_typed_address (value_contents_raw (val), type, tlb); + store_typed_address (value_contents_raw (val).data (), type, tlb); } /* This function implements the lval_computed support for writing a diff --git a/gdb/xstormy16-tdep.c b/gdb/xstormy16-tdep.c index 0d348bf..dfff608 100644 --- a/gdb/xstormy16-tdep.c +++ b/gdb/xstormy16-tdep.c @@ -257,7 +257,7 @@ xstormy16_push_dummy_call (struct gdbarch *gdbarch, break; /* Put argument into registers wordwise. */ - const gdb_byte *val = value_contents (args[i]); + const gdb_byte *val = value_contents (args[i]).data (); for (j = 0; j < typelen; j += xstormy16_reg_size) { ULONGEST regval; @@ -275,7 +275,7 @@ xstormy16_push_dummy_call (struct gdbarch *gdbarch, wordaligned. */ for (j = nargs - 1; j >= i; j--) { - const gdb_byte *bytes = value_contents (args[j]); + const gdb_byte *bytes = value_contents (args[j]).data (); typelen = TYPE_LENGTH (value_enclosing_type (args[j])); slacklen = typelen & 1; diff --git a/gdb/xtensa-tdep.c b/gdb/xtensa-tdep.c index 6862a03..42bff4c 100644 --- a/gdb/xtensa-tdep.c +++ b/gdb/xtensa-tdep.c @@ -1731,7 +1731,7 @@ xtensa_push_dummy_call (struct gdbarch *gdbarch, break; } fprintf_unfiltered (gdb_stdlog, " %s\n", - host_address_to_string (value_contents (arg))); + host_address_to_string (value_contents (arg).data ())); } } @@ -1787,7 +1787,7 @@ xtensa_push_dummy_call (struct gdbarch *gdbarch, break; } info->length = TYPE_LENGTH (arg_type); - info->contents = value_contents (arg); + info->contents = value_contents (arg).data (); /* Align size and onstack_size. */ size = (size + info->align - 1) & ~(info->align - 1); |