[binutils-gdb] [gdb] Add error_value_not_available

Tom de Vries via Gdb-cvs <[email protected]>
Newsgroups gmane.comp.gdb.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=667dbe23e94c2be57d9575ea5844733c5d0f6f4f

commit 667dbe23e94c2be57d9575ea5844733c5d0f6f4f
Author: Tom de Vries <[email protected]>
Date:   Fri Apr 24 19:30:41 2026 +0200

    [gdb] Add error_value_not_available
    
    Add error_value_not_available, and use it.

Diff:
---
 gdb/valops.c | 3 +--
 gdb/value.c  | 8 +++++++-
 gdb/value.h  | 4 ++++
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/gdb/valops.c b/gdb/valops.c
index fccadae6cf6..c8b27868a8c 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -1227,8 +1227,7 @@ value_assign (struct value *toval, struct value *fromval)
 		if (optim)
 		  error_value_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..7213afa8147 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 ()
+{
+  throw_error (NOT_AVAILABLE_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 ()))
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.