This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[OB PATCH] x86 debug address register clarifications


Hi all,

The loop macro ALL_DEBUG_REGISTERS does not iterate over the status or
control registers, so its name is misleading.  This commit renames it
as ALL_DEBUG_ADDRESS_REGISTERS and updates all uses.  This commit also
updates its loop conditions to an equivalent but better form, and
makes two functions use it that had previously hardwired the loop.
A comment on a related field in the x86_debug_reg_state structure is
also updated to reflect that the field refers specifically to address
registers only.

Pushed as obvious.

Thanks,
Gary

---
gdb/ChangeLog:

	* nat/x86-dregs.h (ALL_DEBUG_REGISTERS): Renamed as...
	(ALL_DEBUG_ADDRESS_REGISTERS): New macro.  All uses updated.
	Loop conditions	changed to equivalent form.
	(struct x86_debug_reg_state): Updated dr_ref_count comment.
	* x86-linux-nat.c (x86_linux_prepare_to_resume): Use
	ALL_DEBUG_ADDRESS_REGISTERS.

gdb/gdbserver/ChangeLog:

	* linux-x86-low.c (x86_linux_prepare_to_resume): Use
	ALL_DEBUG_ADDRESS_REGISTERS.
---
 gdb/ChangeLog                 |    9 +++++++++
 gdb/gdbserver/ChangeLog       |    5 +++++
 gdb/gdbserver/linux-x86-low.c |    2 +-
 gdb/gdbserver/x86-low.c       |    2 +-
 gdb/nat/x86-dregs.c           |   12 ++++++------
 gdb/nat/x86-dregs.h           |    7 ++++---
 gdb/x86-linux-nat.c           |    2 +-
 7 files changed, 27 insertions(+), 12 deletions(-)

diff --git a/gdb/gdbserver/linux-x86-low.c b/gdb/gdbserver/linux-x86-low.c
index 6b73886..a66f61e 100644
--- a/gdb/gdbserver/linux-x86-low.c
+++ b/gdb/gdbserver/linux-x86-low.c
@@ -787,7 +787,7 @@ x86_linux_prepare_to_resume (struct lwp_info *lwp)
 
       x86_linux_dr_set (ptid, DR_CONTROL, 0);
 
-      for (i = DR_FIRSTADDR; i <= DR_LASTADDR; i++)
+      ALL_DEBUG_ADDRESS_REGISTERS (i)
 	if (state->dr_ref_count[i] > 0)
 	  {
 	    x86_linux_dr_set (ptid, i, state->dr_mirror[i]);
diff --git a/gdb/gdbserver/x86-low.c b/gdb/gdbserver/x86-low.c
index aaa110e..b48a15d 100644
--- a/gdb/gdbserver/x86-low.c
+++ b/gdb/gdbserver/x86-low.c
@@ -28,7 +28,7 @@ x86_low_init_dregs (struct x86_debug_reg_state *state)
 {
   int i;
 
-  ALL_DEBUG_REGISTERS (i)
+  ALL_DEBUG_ADDRESS_REGISTERS (i)
     {
       state->dr_mirror[i] = 0;
       state->dr_ref_count[i] = 0;
diff --git a/gdb/nat/x86-dregs.c b/gdb/nat/x86-dregs.c
index 5381c77..fbb2426 100644
--- a/gdb/nat/x86-dregs.c
+++ b/gdb/nat/x86-dregs.c
@@ -205,7 +205,7 @@ x86_show_dr (struct x86_debug_reg_state *state,
   debug_printf ("\tCONTROL (DR7): %s          STATUS (DR6): %s\n",
 		phex (state->dr_control_mirror, 8),
 		phex (state->dr_status_mirror, 8));
-  ALL_DEBUG_REGISTERS (i)
+  ALL_DEBUG_ADDRESS_REGISTERS (i)
     {
       debug_printf ("\
 \tDR%d: addr=0x%s, ref.count=%d  DR%d: addr=0x%s, ref.count=%d\n",
@@ -291,7 +291,7 @@ x86_insert_aligned_watchpoint (struct x86_debug_reg_state *state,
   /* First, look for an occupied debug register with the same address
      and the same RW and LEN definitions.  If we find one, we can
      reuse it for this watchpoint as well (and save a register).  */
-  ALL_DEBUG_REGISTERS (i)
+  ALL_DEBUG_ADDRESS_REGISTERS (i)
     {
       if (!X86_DR_VACANT (state, i)
 	  && state->dr_mirror[i] == addr
@@ -303,7 +303,7 @@ x86_insert_aligned_watchpoint (struct x86_debug_reg_state *state,
     }
 
   /* Next, look for a vacant debug register.  */
-  ALL_DEBUG_REGISTERS (i)
+  ALL_DEBUG_ADDRESS_REGISTERS (i)
     {
       if (X86_DR_VACANT (state, i))
 	break;
@@ -346,7 +346,7 @@ x86_remove_aligned_watchpoint (struct x86_debug_reg_state *state,
   int i, retval = -1;
   int all_vacant = 1;
 
-  ALL_DEBUG_REGISTERS (i)
+  ALL_DEBUG_ADDRESS_REGISTERS (i)
     {
       if (!X86_DR_VACANT (state, i)
 	  && state->dr_mirror[i] == addr
@@ -461,7 +461,7 @@ x86_update_inferior_debug_regs (struct x86_debug_reg_state *state,
 {
   int i;
 
-  ALL_DEBUG_REGISTERS (i)
+  ALL_DEBUG_ADDRESS_REGISTERS (i)
     {
       if (X86_DR_VACANT (new_state, i) != X86_DR_VACANT (state, i))
 	x86_dr_low_set_addr (new_state, i);
@@ -620,7 +620,7 @@ x86_dr_stopped_data_address (struct x86_debug_reg_state *state,
      registers.  */
   status = x86_dr_low_get_status ();
 
-  ALL_DEBUG_REGISTERS (i)
+  ALL_DEBUG_ADDRESS_REGISTERS (i)
     {
       if (!X86_DR_WATCH_HIT (status, i))
 	continue;
diff --git a/gdb/nat/x86-dregs.h b/gdb/nat/x86-dregs.h
index fb179a5..aebcbce 100644
--- a/gdb/nat/x86-dregs.h
+++ b/gdb/nat/x86-dregs.h
@@ -85,12 +85,13 @@ struct x86_debug_reg_state
   CORE_ADDR dr_mirror[DR_NADDR];
   unsigned dr_status_mirror, dr_control_mirror;
 
-  /* Reference counts for each debug register.  */
+  /* Reference counts for each debug address register.  */
   int dr_ref_count[DR_NADDR];
 };
 
-/* A macro to loop over all debug registers.  */
-#define ALL_DEBUG_REGISTERS(i)	for (i = 0; i < DR_NADDR; i++)
+/* A macro to loop over all debug address registers.  */
+#define ALL_DEBUG_ADDRESS_REGISTERS(i) \
+  for (i = DR_FIRSTADDR; i <= DR_LASTADDR; i++)
 
 /* Insert a watchpoint to watch a memory region which starts at
    address ADDR and whose length is LEN bytes.  Watch memory accesses
diff --git a/gdb/x86-linux-nat.c b/gdb/x86-linux-nat.c
index 5340dfe..0d070dd 100644
--- a/gdb/x86-linux-nat.c
+++ b/gdb/x86-linux-nat.c
@@ -195,7 +195,7 @@ x86_linux_prepare_to_resume (struct lwp_info *lwp)
 	 results in EINVAL.  */
       x86_linux_dr_set (lwp->ptid, DR_CONTROL, 0);
 
-      for (i = DR_FIRSTADDR; i <= DR_LASTADDR; i++)
+      ALL_DEBUG_ADDRESS_REGISTERS (i)
 	if (state->dr_ref_count[i] > 0)
 	  {
 	    x86_linux_dr_set (lwp->ptid, i, state->dr_mirror[i]);
-- 
1.7.1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]