Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Gary Benson <gbenson@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 04/15] Comment changes
Date: Tue, 17 Jun 2014 14:13:00 -0000	[thread overview]
Message-ID: <1403014378-4349-5-git-send-email-gbenson@redhat.com> (raw)
In-Reply-To: <1403014378-4349-1-git-send-email-gbenson@redhat.com>

This commit fixes various whitespace differences between
i386-nat.[ch] and i386-low.[ch].

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

	* i386-nat.c: Comment changes.

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

	* i386-low.h: Comment changes.
	* i386-low.c: Likewise.
---
 gdb/ChangeLog            |    4 +++
 gdb/gdbserver/ChangeLog  |    5 ++++
 gdb/gdbserver/i386-low.c |   24 +++++++++++++++------
 gdb/gdbserver/i386-low.h |    6 ++--
 gdb/i386-nat.c           |   51 ++++++++++++++++++++++++---------------------
 5 files changed, 56 insertions(+), 34 deletions(-)

diff --git a/gdb/gdbserver/i386-low.c b/gdb/gdbserver/i386-low.c
index 304d6f3..d122ff7 100644
--- a/gdb/gdbserver/i386-low.c
+++ b/gdb/gdbserver/i386-low.c
@@ -21,6 +21,17 @@
 #include "target.h"
 #include "i386-low.h"
 
+/* Support for hardware watchpoints and breakpoints using the i386
+   debug registers.
+
+   This provides several functions for inserting and removing
+   hardware-assisted breakpoints and watchpoints, testing if one or
+   more of the watchpoints triggered and at what address, checking
+   whether a given region can be watched, etc.
+
+   The functions below implement debug registers sharing by reference
+   counts, and allow to watch regions up to 16 bytes long.  */
+
 /* Support for 8-byte wide hw watchpoints.  */
 #ifndef TARGET_HAS_DR_LEN_8
 /* NOTE: sizeof (long) == 4 on win64.  */
@@ -156,8 +167,7 @@ i386_low_init_dregs (struct i386_debug_reg_state *state)
   state->dr_status_mirror  = 0;
 }
 
-/* Print the values of the mirrored debug registers.  This is enabled via
-   the "set debug-hw-points 1" monitor command.  */
+/* Print the values of the mirrored debug registers.  */
 
 static void
 i386_show_dr (struct i386_debug_reg_state *state,
@@ -427,7 +437,7 @@ i386_update_inferior_debug_regs (struct i386_debug_reg_state *inf_state,
 
 /* Insert a watchpoint to watch a memory region which starts at
    address ADDR and whose length is LEN bytes.  Watch memory accesses
-   of the type TYPE_FROM_PACKET.  Return 0 on success, -1 on failure.  */
+   of the type TYPE.  Return 0 on success, -1 on failure.  */
 
 int
 i386_low_insert_watchpoint (struct i386_debug_reg_state *state,
@@ -523,8 +533,8 @@ i386_low_region_ok_for_watchpoint (struct i386_debug_reg_state *state,
 }
 
 /* If the inferior has some break/watchpoint that triggered, set the
-   address associated with that break/watchpoint and return true.
-   Otherwise, return false.  */
+   address associated with that break/watchpoint and return non-zero.
+   Otherwise, return zero.  */
 
 int
 i386_low_stopped_data_address (struct i386_debug_reg_state *state,
@@ -603,8 +613,8 @@ i386_low_stopped_data_address (struct i386_debug_reg_state *state,
   return rc;
 }
 
-/* Return true if the inferior has some watchpoint that triggered.
-   Otherwise return false.  */
+/* Return non-zero if the inferior has some watchpoint that triggered.
+   Otherwise return zero.  */
 
 int
 i386_low_stopped_by_watchpoint (struct i386_debug_reg_state *state)
diff --git a/gdb/gdbserver/i386-low.h b/gdb/gdbserver/i386-low.h
index 8d8e73f..681ade0 100644
--- a/gdb/gdbserver/i386-low.h
+++ b/gdb/gdbserver/i386-low.h
@@ -32,9 +32,9 @@
 /* Debug registers' indices.  */
 #define DR_FIRSTADDR 0
 #define DR_LASTADDR  3
-#define DR_NADDR     4 /* The number of debug address registers.  */
-#define DR_STATUS    6
-#define DR_CONTROL   7
+#define DR_NADDR     4	/* The number of debug address registers.  */
+#define DR_STATUS    6	/* Index of debug status register (DR6).  */
+#define DR_CONTROL   7	/* Index of debug control register (DR7).  */
 
 /* Global state needed to track h/w watchpoints.  */
 
diff --git a/gdb/i386-nat.c b/gdb/i386-nat.c
index f9fb52f..a7742f2 100644
--- a/gdb/i386-nat.c
+++ b/gdb/i386-nat.c
@@ -37,6 +37,7 @@
    The functions below implement debug registers sharing by reference
    counts, and allow to watch regions up to 16 bytes long.  */
 
+/* Low-level function vector.  */
 struct i386_dr_low_type i386_dr_low;
 
 /* Support for 8-byte wide hw watchpoints.  */
@@ -265,9 +266,7 @@ i386_cleanup_dregs (void)
   i386_forget_process (ptid_get_pid (inferior_ptid));
 }
 
-/* Print the values of the mirrored debug registers.  This is called
-   when maint_show_dr is non-zero.  To set that up, type "maint
-   show-debug-regs" at GDB's prompt.  */
+/* Print the values of the mirrored debug registers.  */
 
 static void
 i386_show_dr (struct i386_debug_reg_state *state,
@@ -439,7 +438,7 @@ i386_remove_aligned_watchpoint (struct i386_debug_reg_state *state,
 	  && state->dr_mirror[i] == addr
 	  && I386_DR_GET_RW_LEN (state->dr_control_mirror, i) == len_rw_bits)
 	{
-	  if (--state->dr_ref_count[i] == 0) /* no longer in use?  */
+	  if (--state->dr_ref_count[i] == 0) /* No longer in use?  */
 	    {
 	      /* Reset our mirror.  */
 	      state->dr_mirror[i] = 0;
@@ -646,8 +645,8 @@ i386_region_ok_for_watchpoint (struct target_ops *self,
   return nregs <= DR_NADDR ? 1 : 0;
 }
 
-/* If the inferior has some watchpoint that triggered, set the
-   address associated with that watchpoint and return non-zero.
+/* If the inferior has some break/watchpoint that triggered, set the
+   address associated with that break/watchpoint and return non-zero.
    Otherwise, return zero.  */
 
 static int
@@ -668,24 +667,25 @@ i386_stopped_data_address (struct target_ops *ops, CORE_ADDR *addr_p)
   unsigned control = 0;
 
   /* In non-stop/async, threads can be running while we change the
-     STATE (and friends).  Say, we set a watchpoint, and let threads
-     resume.  Now, say you delete the watchpoint, or add/remove
-     watchpoints such that STATE changes while threads are running.
-     On targets that support non-stop, inserting/deleting watchpoints
-     updates the STATE only.  It does not update the real thread's
-     debug registers; that's only done prior to resume.  Instead, if
-     threads are running when the mirror changes, a temporary and
-     transparent stop on all threads is forced so they can get their
-     copy of the debug registers updated on re-resume.  Now, say,
-     a thread hit a watchpoint before having been updated with the new
-     STATE contents, and we haven't yet handled the corresponding
-     SIGTRAP.  If we trusted STATE below, we'd mistake the real
-     trapped address (from the last time we had updated debug
-     registers in the thread) with whatever was currently in STATE.
-     So to fix this, STATE always represents intention, what we _want_
-     threads to have in debug registers.  To get at the address and
-     cause of the trap, we need to read the state the thread still has
-     in its debug registers.
+     global dr_mirror (and friends).  Say, we set a watchpoint, and
+     let threads resume.  Now, say you delete the watchpoint, or
+     add/remove watchpoints such that dr_mirror changes while threads
+     are running.  On targets that support non-stop,
+     inserting/deleting watchpoints updates the global dr_mirror only.
+     It does not update the real thread's debug registers; that's only
+     done prior to resume.  Instead, if threads are running when the
+     mirror changes, a temporary and transparent stop on all threads
+     is forced so they can get their copy of the debug registers
+     updated on re-resume.  Now, say, a thread hit a watchpoint before
+     having been updated with the new dr_mirror contents, and we
+     haven't yet handled the corresponding SIGTRAP.  If we trusted
+     dr_mirror below, we'd mistake the real trapped address (from the
+     last time we had updated debug registers in the thread) with
+     whatever was currently in dr_mirror.  So to fix this, dr_mirror
+     always represents intention, what we _want_ threads to have in
+     debug registers.  To get at the address and cause of the trap, we
+     need to read the state the thread still has in its debug
+     registers.
 
      In sum, always get the current debug register values the current
      thread has, instead of trusting the global mirror.  If the thread
@@ -727,6 +727,9 @@ i386_stopped_data_address (struct target_ops *ops, CORE_ADDR *addr_p)
   return rc;
 }
 
+/* Return non-zero if the inferior has some watchpoint that triggered.
+   Otherwise return zero.  */
+
 static int
 i386_stopped_by_watchpoint (struct target_ops *ops)
 {
-- 
1.7.1


  parent reply	other threads:[~2014-06-17 14:13 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-17 14:13 [PATCH 00/15] Refactor shared code in i386-{nat,low}.[ch] Gary Benson
2014-06-17 14:13 ` [PATCH 01/15] Whitespace changes Gary Benson
2014-06-17 15:23   ` Pedro Alves
2014-06-17 14:13 ` Gary Benson [this message]
2014-06-17 15:45   ` [PATCH 04/15] Comment changes Pedro Alves
2014-06-17 16:10     ` Gary Benson
2014-06-17 17:11       ` Pedro Alves
2014-06-17 14:13 ` [PATCH 03/15] Remove unused macro Gary Benson
2014-06-17 15:35   ` Pedro Alves
2014-06-17 14:40 ` [PATCH 14/15] Create nat/i386-dregs.c Gary Benson
2014-06-17 16:56   ` Pedro Alves
2014-06-18 13:43     ` Gary Benson
2014-06-17 14:40 ` [PATCH 06/15] Merge printing code Gary Benson
2014-06-17 16:01   ` Pedro Alves
2014-06-17 14:44 ` [PATCH 12/15] Create nat/i386-dregs.h Gary Benson
2014-06-17 16:48   ` Pedro Alves
2014-06-18 11:14     ` Gary Benson
2014-06-17 14:44 ` [PATCH 09/15] Merge i386_update_inferior_debug_regs Gary Benson
2014-06-17 16:06   ` Pedro Alves
2014-06-17 14:48 ` [PATCH 11/15] Rename functions and make nonstatic as necessary Gary Benson
2014-06-17 16:13   ` Pedro Alves
2014-06-18 10:25   ` Siva Chandra
2014-06-18 13:30     ` Gary Benson
2014-06-18 13:55       ` Pedro Alves
2014-06-18 14:03         ` Siva Chandra
2014-06-18 14:09         ` Gary Benson
2014-06-18 14:18           ` Pedro Alves
2014-06-17 14:48 ` [PATCH 07/15] Merge error handling Gary Benson
2014-06-17 16:02   ` Pedro Alves
2014-06-17 14:53 ` [PATCH 10/15] Abstract i386_dr_low access Gary Benson
2014-06-17 16:10   ` Pedro Alves
2014-06-17 14:53 ` [PATCH 05/15] Add a const Gary Benson
2014-06-17 15:46   ` Pedro Alves
2014-06-17 14:53 ` [PATCH 08/15] Rename maint_show_dr to debug_hw_points Gary Benson
2014-06-17 16:03   ` Pedro Alves
2014-06-17 14:53 ` [PATCH 02/15] Remove unnecessary prototypes Gary Benson
2014-06-17 15:26   ` Pedro Alves
2014-06-17 14:58 ` [PATCH 13/15] Move macros from i386-{nat,low}.c to i386-{nat,low}.h Gary Benson
2014-06-17 16:54   ` Pedro Alves
2014-06-18 11:33     ` Gary Benson
2014-06-18 11:50       ` Pedro Alves
2014-06-17 14:58 ` [PATCH 15/15] Buildsystem changes Gary Benson
2014-06-17 16:41   ` Pedro Alves
2014-06-17 17:00 ` [PATCH 00/15] Refactor shared code in i386-{nat,low}.[ch] Pedro Alves
2014-06-18 10:49   ` Gary Benson

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=1403014378-4349-5-git-send-email-gbenson@redhat.com \
    --to=gbenson@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /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