From: Tom Tromey Date: Tue, 31 Jan 2023 23:23:22 +0000 (-0700) Subject: Turn value_non_lval and value_force_lval into methods X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=aa9f4538ccbed2b5a84ece57c047e4f68a38c69e;p=binutils-gdb.git Turn value_non_lval and value_force_lval into methods This changes value_non_lval and value_force_lval to be methods of value. Approved-By: Simon Marchi --- diff --git a/gdb/eval.c b/gdb/eval.c index dca98d07fbe..808cc916bb4 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -111,7 +111,7 @@ expression::evaluate (struct type *expect_type, enum noside noside) if (stack_temporaries.has_value () && value_in_thread_stack_temporaries (retval, inferior_thread ())) - retval = value_non_lval (retval); + retval = retval->non_lval (); return retval; } @@ -1820,7 +1820,7 @@ eval_op_postinc (struct type *expect_type, struct expression *exp, } else { - struct value *arg3 = value_non_lval (arg1); + struct value *arg3 = arg1->non_lval (); struct value *arg2; if (ptrmath_type_p (exp->language_defn, arg1->type ())) @@ -1854,7 +1854,7 @@ eval_op_postdec (struct type *expect_type, struct expression *exp, } else { - struct value *arg3 = value_non_lval (arg1); + struct value *arg3 = arg1->non_lval (); struct value *arg2; if (ptrmath_type_p (exp->language_defn, arg1->type ())) diff --git a/gdb/infcall.c b/gdb/infcall.c index d6992228498..81a073d2123 100644 --- a/gdb/infcall.c +++ b/gdb/infcall.c @@ -492,7 +492,7 @@ get_call_return_value (struct call_return_meta_info *ri) requiring GDB to evaluate the "this" pointer. To evaluate the this pointer, GDB needs the memory address of the value. */ - value_force_lval (retval, ri->struct_addr); + retval->force_lval (ri->struct_addr); push_thread_stack_temporary (thr, retval); } } diff --git a/gdb/value.c b/gdb/value.c index beda62d630f..15bf84c7a9d 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -1567,35 +1567,35 @@ make_cv_value (int cnst, int voltl, struct value *v) return cv_val; } -/* Return a version of ARG that is non-lvalue. */ +/* See value.h. */ struct value * -value_non_lval (struct value *arg) +value::non_lval () { - if (VALUE_LVAL (arg) != not_lval) + if (VALUE_LVAL (this) != not_lval) { - struct type *enc_type = arg->enclosing_type (); + struct type *enc_type = enclosing_type (); struct value *val = value::allocate (enc_type); - gdb::copy (arg->contents_all (), val->contents_all_raw ()); - val->m_type = arg->m_type; - val->set_embedded_offset (arg->embedded_offset ()); - val->set_pointed_to_offset (arg->pointed_to_offset ()); + gdb::copy (contents_all (), val->contents_all_raw ()); + val->m_type = m_type; + val->set_embedded_offset (embedded_offset ()); + val->set_pointed_to_offset (pointed_to_offset ()); return val; } - return arg; + return this; } -/* Write contents of V at ADDR and set its lval type to be LVAL_MEMORY. */ +/* See value.h. */ void -value_force_lval (struct value *v, CORE_ADDR addr) +value::force_lval (CORE_ADDR addr) { - gdb_assert (VALUE_LVAL (v) == not_lval); + gdb_assert (VALUE_LVAL (this) == not_lval); - write_memory (addr, v->contents_raw ().data (), v->type ()->length ()); - v->m_lval = lval_memory; - v->m_location.address = addr; + write_memory (addr, contents_raw ().data (), type ()->length ()); + m_lval = lval_memory; + m_location.address = addr; } void diff --git a/gdb/value.h b/gdb/value.h index 4ecaeb7c607..6cc845c42b8 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -532,6 +532,13 @@ public: for LENGTH bits as optimized out. */ void mark_bits_optimized_out (LONGEST offset, LONGEST length); + /* Return a version of this that is non-lvalue. */ + struct value *non_lval (); + + /* Write contents of this value at ADDR and set its lval type to be + LVAL_MEMORY. */ + void force_lval (CORE_ADDR); + /* Type of value; either not an lval, or one of the various different possible kinds of lval. */ @@ -1446,10 +1453,6 @@ extern void preserve_values (struct objfile *); /* From values.c */ -extern struct value *value_non_lval (struct value *); - -extern void value_force_lval (struct value *, CORE_ADDR); - extern struct value *make_cv_value (int, int, struct value *); extern void preserve_one_value (struct value *, struct objfile *, htab_t);