From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id 1788C3858D1E; Mon, 13 Feb 2023 22:30:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1788C3858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1676327427; bh=DNNf3G30pwynFL1o+YKSCvuEiXjIn3Et0oA3z0vu20k=; h=From:To:Subject:Date:From; b=NQuK3MlhqDPdbTRwvOObPQWt565uG7807NPWQUyFm/mRyP2CIYh/X76myQaTEDgfR gxtmAywP4ecCnR/q4rOfsYXa3bRNVhytUBTM+4bSEHtUqVCkPVW2Xlu9CdLKyX81wg rKjZDz4t37MpQBIIRrrM1Af263MWAY0cQEQOsy2E= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom Tromey To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Turn value_non_lval and value_force_lval into methods X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: d00664dbba2802bacfed2335b6f249fc418182a0 X-Git-Newrev: aa9f4538ccbed2b5a84ece57c047e4f68a38c69e Message-Id: <20230213223027.1788C3858D1E@sourceware.org> Date: Mon, 13 Feb 2023 22:30:27 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Daa9f4538ccbe= d2b5a84ece57c047e4f68a38c69e commit aa9f4538ccbed2b5a84ece57c047e4f68a38c69e Author: Tom Tromey Date: Tue Jan 31 16:23:22 2023 -0700 Turn value_non_lval and value_force_lval into methods =20 This changes value_non_lval and value_force_lval to be methods of value. =20 Approved-By: Simon Marchi Diff: --- gdb/eval.c | 6 +++--- gdb/infcall.c | 2 +- gdb/value.c | 30 +++++++++++++++--------------- gdb/value.h | 11 +++++++---- 4 files changed, 26 insertions(+), 23 deletions(-) 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 no= side noside) =20 if (stack_temporaries.has_value () && value_in_thread_stack_temporaries (retval, inferior_thread ())) - retval =3D value_non_lval (retval); + retval =3D retval->non_lval (); =20 return retval; } @@ -1820,7 +1820,7 @@ eval_op_postinc (struct type *expect_type, struct exp= ression *exp, } else { - struct value *arg3 =3D value_non_lval (arg1); + struct value *arg3 =3D arg1->non_lval (); struct value *arg2; =20 if (ptrmath_type_p (exp->language_defn, arg1->type ())) @@ -1854,7 +1854,7 @@ eval_op_postdec (struct type *expect_type, struct exp= ression *exp, } else { - struct value *arg3 =3D value_non_lval (arg1); + struct value *arg3 =3D arg1->non_lval (); struct value *arg2; =20 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; } =20 -/* Return a version of ARG that is non-lvalue. */ +/* See value.h. */ =20 struct value * -value_non_lval (struct value *arg) +value::non_lval () { - if (VALUE_LVAL (arg) !=3D not_lval) + if (VALUE_LVAL (this) !=3D not_lval) { - struct type *enc_type =3D arg->enclosing_type (); + struct type *enc_type =3D enclosing_type (); struct value *val =3D value::allocate (enc_type); =20 - gdb::copy (arg->contents_all (), val->contents_all_raw ()); - val->m_type =3D 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 =3D m_type; + val->set_embedded_offset (embedded_offset ()); + val->set_pointed_to_offset (pointed_to_offset ()); return val; } - return arg; + return this; } =20 -/* Write contents of V at ADDR and set its lval type to be LVAL_MEMORY. */ +/* See value.h. */ =20 void -value_force_lval (struct value *v, CORE_ADDR addr) +value::force_lval (CORE_ADDR addr) { - gdb_assert (VALUE_LVAL (v) =3D=3D not_lval); + gdb_assert (VALUE_LVAL (this) =3D=3D not_lval); =20 - write_memory (addr, v->contents_raw ().data (), v->type ()->length ()); - v->m_lval =3D lval_memory; - v->m_location.address =3D addr; + write_memory (addr, contents_raw ().data (), type ()->length ()); + m_lval =3D lval_memory; + m_location.address =3D addr; } =20 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); =20 + /* 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); + =20 /* 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 *); =20 /* From values.c */ =20 -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 *); =20 extern void preserve_one_value (struct value *, struct objfile *, htab_t);