[PATCH v2 1/2] gdb/regcache: return REG_UNAVAILABLE if raw_update raises NOT_AVAILABLE_ERROR

Tankut Baris Aktemur tankut.baris.aktemur@intel.com
Tue Feb 8 09:15:01 GMT 2022


In regcache's raw_read, it is possible that 'raw_update' fails with an
exception.  Catch this exception and return REG_UNAVAILABLE if the
error is of kind NOT_AVAILABLE_ERROR.  This makes clients' lives easier.

Regression-tested on X86_64-Linux.
---
 gdb/regcache.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/gdb/regcache.c b/gdb/regcache.c
index 00d7a10e289..0379e6a8d0f 100644
--- a/gdb/regcache.c
+++ b/gdb/regcache.c
@@ -598,7 +598,16 @@ enum register_status
 readable_regcache::raw_read (int regnum, gdb_byte *buf)
 {
   gdb_assert (buf != NULL);
-  raw_update (regnum);
+  try
+    {
+      raw_update (regnum);
+    }
+  catch (const gdb_exception_error &ex)
+    {
+      if (ex.error == NOT_AVAILABLE_ERROR)
+	return REG_UNAVAILABLE;
+      throw;
+    }
 
   if (m_register_status[regnum] != REG_VALID)
     memset (buf, 0, m_descr->sizeof_register[regnum]);
-- 
2.33.1

Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva  
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928



More information about the Gdb-patches mailing list