diff options
author | Tom Tromey <tom@tromey.com> | 2023-01-31 16:23:22 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2023-02-13 15:22:17 -0700 |
commit | aa9f4538ccbed2b5a84ece57c047e4f68a38c69e (patch) | |
tree | 89773923872228ec388b90f476001f51b2f7d74e | |
parent | d00664dbba2802bacfed2335b6f249fc418182a0 (diff) | |
download | gdb-aa9f4538ccbed2b5a84ece57c047e4f68a38c69e.zip gdb-aa9f4538ccbed2b5a84ece57c047e4f68a38c69e.tar.gz gdb-aa9f4538ccbed2b5a84ece57c047e4f68a38c69e.tar.bz2 |
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 <simon.marchi@efficios.com>
-rw-r--r-- | gdb/eval.c | 6 | ||||
-rw-r--r-- | gdb/infcall.c | 2 | ||||
-rw-r--r-- | gdb/value.c | 30 | ||||
-rw-r--r-- | gdb/value.h | 11 |
4 files changed, 26 insertions, 23 deletions
@@ -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 d699222..81a073d 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 beda62d..15bf84c 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 4ecaeb7..6cc845c 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); |