From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 46/47] Introduce set_lval method on value
Date: Thu, 09 Feb 2023 14:39:07 -0700 [thread overview]
Message-ID: <20230209-submit-value-fixups-2023-v1-46-55dc2794dbb9@tromey.com> (raw)
In-Reply-To: <20230209-submit-value-fixups-2023-v1-0-55dc2794dbb9@tromey.com>
This introduces the set_lval method on value, one step toward removing
deprecated_lval_hack. Ultimately I think the goal should be for some
of these set_* methods to be replaced with constructors; but I haven't
done this, as the series is already too long. Other 'deprecated'
methods can probably be handled the same way.
---
gdb/aarch64-tdep.c | 2 +-
gdb/ada-lang.c | 6 +++---
gdb/amd64-tdep.c | 2 +-
gdb/elfread.c | 4 ++--
gdb/eval.c | 4 ++--
gdb/findvar.c | 12 ++++++------
gdb/i386-tdep.c | 2 +-
gdb/regcache.c | 2 +-
gdb/rust-lang.c | 2 +-
gdb/valops.c | 4 ++--
gdb/value.c | 20 ++++++++++----------
gdb/value.h | 4 ++++
12 files changed, 34 insertions(+), 30 deletions(-)
diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c
index fa8db9c788d..0bf6085c43a 100644
--- a/gdb/aarch64-tdep.c
+++ b/gdb/aarch64-tdep.c
@@ -2783,7 +2783,7 @@ aarch64_pseudo_read_value (struct gdbarch *gdbarch, readable_regcache *regcache,
aarch64_gdbarch_tdep *tdep = gdbarch_tdep<aarch64_gdbarch_tdep> (gdbarch);
struct value *result_value = value::allocate (register_type (gdbarch, regnum));
- VALUE_LVAL (result_value) = lval_register;
+ result_value->set_lval (lval_register);
VALUE_REGNUM (result_value) = regnum;
if (is_w_pseudo_register (gdbarch, regnum))
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index cc69281075e..1fd424c60c2 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -4356,7 +4356,7 @@ ensure_lval (struct value *val)
const CORE_ADDR addr =
value_as_long (value_allocate_space_in_inferior (len));
- VALUE_LVAL (val) = lval_memory;
+ val->set_lval (lval_memory);
val->set_address (addr);
write_memory (addr, val->contents ().data (), len);
}
@@ -10854,7 +10854,7 @@ ada_var_msym_value_operation::evaluate_for_cast (struct type *expect_type,
{
if (val->lazy ())
val->fetch_lazy ();
- VALUE_LVAL (val) = not_lval;
+ val->set_lval (not_lval);
}
return val;
}
@@ -10876,7 +10876,7 @@ ada_var_value_operation::evaluate_for_cast (struct type *expect_type,
{
if (val->lazy ())
val->fetch_lazy ();
- VALUE_LVAL (val) = not_lval;
+ val->set_lval (not_lval);
}
return val;
}
diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c
index 38440639565..9ce3e37a159 100644
--- a/gdb/amd64-tdep.c
+++ b/gdb/amd64-tdep.c
@@ -356,7 +356,7 @@ amd64_pseudo_register_read_value (struct gdbarch *gdbarch,
i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
value *result_value = value::allocate (register_type (gdbarch, regnum));
- VALUE_LVAL (result_value) = lval_register;
+ result_value->set_lval (lval_register);
VALUE_REGNUM (result_value) = regnum;
gdb_byte *buf = result_value->contents_raw ().data ();
diff --git a/gdb/elfread.c b/gdb/elfread.c
index 6107a7fac69..ca684aab57e 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -923,7 +923,7 @@ elf_gnu_ifunc_resolve_addr (struct gdbarch *gdbarch, CORE_ADDR pc)
name_at_pc = NULL;
function = value::allocate (func_func_type);
- VALUE_LVAL (function) = lval_memory;
+ function->set_lval (lval_memory);
function->set_address (pc);
/* STT_GNU_IFUNC resolver functions usually receive the HWCAP vector as
@@ -1034,7 +1034,7 @@ elf_gnu_ifunc_resolver_return_stop (code_breakpoint *b)
gdb_assert (b->loc->next == NULL);
func_func = value::allocate (func_func_type);
- VALUE_LVAL (func_func) = lval_memory;
+ func_func->set_lval (lval_memory);
func_func->set_address (b->loc->related_address);
value = value::allocate (value_type);
diff --git a/gdb/eval.c b/gdb/eval.c
index 2bff97227dd..e043991c254 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -2879,7 +2879,7 @@ var_msym_value_operation::evaluate_for_cast (struct type *to_type,
{
if (val->lazy ())
val->fetch_lazy ();
- VALUE_LVAL (val) = not_lval;
+ val->set_lval (not_lval);
}
return val;
}
@@ -2900,7 +2900,7 @@ var_value_operation::evaluate_for_cast (struct type *to_type,
{
if (val->lazy ())
val->fetch_lazy ();
- VALUE_LVAL (val) = not_lval;
+ val->set_lval (not_lval);
}
return val;
}
diff --git a/gdb/findvar.c b/gdb/findvar.c
index a82cf8c0afa..37ae518d6c4 100644
--- a/gdb/findvar.c
+++ b/gdb/findvar.c
@@ -295,7 +295,7 @@ value_of_register_lazy (frame_info_ptr frame, int regnum)
gdb_assert (frame_id_p (get_frame_id (next_frame)));
reg_val = value::allocate_lazy (register_type (gdbarch, regnum));
- VALUE_LVAL (reg_val) = lval_register;
+ reg_val->set_lval (lval_register);
VALUE_REGNUM (reg_val) = regnum;
VALUE_NEXT_FRAME_ID (reg_val) = get_frame_id (next_frame);
@@ -589,7 +589,7 @@ language_defn::read_var_value (struct symbol *var,
v = value::allocate (type);
store_signed_integer (v->contents_raw ().data (), type->length (),
type_byte_order (type), var->value_longest ());
- VALUE_LVAL (v) = not_lval;
+ v->set_lval (not_lval);
return v;
case LOC_LABEL:
@@ -616,7 +616,7 @@ language_defn::read_var_value (struct symbol *var,
struct type *void_ptr_type
= builtin_type (var->arch ())->builtin_data_ptr;
v = value_cast_pointers (void_ptr_type, v, 0);
- VALUE_LVAL (v) = not_lval;
+ v->set_lval (not_lval);
return v;
}
@@ -629,7 +629,7 @@ language_defn::read_var_value (struct symbol *var,
v = value::allocate (type);
memcpy (v->contents_raw ().data (), var->value_bytes (),
type->length ());
- VALUE_LVAL (v) = not_lval;
+ v->set_lval (not_lval);
return v;
case LOC_STATIC:
@@ -804,7 +804,7 @@ default_value_from_register (struct gdbarch *gdbarch, struct type *type,
struct value *value = value::allocate (type);
frame_info_ptr frame;
- VALUE_LVAL (value) = lval_register;
+ value->set_lval (lval_register);
frame = frame_find_by_id (frame_id);
if (frame == NULL)
@@ -896,7 +896,7 @@ value_from_register (struct type *type, int regnum, frame_info_ptr frame)
is that gdbarch_register_to_value populates the entire value
including the location. */
v = value::allocate (type);
- VALUE_LVAL (v) = lval_register;
+ v->set_lval (lval_register);
VALUE_NEXT_FRAME_ID (v) = get_frame_id (get_next_frame_sentinel_okay (frame));
VALUE_REGNUM (v) = regnum;
ok = gdbarch_register_to_value (gdbarch, frame, regnum, type1,
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index 53e531ca90c..989803f3816 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -3558,7 +3558,7 @@ i386_pseudo_register_read_value (struct gdbarch *gdbarch,
struct value *result;
result = value::allocate (register_type (gdbarch, regnum));
- VALUE_LVAL (result) = lval_register;
+ result->set_lval (lval_register);
VALUE_REGNUM (result) = regnum;
i386_pseudo_register_read_into_value (gdbarch, regcache, regnum, result);
diff --git a/gdb/regcache.c b/gdb/regcache.c
index 09dd6a4b79e..af76fab1a34 100644
--- a/gdb/regcache.c
+++ b/gdb/regcache.c
@@ -744,7 +744,7 @@ readable_regcache::cooked_read_value (int regnum)
struct value *result;
result = value::allocate (register_type (m_descr->gdbarch, regnum));
- VALUE_LVAL (result) = lval_register;
+ result->set_lval (lval_register);
VALUE_REGNUM (result) = regnum;
/* It is more efficient in general to do this delegation in this
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index 013b8a4c0d2..27b5928298f 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -350,7 +350,7 @@ rust_val_print_slice (struct value *val, struct ui_file *stream, int recurse,
struct type *array_type = lookup_array_range_type (elt_type, 0,
llen - 1);
struct value *array = value::allocate_lazy (array_type);
- VALUE_LVAL (array) = lval_memory;
+ array->set_lval (lval_memory);
array->set_address (value_as_address (base));
array->fetch_lazy ();
generic_value_print (array, stream, recurse, options,
diff --git a/gdb/valops.c b/gdb/valops.c
index e9641b9066b..6a0a6706157 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -1024,7 +1024,7 @@ struct value *
value_at_non_lval (struct type *type, CORE_ADDR addr)
{
struct value *result = value_at (type, addr);
- VALUE_LVAL (result) = not_lval;
+ result->set_lval (not_lval);
return result;
}
@@ -1373,7 +1373,7 @@ value_repeat (struct value *arg1, int count)
val = allocate_repeat_value (arg1->enclosing_type (), count);
- VALUE_LVAL (val) = lval_memory;
+ val->set_lval (lval_memory);
val->set_address (arg1->address ());
read_value_memory (val, 0, val->stack (), val->address (),
diff --git a/gdb/value.c b/gdb/value.c
index 54de45eb22e..bba78c3d10e 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -848,7 +848,7 @@ value::allocate_computed (struct type *type,
{
struct value *v = value::allocate_lazy (type);
- VALUE_LVAL (v) = lval_computed;
+ v->set_lval (lval_computed);
v->m_location.computed.funcs = funcs;
v->m_location.computed.closure = closure;
@@ -1362,7 +1362,7 @@ value::copy () const
else
val = value::allocate (encl_type);
val->m_type = m_type;
- VALUE_LVAL (val) = m_lval;
+ val->set_lval (m_lval);
val->m_location = m_location;
val->m_offset = m_offset;
val->m_bitpos = m_bitpos;
@@ -1455,9 +1455,9 @@ value::set_component_location (const struct value *whole)
gdb_assert (whole->m_lval != lval_xcallable);
if (whole->m_lval == lval_internalvar)
- VALUE_LVAL (this) = lval_internalvar_component;
+ m_lval = lval_internalvar_component;
else
- VALUE_LVAL (this) = whole->m_lval;
+ m_lval = whole->m_lval;
m_location = whole->m_location;
if (whole->m_lval == lval_computed)
@@ -1501,7 +1501,7 @@ value::set_component_location (const struct value *whole)
if (VALUE_LVAL (this) == lval_internalvar_component)
{
gdb_assert (lazy ());
- VALUE_LVAL (this) = lval_memory;
+ m_lval = lval_memory;
}
else
gdb_assert (VALUE_LVAL (this) == lval_memory);
@@ -1917,7 +1917,7 @@ value_of_internalvar (struct gdbarch *gdbarch, struct internalvar *var)
if (var->kind != INTERNALVAR_MAKE_VALUE
&& val->lval () != lval_computed)
{
- VALUE_LVAL (val) = lval_internalvar;
+ val->set_lval (lval_internalvar);
VALUE_INTERNALVAR (val) = var;
}
@@ -2838,7 +2838,7 @@ value_fn_field (struct value **arg1p, struct fn_field *f,
}
v = value::allocate (ftype);
- VALUE_LVAL (v) = lval_memory;
+ v->set_lval (lval_memory);
if (sym)
{
v->set_address (sym->value_block ()->entry_pc ());
@@ -3184,7 +3184,7 @@ value::zero (struct type *type, enum lval_type lv)
{
struct value *val = value::allocate_lazy (type);
- VALUE_LVAL (val) = (lv == lval_computed ? not_lval : lv);
+ val->set_lval (lv == lval_computed ? not_lval : lv);
val->m_is_zero = true;
return val;
}
@@ -3259,7 +3259,7 @@ value_from_contents_and_address_unresolved (struct type *type,
v = value::allocate_lazy (type);
else
v = value_from_contents (type, valaddr);
- VALUE_LVAL (v) = lval_memory;
+ v->set_lval (lval_memory);
v->set_address (address);
return v;
}
@@ -3288,7 +3288,7 @@ value_from_contents_and_address (struct type *type,
if (TYPE_DATA_LOCATION (resolved_type_no_typedef) != NULL
&& TYPE_DATA_LOCATION_KIND (resolved_type_no_typedef) == PROP_CONST)
address = TYPE_DATA_LOCATION_ADDR (resolved_type_no_typedef);
- VALUE_LVAL (v) = lval_memory;
+ v->set_lval (lval_memory);
v->set_address (address);
return v;
}
diff --git a/gdb/value.h b/gdb/value.h
index 373711f3932..36bc00629d8 100644
--- a/gdb/value.h
+++ b/gdb/value.h
@@ -336,6 +336,10 @@ struct value
enum lval_type lval () const
{ return m_lval; }
+ /* Set the 'lval' of this value. */
+ void set_lval (lval_type val)
+ { m_lval = val; }
+
/* Set or return field indicating whether a variable is initialized or
not, based on debugging information supplied by the compiler.
1 = initialized; 0 = uninitialized. */
--
2.39.1
next prev parent reply other threads:[~2023-02-09 23:37 UTC|newest]
Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-09 21:38 [PATCH 00/47] Use methods for struct value Tom Tromey
2023-02-09 21:38 ` [PATCH 01/47] Rename all fields of " Tom Tromey
2023-02-10 21:05 ` Tom Tromey
2023-02-09 21:38 ` [PATCH 02/47] Move ~value body out-of-line Tom Tromey
2023-02-09 21:38 ` [PATCH 03/47] Move struct value to value.h Tom Tromey
2023-02-09 21:38 ` [PATCH 04/47] Turn value_type into method Tom Tromey
2023-02-09 21:38 ` [PATCH 05/47] Turn deprecated_set_value_type into a method Tom Tromey
2023-02-09 21:38 ` [PATCH 06/47] Turn value_arch into method Tom Tromey
2023-02-10 2:08 ` Simon Marchi
2023-02-10 16:36 ` Tom Tromey
2023-02-09 21:38 ` [PATCH 07/47] Turn value_bitsize " Tom Tromey
2023-02-09 21:38 ` [PATCH 08/47] Turn value_bitpos " Tom Tromey
2023-02-09 21:38 ` [PATCH 09/47] Turn value_parent " Tom Tromey
2023-02-09 21:38 ` [PATCH 10/47] Turn value_offset " Tom Tromey
2023-02-09 21:38 ` [PATCH 11/47] Turn deprecated_value_modifiable " Tom Tromey
2023-02-09 21:38 ` [PATCH 12/47] Turn value_enclosing_type " Tom Tromey
2023-02-09 21:38 ` [PATCH 13/47] Turn some value offset functions " Tom Tromey
2023-02-09 21:38 ` [PATCH 14/47] Turn value_lazy and set_value_lazy functions into methods Tom Tromey
2023-02-09 21:38 ` [PATCH 15/47] Turn value_stack and set_value_stack " Tom Tromey
2023-02-09 21:38 ` [PATCH 16/47] Turn value_computed_closure and value_computed_funcs " Tom Tromey
2023-02-09 21:38 ` [PATCH 17/47] Convert value_lval_const and deprecated_lval_hack to methods Tom Tromey
2023-02-09 21:38 ` [PATCH 18/47] Turn value_initialized and set_value_initialized functions into methods Tom Tromey
2023-02-09 21:38 ` [PATCH 19/47] Turn value_address and set_value_address " Tom Tromey
2023-02-09 21:38 ` [PATCH 20/47] Turn more deprecated_* " Tom Tromey
2023-02-09 21:38 ` [PATCH 21/47] Turn allocate_value_lazy into a static "constructor" Tom Tromey
2023-02-09 21:38 ` [PATCH 22/47] Turn allocate_value " Tom Tromey
2023-02-09 21:38 ` [PATCH 23/47] Turn allocate_computed_value into " Tom Tromey
2023-02-09 21:38 ` [PATCH 24/47] Turn allocate_optimized_out_value " Tom Tromey
2023-02-09 21:38 ` [PATCH 25/47] Turn value_zero " Tom Tromey
2023-02-09 21:38 ` [PATCH 26/47] Turn some value_contents functions into methods Tom Tromey
2023-02-09 21:38 ` [PATCH 27/47] Turn value_fetch_lazy into a method Tom Tromey
2023-02-09 21:38 ` [PATCH 28/47] Turn allocate_value_contents " Tom Tromey
2023-02-09 21:38 ` [PATCH 29/47] Turn value_contents_eq " Tom Tromey
2023-02-10 2:18 ` Simon Marchi
2023-02-10 17:46 ` Tom Tromey
2023-02-09 21:38 ` [PATCH 30/47] Turn value_bits_synthetic_pointer " Tom Tromey
2023-02-09 21:38 ` [PATCH 31/47] Move value_ref_policy methods out-of-line Tom Tromey
2023-02-09 21:38 ` [PATCH 32/47] Turn value_incref and value_decref into methods Tom Tromey
2023-02-09 21:38 ` [PATCH 33/47] Turn remaining value_contents functions " Tom Tromey
2023-02-10 2:24 ` Simon Marchi
2023-02-10 17:46 ` Tom Tromey
2023-02-09 21:38 ` [PATCH 34/47] Fully qualify calls to copy in value.c Tom Tromey
2023-02-09 21:38 ` [PATCH 35/47] Turn value_copy into a method Tom Tromey
2023-02-10 2:42 ` Simon Marchi
2023-02-10 18:03 ` Tom Tromey
2023-02-09 21:38 ` [PATCH 36/47] Turn many optimized-out value functions into methods Tom Tromey
2023-02-09 21:38 ` [PATCH 37/47] Turn value_non_lval and value_force_lval " Tom Tromey
2023-02-09 21:38 ` [PATCH 38/47] Turn set_value_component_location into method Tom Tromey
2023-02-09 21:39 ` [PATCH 39/47] Change some code to use value methods Tom Tromey
2023-02-09 21:39 ` [PATCH 40/47] Turn some xmethod functions into methods Tom Tromey
2023-02-09 21:39 ` [PATCH 41/47] Turn preserve_one_value into method Tom Tromey
2023-02-09 21:39 ` [PATCH 42/47] Turn various value copying-related functions into methods Tom Tromey
2023-02-10 20:20 ` Tom Tromey
2023-02-09 21:39 ` [PATCH 43/47] Add value::set_modifiable Tom Tromey
2023-02-09 21:39 ` [PATCH 44/47] Make struct value data members private Tom Tromey
2023-02-09 21:39 ` [PATCH 45/47] Make ~value private Tom Tromey
2023-02-09 21:39 ` Tom Tromey [this message]
2023-02-09 21:39 ` [PATCH 47/47] Remove deprecated_lval_hack Tom Tromey
2023-02-10 2:54 ` [PATCH 00/47] Use methods for struct value Simon Marchi
2023-02-10 18:08 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230209-submit-value-fixups-2023-v1-46-55dc2794dbb9@tromey.com \
--to=tom@tromey.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).