Turn many optimized-out value functions into methods

This turns many functions that are related to optimized-out or
availability-checking to be methods of value.  The static function
value_entirely_covered_by_range_vector is also converted to be a
private method.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
This commit is contained in:
Tom Tromey 2023-01-31 16:13:08 -07:00
parent cda0334434
commit d00664dbba
37 changed files with 237 additions and 272 deletions

View File

@ -2766,8 +2766,8 @@ aarch64_pseudo_read_value_1 (struct gdbarch *gdbarch,
gdb_static_assert (AARCH64_V0_REGNUM == AARCH64_SVE_Z0_REGNUM);
if (regcache->raw_read (v_regnum, reg_buf) != REG_VALID)
mark_value_bytes_unavailable (result_value, 0,
result_value->type ()->length ());
result_value->mark_bytes_unavailable (0,
result_value->type ()->length ());
else
memcpy (result_value->contents_raw ().data (), reg_buf, regsize);
@ -2801,7 +2801,7 @@ aarch64_pseudo_read_value (struct gdbarch *gdbarch, readable_regcache *regcache,
/* Read the bottom 4 bytes of X. */
if (regcache->raw_read_part (x_regnum, offset, 4, data) != REG_VALID)
mark_value_bytes_unavailable (result_value, 0, 4);
result_value->mark_bytes_unavailable (0, 4);
else
memcpy (result_value->contents_raw ().data (), data, 4);

View File

@ -555,7 +555,7 @@ coerce_unspec_val_to_type (struct value *val, struct type *type)
{
struct value *result;
if (value_optimized_out (val))
if (val->optimized_out ())
result = value::allocate_optimized_out (type);
else if (val->lazy ()
/* Be careful not to make a lazy not_lval value. */

View File

@ -918,7 +918,7 @@ ada_value_print_array (struct value *val, struct ui_file *stream, int recurse,
gdb_printf (stream, "(");
print_optional_low_bound (stream, type, options);
if (value_entirely_optimized_out (val))
if (val->entirely_optimized_out ())
val_print_optimized_out (val, stream);
else if (TYPE_FIELD_BITSIZE (type, 0) > 0)
{

View File

@ -241,8 +241,8 @@ alpha_register_to_value (frame_info_ptr frame, int regnum,
struct value *value = get_frame_register_value (frame, regnum);
gdb_assert (value != NULL);
*optimizedp = value_optimized_out (value);
*unavailablep = !value_entirely_available (value);
*optimizedp = value->optimized_out ();
*unavailablep = !value->entirely_available ();
if (*optimizedp || *unavailablep)
{

View File

@ -375,8 +375,8 @@ amd64_pseudo_register_read_value (struct gdbarch *gdbarch,
if (status == REG_VALID)
memcpy (buf, raw_buf + 1, 1);
else
mark_value_bytes_unavailable (result_value, 0,
result_value->type ()->length ());
result_value->mark_bytes_unavailable (0,
result_value->type ()->length ());
}
else
{
@ -385,8 +385,8 @@ amd64_pseudo_register_read_value (struct gdbarch *gdbarch,
if (status == REG_VALID)
memcpy (buf, raw_buf, 1);
else
mark_value_bytes_unavailable (result_value, 0,
result_value->type ()->length ());
result_value->mark_bytes_unavailable (0,
result_value->type ()->length ());
}
}
else if (i386_dword_regnum_p (gdbarch, regnum))
@ -398,8 +398,8 @@ amd64_pseudo_register_read_value (struct gdbarch *gdbarch,
if (status == REG_VALID)
memcpy (buf, raw_buf, 4);
else
mark_value_bytes_unavailable (result_value, 0,
result_value->type ()->length ());
result_value->mark_bytes_unavailable (0,
result_value->type ()->length ());
}
else
i386_pseudo_register_read_into_value (gdbarch, regcache, regnum,

View File

@ -257,9 +257,9 @@ c_value_print_array (struct value *val,
long as the entire array is valid. */
if (c_textual_element_type (unresolved_elttype,
options->format)
&& value_bytes_available (val, 0, type->length ())
&& !value_bits_any_optimized_out (val, 0,
TARGET_CHAR_BIT * type->length ()))
&& val->bytes_available (0, type->length ())
&& !val->bits_any_optimized_out (0,
TARGET_CHAR_BIT * type->length ()))
{
int force_ellipses = 0;
@ -520,7 +520,7 @@ c_value_print (struct value *val, struct ui_file *stream,
/* Pointer to class, check real type of object. */
gdb_printf (stream, "(");
if (value_entirely_available (val))
if (val->entirely_available ())
{
real_type = value_rtti_indirect_type (val, &full, &top,
&using_enc);

View File

@ -578,9 +578,9 @@ store_regs (struct type *regs_type, CORE_ADDR regs_base)
regnum = compile_register_name_demangle (gdbarch, reg_name);
regval = value_from_register (reg_type, regnum, get_current_frame ());
if (value_optimized_out (regval))
if (regval->optimized_out ())
error (_("Register \"%s\" is optimized out."), reg_name);
if (!value_entirely_available (regval))
if (!regval->entirely_available ())
error (_("Register \"%s\" is not available."), reg_name);
inferior_addr = regs_base + reg_offset;

View File

@ -550,7 +550,7 @@ cp_print_static_field (struct type *type,
{
struct value_print_options opts;
if (value_entirely_optimized_out (val))
if (val->entirely_optimized_out ())
{
val_print_optimized_out (val, stream);
return;

View File

@ -38,9 +38,8 @@ dynamic_array_type (struct type *type,
&& type->field (0).type ()->code () == TYPE_CODE_INT
&& strcmp (type->field (0).name (), "length") == 0
&& strcmp (type->field (1).name (), "ptr") == 0
&& !value_bits_any_optimized_out (val,
TARGET_CHAR_BIT * embedded_offset,
TARGET_CHAR_BIT * type->length ()))
&& !val->bits_any_optimized_out (TARGET_CHAR_BIT * embedded_offset,
TARGET_CHAR_BIT * type->length ()))
{
CORE_ADDR addr;
struct type *elttype;

View File

@ -233,12 +233,12 @@ rw_pieced_value (value *v, value *from, bool check_optimized)
{
if (check_optimized)
return true;
mark_value_bits_optimized_out (v, offset,
this_size_bits);
v->mark_bits_optimized_out (offset,
this_size_bits);
}
if (unavail && !check_optimized)
mark_value_bits_unavailable (v, offset,
this_size_bits);
v->mark_bits_unavailable (offset,
this_size_bits);
break;
}
@ -358,7 +358,7 @@ rw_pieced_value (value *v, value *from, bool check_optimized)
if (from != nullptr)
{
mark_value_bits_optimized_out (v, offset, this_size_bits);
v->mark_bits_optimized_out (offset, this_size_bits);
break;
}
@ -390,7 +390,7 @@ rw_pieced_value (value *v, value *from, bool check_optimized)
if (from != nullptr)
{
mark_value_bits_optimized_out (v, offset, this_size_bits);
v->mark_bits_optimized_out (offset, this_size_bits);
break;
}
@ -413,7 +413,7 @@ rw_pieced_value (value *v, value *from, bool check_optimized)
case DWARF_VALUE_IMPLICIT_POINTER:
if (from != nullptr)
{
mark_value_bits_optimized_out (v, offset, this_size_bits);
v->mark_bits_optimized_out (offset, this_size_bits);
break;
}
@ -424,7 +424,7 @@ rw_pieced_value (value *v, value *from, bool check_optimized)
case DWARF_VALUE_OPTIMIZED_OUT:
if (check_optimized)
return true;
mark_value_bits_optimized_out (v, offset, this_size_bits);
v->mark_bits_optimized_out (offset, this_size_bits);
break;
default:
@ -960,7 +960,7 @@ dwarf_expr_context::fetch_result (struct type *type, struct type *subobj_type,
retval = value_from_register (subobj_type, gdb_regnum,
this->m_frame);
if (value_optimized_out (retval))
if (retval->optimized_out ())
{
/* This means the register has undefined value / was
not saved. As we're computing the location of some

View File

@ -1515,8 +1515,8 @@ dwarf2_evaluate_loc_desc_full (struct type *type, frame_info_ptr frame,
{
free_values.free_to_mark ();
retval = value::allocate (subobj_type);
mark_value_bytes_unavailable (retval, 0,
subobj_type->length ());
retval->mark_bytes_unavailable (0,
subobj_type->length ());
return retval;
}
else if (ex.error == NO_ENTRY_VALUE_ERROR)
@ -1609,7 +1609,7 @@ dwarf2_locexpr_baton_eval (const struct dwarf2_locexpr_baton *dlbaton,
throw;
}
if (value_optimized_out (result))
if (result->optimized_out ())
return 0;
if (VALUE_LVAL (result) == lval_memory)
@ -1709,7 +1709,7 @@ dwarf2_evaluate_property (const struct dynamic_prop *prop,
val = dwarf2_evaluate_loc_desc (baton->property_type, frame, data,
size, baton->loclist.per_cu,
baton->loclist.per_objfile);
if (!value_optimized_out (val))
if (!val->optimized_out ())
{
*value = value_as_address (val);
return true;

View File

@ -269,11 +269,11 @@ class fortran_array_printer_impl : public fortran_array_walker_base_impl
struct value *e_val = value_from_component (m_val, elt_type, elt_off);
struct value *e_prev = value_from_component (m_val, elt_type,
elt_off_prev);
repeated = ((value_entirely_available (e_prev)
&& value_entirely_available (e_val)
repeated = ((e_prev->entirely_available ()
&& e_val->entirely_available ()
&& e_prev->contents_eq (e_val))
|| (value_entirely_unavailable (e_prev)
&& value_entirely_unavailable (e_val)));
|| (e_prev->entirely_unavailable ()
&& e_val->entirely_unavailable ()));
}
if (repeated)
@ -376,11 +376,11 @@ class fortran_array_printer_impl : public fortran_array_walker_base_impl
struct value *e_val1 = value_from_component (val, type, offset1);
struct value *e_val2 = value_from_component (val, type, offset2);
return ((value_entirely_available (e_val1)
&& value_entirely_available (e_val2)
return ((e_val1->entirely_available ()
&& e_val2->entirely_available ()
&& e_val1->contents_eq (e_val2))
|| (value_entirely_unavailable (e_val1)
&& value_entirely_unavailable (e_val2)));
|| (e_val1->entirely_unavailable ()
&& e_val2->entirely_unavailable ()));
}
}

View File

@ -906,9 +906,9 @@ value_from_register (struct type *type, int regnum, frame_info_ptr frame)
if (!ok)
{
if (optim)
mark_value_bytes_optimized_out (v, 0, type->length ());
v->mark_bytes_optimized_out (0, type->length ());
if (unavail)
mark_value_bytes_unavailable (v, 0, type->length ());
v->mark_bytes_unavailable (0, type->length ());
}
}
else
@ -971,7 +971,7 @@ address_from_register (int regnum, frame_info_ptr frame)
value = gdbarch_value_from_register (gdbarch, type, regnum, null_frame_id);
read_frame_register_value (value, frame);
if (value_optimized_out (value))
if (value->optimized_out ())
{
/* This function is used while computing a location expression.
Complain about the value being optimized out, rather than

View File

@ -1189,8 +1189,8 @@ frame_register_unwind (frame_info_ptr next_frame, int regnum,
gdb_assert (value != NULL);
*optimizedp = value_optimized_out (value);
*unavailablep = !value_entirely_available (value);
*optimizedp = value->optimized_out ();
*unavailablep = !value->entirely_available ();
*lvalp = VALUE_LVAL (value);
*addrp = value->address ();
if (*lvalp == lval_register)
@ -1289,7 +1289,7 @@ frame_unwind_register_value (frame_info_ptr next_frame, int regnum)
string_file debug_file;
gdb_printf (&debug_file, " ->");
if (value_optimized_out (value))
if (value->optimized_out ())
{
gdb_printf (&debug_file, " ");
val_print_not_saved (&debug_file);
@ -1342,12 +1342,12 @@ frame_unwind_register_signed (frame_info_ptr next_frame, int regnum)
gdb_assert (value != NULL);
if (value_optimized_out (value))
if (value->optimized_out ())
{
throw_error (OPTIMIZED_OUT_ERROR,
_("Register %d was not saved"), regnum);
}
if (!value_entirely_available (value))
if (!value->entirely_available ())
{
throw_error (NOT_AVAILABLE_ERROR,
_("Register %d is not available"), regnum);
@ -1375,12 +1375,12 @@ frame_unwind_register_unsigned (frame_info_ptr next_frame, int regnum)
gdb_assert (value != NULL);
if (value_optimized_out (value))
if (value->optimized_out ())
{
throw_error (OPTIMIZED_OUT_ERROR,
_("Register %d was not saved"), regnum);
}
if (!value_entirely_available (value))
if (!value->entirely_available ())
{
throw_error (NOT_AVAILABLE_ERROR,
_("Register %d is not available"), regnum);
@ -1405,8 +1405,8 @@ read_frame_register_unsigned (frame_info_ptr frame, int regnum,
{
struct value *regval = get_frame_register_value (frame, regnum);
if (!value_optimized_out (regval)
&& value_entirely_available (regval))
if (!regval->optimized_out ()
&& regval->entirely_available ())
{
struct gdbarch *gdbarch = get_frame_arch (frame);
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
@ -1537,8 +1537,8 @@ get_frame_register_bytes (frame_info_ptr frame, int regnum,
= frame_unwind_register_value (frame_info_ptr (frame->next),
regnum);
gdb_assert (value != NULL);
*optimizedp = value_optimized_out (value);
*unavailablep = !value_entirely_available (value);
*optimizedp = value->optimized_out ();
*unavailablep = !value->entirely_available ();
if (*optimizedp || *unavailablep)
{

View File

@ -366,8 +366,8 @@ gnuv2_baseclass_offset (struct type *type, int index,
field_offset = type->field (i).loc_bitpos () / 8;
field_length = field_type->length ();
if (!value_bytes_available (val, embedded_offset + field_offset,
field_length))
if (!val->bytes_available (embedded_offset + field_offset,
field_length))
throw_error (NOT_AVAILABLE_ERROR,
_("Virtual baseclass pointer is not available"));

View File

@ -969,7 +969,7 @@ gdbscm_apply_val_pretty_printer (const struct extension_language_defn *extlang,
value->fetch_lazy ();
/* No pretty-printer support for unavailable values. */
if (!value_bytes_available (value, 0, type->length ()))
if (!value->bytes_available (0, type->length ()))
return EXT_LANG_RC_NOP;
if (!gdb_scheme_initialized)

View File

@ -390,7 +390,7 @@ gdbscm_value_optimized_out_p (SCM self)
return gdbscm_wrap ([=]
{
return scm_from_bool (value_optimized_out (v_smob->value));
return scm_from_bool (v_smob->value->optimized_out ());
});
}

View File

@ -3388,8 +3388,8 @@ i386_pseudo_register_read_into_value (struct gdbarch *gdbarch,
/* Extract (always little endian). */
status = regcache->raw_read (fpnum, raw_buf);
if (status != REG_VALID)
mark_value_bytes_unavailable (result_value, 0,
result_value->type ()->length ());
result_value->mark_bytes_unavailable (0,
result_value->type ()->length ());
else
memcpy (buf, raw_buf, register_size (gdbarch, regnum));
}
@ -3404,7 +3404,7 @@ i386_pseudo_register_read_into_value (struct gdbarch *gdbarch,
status = regcache->raw_read (I387_BND0R_REGNUM (tdep) + regnum,
raw_buf);
if (status != REG_VALID)
mark_value_bytes_unavailable (result_value, 0, 16);
result_value->mark_bytes_unavailable (0, 16);
else
{
enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
@ -3426,7 +3426,7 @@ i386_pseudo_register_read_into_value (struct gdbarch *gdbarch,
/* Extract (always little endian). */
status = regcache->raw_read (tdep->k0_regnum + regnum, raw_buf);
if (status != REG_VALID)
mark_value_bytes_unavailable (result_value, 0, 8);
result_value->mark_bytes_unavailable (0, 8);
else
memcpy (buf, raw_buf, 8);
}
@ -3440,7 +3440,7 @@ i386_pseudo_register_read_into_value (struct gdbarch *gdbarch,
status = regcache->raw_read (I387_XMM0_REGNUM (tdep) + regnum,
raw_buf);
if (status != REG_VALID)
mark_value_bytes_unavailable (result_value, 0, 16);
result_value->mark_bytes_unavailable (0, 16);
else
memcpy (buf, raw_buf, 16);
@ -3448,7 +3448,7 @@ i386_pseudo_register_read_into_value (struct gdbarch *gdbarch,
status = regcache->raw_read (tdep->ymm0h_regnum + regnum,
raw_buf);
if (status != REG_VALID)
mark_value_bytes_unavailable (result_value, 16, 16);
result_value->mark_bytes_unavailable (16, 16);
else
memcpy (buf + 16, raw_buf, 16);
}
@ -3459,7 +3459,7 @@ i386_pseudo_register_read_into_value (struct gdbarch *gdbarch,
- num_lower_zmm_regs,
raw_buf);
if (status != REG_VALID)
mark_value_bytes_unavailable (result_value, 0, 16);
result_value->mark_bytes_unavailable (0, 16);
else
memcpy (buf, raw_buf, 16);
@ -3468,7 +3468,7 @@ i386_pseudo_register_read_into_value (struct gdbarch *gdbarch,
- num_lower_zmm_regs,
raw_buf);
if (status != REG_VALID)
mark_value_bytes_unavailable (result_value, 16, 16);
result_value->mark_bytes_unavailable (16, 16);
else
memcpy (buf + 16, raw_buf, 16);
}
@ -3477,7 +3477,7 @@ i386_pseudo_register_read_into_value (struct gdbarch *gdbarch,
status = regcache->raw_read (tdep->zmm0h_regnum + regnum,
raw_buf);
if (status != REG_VALID)
mark_value_bytes_unavailable (result_value, 32, 32);
result_value->mark_bytes_unavailable (32, 32);
else
memcpy (buf + 32, raw_buf, 32);
}
@ -3489,14 +3489,14 @@ i386_pseudo_register_read_into_value (struct gdbarch *gdbarch,
status = regcache->raw_read (I387_XMM0_REGNUM (tdep) + regnum,
raw_buf);
if (status != REG_VALID)
mark_value_bytes_unavailable (result_value, 0, 16);
result_value->mark_bytes_unavailable (0, 16);
else
memcpy (buf, raw_buf, 16);
/* Read upper 128bits. */
status = regcache->raw_read (tdep->ymm0h_regnum + regnum,
raw_buf);
if (status != REG_VALID)
mark_value_bytes_unavailable (result_value, 16, 32);
result_value->mark_bytes_unavailable (16, 32);
else
memcpy (buf + 16, raw_buf, 16);
}
@ -3507,14 +3507,14 @@ i386_pseudo_register_read_into_value (struct gdbarch *gdbarch,
status = regcache->raw_read (I387_XMM16_REGNUM (tdep) + regnum,
raw_buf);
if (status != REG_VALID)
mark_value_bytes_unavailable (result_value, 0, 16);
result_value->mark_bytes_unavailable (0, 16);
else
memcpy (buf, raw_buf, 16);
/* Read upper 128bits. */
status = regcache->raw_read (tdep->ymm16h_regnum + regnum,
raw_buf);
if (status != REG_VALID)
mark_value_bytes_unavailable (result_value, 16, 16);
result_value->mark_bytes_unavailable (16, 16);
else
memcpy (buf + 16, raw_buf, 16);
}
@ -3525,8 +3525,8 @@ i386_pseudo_register_read_into_value (struct gdbarch *gdbarch,
/* Extract (always little endian). */
status = regcache->raw_read (gpnum, raw_buf);
if (status != REG_VALID)
mark_value_bytes_unavailable (result_value, 0,
result_value->type ()->length ());
result_value->mark_bytes_unavailable (0,
result_value->type ()->length ());
else
memcpy (buf, raw_buf, 2);
}
@ -3538,8 +3538,8 @@ i386_pseudo_register_read_into_value (struct gdbarch *gdbarch,
upper registers. */
status = regcache->raw_read (gpnum % 4, raw_buf);
if (status != REG_VALID)
mark_value_bytes_unavailable (result_value, 0,
result_value->type ()->length ());
result_value->mark_bytes_unavailable (0,
result_value->type ()->length ());
else if (gpnum >= 4)
memcpy (buf, raw_buf + 1, 1);
else

View File

@ -282,7 +282,7 @@ i387_print_float_info (struct gdbarch *gdbarch, struct ui_file *file,
regnum = (fpreg + 8 - top) % 8 + I387_ST0_REGNUM (tdep);
regval = get_frame_register_value (frame, regnum);
if (value_entirely_available (regval))
if (regval->entirely_available ())
{
const gdb_byte *raw = regval->contents ().data ();

View File

@ -2172,8 +2172,8 @@ default_print_one_register_info (struct ui_file *file,
format_stream.puts (name);
pad_to_column (format_stream, value_column_1);
print_raw_format = (value_entirely_available (val)
&& !value_optimized_out (val));
print_raw_format = (val->entirely_available ()
&& !val->optimized_out ());
/* If virtual format is floating, print it that way, and in raw
hex. */

View File

@ -7989,7 +7989,7 @@ insert_exception_resume_breakpoint (struct thread_info *tp,
b, VAR_DOMAIN);
value = read_var_value (vsym.symbol, vsym.block, frame);
/* If the value was optimized out, revert to the old behavior. */
if (! value_optimized_out (value))
if (! value->optimized_out ())
{
handler = value_as_address (value);

View File

@ -501,14 +501,13 @@ list_arg_or_local (const struct frame_arg *arg, enum what_to_list what,
&& (arg->val || arg->error)));
if (skip_unavailable && arg->val != NULL
&& (value_entirely_unavailable (arg->val)
&& (arg->val->entirely_unavailable ()
/* A scalar object that does not have all bits available is
also considered unavailable, because all bits contribute
to its representation. */
|| (val_print_scalar_type_p (arg->val->type ())
&& !value_bytes_available (arg->val,
arg->val->embedded_offset (),
arg->val->type ()->length ()))))
&& !arg->val->bytes_available (arg->val->embedded_offset (),
arg->val->type ()->length ()))))
return;
gdb::optional<ui_out_emit_tuple> tuple_emitter;

View File

@ -1096,7 +1096,7 @@ output_register (frame_info_ptr frame, int regnum, int format,
struct value *val = value_of_register (regnum, frame);
struct value_print_options opts;
if (skip_unavailable && !value_entirely_available (val))
if (skip_unavailable && !val->entirely_available ())
return;
ui_out_emit_tuple tuple_emitter (uiout, NULL);

View File

@ -6585,8 +6585,8 @@ print_gp_register_row (struct ui_file *file, frame_info_ptr frame,
/* OK: get the data in raw format. */
value = get_frame_register_value (frame, regnum);
if (value_optimized_out (value)
|| !value_entirely_available (value))
if (value->optimized_out ()
|| !value->entirely_available ())
{
gdb_printf (file, "%*s ",
(int) mips_abi_regsize (gdbarch) * 2,

View File

@ -818,7 +818,7 @@ pascal_object_print_static_field (struct value *val,
struct type *type = val->type ();
struct value_print_options opts;
if (value_entirely_optimized_out (val))
if (val->entirely_optimized_out ())
{
val_print_optimized_out (val, stream);
return;

View File

@ -1280,8 +1280,8 @@ should_validate_memtags (struct value *value)
/* OK, we have an address value. Check we have a complete value we
can extract. */
if (value_optimized_out (value)
|| !value_entirely_available (value))
if (value->optimized_out ()
|| !value->entirely_available ())
return false;
/* We do. Check whether it includes any tags. */

View File

@ -582,7 +582,7 @@ gdbpy_apply_val_pretty_printer (const struct extension_language_defn *extlang,
value->fetch_lazy ();
/* No pretty-printer support for unavailable values. */
if (!value_bytes_available (value, 0, type->length ()))
if (!value->bytes_available (0, type->length ()))
return EXT_LANG_RC_NOP;
if (!gdb_python_initialized)

View File

@ -1197,7 +1197,7 @@ valpy_get_is_optimized_out (PyObject *self, void *closure)
try
{
opt = value_optimized_out (value);
opt = value->optimized_out ();
}
catch (const gdb_exception &except)
{

View File

@ -715,7 +715,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))
if (computed->entirely_available ())
memcpy (buf, computed->contents_raw ().data (),
m_descr->sizeof_register[regnum]);
else
@ -752,8 +752,8 @@ readable_regcache::cooked_read_value (int regnum)
API is preferred. */
if (cooked_read (regnum,
result->contents_raw ().data ()) == REG_UNAVAILABLE)
mark_value_bytes_unavailable (result, 0,
result->type ()->length ());
result->mark_bytes_unavailable (0,
result->type ()->length ());
return result;
}

View File

@ -1126,8 +1126,8 @@ riscv_print_one_register_info (struct gdbarch *gdbarch,
return;
}
print_raw_format = (value_entirely_available (val)
&& !value_optimized_out (val));
print_raw_format = (val->entirely_available ()
&& !val->optimized_out ());
if (regtype->code () == TYPE_CODE_FLT
|| (regtype->code () == TYPE_CODE_UNION

View File

@ -2199,7 +2199,7 @@ s390_unwind_pseudo_register (frame_info_ptr this_frame, int regnum)
struct value *val;
val = frame_unwind_register_value (this_frame, S390_PSWA_REGNUM);
if (!value_optimized_out (val))
if (!val->optimized_out ())
{
LONGEST pswa = value_as_long (val);
@ -2216,7 +2216,7 @@ s390_unwind_pseudo_register (frame_info_ptr this_frame, int regnum)
struct value *val;
val = frame_unwind_register_value (this_frame, S390_PSWM_REGNUM);
if (!value_optimized_out (val))
if (!val->optimized_out ())
{
LONGEST pswm = value_as_long (val);
@ -2235,7 +2235,7 @@ s390_unwind_pseudo_register (frame_info_ptr this_frame, int regnum)
struct value *val;
val = frame_unwind_register_value (this_frame, S390_R0_REGNUM + reg);
if (!value_optimized_out (val))
if (!val->optimized_out ())
return value_cast (type, val);
}

View File

@ -550,7 +550,7 @@ read_frame_arg (const frame_print_options &fp_opts,
&& SYMBOL_COMPUTED_OPS (sym)->read_variable_at_entry != NULL
&& fp_opts.print_entry_values != print_entry_values_no
&& (fp_opts.print_entry_values != print_entry_values_if_needed
|| !val || value_optimized_out (val)))
|| !val || val->optimized_out ()))
{
try
{
@ -568,7 +568,7 @@ read_frame_arg (const frame_print_options &fp_opts,
}
}
if (entryval != NULL && value_optimized_out (entryval))
if (entryval != NULL && entryval->optimized_out ())
entryval = NULL;
if (fp_opts.print_entry_values == print_entry_values_compact
@ -672,7 +672,7 @@ read_frame_arg (const frame_print_options &fp_opts,
if (fp_opts.print_entry_values == print_entry_values_only
|| fp_opts.print_entry_values == print_entry_values_both
|| (fp_opts.print_entry_values == print_entry_values_preferred
&& (!val || value_optimized_out (val))))
&& (!val || val->optimized_out ())))
{
entryval = value::allocate_optimized_out (sym->type ());
entryval_error = NULL;
@ -681,7 +681,7 @@ read_frame_arg (const frame_print_options &fp_opts,
if ((fp_opts.print_entry_values == print_entry_values_compact
|| fp_opts.print_entry_values == print_entry_values_if_needed
|| fp_opts.print_entry_values == print_entry_values_preferred)
&& (!val || value_optimized_out (val)) && entryval != NULL)
&& (!val || val->optimized_out ()) && entryval != NULL)
{
val = NULL;
val_error = NULL;
@ -1708,7 +1708,7 @@ info_frame_command_core (frame_info_ptr fi, bool selected_frame_p)
struct value *value = frame_unwind_register_value (fi, sp_regnum);
gdb_assert (value != NULL);
if (!value_optimized_out (value) && value_entirely_available (value))
if (!value->optimized_out () && value->entirely_available ())
{
if (VALUE_LVAL (value) == not_lval)
{

View File

@ -188,10 +188,10 @@ value_subscript (struct value *array, LONGEST index)
struct type *elt_type = check_typedef (tarray->target_type ());
LONGEST elt_size = type_length_units (elt_type);
if (!array->lazy ()
&& !value_bytes_available (array, elt_size * index, elt_size))
&& !array->bytes_available (elt_size * index, elt_size))
{
struct value *val = value::allocate (elt_type);
mark_value_bytes_unavailable (val, 0, elt_size);
val->mark_bytes_unavailable (0, elt_size);
VALUE_LVAL (val) = lval_memory;
val->set_address (array->address () + elt_size * index);
return val;

View File

@ -1066,9 +1066,9 @@ read_value_memory (struct value *val, LONGEST bit_offset,
if (status == TARGET_XFER_OK)
/* nothing */;
else if (status == TARGET_XFER_UNAVAILABLE)
mark_value_bits_unavailable (val, (xfered_total * HOST_CHAR_BIT
+ bit_offset),
xfered_partial * HOST_CHAR_BIT);
val->mark_bits_unavailable ((xfered_total * HOST_CHAR_BIT
+ bit_offset),
xfered_partial * HOST_CHAR_BIT);
else if (status == TARGET_XFER_EOF)
memory_error (TARGET_XFER_E_IO, memaddr + xfered_total);
else

View File

@ -373,9 +373,8 @@ valprint_check_validity (struct ui_file *stream,
&& type->code () != TYPE_CODE_STRUCT
&& type->code () != TYPE_CODE_ARRAY)
{
if (value_bits_any_optimized_out (val,
TARGET_CHAR_BIT * embedded_offset,
TARGET_CHAR_BIT * type->length ()))
if (val->bits_any_optimized_out (TARGET_CHAR_BIT * embedded_offset,
TARGET_CHAR_BIT * type->length ()))
{
val_print_optimized_out (val, stream);
return 0;
@ -403,7 +402,7 @@ valprint_check_validity (struct ui_file *stream,
return is_ref;
}
if (!value_bytes_available (val, embedded_offset, type->length ()))
if (!val->bytes_available (embedded_offset, type->length ()))
{
val_print_unavailable (stream);
return 0;
@ -1131,7 +1130,7 @@ value_check_printable (struct value *val, struct ui_file *stream,
return 0;
}
if (value_entirely_optimized_out (val))
if (val->entirely_optimized_out ())
{
if (options->summary && !val_print_scalar_type_p (val->type ()))
gdb_printf (stream, "...");
@ -1140,7 +1139,7 @@ value_check_printable (struct value *val, struct ui_file *stream,
return 0;
}
if (value_entirely_unavailable (val))
if (val->entirely_unavailable ())
{
if (options->summary && !val_print_scalar_type_p (val->type ()))
gdb_printf (stream, "...");
@ -1304,10 +1303,10 @@ value_print_scalar_formatted (struct value *val,
/* A scalar object that does not have all bits available can't be
printed, because all bits contribute to its representation. */
if (value_bits_any_optimized_out (val, 0,
TARGET_CHAR_BIT * type->length ()))
if (val->bits_any_optimized_out (0,
TARGET_CHAR_BIT * type->length ()))
val_print_optimized_out (val, stream);
else if (!value_bytes_available (val, 0, type->length ()))
else if (!val->bytes_available (0, type->length ()))
val_print_unavailable (stream);
else
print_scalar_formatted (valaddr, type, options, size, stream);
@ -2017,8 +2016,8 @@ value_print_array_elements (struct value *val, struct ui_file *stream,
UINT_MAX (unlimited). */
if (options->repeat_count_threshold < UINT_MAX)
{
bool unavailable = value_entirely_unavailable (element);
bool available = value_entirely_available (element);
bool unavailable = element->entirely_unavailable ();
bool available = element->entirely_available ();
while (rep1 < len)
{
@ -2027,10 +2026,10 @@ value_print_array_elements (struct value *val, struct ui_file *stream,
rep1 * bit_stride,
bit_stride);
bool repeated = ((available
&& value_entirely_available (rep_elt)
&& rep_elt->entirely_available ()
&& element->contents_eq (rep_elt))
|| (unavailable
&& value_entirely_unavailable (rep_elt)));
&& rep_elt->entirely_unavailable ()));
if (!repeated)
break;
++reps;

View File

@ -169,23 +169,21 @@ value::arch () const
}
int
value_bits_available (const struct value *value,
LONGEST offset, ULONGEST length)
value::bits_available (LONGEST offset, ULONGEST length) const
{
gdb_assert (!value->m_lazy);
gdb_assert (!m_lazy);
/* Don't pretend we have anything available there in the history beyond
the boundaries of the value recorded. It's not like inferior memory
where there is actual stuff underneath. */
ULONGEST val_len = TARGET_CHAR_BIT * value->enclosing_type ()->length ();
return !((value->m_in_history
ULONGEST val_len = TARGET_CHAR_BIT * enclosing_type ()->length ();
return !((m_in_history
&& (offset < 0 || offset + length > val_len))
|| ranges_contain (value->m_unavailable, offset, length));
|| ranges_contain (m_unavailable, offset, length));
}
int
value_bytes_available (const struct value *value,
LONGEST offset, ULONGEST length)
value::bytes_available (LONGEST offset, ULONGEST length) const
{
ULONGEST sign = (1ULL << (sizeof (ULONGEST) * 8 - 1)) / TARGET_CHAR_BIT;
ULONGEST mask = (sign << 1) - 1;
@ -195,70 +193,52 @@ value_bytes_available (const struct value *value,
|| (length > 0 && (~offset & (offset + length - 1) & sign) != 0))
error (_("Integer overflow in data location calculation"));
return value_bits_available (value,
offset * TARGET_CHAR_BIT,
length * TARGET_CHAR_BIT);
return bits_available (offset * TARGET_CHAR_BIT, length * TARGET_CHAR_BIT);
}
int
value_bits_any_optimized_out (const struct value *value, int bit_offset, int bit_length)
value::bits_any_optimized_out (int bit_offset, int bit_length) const
{
gdb_assert (!value->m_lazy);
gdb_assert (!m_lazy);
return ranges_contain (value->m_optimized_out, bit_offset, bit_length);
return ranges_contain (m_optimized_out, bit_offset, bit_length);
}
int
value_entirely_available (struct value *value)
value::entirely_available ()
{
/* We can only tell whether the whole value is available when we try
to read it. */
if (value->m_lazy)
value->fetch_lazy ();
if (m_lazy)
fetch_lazy ();
if (value->m_unavailable.empty ())
if (m_unavailable.empty ())
return 1;
return 0;
}
/* Returns true if VALUE is entirely covered by RANGES. If the value
is lazy, it'll be read now. Note that RANGE is a pointer to
pointer because reading the value might change *RANGE. */
/* See value.h. */
static int
value_entirely_covered_by_range_vector (struct value *value,
const std::vector<range> &ranges)
int
value::entirely_covered_by_range_vector (const std::vector<range> &ranges)
{
/* We can only tell whether the whole value is optimized out /
unavailable when we try to read it. */
if (value->m_lazy)
value->fetch_lazy ();
if (m_lazy)
fetch_lazy ();
if (ranges.size () == 1)
{
const struct range &t = ranges[0];
if (t.offset == 0
&& t.length == (TARGET_CHAR_BIT
* value->enclosing_type ()->length ()))
&& t.length == TARGET_CHAR_BIT * enclosing_type ()->length ())
return 1;
}
return 0;
}
int
value_entirely_unavailable (struct value *value)
{
return value_entirely_covered_by_range_vector (value, value->m_unavailable);
}
int
value_entirely_optimized_out (struct value *value)
{
return value_entirely_covered_by_range_vector (value, value->m_optimized_out);
}
/* Insert into the vector pointed to by VECTORP the bit range starting of
OFFSET bits, and extending for the next LENGTH bits. */
@ -429,19 +409,16 @@ insert_into_bit_range_vector (std::vector<range> *vectorp,
}
void
mark_value_bits_unavailable (struct value *value,
LONGEST offset, ULONGEST length)
value::mark_bits_unavailable (LONGEST offset, ULONGEST length)
{
insert_into_bit_range_vector (&value->m_unavailable, offset, length);
insert_into_bit_range_vector (&m_unavailable, offset, length);
}
void
mark_value_bytes_unavailable (struct value *value,
LONGEST offset, ULONGEST length)
value::mark_bytes_unavailable (LONGEST offset, ULONGEST length)
{
mark_value_bits_unavailable (value,
offset * TARGET_CHAR_BIT,
length * TARGET_CHAR_BIT);
mark_bits_unavailable (offset * TARGET_CHAR_BIT,
length * TARGET_CHAR_BIT);
}
/* Find the first range in RANGES that overlaps the range defined by
@ -1012,7 +989,7 @@ value::allocate_optimized_out (struct type *type)
{
struct value *retval = value::allocate_lazy (type);
mark_value_bytes_optimized_out (retval, 0, type->length ());
retval->mark_bytes_optimized_out (0, type->length ());
retval->set_lazy (0);
return retval;
}
@ -1061,7 +1038,7 @@ value_actual_type (struct value *value, int resolve_simple_types,
if (result->is_pointer_or_reference ()
&& (check_typedef (result->target_type ())->code ()
== TYPE_CODE_STRUCT)
&& !value_optimized_out (value))
&& !value->optimized_out ())
{
struct type *real_type;
@ -1204,10 +1181,9 @@ value_contents_copy_raw (struct value *dst, LONGEST dst_offset,
/* The overwritten DST range gets unavailability ORed in, not
replaced. Make sure to remember to implement replacing if it
turns out actually necessary. */
gdb_assert (value_bytes_available (dst, dst_offset, length));
gdb_assert (!value_bits_any_optimized_out (dst,
TARGET_CHAR_BIT * dst_offset,
TARGET_CHAR_BIT * length));
gdb_assert (dst->bytes_available (dst_offset, length));
gdb_assert (!dst->bits_any_optimized_out (TARGET_CHAR_BIT * dst_offset,
TARGET_CHAR_BIT * length));
/* Copy the data. */
gdb::array_view<gdb_byte> dst_contents
@ -1247,9 +1223,9 @@ value_contents_copy_raw_bitwise (struct value *dst, LONGEST dst_bit_offset,
turns out actually necessary. */
LONGEST dst_offset = dst_bit_offset / TARGET_CHAR_BIT;
LONGEST length = bit_length / TARGET_CHAR_BIT;
gdb_assert (value_bytes_available (dst, dst_offset, length));
gdb_assert (!value_bits_any_optimized_out (dst, dst_bit_offset,
bit_length));
gdb_assert (dst->bytes_available (dst_offset, length));
gdb_assert (!dst->bits_any_optimized_out (dst_bit_offset,
bit_length));
/* Copy the data. */
gdb::array_view<gdb_byte> dst_contents = dst->contents_all_raw ();
@ -1303,26 +1279,26 @@ value::contents_writeable ()
}
int
value_optimized_out (struct value *value)
value::optimized_out ()
{
if (value->m_lazy)
if (m_lazy)
{
/* See if we can compute the result without fetching the
value. */
if (VALUE_LVAL (value) == lval_memory)
if (VALUE_LVAL (this) == lval_memory)
return false;
else if (VALUE_LVAL (value) == lval_computed)
else if (VALUE_LVAL (this) == lval_computed)
{
const struct lval_funcs *funcs = value->m_location.computed.funcs;
const struct lval_funcs *funcs = m_location.computed.funcs;
if (funcs->is_optimized_out != nullptr)
return funcs->is_optimized_out (value);
return funcs->is_optimized_out (this);
}
/* Fall back to fetching. */
try
{
value->fetch_lazy ();
fetch_lazy ();
}
catch (const gdb_exception_error &ex)
{
@ -1341,27 +1317,25 @@ value_optimized_out (struct value *value)
}
}
return !value->m_optimized_out.empty ();
return !m_optimized_out.empty ();
}
/* Mark contents of VALUE as optimized out, starting at OFFSET bytes, and
the following LENGTH bytes. */
void
mark_value_bytes_optimized_out (struct value *value, int offset, int length)
value::mark_bytes_optimized_out (int offset, int length)
{
mark_value_bits_optimized_out (value,
offset * TARGET_CHAR_BIT,
length * TARGET_CHAR_BIT);
mark_bits_optimized_out (offset * TARGET_CHAR_BIT,
length * TARGET_CHAR_BIT);
}
/* See value.h. */
void
mark_value_bits_optimized_out (struct value *value,
LONGEST offset, LONGEST length)
value::mark_bits_optimized_out (LONGEST offset, LONGEST length)
{
insert_into_bit_range_vector (&value->m_optimized_out, offset, length);
insert_into_bit_range_vector (&m_optimized_out, offset, length);
}
int
@ -1546,8 +1520,8 @@ value::copy () const
val->m_limited_length = m_limited_length;
if (!val->lazy ()
&& !(value_entirely_optimized_out (val)
|| value_entirely_unavailable (val)))
&& !(val->entirely_optimized_out ()
|| val->entirely_unavailable ()))
{
ULONGEST length = val->m_limited_length;
if (length == 0)
@ -1721,8 +1695,8 @@ record_latest_value (struct value *val)
ULONGEST limit = val->m_limited_length;
if (limit != 0)
mark_value_bytes_unavailable (val, limit,
enclosing_type->length () - limit);
val->mark_bytes_unavailable (limit,
enclosing_type->length () - limit);
/* Mark the value as recorded in the history for the availability check. */
val->m_in_history = true;
@ -3159,8 +3133,8 @@ unpack_value_field_as_long (struct type *type, const gdb_byte *valaddr,
gdb_assert (val != NULL);
bit_offset = embedded_offset * TARGET_CHAR_BIT + bitpos;
if (value_bits_any_optimized_out (val, bit_offset, bitsize)
|| !value_bits_available (val, bit_offset, bitsize))
if (val->bits_any_optimized_out (bit_offset, bitsize)
|| !val->bits_available (bit_offset, bitsize))
return 0;
*result = unpack_bits_as_long (field_type, valaddr + embedded_offset,
@ -3905,7 +3879,7 @@ value::fetch_lazy_register ()
user_reg_map_regnum_to_name (gdbarch, regnum));
gdb_printf (&debug_file, "->");
if (value_optimized_out (new_val))
if (new_val->optimized_out ())
{
gdb_printf (&debug_file, " ");
val_print_optimized_out (new_val, &debug_file);
@ -4174,8 +4148,8 @@ test_value_copy ()
value_ref_ptr val = release_value (value::allocate_optimized_out (type));
value_ref_ptr copy = release_value (val.get ()->copy ());
SELF_CHECK (value_entirely_optimized_out (val.get ()));
SELF_CHECK (value_entirely_optimized_out (copy.get ()));
SELF_CHECK (val.get ()->entirely_optimized_out ());
SELF_CHECK (copy.get ()->entirely_optimized_out ());
}
} /* namespace selftests */

View File

@ -262,7 +262,6 @@ struct value
void set_lazy (int val)
{ m_lazy = val; }
/* If a value represents a C++ object, then the `type' field gives the
object's compile-time type. If the object actually belongs to some
class derived from `type', perhaps with other base classes and
@ -479,6 +478,60 @@ struct value
drops to 0, it will be freed. */
void decref ();
/* Given a value, determine whether the contents bytes starting at
OFFSET and extending for LENGTH bytes are available. This returns
nonzero if all bytes in the given range are available, zero if any
byte is unavailable. */
int bytes_available (LONGEST offset, ULONGEST length) const;
/* Given a value, determine whether the contents bits starting at
OFFSET and extending for LENGTH bits are available. This returns
nonzero if all bits in the given range are available, zero if any
bit is unavailable. */
int bits_available (LONGEST offset, ULONGEST length) const;
/* Like bytes_available, but return false if any byte in the
whole object is unavailable. */
int entirely_available ();
/* Like entirely_available, but return false if any byte in the
whole object is available. */
int entirely_unavailable ()
{ return entirely_covered_by_range_vector (m_unavailable); }
/* Mark this value's content bytes starting at OFFSET and extending
for LENGTH bytes as unavailable. */
void mark_bytes_unavailable (LONGEST offset, ULONGEST length);
/* Mark this value's content bits starting at OFFSET and extending
for LENGTH bits as unavailable. */
void mark_bits_unavailable (LONGEST offset, ULONGEST length);
/* If nonzero, this is the value of a variable which does not actually
exist in the program, at least partially. If the value is lazy,
this may fetch it now. */
int optimized_out ();
/* Given a value, return true if any of the contents bits starting at
OFFSET and extending for LENGTH bits is optimized out, false
otherwise. */
int bits_any_optimized_out (int bit_offset, int bit_length) const;
/* Like optimized_out, but return true iff the whole value is
optimized out. */
int entirely_optimized_out ()
{
return entirely_covered_by_range_vector (m_optimized_out);
}
/* Mark this value's content bytes starting at OFFSET and extending
for LENGTH bytes as optimized out. */
void mark_bytes_optimized_out (int offset, int length);
/* Mark this value's content bits starting at OFFSET and extending
for LENGTH bits as optimized out. */
void mark_bits_optimized_out (LONGEST offset, LONGEST length);
/* Type of value; either not an lval, or one of the various
different possible kinds of lval. */
@ -697,6 +750,11 @@ struct value
void require_not_optimized_out () const;
void require_available () const;
/* Returns true if this value is entirely covered by RANGES. If the
value is lazy, it'll be read now. Note that RANGE is a pointer
to pointer because reading the value might change *RANGE. */
int entirely_covered_by_range_vector (const std::vector<range> &ranges);
};
inline void
@ -793,34 +851,6 @@ struct lval_funcs
extern void error_value_optimized_out (void);
/* If nonzero, this is the value of a variable which does not actually
exist in the program, at least partially. If the value is lazy,
this may fetch it now. */
extern int value_optimized_out (struct value *value);
/* Given a value, return true if any of the contents bits starting at
OFFSET and extending for LENGTH bits is optimized out, false
otherwise. */
extern int value_bits_any_optimized_out (const struct value *value,
int bit_offset, int bit_length);
/* Like value_optimized_out, but return true iff the whole value is
optimized out. */
extern int value_entirely_optimized_out (struct value *value);
/* Mark VALUE's content bytes starting at OFFSET and extending for
LENGTH bytes as optimized out. */
extern void mark_value_bytes_optimized_out (struct value *value,
int offset, int length);
/* Mark VALUE's content bits starting at OFFSET and extending for
LENGTH bits as optimized out. */
extern void mark_value_bits_optimized_out (struct value *value,
LONGEST offset, LONGEST length);
/* Set COMPONENT's location as appropriate for a component of WHOLE
--- regardless of what kind of lvalue WHOLE is. */
extern void set_value_component_location (struct value *component,
@ -877,42 +907,6 @@ extern struct value *coerce_ref (struct value *value);
extern struct value *coerce_array (struct value *value);
/* Given a value, determine whether the contents bytes starting at
OFFSET and extending for LENGTH bytes are available. This returns
nonzero if all bytes in the given range are available, zero if any
byte is unavailable. */
extern int value_bytes_available (const struct value *value,
LONGEST offset, ULONGEST length);
/* Given a value, determine whether the contents bits starting at
OFFSET and extending for LENGTH bits are available. This returns
nonzero if all bits in the given range are available, zero if any
bit is unavailable. */
extern int value_bits_available (const struct value *value,
LONGEST offset, ULONGEST length);
/* Like value_bytes_available, but return false if any byte in the
whole object is unavailable. */
extern int value_entirely_available (struct value *value);
/* Like value_entirely_available, but return false if any byte in the
whole object is available. */
extern int value_entirely_unavailable (struct value *value);
/* Mark VALUE's content bytes starting at OFFSET and extending for
LENGTH bytes as unavailable. */
extern void mark_value_bytes_unavailable (struct value *value,
LONGEST offset, ULONGEST length);
/* Mark VALUE's content bits starting at OFFSET and extending for
LENGTH bits as unavailable. */
extern void mark_value_bits_unavailable (struct value *value,
LONGEST offset, ULONGEST length);
/* Read LENGTH addressable memory units starting at MEMADDR into BUFFER,
which is (or will be copied to) VAL's contents buffer offset by
BIT_OFFSET bits. Marks value contents ranges as unavailable if