public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Gary Benson <gbenson@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 06/15] Merge printing code
Date: Tue, 17 Jun 2014 14:40:00 -0000	[thread overview]
Message-ID: <1403014378-4349-7-git-send-email-gbenson@redhat.com> (raw)
In-Reply-To: <1403014378-4349-1-git-send-email-gbenson@redhat.com>

This commit synchronizes the debug printing code in i386-nat.c and
i386-low.c.

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

	* i386-nat.c (debug_printf): New macro.
	(i386_get_debug_register_length): Likewise.
	(TARGET_HAS_DR_LEN_8): Use above macro.
	(i386_show_dr): Use debug_printf instead of puts_unfiltered
	and printf_unfiltered.  Use phex to format values.

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

	* i386-low.c (i386_get_debug_register_length): New macro.
	(TARGET_HAS_DR_LEN_8): Remove conditional.  Use above macro.
	(i386_show_dr): Use debug_printf instead of fprintf.  Use
	phex to format values.
---
 gdb/ChangeLog            |    8 ++++++
 gdb/gdbserver/ChangeLog  |    7 ++++++
 gdb/gdbserver/i386-low.c |   50 ++++++++++++++++++++++-------------------
 gdb/i386-nat.c           |   55 ++++++++++++++++++++++++++--------------------
 4 files changed, 73 insertions(+), 47 deletions(-)

diff --git a/gdb/gdbserver/i386-low.c b/gdb/gdbserver/i386-low.c
index d122ff7..b154fcd 100644
--- a/gdb/gdbserver/i386-low.c
+++ b/gdb/gdbserver/i386-low.c
@@ -32,11 +32,12 @@
    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
+/* Debug register size, in bytes.  */
 /* NOTE: sizeof (long) == 4 on win64.  */
-#define TARGET_HAS_DR_LEN_8 (sizeof (void *) == 8)
-#endif
+#define i386_get_debug_register_length() (sizeof (void *))
+
+/* Support for 8-byte wide hw watchpoints.  */
+#define TARGET_HAS_DR_LEN_8 (i386_get_debug_register_length () == 8)
 
 /* DR7 Debug Control register fields.  */
 
@@ -176,29 +177,32 @@ i386_show_dr (struct i386_debug_reg_state *state,
 {
   int i;
 
-  fprintf (stderr, "%s", func);
+  debug_printf ("%s", func);
   if (addr || len)
-    fprintf (stderr, " (addr=%lx, len=%d, type=%s)",
-	     (unsigned long) addr, len,
-	     type == hw_write ? "data-write"
-	     : (type == hw_read ? "data-read"
-		: (type == hw_access ? "data-read/write"
-		   : (type == hw_execute ? "instruction-execute"
-		      /* FIXME: if/when I/O read/write
-			 watchpoints are supported, add them
-			 here.  */
-		      : "??unknown??"))));
-  fprintf (stderr, ":\n");
-  fprintf (stderr, "\tCONTROL (DR7): %08x          STATUS (DR6): %08x\n",
-	   state->dr_control_mirror, state->dr_status_mirror);
+    debug_printf (" (addr=%s, len=%d, type=%s)",
+		  phex (addr, 8), len,
+		  type == hw_write ? "data-write"
+		  : (type == hw_read ? "data-read"
+		     : (type == hw_access ? "data-read/write"
+			: (type == hw_execute ? "instruction-execute"
+			   /* FIXME: if/when I/O read/write
+			      watchpoints are supported, add them
+			      here.  */
+			   : "??unknown??"))));
+  debug_printf (":\n");
+  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)
     {
-      fprintf (stderr, "\
+      debug_printf ("\
 \tDR%d: addr=0x%s, ref.count=%d  DR%d: addr=0x%s, ref.count=%d\n",
-	      i, paddress (state->dr_mirror[i]),
-	      state->dr_ref_count[i],
-	      i + 1, paddress (state->dr_mirror[i + 1]),
-	      state->dr_ref_count[i + 1]);
+		    i, phex (state->dr_mirror[i],
+			     i386_get_debug_register_length ()),
+		    state->dr_ref_count[i],
+		    i + 1, phex (state->dr_mirror[i + 1],
+				 i386_get_debug_register_length ()),
+		    state->dr_ref_count[i + 1]);
       i++;
     }
 }
diff --git a/gdb/i386-nat.c b/gdb/i386-nat.c
index 23efb33..91d868d 100644
--- a/gdb/i386-nat.c
+++ b/gdb/i386-nat.c
@@ -37,11 +37,19 @@
    The functions below implement debug registers sharing by reference
    counts, and allow to watch regions up to 16 bytes long.  */
 
+/* Function used for printing mirrored debug registers.  */
+#define debug_printf(fmt, args...) \
+  fprintf_unfiltered (gdb_stdlog, fmt, ##args);
+
 /* Low-level function vector.  */
 struct i386_dr_low_type i386_dr_low;
 
+/* Debug register size, in bytes.  */
+#define i386_get_debug_register_length() \
+  (i386_dr_low.debug_register_length)
+
 /* Support for 8-byte wide hw watchpoints.  */
-#define TARGET_HAS_DR_LEN_8 (i386_dr_low.debug_register_length == 8)
+#define TARGET_HAS_DR_LEN_8 (i386_get_debug_register_length () == 8)
 
 /* DR7 Debug Control register fields.  */
 
@@ -273,35 +281,34 @@ i386_show_dr (struct i386_debug_reg_state *state,
 	      const char *func, CORE_ADDR addr,
 	      int len, enum target_hw_bp_type type)
 {
-  int addr_size = gdbarch_addr_bit (target_gdbarch ()) / 8;
   int i;
 
-  puts_unfiltered (func);
+  debug_printf ("%s", func);
   if (addr || len)
-    printf_unfiltered (" (addr=%lx, len=%d, type=%s)",
-		       /* This code is for ia32, so casting CORE_ADDR
-			  to unsigned long should be okay.  */
-		       (unsigned long) addr, len,
-		       type == hw_write ? "data-write"
-		       : (type == hw_read ? "data-read"
-			  : (type == hw_access ? "data-read/write"
-			     : (type == hw_execute ? "instruction-execute"
-				/* FIXME: if/when I/O read/write
-				   watchpoints are supported, add them
-				   here.  */
-				: "??unknown??"))));
-  puts_unfiltered (":\n");
-  printf_unfiltered ("\tCONTROL (DR7): %s          STATUS (DR6): %s\n",
-		     phex (state->dr_control_mirror, 8),
-		     phex (state->dr_status_mirror, 8));
+    debug_printf (" (addr=%s, len=%d, type=%s)",
+		  phex (addr, 8), len,
+		  type == hw_write ? "data-write"
+		  : (type == hw_read ? "data-read"
+		     : (type == hw_access ? "data-read/write"
+			: (type == hw_execute ? "instruction-execute"
+			   /* FIXME: if/when I/O read/write
+			      watchpoints are supported, add them
+			      here.  */
+			   : "??unknown??"))));
+  debug_printf (":\n");
+  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)
     {
-      printf_unfiltered ("\
+      debug_printf ("\
 \tDR%d: addr=0x%s, ref.count=%d  DR%d: addr=0x%s, ref.count=%d\n",
-			 i, phex (state->dr_mirror[i], addr_size),
-			 state->dr_ref_count[i],
-			 i + 1, phex (state->dr_mirror[i + 1], addr_size),
-			 state->dr_ref_count[i + 1]);
+		    i, phex (state->dr_mirror[i],
+			     i386_get_debug_register_length ()),
+		    state->dr_ref_count[i],
+		    i + 1, phex (state->dr_mirror[i + 1],
+				 i386_get_debug_register_length ()),
+		    state->dr_ref_count[i + 1]);
       i++;
     }
 }
-- 
1.7.1

  parent reply	other threads:[~2014-06-17 14:40 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 04/15] Comment changes Gary Benson
2014-06-17 15:45   ` Pedro Alves
2014-06-17 16:10     ` Gary Benson
2014-06-17 17:11       ` Pedro Alves
2014-06-17 14:13 ` [PATCH 01/15] Whitespace changes Gary Benson
2014-06-17 15:23   ` 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 ` Gary Benson [this message]
2014-06-17 16:01   ` [PATCH 06/15] Merge printing code 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:44 ` [PATCH 09/15] Merge i386_update_inferior_debug_regs Gary Benson
2014-06-17 16:06   ` 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:48 ` [PATCH 07/15] Merge error handling Gary Benson
2014-06-17 16:02   ` 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:53 ` [PATCH 02/15] Remove unnecessary prototypes Gary Benson
2014-06-17 15:26   ` 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 05/15] Add a const Gary Benson
2014-06-17 15:46   ` 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: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-7-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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).