[PATCH 2/3] gdb/regcache: return REG_UNAVAILABLE if raw_update raises NOT_AVAILABLE_ERROR
Tankut Baris Aktemur
tankut.baris.aktemur@intel.com
Fri Nov 13 16:57:24 GMT 2020
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/ChangeLog:
2020-11-13 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* regcache.c (readable_regcache::raw_read): Return REG_UNAVAILABLE
if raw_update raises NOT_AVAILABLE_ERROR.
---
gdb/regcache.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/gdb/regcache.c b/gdb/regcache.c
index 91d3202b94b..0b2373b15db 100644
--- a/gdb/regcache.c
+++ b/gdb/regcache.c
@@ -594,7 +594,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.17.1
More information about the Gdb-patches
mailing list