* [PATCH] Call error_value_optimized_out from value_assign
@ 2026-04-21 19:41 Tom Tromey
2026-04-24 9:37 ` Tom de Vries
0 siblings, 1 reply; 4+ messages in thread
From: Tom Tromey @ 2026-04-21 19:41 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
value_assign will throw an exception indicating that the value is
optimized out, but it seemed better to me for it to use the utility
function error_value_optimized_out.
---
gdb/valops.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/gdb/valops.c b/gdb/valops.c
index 515e43ccdfa..fccadae6cf6 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -1225,8 +1225,7 @@ value_assign (struct value *toval, struct value *fromval)
&unavail))
{
if (optim)
- throw_error (OPTIMIZED_OUT_ERROR,
- _("value has been optimized out"));
+ error_value_optimized_out ();
if (unavail)
throw_error (NOT_AVAILABLE_ERROR,
_("value is not available"));
base-commit: 8927b500532538cd86aae2d777c6452c51a210c6
--
2.53.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Call error_value_optimized_out from value_assign
2026-04-21 19:41 [PATCH] Call error_value_optimized_out from value_assign Tom Tromey
@ 2026-04-24 9:37 ` Tom de Vries
2026-04-24 14:37 ` Tom Tromey
0 siblings, 1 reply; 4+ messages in thread
From: Tom de Vries @ 2026-04-24 9:37 UTC (permalink / raw)
To: Tom Tromey, gdb-patches
On 4/21/26 9:41 PM, Tom Tromey wrote:
> value_assign will throw an exception indicating that the value is
> optimized out, but it seemed better to me for it to use the utility
> function error_value_optimized_out.
Hi Tom,
LGTM.
Approved-By: Tom de Vries <tdevries@suse.de>
I wondered about the NOT_AVAILABLE_ERROR, and I think we could do
something similar, see unverified patch below.
I'll submit it as a separate patch, after you merge this one. I'm not
sure if it makes sense, but given that it touches the same code, you
could also merge it into your patch.
Thanks,
- Tom
diff --git a/gdb/valops.c b/gdb/valops.c
index 515e43ccdfa..95888d3539a 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -1228,8 +1228,7 @@ value_assign (struct value *toval, struct value
*fromval)
throw_error (OPTIMIZED_OUT_ERROR,
_("value has been optimized out"));
if (unavail)
- throw_error (NOT_AVAILABLE_ERROR,
- _("value is not available"));
+ error_value_not_available ();
}
modify_field (type, buffer, value_as_long (fromval),
diff --git a/gdb/value.c b/gdb/value.c
index 2d90780f57a..332b3c4bbc7 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -1127,6 +1127,12 @@ error_value_optimized_out (void)
throw_error (OPTIMIZED_OUT_ERROR, _("value has been optimized out"));
}
+void
+error_value_not_available (void)
+{
+ throw_error (OPTIMIZED_OUT_ERROR, _("value is not available"));
+}
+
void
value::require_not_optimized_out () const
{
@@ -1144,7 +1150,7 @@ void
value::require_available () const
{
if (!m_unavailable.empty ())
- throw_error (NOT_AVAILABLE_ERROR, _("value is not available"));
+ error_value_not_available ();
}
gdb::array_view<const gdb_byte>
diff --git a/gdb/value.h b/gdb/value.h
index 201db773a84..0267ee804e1 100644
--- a/gdb/value.h
+++ b/gdb/value.h
@@ -987,6 +987,10 @@ struct lval_funcs
[[noreturn]] extern void error_value_optimized_out ();
+/* Throw an error complaining that the value is not available. */
+
+[[noreturn]] extern void error_value_not_available ();
+
/* Pointer to internal variable. */
#define VALUE_INTERNALVAR(val) (*((val)->deprecated_internalvar_hack ()))
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Call error_value_optimized_out from value_assign
2026-04-24 9:37 ` Tom de Vries
@ 2026-04-24 14:37 ` Tom Tromey
2026-04-24 17:37 ` Tom de Vries
0 siblings, 1 reply; 4+ messages in thread
From: Tom Tromey @ 2026-04-24 14:37 UTC (permalink / raw)
To: Tom de Vries; +Cc: Tom Tromey, gdb-patches
>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:
Tom> Approved-By: Tom de Vries <tdevries@suse.de>
Thanks.
Tom> I wondered about the NOT_AVAILABLE_ERROR, and I think we could do
Tom> something similar, see unverified patch below.
Makes sense.
Tom> I'll submit it as a separate patch, after you merge this one. I'm not
Tom> sure if it makes sense, but given that it touches the same code, you
Tom> could also merge it into your patch.
Tom> +void
Tom> +error_value_not_available (void)
Tom> +{
Tom> + throw_error (OPTIMIZED_OUT_ERROR, _("value is not available"));
Should use NOT_AVAILABLE_ERROR here.
Also (void) is a C-ism.
Tom
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Call error_value_optimized_out from value_assign
2026-04-24 14:37 ` Tom Tromey
@ 2026-04-24 17:37 ` Tom de Vries
0 siblings, 0 replies; 4+ messages in thread
From: Tom de Vries @ 2026-04-24 17:37 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
On 4/24/26 4:37 PM, Tom Tromey wrote:
>>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:
>
> Tom> Approved-By: Tom de Vries <tdevries@suse.de>
>
> Thanks.
>
> Tom> I wondered about the NOT_AVAILABLE_ERROR, and I think we could do
> Tom> something similar, see unverified patch below.
>
> Makes sense.
>
> Tom> I'll submit it as a separate patch, after you merge this one. I'm not
> Tom> sure if it makes sense, but given that it touches the same code, you
> Tom> could also merge it into your patch.
>
> Tom> +void
> Tom> +error_value_not_available (void)
> Tom> +{
> Tom> + throw_error (OPTIMIZED_OUT_ERROR, _("value is not available"));
>
> Should use NOT_AVAILABLE_ERROR here.
>
> Also (void) is a C-ism.
>
Thanks, I've pushed this (
https://sourceware.org/pipermail/gdb-patches/2026-April/226811.html )
with those two issues fixed.
Thanks,
- Tom
> Tom
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-04-24 17:38 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-04-21 19:41 [PATCH] Call error_value_optimized_out from value_assign Tom Tromey
2026-04-24 9:37 ` Tom de Vries
2026-04-24 14:37 ` Tom Tromey
2026-04-24 17:37 ` Tom de Vries
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox