Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Andrew Burgess <andrew.burgess@embecosm.com>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simark@simark.ca>,
	Andrew Burgess <andrew.burgess@embecosm.com>
Subject: [PATCHv2 2/3] gdb/regcache: When saving, ignore registers that can't be read
Date: Tue, 27 Nov 2018 11:13:00 -0000	[thread overview]
Message-ID: <1fdb87a3328423d35fda3d45bdf54fa11bb8d82c.1543317060.git.andrew.burgess@embecosm.com> (raw)
In-Reply-To: <cover.1543317060.git.andrew.burgess@embecosm.com>
In-Reply-To: <cover.1543317060.git.andrew.burgess@embecosm.com>

The previous commit addressed an assertion that could trigger if a
target threw an error while saving state ahead of an inferior function
call.

The specific case that highlighted this issue was a RISC-V target that
claimed to support floating point registers, but when GDB tried to
read a floating point register the remote sent back an error.

With the previous commit we no longer see an assertion for this
target, now GDB abandons the inferior function call.

Although this is slightly better, it feels like for this specific case
GDB could do even better.  If during a call to reg_buffer::save GDB
encounters an error trying to read a register then GDB should simply
mark the register as unavailable and carry on.  The consequence of
marking the register unavailable is that GDB will not then try to
restore the register once the inferior function call is complete.

What I haven't done in this commit is provide any user feedback that
GDB would like to backup a particular register, but can't.  Right now
I figure that if the user cares about this they would probably try 'p
$reg_name' themselves, at which point it becomes obvious that the
register can't be read.  That said, I'm open to adding a warning that
the register failed to save if that is thought important.

I've tested this using on X86-64/Linux native, and for
native-gdbserver with no regressions.  Against my miss-behaving target
I can now make inferior calls without any problems.

gdb/ChangeLog:

	* regcache.c (reg_buffer::save): When saving the current register
	state, ignore registers that can't be read.
---
 gdb/ChangeLog  |  5 +++++
 gdb/regcache.c | 12 +++++++++++-
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/gdb/regcache.c b/gdb/regcache.c
index 6e0e8c3e7e0..c9503295f59 100644
--- a/gdb/regcache.c
+++ b/gdb/regcache.c
@@ -277,7 +277,17 @@ reg_buffer::save (register_read_ftype cooked_read)
       if (gdbarch_register_reggroup_p (gdbarch, regnum, save_reggroup))
 	{
 	  gdb_byte *dst_buf = register_buffer (regnum);
-	  enum register_status status = cooked_read (regnum, dst_buf);
+	  enum register_status status;
+
+	  TRY
+	    {
+	      status = cooked_read (regnum, dst_buf);
+	    }
+	  CATCH (ex, RETURN_MASK_ERROR)
+	    {
+	      status = REG_UNAVAILABLE;
+	    }
+	  END_CATCH
 
 	  gdb_assert (status != REG_UNKNOWN);
 
-- 
2.14.5


  parent reply	other threads:[~2018-11-27 11:13 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-21 18:17 [PATCH] " Andrew Burgess
2018-11-26  2:48 ` Simon Marchi
2018-11-27 11:13   ` [PATCHv2 1/3] gdb/infcall: Make infcall_suspend_state more class like Andrew Burgess
2018-11-27 11:13   ` [PATCHv2 0/3] Handle Errors While Preparing For Inferior Call Andrew Burgess
2018-12-12 15:16     ` [PATCHv3 2/2] gdb: Update test pattern to deal with native-extended-gdbserver Andrew Burgess
2018-12-12 16:13       ` Pedro Alves
2018-12-12 15:16     ` [PATCHv3 0/2] Handle Errors While Preparing For Inferior Call Andrew Burgess
2018-12-12 16:14       ` Pedro Alves
2018-12-12 17:40         ` Andrew Burgess
2018-12-12 15:16     ` [PATCHv3 1/2] gdb/infcall: Make infcall_suspend_state more class like Andrew Burgess
2018-12-12 16:13       ` Pedro Alves
2018-11-27 11:13   ` [PATCHv2 3/3] gdb: Update test pattern to deal with native-extended-gdbserver Andrew Burgess
2018-11-27 11:13   ` Andrew Burgess [this message]
2018-11-27 12:41     ` [PATCHv2 2/3] gdb/regcache: When saving, ignore registers that can't be read Pedro Alves
2018-11-27 15:30       ` Andrew Burgess
2018-11-27 16:57         ` Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1fdb87a3328423d35fda3d45bdf54fa11bb8d82c.1543317060.git.andrew.burgess@embecosm.com \
    --to=andrew.burgess@embecosm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=simark@simark.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox