aboutsummaryrefslogtreecommitdiff
path: root/gdb/value.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2021-09-10 12:40:54 -0600
committerTom Tromey <tromey@adacore.com>2021-10-05 12:34:55 -0600
commita519e8ffe2b0f008deaef1517562090d9eaadccc (patch)
tree71b6a30706c0849c861c8d38cc25df4954be16fc /gdb/value.c
parent25b0a5714c9ef139bb50adf392154f528d6a4c8d (diff)
downloadgdb-a519e8ffe2b0f008deaef1517562090d9eaadccc.zip
gdb-a519e8ffe2b0f008deaef1517562090d9eaadccc.tar.gz
gdb-a519e8ffe2b0f008deaef1517562090d9eaadccc.tar.bz2
Add lval_funcs::is_optimized_out
This adds an is_optimized_out function pointer to lval_funcs, and changes value_optimized_out to call it. This new function lets gdb determine if a value is optimized out without necessarily fetching the value. This is needed for a subsequent patch, where an attempt to access a lazy value would fail due to the value size limit -- however, the access was only needed to determine the optimized-out state.
Diffstat (limited to 'gdb/value.c')
-rw-r--r--gdb/value.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/gdb/value.c b/gdb/value.c
index b9d3112..3aa5fac 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -1407,10 +1407,21 @@ value_contents_writeable (struct value *value)
int
value_optimized_out (struct value *value)
{
- /* We can only know if a value is optimized out once we have tried to
- fetch it. */
- if (value->optimized_out.empty () && value->lazy)
+ if (value->lazy)
{
+ /* See if we can compute the result without fetching the
+ value. */
+ if (VALUE_LVAL (value) == lval_memory)
+ return false;
+ else if (VALUE_LVAL (value) == lval_computed)
+ {
+ const struct lval_funcs *funcs = value->location.computed.funcs;
+
+ if (funcs->is_optimized_out != nullptr)
+ return funcs->is_optimized_out (value);
+ }
+
+ /* Fall back to fetching. */
try
{
value_fetch_lazy (value);