From patchwork Tue Jun 17 14:12:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gary Benson X-Patchwork-Id: 1520 Received: (qmail 31985 invoked by alias); 17 Jun 2014 14:40:43 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 31954 invoked by uid 89); 17 Jun 2014 14:40:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 17 Jun 2014 14:40:40 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s5HED7J8024522 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 17 Jun 2014 10:13:07 -0400 Received: from blade.nx (ovpn-116-59.ams2.redhat.com [10.36.116.59]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s5HED5wR031560 for ; Tue, 17 Jun 2014 10:13:06 -0400 Received: from blade.nx (localhost [127.0.0.1]) by blade.nx (Postfix) with ESMTP id 89350262481 for ; Tue, 17 Jun 2014 15:13:04 +0100 (BST) From: Gary Benson To: gdb-patches@sourceware.org Subject: [PATCH 06/15] Merge printing code Date: Tue, 17 Jun 2014 15:12:49 +0100 Message-Id: <1403014378-4349-7-git-send-email-gbenson@redhat.com> In-Reply-To: <1403014378-4349-1-git-send-email-gbenson@redhat.com> References: <1403014378-4349-1-git-send-email-gbenson@redhat.com> X-IsSubscribed: yes This commit synchronizes the debug printing code in i386-nat.c and i386-low.c. gdb/ 2014-06-17 Gary Benson * 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 * 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++; } }