[2/6] Convert fatal to gdb_assert in both i386_dr_low_set_addr

Message ID 1407340688-13721-3-git-send-email-gbenson@redhat.com
State Committed
Headers

Commit Message

Gary Benson Aug. 6, 2014, 3:58 p.m. UTC
  This commit converts if..fatal checks in both i386_dr_low_set_addr
implementations to gdb_asserts.  It's not obvious from the context,
but the conditional in both cases is changed to match the equivalent
conditional in the i386_dr_low_get_addr implementations.  Nothing
fundamental has changed because DR_FIRSTADDR is zero.  This commit
also removes a vague comment in Linux i386_dr_low_get_addr.  I could
have reworded the comment (and replicated it three times for the other
identical assertions) but I think the existence of specific functions
for the status and control registers makes it fairly obvious what is
going on.

gdb/gdbserver/
2014-08-06  Gary Benson  <gbenson@redhat.com>

	* linux-x86-low.c (i386_dr_low_set_addr): Replace check with
	gdb_assert.
	(i386_dr_low_get_addr): Remove vague comment.
	(win32-i386-low.c): Replace check with gdb_assert.
---
 gdb/gdbserver/ChangeLog        |    7 +++++++
 gdb/gdbserver/linux-x86-low.c  |    4 +---
 gdb/gdbserver/win32-i386-low.c |    3 +--
 3 files changed, 9 insertions(+), 5 deletions(-)
  

Comments

Pedro Alves Aug. 20, 2014, 4:09 p.m. UTC | #1
On 08/06/2014 04:58 PM, Gary Benson wrote:
> This commit converts if..fatal checks in both i386_dr_low_set_addr
> implementations to gdb_asserts.  It's not obvious from the context,
> but the conditional in both cases is changed to match the equivalent
> conditional in the i386_dr_low_get_addr implementations.  Nothing
> fundamental has changed because DR_FIRSTADDR is zero.  This commit
> also removes a vague comment in Linux i386_dr_low_get_addr.  I could
> have reworded the comment (and replicated it three times for the other
> identical assertions) but I think the existence of specific functions
> for the status and control registers makes it fairly obvious what is
> going on.
> 

OK, with ...

> gdb/gdbserver/
> 2014-08-06  Gary Benson  <gbenson@redhat.com>
> 
> 	* linux-x86-low.c (i386_dr_low_set_addr): Replace check with
> 	gdb_assert.
> 	(i386_dr_low_get_addr): Remove vague comment.
> 	(win32-i386-low.c): Replace check with gdb_assert.

... the win32 entry fixed.

Thanks,
Pedro Alves
  

Patch

diff --git a/gdb/gdbserver/linux-x86-low.c b/gdb/gdbserver/linux-x86-low.c
index 7f32ea3..7e07522 100644
--- a/gdb/gdbserver/linux-x86-low.c
+++ b/gdb/gdbserver/linux-x86-low.c
@@ -593,8 +593,7 @@  i386_dr_low_set_addr (int regnum, CORE_ADDR addr)
   /* Only update the threads of this process.  */
   int pid = pid_of (current_inferior);
 
-  if (! (regnum >= 0 && regnum <= DR_LASTADDR - DR_FIRSTADDR))
-    fatal ("Invalid debug register %d", regnum);
+  gdb_assert (DR_FIRSTADDR <= regnum && regnum <= DR_LASTADDR);
 
   find_inferior (&all_threads, update_debug_registers_callback, &pid);
 }
@@ -606,7 +605,6 @@  i386_dr_low_get_addr (int regnum)
 {
   ptid_t ptid = ptid_of (current_inferior);
 
-  /* DR6 and DR7 are retrieved with some other way.  */
   gdb_assert (DR_FIRSTADDR <= regnum && regnum <= DR_LASTADDR);
 
   return x86_linux_dr_get (ptid, regnum);
diff --git a/gdb/gdbserver/win32-i386-low.c b/gdb/gdbserver/win32-i386-low.c
index e894677..39149f3 100644
--- a/gdb/gdbserver/win32-i386-low.c
+++ b/gdb/gdbserver/win32-i386-low.c
@@ -48,8 +48,7 @@  static int debug_registers_used = 0;
 static void
 i386_dr_low_set_addr (int regnum, CORE_ADDR addr)
 {
-  if (! (regnum >= 0 && regnum <= DR_LASTADDR - DR_FIRSTADDR))
-    fatal ("Invalid debug register %d", regnum);
+  gdb_assert (DR_FIRSTADDR <= regnum && regnum <= DR_LASTADDR);
 
   /* debug_reg_state.dr_mirror is already set.
      Just notify i386_set_thread_context, i386_thread_added