diff options
author | Tom Tromey <tom@tromey.com> | 2023-02-09 06:55:48 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2023-02-13 15:22:20 -0700 |
commit | 736355f2e186a6a5275cac26d9486a5cc28f755c (patch) | |
tree | 5a528ef4fc5572a7f05b366624faa4905bde41b1 | |
parent | 6f9c9d71c2420e9bc6825cef59a922f5fb863e1a (diff) | |
download | gdb-736355f2e186a6a5275cac26d9486a5cc28f755c.zip gdb-736355f2e186a6a5275cac26d9486a5cc28f755c.tar.gz gdb-736355f2e186a6a5275cac26d9486a5cc28f755c.tar.bz2 |
Remove deprecated_lval_hack
This removes deprecated_lval_hack and the VALUE_LVAL macro, replacing
all uses with a call to value::lval.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
-rw-r--r-- | gdb/ada-lang.c | 28 | ||||
-rw-r--r-- | gdb/breakpoint.c | 8 | ||||
-rw-r--r-- | gdb/c-lang.c | 6 | ||||
-rw-r--r-- | gdb/cli/cli-dump.c | 2 | ||||
-rw-r--r-- | gdb/compile/compile-c-symbols.c | 2 | ||||
-rw-r--r-- | gdb/compile/compile-cplus-symbols.c | 2 | ||||
-rw-r--r-- | gdb/compile/compile-loc2c.c | 2 | ||||
-rw-r--r-- | gdb/dwarf2/frame.c | 2 | ||||
-rw-r--r-- | gdb/dwarf2/loc.c | 6 | ||||
-rw-r--r-- | gdb/eval.c | 12 | ||||
-rw-r--r-- | gdb/expop.h | 2 | ||||
-rw-r--r-- | gdb/f-lang.c | 8 | ||||
-rw-r--r-- | gdb/findvar.c | 2 | ||||
-rw-r--r-- | gdb/frame.c | 8 | ||||
-rw-r--r-- | gdb/gdbtypes.c | 2 | ||||
-rw-r--r-- | gdb/infcall.c | 2 | ||||
-rw-r--r-- | gdb/m2-lang.c | 2 | ||||
-rw-r--r-- | gdb/opencl-lang.c | 6 | ||||
-rw-r--r-- | gdb/ppc-linux-nat.c | 8 | ||||
-rw-r--r-- | gdb/printcmd.c | 8 | ||||
-rw-r--r-- | gdb/python/py-unwind.c | 2 | ||||
-rw-r--r-- | gdb/rust-lang.c | 4 | ||||
-rw-r--r-- | gdb/stack.c | 6 | ||||
-rw-r--r-- | gdb/valarith.c | 14 | ||||
-rw-r--r-- | gdb/valops.c | 34 | ||||
-rw-r--r-- | gdb/value.c | 44 | ||||
-rw-r--r-- | gdb/value.h | 10 | ||||
-rw-r--r-- | gdb/varobj.c | 2 |
28 files changed, 112 insertions, 122 deletions
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 1fd424c..ec85729 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -559,7 +559,7 @@ coerce_unspec_val_to_type (struct value *val, struct type *type) result = value::allocate_optimized_out (type); else if (val->lazy () /* Be careful not to make a lazy not_lval value. */ - || (VALUE_LVAL (val) != not_lval + || (val->lval () != not_lval && type->length () > val->type ()->length ())) result = value::allocate_lazy (type); else @@ -570,7 +570,7 @@ coerce_unspec_val_to_type (struct value *val, struct type *type) result->set_component_location (val); result->set_bitsize (val->bitsize ()); result->set_bitpos (val->bitpos ()); - if (VALUE_LVAL (result) == lval_memory) + if (result->lval () == lval_memory) result->set_address (val->address ()); return result; } @@ -2810,7 +2810,7 @@ ada_value_primitive_packed_val (struct value *obj, const gdb_byte *valaddr, v = value::allocate (type); src = valaddr + offset; } - else if (VALUE_LVAL (obj) == lval_memory && obj->lazy ()) + else if (obj->lval () == lval_memory && obj->lazy ()) { int src_len = (bit_size + bit_offset + HOST_CHAR_BIT - 1) / 8; gdb_byte *buf; @@ -2891,7 +2891,7 @@ ada_value_assign (struct value *toval, struct value *fromval) if (!toval->deprecated_modifiable ()) error (_("Left operand of assignment is not a modifiable lvalue.")); - if (VALUE_LVAL (toval) == lval_memory + if (toval->lval () == lval_memory && bits > 0 && (type->code () == TYPE_CODE_FLT || type->code () == TYPE_CODE_STRUCT)) @@ -4349,8 +4349,8 @@ ada_read_renaming_var_value (struct symbol *renaming_sym, static struct value * ensure_lval (struct value *val) { - if (VALUE_LVAL (val) == not_lval - || VALUE_LVAL (val) == lval_internalvar) + if (val->lval () == not_lval + || val->lval () == lval_internalvar) { int len = ada_check_typedef (val->type ())->length (); const CORE_ADDR addr = @@ -4523,7 +4523,7 @@ ada_convert_actual (struct value *actual, struct type *formal_type0) result = desc_data (actual); else if (formal_type->code () != TYPE_CODE_PTR) { - if (VALUE_LVAL (actual) != lval_memory) + if (actual->lval () != lval_memory) { struct value *val; @@ -8841,7 +8841,7 @@ ada_to_fixed_value_create (struct type *type0, CORE_ADDR address, if (type == type0 && val0 != NULL) return val0; - if (VALUE_LVAL (val0) != lval_memory) + if (val0->lval () != lval_memory) { /* Our value does not live in memory; it could be a convenience variable, for instance. Create a not_lval value using val0's @@ -9771,12 +9771,12 @@ ada_assign_operation::evaluate (struct type *expect_type, In the case of assigning to a convenience variable, the lhs should be exactly the result of the evaluation of the rhs. */ struct type *type = arg1->type (); - if (VALUE_LVAL (arg1) == lval_internalvar) + if (arg1->lval () == lval_internalvar) type = NULL; value *arg2 = std::get<1> (m_storage)->evaluate (type, exp, noside); if (noside == EVAL_AVOID_SIDE_EFFECTS) return arg1; - if (VALUE_LVAL (arg1) == lval_internalvar) + if (arg1->lval () == lval_internalvar) { /* Nothing. */ } @@ -10279,7 +10279,7 @@ ada_ternop_slice (struct expression *exp, convert to a pointer. */ if (array->type ()->code () == TYPE_CODE_REF || (array->type ()->code () == TYPE_CODE_ARRAY - && VALUE_LVAL (array) == lval_memory)) + && array->lval () == lval_memory)) array = value_addr (array); if (noside == EVAL_AVOID_SIDE_EFFECTS @@ -10850,7 +10850,7 @@ ada_var_msym_value_operation::evaluate_for_cast (struct type *expect_type, /* Follow the Ada language semantics that do not allow taking an address of the result of a cast (view conversion in Ada). */ - if (VALUE_LVAL (val) == lval_memory) + if (val->lval () == lval_memory) { if (val->lazy ()) val->fetch_lazy (); @@ -10872,7 +10872,7 @@ ada_var_value_operation::evaluate_for_cast (struct type *expect_type, /* Follow the Ada language semantics that do not allow taking an address of the result of a cast (view conversion in Ada). */ - if (VALUE_LVAL (val) == lval_memory) + if (val->lval () == lval_memory) { if (val->lazy ()) val->fetch_lazy (); @@ -11169,7 +11169,7 @@ ada_funcall_operation::evaluate (struct type *expect_type, callee = ada_to_fixed_value (coerce_ref (callee)); } else if (callee->type ()->code () == TYPE_CODE_ARRAY - && VALUE_LVAL (callee) == lval_memory) + && callee->lval () == lval_memory) callee = value_addr (callee); struct type *type = ada_check_typedef (callee->type ()); diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 62ef310..ebb2843 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -2074,7 +2074,7 @@ update_watchpoint (struct watchpoint *b, bool reparse) must watch it. If the first value returned is still lazy, that means an error occurred reading it; watch it anyway in case it becomes readable. */ - if (VALUE_LVAL (v) == lval_memory + if (v->lval () == lval_memory && (v == val_chain[0] || ! v->lazy ())) { struct type *vtype = check_typedef (v->type ()); @@ -10412,7 +10412,7 @@ can_use_hardware_watchpoint (const std::vector<value_ref_ptr> &vals) { struct value *v = iter.get (); - if (VALUE_LVAL (v) == lval_memory) + if (v->lval () == lval_memory) { if (v != head && v->lazy ()) /* A lazy memory lvalue in the chain is one that GDB never @@ -10450,10 +10450,10 @@ can_use_hardware_watchpoint (const std::vector<value_ref_ptr> &vals) } } } - else if (VALUE_LVAL (v) != not_lval + else if (v->lval () != not_lval && v->deprecated_modifiable () == 0) return 0; /* These are values from the history (e.g., $1). */ - else if (VALUE_LVAL (v) == lval_register) + else if (v->lval () == lval_register) return 0; /* Cannot watch a register with a HW watchpoint. */ } diff --git a/gdb/c-lang.c b/gdb/c-lang.c index e4027d8..6535ab9 100644 --- a/gdb/c-lang.c +++ b/gdb/c-lang.c @@ -294,8 +294,8 @@ c_get_string (struct value *value, gdb::unique_xmalloc_ptr<gdb_byte> *buffer, C struct hack. So, only do this if either no length was specified, or the length is within the existing bounds. This avoids running off the end of the value's contents. */ - if ((VALUE_LVAL (value) == not_lval - || VALUE_LVAL (value) == lval_internalvar + if ((value->lval () == not_lval + || value->lval () == lval_internalvar || type->code () == TYPE_CODE_ARRAY) && fetchlimit != UINT_MAX && (*length < 0 || *length <= fetchlimit)) @@ -328,7 +328,7 @@ c_get_string (struct value *value, gdb::unique_xmalloc_ptr<gdb_byte> *buffer, CORE_ADDR addr; if (type->code () == TYPE_CODE_ARRAY) { - if (VALUE_LVAL (value) != lval_memory) + if (value->lval () != lval_memory) error (_("Attempt to take address of value " "not located in memory.")); addr = value->address (); diff --git a/gdb/cli/cli-dump.c b/gdb/cli/cli-dump.c index 769f6a5..08984f6 100644 --- a/gdb/cli/cli-dump.c +++ b/gdb/cli/cli-dump.c @@ -230,7 +230,7 @@ dump_value_to_file (const char *cmd, const char *mode, const char *file_format) { CORE_ADDR vaddr; - if (VALUE_LVAL (val)) + if (val->lval ()) { vaddr = val->address (); } diff --git a/gdb/compile/compile-c-symbols.c b/gdb/compile/compile-c-symbols.c index 5b53ab3..6faff0e 100644 --- a/gdb/compile/compile-c-symbols.c +++ b/gdb/compile/compile-c-symbols.c @@ -156,7 +156,7 @@ convert_one_symbol (compile_c_instance *context, } val = read_var_value (sym.symbol, sym.block, frame); - if (VALUE_LVAL (val) != lval_memory) + if (val->lval () != lval_memory) error (_("Symbol \"%s\" cannot be used for compilation " "evaluation as its address has not been found."), sym.symbol->print_name ()); diff --git a/gdb/compile/compile-cplus-symbols.c b/gdb/compile/compile-cplus-symbols.c index 2844777..039aee3 100644 --- a/gdb/compile/compile-cplus-symbols.c +++ b/gdb/compile/compile-cplus-symbols.c @@ -150,7 +150,7 @@ convert_one_symbol (compile_cplus_instance *instance, } val = read_var_value (sym.symbol, sym.block, frame); - if (VALUE_LVAL (val) != lval_memory) + if (val->lval () != lval_memory) error (_("Symbol \"%s\" cannot be used for compilation " "evaluation as its address has not been found."), sym.symbol->print_name ()); diff --git a/gdb/compile/compile-loc2c.c b/gdb/compile/compile-loc2c.c index ae30dd6..558460a 100644 --- a/gdb/compile/compile-loc2c.c +++ b/gdb/compile/compile-loc2c.c @@ -642,7 +642,7 @@ do_compile_dwarf_expr_to_c (int indent, string_file *stream, sym->print_name ()); val = read_var_value (sym, NULL, frame); - if (VALUE_LVAL (val) != lval_memory) + if (val->lval () != lval_memory) error (_("Symbol \"%s\" cannot be used for compilation evaluation " "as its address has not been found."), sym->print_name ()); diff --git a/gdb/dwarf2/frame.c b/gdb/dwarf2/frame.c index a83df21..a561aaf 100644 --- a/gdb/dwarf2/frame.c +++ b/gdb/dwarf2/frame.c @@ -235,7 +235,7 @@ execute_stack_op (const gdb_byte *exp, ULONGEST len, int addr_size, ctx.push_address (initial, initial_in_stack_memory); value *result_val = ctx.evaluate (exp, len, true, nullptr, this_frame); - if (VALUE_LVAL (result_val) == lval_memory) + if (result_val->lval () == lval_memory) return result_val->address (); else return value_as_address (result_val); diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c index 616db13..27c4b7c 100644 --- a/gdb/dwarf2/loc.c +++ b/gdb/dwarf2/loc.c @@ -684,7 +684,7 @@ call_site_target::iterate_over_addresses dwarf_block->per_cu, dwarf_block->per_objfile); /* DW_AT_call_target is a DWARF expression, not a DWARF location. */ - if (VALUE_LVAL (val) == lval_memory) + if (val->lval () == lval_memory) callback (val->address ()); else callback (value_as_address (val)); @@ -1612,11 +1612,11 @@ dwarf2_locexpr_baton_eval (const struct dwarf2_locexpr_baton *dlbaton, if (result->optimized_out ()) return 0; - if (VALUE_LVAL (result) == lval_memory) + if (result->lval () == lval_memory) *valp = result->address (); else { - if (VALUE_LVAL (result) == not_lval) + if (result->lval () == not_lval) *is_reference = false; *valp = value_as_address (result); @@ -1224,7 +1224,7 @@ eval_op_structop_struct (struct type *expect_type, struct expression *exp, struct value *arg3 = value_struct_elt (&arg1, {}, string, NULL, "structure"); if (noside == EVAL_AVOID_SIDE_EFFECTS) - arg3 = value::zero (arg3->type (), VALUE_LVAL (arg3)); + arg3 = value::zero (arg3->type (), arg3->lval ()); return arg3; } @@ -1280,7 +1280,7 @@ eval_op_structop_ptr (struct type *expect_type, struct expression *exp, struct value *arg3 = value_struct_elt (&arg1, {}, string, NULL, "structure pointer"); if (noside == EVAL_AVOID_SIDE_EFFECTS) - arg3 = value::zero (arg3->type (), VALUE_LVAL (arg3)); + arg3 = value::zero (arg3->type (), arg3->lval ()); return arg3; } @@ -1447,7 +1447,7 @@ eval_op_subscript (struct type *expect_type, struct expression *exp, } if (noside == EVAL_AVOID_SIDE_EFFECTS) - return value::zero (type->target_type (), VALUE_LVAL (arg1)); + return value::zero (type->target_type (), arg1->lval ()); else return value_subscript (arg1, value_as_long (arg2)); } @@ -2590,7 +2590,7 @@ evaluate_subexp_for_address_base (struct expression *exp, enum noside noside, if (TYPE_IS_REFERENCE (type)) return value::zero (lookup_pointer_type (type->target_type ()), not_lval); - else if (VALUE_LVAL (x) == lval_memory || value_must_coerce_to_target (x)) + else if (x->lval () == lval_memory || value_must_coerce_to_target (x)) return value::zero (lookup_pointer_type (x->type ()), not_lval); else @@ -2875,7 +2875,7 @@ var_msym_value_operation::evaluate_for_cast (struct type *to_type, val = value_cast (to_type, val); /* Don't allow e.g. '&(int)var_with_no_debug_info'. */ - if (VALUE_LVAL (val) == lval_memory) + if (val->lval () == lval_memory) { if (val->lazy ()) val->fetch_lazy (); @@ -2896,7 +2896,7 @@ var_value_operation::evaluate_for_cast (struct type *to_type, val = value_cast (to_type, val); /* Don't allow e.g. '&(int)var_with_no_debug_info'. */ - if (VALUE_LVAL (val) == lval_memory) + if (val->lval () == lval_memory) { if (val->lazy ()) val->fetch_lazy (); diff --git a/gdb/expop.h b/gdb/expop.h index e534747..d973d23 100644 --- a/gdb/expop.h +++ b/gdb/expop.h @@ -1889,7 +1889,7 @@ public: expected type. This avoids a weird case where re-assigning a string or array to an internal variable could error with "Too many array elements". */ - struct type *xtype = (VALUE_LVAL (lhs) == lval_internalvar + struct type *xtype = (lhs->lval () == lval_internalvar ? nullptr : lhs->type ()); value *rhs = std::get<1> (m_storage)->evaluate (xtype, exp, noside); diff --git a/gdb/f-lang.c b/gdb/f-lang.c index d935f59..0d7863e 100644 --- a/gdb/f-lang.c +++ b/gdb/f-lang.c @@ -1363,7 +1363,7 @@ fortran_undetermined::value_subarray (value *array, if (index < lb || (dim_type->index_type ()->bounds ()->high.kind () != PROP_UNDEFINED && index > ub) - || (VALUE_LVAL (array) != lval_memory + || (array->lval () != lval_memory && dim_type->index_type ()->bounds ()->high.kind () == PROP_UNDEFINED)) { if (type_not_associated (dim_type)) @@ -1460,7 +1460,7 @@ fortran_undetermined::value_subarray (value *array, } else { - if (VALUE_LVAL (array) == lval_memory) + if (array->lval () == lval_memory) { /* If the value we're taking a slice from is not yet loaded, or the requested slice is outside the values content range then @@ -1637,7 +1637,7 @@ fortran_structop_operation::evaluate (struct type *expect_type, = gdb::make_array_view (valaddr, elt_type->length ()); elt_type = resolve_dynamic_type (elt_type, view, address); } - elt = value::zero (elt_type, VALUE_LVAL (elt)); + elt = value::zero (elt_type, elt->lval ()); } return elt; @@ -1872,7 +1872,7 @@ fortran_argument_convert (struct value *value, bool is_artificial) { /* If the value is not in the inferior e.g. registers values, convenience variables and user input. */ - if (VALUE_LVAL (value) != lval_memory) + if (value->lval () != lval_memory) { struct type *type = value->type (); const int length = type->length (); diff --git a/gdb/findvar.c b/gdb/findvar.c index 37ae518..7006500 100644 --- a/gdb/findvar.c +++ b/gdb/findvar.c @@ -846,7 +846,7 @@ read_frame_register_value (struct value *value, frame_info_ptr frame) int regnum = VALUE_REGNUM (value); int len = type_length_units (check_typedef (value->type ())); - gdb_assert (VALUE_LVAL (value) == lval_register); + gdb_assert (value->lval () == lval_register); /* Skip registers wholly inside of REG_OFFSET. */ while (reg_offset >= register_size (gdbarch, regnum)) diff --git a/gdb/frame.c b/gdb/frame.c index bf9b055..be4c58e 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -930,7 +930,7 @@ frame_find_by_id (struct frame_id id) and get_prev_frame performs a series of checks that are relatively expensive). This optimization is particularly useful when this function is called from another function (such as value_fetch_lazy, case - VALUE_LVAL (val) == lval_register) which already loops over all frames, + val->lval () == lval_register) which already loops over all frames, making the overall behavior O(n^2). */ frame = frame_stash_find (id); if (frame) @@ -1191,7 +1191,7 @@ frame_register_unwind (frame_info_ptr next_frame, int regnum, *optimizedp = value->optimized_out (); *unavailablep = !value->entirely_available (); - *lvalp = VALUE_LVAL (value); + *lvalp = value->lval (); *addrp = value->address (); if (*lvalp == lval_register) *realnump = VALUE_REGNUM (value); @@ -1296,10 +1296,10 @@ frame_unwind_register_value (frame_info_ptr next_frame, int regnum) } else { - if (VALUE_LVAL (value) == lval_register) + if (value->lval () == lval_register) gdb_printf (&debug_file, " register=%d", VALUE_REGNUM (value)); - else if (VALUE_LVAL (value) == lval_memory) + else if (value->lval () == lval_memory) gdb_printf (&debug_file, " address=%s", paddress (gdbarch, value->address ())); diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 73ccd1c..f22ba44 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -4908,7 +4908,7 @@ rank_one_type (struct type *parm, struct type *arg, struct value *value) if (TYPE_IS_REFERENCE (parm) && value != NULL) { - if (VALUE_LVAL (value) == not_lval) + if (value->lval () == not_lval) { /* Rvalues should preferably bind to rvalue references or const lvalue references. */ diff --git a/gdb/infcall.c b/gdb/infcall.c index 81a073d..9ed17bf 100644 --- a/gdb/infcall.c +++ b/gdb/infcall.c @@ -343,7 +343,7 @@ find_function_addr (struct value *function, int found_descriptor = 0; funaddr = 0; /* pacify "gcc -Werror" */ - if (VALUE_LVAL (function) == lval_memory) + if (function->lval () == lval_memory) { CORE_ADDR nfunaddr; diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c index ffa2faa..72d0b58 100644 --- a/gdb/m2-lang.c +++ b/gdb/m2-lang.c @@ -104,7 +104,7 @@ eval_op_m2_subscript (struct type *expect_type, struct expression *exp, } if (noside == EVAL_AVOID_SIDE_EFFECTS) - return value::zero (type->target_type (), VALUE_LVAL (arg1)); + return value::zero (type->target_type (), arg1->lval ()); else return value_subscript (arg1, value_as_long (arg2)); } diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c index b3e82f4..3e4a9c3 100644 --- a/gdb/opencl-lang.c +++ b/gdb/opencl-lang.c @@ -300,7 +300,7 @@ create_value (struct gdbarch *gdbarch, struct value *val, enum noside noside, else { /* Check whether to create a lvalue or not. */ - if (VALUE_LVAL (val) != not_lval && !array_has_dups (indices, n)) + if (val->lval () != not_lval && !array_has_dups (indices, n)) { struct lval_closure *c = allocate_lval_closure (indices, n, val); ret = value::allocate_computed (dst_type, &opencl_value_funcs, c); @@ -687,7 +687,7 @@ eval_opencl_assign (struct type *expect_type, struct expression *exp, struct type *type1 = arg1->type (); if (arg1->deprecated_modifiable () - && VALUE_LVAL (arg1) != lval_internalvar) + && arg1->lval () != lval_internalvar) arg2 = opencl_value_cast (type1, arg2); return value_assign (arg1, arg2); @@ -714,7 +714,7 @@ opencl_structop_operation::evaluate (struct type *expect_type, NULL, "structure"); if (noside == EVAL_AVOID_SIDE_EFFECTS) - v = value::zero (v->type (), VALUE_LVAL (v)); + v = value::zero (v->type (), v->lval ()); return v; } } diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c index 6d4bf2c..e4fcce6 100644 --- a/gdb/ppc-linux-nat.c +++ b/gdb/ppc-linux-nat.c @@ -2455,9 +2455,9 @@ ppc_linux_nat_target::num_memory_accesses (const std::vector<value_ref_ptr> struct value *v = iter.get (); /* Constants and values from the history are fine. */ - if (VALUE_LVAL (v) == not_lval || v->->deprecated_modifiable () == 0) + if (v->lval () == not_lval || v->->deprecated_modifiable () == 0) continue; - else if (VALUE_LVAL (v) == lval_memory) + else if (v->lval () == lval_memory) { /* A lazy memory lvalue is one that GDB never needed to fetch; we either just used its address (e.g., `a' in `a.b') or @@ -2509,7 +2509,7 @@ ppc_linux_nat_target::check_condition (CORE_ADDR watch_addr, return 0; if (num_accesses_left == 1 && num_accesses_right == 0 - && VALUE_LVAL (left_val) == lval_memory + && left_val->lval () == lval_memory && left_val->address () == watch_addr) { *data_value = value_as_long (right_val); @@ -2519,7 +2519,7 @@ ppc_linux_nat_target::check_condition (CORE_ADDR watch_addr, *len = check_typedef (left_val->type ())->length (); } else if (num_accesses_left == 0 && num_accesses_right == 1 - && VALUE_LVAL (right_val) == lval_memory + && right_val->lval () == lval_memory && right_val->address () == watch_addr) { *data_value = value_as_long (left_val); diff --git a/gdb/printcmd.c b/gdb/printcmd.c index 58047c7..13945ab 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -297,7 +297,7 @@ print_formatted (struct value *val, int size, struct type *type = check_typedef (val->type ()); int len = type->length (); - if (VALUE_LVAL (val) == lval_memory) + if (val->lval () == lval_memory) next_address = val->address () + len; if (size) @@ -1904,7 +1904,7 @@ x_command (const char *exp, int from_tty) /* In rvalue contexts, such as this, functions are coerced into pointers to functions. This makes "x/i main" work. */ if (val->type ()->code () == TYPE_CODE_FUNC - && VALUE_LVAL (val) == lval_memory) + && val->lval () == lval_memory) next_address = val->address (); else next_address = value_as_address (val); @@ -2446,7 +2446,7 @@ printf_c_string (struct ui_file *stream, const char *format, const gdb_byte *str; if (value->type ()->code () != TYPE_CODE_PTR - && VALUE_LVAL (value) == lval_internalvar + && value->lval () == lval_internalvar && c_is_string_type_p (value->type ())) { size_t len = value->type ()->length (); @@ -2518,7 +2518,7 @@ printf_wide_c_string (struct ui_file *stream, const char *format, "wchar_t", NULL, 0); int wcwidth = wctype->length (); - if (VALUE_LVAL (value) == lval_internalvar + if (value->lval () == lval_internalvar && c_is_string_type_p (value->type ())) { str = value->contents ().data (); diff --git a/gdb/python/py-unwind.c b/gdb/python/py-unwind.c index 97b472f..5b512c9 100644 --- a/gdb/python/py-unwind.c +++ b/gdb/python/py-unwind.c @@ -272,7 +272,7 @@ unwind_infopy_add_saved_register (PyObject *self, PyObject *args) { struct value *user_reg_value = value_of_user_reg (regnum, pending_frame->frame_info); - if (VALUE_LVAL (user_reg_value) == lval_register) + if (user_reg_value->lval () == lval_register) regnum = VALUE_REGNUM (user_reg_value); if (regnum >= gdbarch_num_cooked_regs (pending_frame->gdbarch)) { diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index 27b5928..fb9db9f 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -1204,7 +1204,7 @@ rust_subscript (struct type *expect_type, struct expression *exp, else new_type = base_type; - return value::zero (new_type, VALUE_LVAL (lhs)); + return value::zero (new_type, lhs->lval ()); } else { @@ -1470,7 +1470,7 @@ rust_structop::evaluate (struct type *expect_type, else result = value_struct_elt (&lhs, {}, field_name, NULL, "structure"); if (noside == EVAL_AVOID_SIDE_EFFECTS) - result = value::zero (result->type (), VALUE_LVAL (result)); + result = value::zero (result->type (), result->lval ()); return result; } diff --git a/gdb/stack.c b/gdb/stack.c index 934220e..a26f65a 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -1710,7 +1710,7 @@ info_frame_command_core (frame_info_ptr fi, bool selected_frame_p) if (!value->optimized_out () && value->entirely_available ()) { - if (VALUE_LVAL (value) == not_lval) + if (value->lval () == not_lval) { CORE_ADDR sp; enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); @@ -1723,13 +1723,13 @@ info_frame_command_core (frame_info_ptr fi, bool selected_frame_p) gdb_puts (paddress (gdbarch, sp)); gdb_printf ("\n"); } - else if (VALUE_LVAL (value) == lval_memory) + else if (value->lval () == lval_memory) { gdb_printf (" Previous frame's sp at "); gdb_puts (paddress (gdbarch, value->address ())); gdb_printf ("\n"); } - else if (VALUE_LVAL (value) == lval_register) + else if (value->lval () == lval_register) { gdb_printf (" Previous frame's sp in %s\n", gdbarch_register_name (gdbarch, diff --git a/gdb/valarith.c b/gdb/valarith.c index 427cafd..0ab684a 100644 --- a/gdb/valarith.c +++ b/gdb/valarith.c @@ -93,7 +93,7 @@ value_ptradd (struct value *arg1, LONGEST arg2) result = value_from_pointer (valptrtype, value_as_address (arg1) + sz * arg2); - if (VALUE_LVAL (result) != lval_internalvar) + if (result->lval () != lval_internalvar) result->set_component_location (arg1); return result; } @@ -159,7 +159,7 @@ value_subscript (struct value *array, LONGEST index) if (!lowerbound.has_value ()) lowerbound = 0; - if (VALUE_LVAL (array) != lval_memory) + if (array->lval () != lval_memory) return value_subscripted_rvalue (array, index, *lowerbound); gdb::optional<LONGEST> upperbound @@ -235,7 +235,7 @@ value_subscripted_rvalue (struct value *array, LONGEST index, if (index < lowerbound || (!array_upper_bound_undefined && elt_offs >= type_length_units (array_type)) - || (VALUE_LVAL (array) != lval_memory && array_upper_bound_undefined)) + || (array->lval () != lval_memory && array_upper_bound_undefined)) { if (type_not_associated (array_type)) error (_("no such vector element (vector not associated)")); @@ -532,7 +532,7 @@ value_x_binop (struct value *arg1, struct value *arg2, enum exp_opcode op, if (return_type == NULL) error (_("Xmethod is missing return type.")); - return value::zero (return_type, VALUE_LVAL (arg1)); + return value::zero (return_type, arg1->lval ()); } return argvec[0]->call_xmethod (argvec.slice (1)); } @@ -541,7 +541,7 @@ value_x_binop (struct value *arg1, struct value *arg2, enum exp_opcode op, struct type *return_type; return_type = check_typedef (argvec[0]->type ())->target_type (); - return value::zero (return_type, VALUE_LVAL (arg1)); + return value::zero (return_type, arg1->lval ()); } return call_function_by_hand (argvec[0], NULL, argvec.slice (1, 2 - static_memfuncp)); @@ -645,7 +645,7 @@ value_x_unop (struct value *arg1, enum exp_opcode op, enum noside noside) if (return_type == NULL) error (_("Xmethod is missing return type.")); - return value::zero (return_type, VALUE_LVAL (arg1)); + return value::zero (return_type, arg1->lval ()); } return argvec[0]->call_xmethod (argvec[1]); } @@ -654,7 +654,7 @@ value_x_unop (struct value *arg1, enum exp_opcode op, enum noside noside) struct type *return_type; return_type = check_typedef (argvec[0]->type ())->target_type (); - return value::zero (return_type, VALUE_LVAL (arg1)); + return value::zero (return_type, arg1->lval ()); } return call_function_by_hand (argvec[0], NULL, argvec.slice (1, nargs)); diff --git a/gdb/valops.c b/gdb/valops.c index a90bcbe..3901053 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -653,7 +653,7 @@ value_cast (struct type *type, struct value *arg2) arg2->set_pointed_to_offset (0); /* pai: chk_val */ return arg2; } - else if (VALUE_LVAL (arg2) == lval_memory) + else if (arg2->lval () == lval_memory) return value_at_lazy (to_type, arg2->address ()); else { @@ -971,7 +971,7 @@ value_one (struct type *type) } /* value_one result is never used for assignments to. */ - gdb_assert (VALUE_LVAL (val) == not_lval); + gdb_assert (val->lval () == not_lval); return val; } @@ -1095,7 +1095,7 @@ value_assign (struct value *toval, struct value *fromval) toval = coerce_ref (toval); type = toval->type (); - if (VALUE_LVAL (toval) != lval_internalvar) + if (toval->lval () != lval_internalvar) fromval = value_cast (type, fromval); else { @@ -1112,7 +1112,7 @@ value_assign (struct value *toval, struct value *fromval) and then restore the new frame afterwards. */ old_frame = get_frame_id (deprecated_safe_get_selected_frame ()); - switch (VALUE_LVAL (toval)) + switch (toval->lval ()) { case lval_internalvar: set_internalvar (VALUE_INTERNALVAR (toval), fromval); @@ -1292,7 +1292,7 @@ value_assign (struct value *toval, struct value *fromval) cause the frame cache and regcache to be out of date. Assigning to memory also can. We just do this on all assignments to registers or memory, for simplicity's sake; I doubt the slowdown matters. */ - switch (VALUE_LVAL (toval)) + switch (toval->lval ()) { case lval_memory: case lval_register: @@ -1366,7 +1366,7 @@ value_repeat (struct value *arg1, int count) { struct value *val; - if (VALUE_LVAL (arg1) != lval_memory) + if (arg1->lval () != lval_memory) error (_("Only values in memory can be extended with '@'.")); if (count < 1) error (_("Invalid number %d of repetitions."), count); @@ -1406,7 +1406,7 @@ address_of_variable (struct symbol *var, const struct block *b) val = value_of_variable (var, b); type = val->type (); - if ((VALUE_LVAL (val) == lval_memory && val->lazy ()) + if ((val->lval () == lval_memory && val->lazy ()) || type->code () == TYPE_CODE_FUNC) { CORE_ADDR addr = val->address (); @@ -1415,7 +1415,7 @@ address_of_variable (struct symbol *var, const struct block *b) } /* Not a memory address; check what the problem was. */ - switch (VALUE_LVAL (val)) + switch (val->lval ()) { case lval_register: { @@ -1452,9 +1452,9 @@ value_must_coerce_to_target (struct value *val) struct type *valtype; /* The only lval kinds which do not live in target memory. */ - if (VALUE_LVAL (val) != not_lval - && VALUE_LVAL (val) != lval_internalvar - && VALUE_LVAL (val) != lval_xcallable) + if (val->lval () != not_lval + && val->lval () != lval_internalvar + && val->lval () != lval_xcallable) return false; valtype = check_typedef (val->type ()); @@ -1522,7 +1522,7 @@ value_coerce_array (struct value *arg1) be a good time to do so. */ arg1 = value_coerce_to_target (arg1); - if (VALUE_LVAL (arg1) != lval_memory) + if (arg1->lval () != lval_memory) error (_("Attempt to take address of value not located in memory.")); return value_from_pointer (lookup_pointer_type (type->target_type ()), @@ -1537,7 +1537,7 @@ value_coerce_function (struct value *arg1) { struct value *retval; - if (VALUE_LVAL (arg1) != lval_memory) + if (arg1->lval () != lval_memory) error (_("Attempt to take address of value not located in memory.")); retval = value_from_pointer (lookup_pointer_type (arg1->type ()), @@ -1586,7 +1586,7 @@ value_addr (struct value *arg1) then this would be a good time to force it to memory. */ arg1 = value_coerce_to_target (arg1); - if (VALUE_LVAL (arg1) != lval_memory) + if (arg1->lval () != lval_memory) error (_("Attempt to take address of value not located in memory.")); /* Get target memory address. */ @@ -1637,7 +1637,7 @@ value_ind (struct value *arg1) base_type = check_typedef (arg1->type ()); - if (VALUE_LVAL (arg1) == lval_computed) + if (arg1->lval () == lval_computed) { const struct lval_funcs *funcs = arg1->computed_funcs (); @@ -3963,7 +3963,7 @@ value_full_object (struct value *argp, } /* Check if object is in memory. */ - if (VALUE_LVAL (argp) != lval_memory) + if (argp->lval () != lval_memory) { warning (_("Couldn't retrieve complete object of RTTI " "type %s; object may be in register(s)."), @@ -4077,7 +4077,7 @@ value_slice (struct value *array, int lowbound, int length) slice_range_type); slice_type->set_code (array_type->code ()); - if (VALUE_LVAL (array) == lval_memory && array->lazy ()) + if (array->lval () == lval_memory && array->lazy ()) slice = value::allocate_lazy (slice_type); else { diff --git a/gdb/value.c b/gdb/value.c index 6b01d25..0adf6fa 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -149,14 +149,14 @@ static struct cmd_list_element *functionlist; value::~value () { - if (VALUE_LVAL (this) == lval_computed) + if (this->lval () == lval_computed) { const struct lval_funcs *funcs = m_location.computed.funcs; if (funcs->free_closure) funcs->free_closure (this); } - else if (VALUE_LVAL (this) == lval_xcallable) + else if (this->lval () == lval_xcallable) delete m_location.xm_worker; } @@ -1262,9 +1262,9 @@ value::optimized_out () { /* See if we can compute the result without fetching the value. */ - if (VALUE_LVAL (this) == lval_memory) + if (this->lval () == lval_memory) return false; - else if (VALUE_LVAL (this) == lval_computed) + else if (this->lval () == lval_computed) { const struct lval_funcs *funcs = m_location.computed.funcs; @@ -1515,7 +1515,7 @@ value::copy () const gdb::copy (arg_view, val_contents); } - if (VALUE_LVAL (val) == lval_computed) + if (val->lval () == lval_computed) { const struct lval_funcs *funcs = val->m_location.computed.funcs; @@ -1549,7 +1549,7 @@ make_cv_value (int cnst, int voltl, struct value *v) struct value * value::non_lval () { - if (VALUE_LVAL (this) != not_lval) + if (this->lval () != not_lval) { struct type *enc_type = enclosing_type (); struct value *val = value::allocate (enc_type); @@ -1568,7 +1568,7 @@ value::non_lval () void value::force_lval (CORE_ADDR addr) { - gdb_assert (VALUE_LVAL (this) == not_lval); + gdb_assert (this->lval () == not_lval); write_memory (addr, contents_raw ().data (), type ()->length ()); m_lval = lval_memory; @@ -1626,13 +1626,13 @@ value::set_component_location (const struct value *whole) carry around both the parent value contents, and the contents of any dynamic fields within the parent. This is a substantial change to how values work in GDB. */ - if (VALUE_LVAL (this) == lval_internalvar_component) + if (this->lval () == lval_internalvar_component) { gdb_assert (lazy ()); m_lval = lval_memory; } else - gdb_assert (VALUE_LVAL (this) == lval_memory); + gdb_assert (this->lval () == lval_memory); set_address (TYPE_DATA_LOCATION_ADDR (type)); } } @@ -2159,7 +2159,7 @@ set_internalvar (struct internalvar *var, struct value *val) break; case TYPE_CODE_INTERNAL_FUNCTION: - gdb_assert (VALUE_LVAL (val) == lval_internalvar); + gdb_assert (val->lval () == lval_internalvar); new_kind = INTERNALVAR_FUNCTION; get_internalvar_function (VALUE_INTERNALVAR (val), &new_data.fn.function); @@ -2282,7 +2282,7 @@ value_internal_function_name (struct value *val) struct internal_function *ifn; int result; - gdb_assert (VALUE_LVAL (val) == lval_internalvar); + gdb_assert (val->lval () == lval_internalvar); result = get_internalvar_function (VALUE_INTERNALVAR (val), &ifn); gdb_assert (result); @@ -2297,7 +2297,7 @@ call_internal_function (struct gdbarch *gdbarch, struct internal_function *ifn; int result; - gdb_assert (VALUE_LVAL (func) == lval_internalvar); + gdb_assert (func->lval () == lval_internalvar); result = get_internalvar_function (VALUE_INTERNALVAR (func), &ifn); gdb_assert (result); @@ -2888,7 +2888,7 @@ value::primitive_field (LONGEST offset, int fieldno, struct type *arg_type) LONGEST boffset; /* Lazy register values with offsets are not supported. */ - if (VALUE_LVAL (this) == lval_register && lazy ()) + if (this->lval () == lval_register && lazy ()) fetch_lazy (); /* We special case virtual inheritance here because this @@ -2932,7 +2932,7 @@ value::primitive_field (LONGEST offset, int fieldno, struct type *arg_type) / (HOST_CHAR_BIT * unit_size)); /* Lazy register values with offsets are not supported. */ - if (VALUE_LVAL (this) == lval_register && lazy ()) + if (this->lval () == lval_register && lazy ()) fetch_lazy (); if (lazy ()) @@ -3526,7 +3526,7 @@ value_from_component (struct value *whole, struct type *type, LONGEST offset) { struct value *v; - if (VALUE_LVAL (whole) == lval_memory && whole->lazy ()) + if (whole->lval () == lval_memory && whole->lazy ()) v = value::allocate_lazy (type); else { @@ -3761,7 +3761,7 @@ value::fetch_lazy_register () refer to the entire register. */ gdb_assert (offset () == 0); - while (VALUE_LVAL (new_val) == lval_register && new_val->lazy ()) + while (new_val->lval () == lval_register && new_val->lazy ()) { struct frame_id next_frame_id = VALUE_NEXT_FRAME_ID (new_val); @@ -3796,7 +3796,7 @@ value::fetch_lazy_register () sniffer trying to unwind), bypassing its validations. In any case, it should always be an internal error to end up in this situation. */ - if (VALUE_LVAL (new_val) == lval_register + if (new_val->lval () == lval_register && new_val->lazy () && VALUE_NEXT_FRAME_ID (new_val) == next_frame_id) internal_error (_("infinite loop while fetching a register")); @@ -3840,10 +3840,10 @@ value::fetch_lazy_register () int i; gdb::array_view<const gdb_byte> buf = new_val->contents (); - if (VALUE_LVAL (new_val) == lval_register) + if (new_val->lval () == lval_register) gdb_printf (&debug_file, " register=%d", VALUE_REGNUM (new_val)); - else if (VALUE_LVAL (new_val) == lval_memory) + else if (new_val->lval () == lval_memory) gdb_printf (&debug_file, " address=%s", paddress (gdbarch, new_val->address ())); @@ -3883,11 +3883,11 @@ value::fetch_lazy () } else if (bitsize ()) fetch_lazy_bitfield (); - else if (VALUE_LVAL (this) == lval_memory) + else if (this->lval () == lval_memory) fetch_lazy_memory (); - else if (VALUE_LVAL (this) == lval_register) + else if (this->lval () == lval_register) fetch_lazy_register (); - else if (VALUE_LVAL (this) == lval_computed + else if (this->lval () == lval_computed && computed_funcs ()->read != NULL) computed_funcs ()->read (this); else diff --git a/gdb/value.h b/gdb/value.h index 9b31511..8b45f7f 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -329,9 +329,6 @@ public: uses. */ void *computed_closure () const; - enum lval_type *deprecated_lval_hack () - { return &m_lval; } - enum lval_type lval () const { return m_lval; } @@ -952,13 +949,6 @@ struct lval_funcs extern void error_value_optimized_out (void); -/* While the following fields are per- VALUE .CONTENT .PIECE (i.e., a - single value might have multiple LVALs), this hacked interface is - limited to just the first PIECE. Expect further change. */ -/* Type of value; either not an lval, or one of the various different - possible kinds of lval. */ -#define VALUE_LVAL(val) (*((val)->deprecated_lval_hack ())) - /* Pointer to internal variable. */ #define VALUE_INTERNALVAR(val) (*((val)->deprecated_internalvar_hack ())) diff --git a/gdb/varobj.c b/gdb/varobj.c index 72d5e7f..37b64a0 100644 --- a/gdb/varobj.c +++ b/gdb/varobj.c @@ -2270,7 +2270,7 @@ varobj_editable_p (const struct varobj *var) struct type *type; if (!(var->root->is_valid && var->value != nullptr - && VALUE_LVAL (var->value.get ()))) + && var->value.get ()->lval ())) return false; type = varobj_get_value_type (var); |