From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 24/47] Turn allocate_optimized_out_value into static "constructor"
Date: Thu, 09 Feb 2023 14:38:45 -0700 [thread overview]
Message-ID: <20230209-submit-value-fixups-2023-v1-24-55dc2794dbb9@tromey.com> (raw)
In-Reply-To: <20230209-submit-value-fixups-2023-v1-0-55dc2794dbb9@tromey.com>
This turns allocate_optimized_out_value into a static "constructor" of
value.
---
gdb/ada-lang.c | 2 +-
gdb/dwarf2/expr.c | 2 +-
gdb/dwarf2/loc.c | 10 +++++-----
gdb/eval.c | 2 +-
gdb/findvar.c | 2 +-
gdb/frame-unwind.c | 2 +-
gdb/python/py-type.c | 2 +-
gdb/s390-tdep.c | 2 +-
gdb/stack.c | 2 +-
gdb/value.c | 10 +++++-----
gdb/value.h | 5 +++--
11 files changed, 21 insertions(+), 20 deletions(-)
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 3d2c9f4f2ab..727f816b519 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -556,7 +556,7 @@ coerce_unspec_val_to_type (struct value *val, struct type *type)
struct value *result;
if (value_optimized_out (val))
- result = allocate_optimized_out_value (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
diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c
index ad6cf563562..db88dc368fd 100644
--- a/gdb/dwarf2/expr.c
+++ b/gdb/dwarf2/expr.c
@@ -1044,7 +1044,7 @@ dwarf_expr_context::fetch_result (struct type *type, struct type *subobj_type,
break;
case DWARF_VALUE_OPTIMIZED_OUT:
- retval = allocate_optimized_out_value (subobj_type);
+ retval = value::allocate_optimized_out (subobj_type);
break;
/* DWARF_VALUE_IMPLICIT_POINTER was converted to a pieced
diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c
index 743a0cefd6d..96686d9a110 100644
--- a/gdb/dwarf2/loc.c
+++ b/gdb/dwarf2/loc.c
@@ -1429,7 +1429,7 @@ fetch_const_value_from_synthetic_pointer (sect_offset die, LONGEST byte_offset,
invalid_synthetic_pointer ();
}
else
- result = allocate_optimized_out_value (type->target_type ());
+ result = value::allocate_optimized_out (type->target_type ());
return result;
}
@@ -1497,7 +1497,7 @@ dwarf2_evaluate_loc_desc_full (struct type *type, frame_info_ptr frame,
invalid_synthetic_pointer ();
if (size == 0)
- return allocate_optimized_out_value (subobj_type);
+ return value::allocate_optimized_out (subobj_type);
dwarf_expr_context ctx (per_objfile, per_cu->addr_size ());
@@ -1524,7 +1524,7 @@ dwarf2_evaluate_loc_desc_full (struct type *type, frame_info_ptr frame,
if (entry_values_debug)
exception_print (gdb_stdout, ex);
free_values.free_to_mark ();
- return allocate_optimized_out_value (subobj_type);
+ return value::allocate_optimized_out (subobj_type);
}
else
throw;
@@ -3906,11 +3906,11 @@ loclist_read_variable_at_entry (struct symbol *symbol, frame_info_ptr frame)
CORE_ADDR pc;
if (frame == NULL || !get_frame_func_if_available (frame, &pc))
- return allocate_optimized_out_value (symbol->type ());
+ return value::allocate_optimized_out (symbol->type ());
data = dwarf2_find_location_expression (dlbaton, &size, pc);
if (data == NULL)
- return allocate_optimized_out_value (symbol->type ());
+ return value::allocate_optimized_out (symbol->type ());
return value_of_dwarf_block_entry (symbol->type (), frame, data, size);
}
diff --git a/gdb/eval.c b/gdb/eval.c
index 5f8d294322b..bb72043a28a 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -2855,7 +2855,7 @@ var_value_operation::evaluate_for_sizeof (struct expression *exp,
return value_zero (size_type, not_lval);
else if (is_dynamic_type (type->index_type ())
&& type->bounds ()->high.kind () == PROP_UNDEFINED)
- return allocate_optimized_out_value (size_type);
+ return value::allocate_optimized_out (size_type);
}
}
return evaluate_subexp_for_sizeof_base (exp, type);
diff --git a/gdb/findvar.c b/gdb/findvar.c
index b59962c65ba..048e439ac33 100644
--- a/gdb/findvar.c
+++ b/gdb/findvar.c
@@ -769,7 +769,7 @@ language_defn::read_var_value (struct symbol *var,
case LOC_OPTIMIZED_OUT:
if (is_dynamic_type (type))
type = resolve_dynamic_type (type, {}, /* Unused address. */ 0);
- return allocate_optimized_out_value (type);
+ return value::allocate_optimized_out (type);
default:
error (_("Cannot look up value of a botched symbol `%s'."),
diff --git a/gdb/frame-unwind.c b/gdb/frame-unwind.c
index 1e5e821beba..6c8a094242f 100644
--- a/gdb/frame-unwind.c
+++ b/gdb/frame-unwind.c
@@ -266,7 +266,7 @@ frame_unwind_got_optimized (frame_info_ptr frame, int regnum)
struct gdbarch *gdbarch = frame_unwind_arch (frame);
struct type *type = register_type (gdbarch, regnum);
- return allocate_optimized_out_value (type);
+ return value::allocate_optimized_out (type);
}
/* Return a value which indicates that FRAME copied REGNUM into
diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c
index 81b595140af..0a3787815ec 100644
--- a/gdb/python/py-type.c
+++ b/gdb/python/py-type.c
@@ -1189,7 +1189,7 @@ typy_optimized_out (PyObject *self, PyObject *args)
{
struct type *type = ((type_object *) self)->type;
- return value_to_value_object (allocate_optimized_out_value (type));
+ return value_to_value_object (value::allocate_optimized_out (type));
}
/* Return a gdb.Field object for the field named by the argument. */
diff --git a/gdb/s390-tdep.c b/gdb/s390-tdep.c
index 9aa2c06cec1..822f66dfc3c 100644
--- a/gdb/s390-tdep.c
+++ b/gdb/s390-tdep.c
@@ -2239,7 +2239,7 @@ s390_unwind_pseudo_register (frame_info_ptr this_frame, int regnum)
return value_cast (type, val);
}
- return allocate_optimized_out_value (type);
+ return value::allocate_optimized_out (type);
}
/* Translate a .eh_frame register to DWARF register, or adjust a
diff --git a/gdb/stack.c b/gdb/stack.c
index 9952c3a73df..ca6087f3414 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -674,7 +674,7 @@ read_frame_arg (const frame_print_options &fp_opts,
|| (fp_opts.print_entry_values == print_entry_values_preferred
&& (!val || value_optimized_out (val))))
{
- entryval = allocate_optimized_out_value (sym->type ());
+ entryval = value::allocate_optimized_out (sym->type ());
entryval_error = NULL;
}
}
diff --git a/gdb/value.c b/gdb/value.c
index 24cb9c51b8d..f0e58a41768 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -876,10 +876,10 @@ value::allocate_computed (struct type *type,
return v;
}
-/* Allocate NOT_LVAL value for type TYPE being OPTIMIZED_OUT. */
+/* See value.h. */
struct value *
-allocate_optimized_out_value (struct type *type)
+value::allocate_optimized_out (struct type *type)
{
struct value *retval = value::allocate_lazy (type);
@@ -2709,7 +2709,7 @@ value_static_field (struct type *type, int fieldno)
struct type *field_type = type->field (fieldno).type ();
if (!msym.minsym)
- retval = allocate_optimized_out_value (field_type);
+ retval = value::allocate_optimized_out (field_type);
else
retval = value_at_lazy (field_type, msym.value_address ());
}
@@ -3058,7 +3058,7 @@ unpack_value_bitfield (struct value *dest_val,
valid. Optimized out/unavailable bits are read as zero, but
that's OK, as they'll end up marked below. If the VAL is
wholly-invalid we may have skipped allocating its contents,
- though. See allocate_optimized_out_value. */
+ though. See value::allocate_optimized_out. */
if (valaddr != NULL)
{
LONGEST num;
@@ -4017,7 +4017,7 @@ test_value_copy ()
/* Verify that we can copy an entirely optimized out value, that may not have
its contents allocated. */
- value_ref_ptr val = release_value (allocate_optimized_out_value (type));
+ value_ref_ptr val = release_value (value::allocate_optimized_out (type));
value_ref_ptr copy = release_value (value_copy (val.get ()));
SELF_CHECK (value_entirely_optimized_out (val.get ()));
diff --git a/gdb/value.h b/gdb/value.h
index 8e408da2bb6..771e50a0b38 100644
--- a/gdb/value.h
+++ b/gdb/value.h
@@ -174,6 +174,9 @@ struct value
const struct lval_funcs *funcs,
void *closure);
+ /* Allocate NOT_LVAL value for type TYPE being OPTIMIZED_OUT. */
+ static struct value *allocate_optimized_out (struct type *type);
+
~value ();
DISABLE_COPY_AND_ASSIGN (value);
@@ -609,8 +612,6 @@ struct lval_funcs
void (*free_closure) (struct value *v);
};
-extern struct value *allocate_optimized_out_value (struct type *type);
-
/* Throw an error complaining that the value has been optimized
out. */
--
2.39.1
next prev parent reply other threads:[~2023-02-09 21:38 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 ` Tom Tromey [this message]
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 ` [PATCH 46/47] Introduce set_lval method on value Tom Tromey
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-24-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).