From patchwork Tue Jun 17 14:12:53 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gary Benson X-Patchwork-Id: 1529 Received: (qmail 16671 invoked by alias); 17 Jun 2014 14:53:07 -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 16622 invoked by uid 89); 17 Jun 2014 14:53:07 -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:53:06 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s5HED7qF021065 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 17 Jun 2014 10:13:08 -0400 Received: from blade.nx (ovpn-116-59.ams2.redhat.com [10.36.116.59]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s5HED6Pg018296 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 EF968262485 for ; Tue, 17 Jun 2014 15:13:04 +0100 (BST) From: Gary Benson To: gdb-patches@sourceware.org Subject: [PATCH 10/15] Abstract i386_dr_low access Date: Tue, 17 Jun 2014 15:12:53 +0100 Message-Id: <1403014378-4349-11-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 adds macros to abstract access to the i386_dr_low function vector used by i386-nat.c. The macros are named so as to match the names of the functions that do the same work in gdbserver. gdb/ 2014-06-17 Gary Benson * i386-nat.c (i386_dr_low_can_set_addr): New macro. (i386_dr_low_can_set_control): Likewise. (i386_dr_low_set_addr): Likewise. (i386_dr_low_set_control): Likewise. (i386_dr_low_get_addr): Likewise. (i386_dr_low_get_status): Likewise. (i386_dr_low_get_control): Likewise. (i386_insert_aligned_watchpoint): Use new macros. (i386_update_inferior_debug_regs): Likewise. (i386_stopped_data_address): Likewise. gdb/gdbserver/ 2014-06-17 Gary Benson * i386-low.c (i386_dr_low_can_set_addr): New macro. (i386_dr_low_can_set_control): Likewise. (i386_insert_aligned_watchpoint): New check. --- gdb/ChangeLog | 13 +++++++++++++ gdb/gdbserver/ChangeLog | 6 ++++++ gdb/gdbserver/i386-low.c | 6 ++++++ gdb/i386-nat.c | 25 +++++++++++++++++++------ 4 files changed, 44 insertions(+), 6 deletions(-) diff --git a/gdb/gdbserver/i386-low.c b/gdb/gdbserver/i386-low.c index 8c50838..8d6f26c 100644 --- a/gdb/gdbserver/i386-low.c +++ b/gdb/gdbserver/i386-low.c @@ -32,6 +32,9 @@ The functions below implement debug registers sharing by reference counts, and allow to watch regions up to 16 bytes long. */ +#define i386_dr_low_can_set_addr() 1 +#define i386_dr_low_can_set_control() 1 + /* Debug register size, in bytes. */ /* NOTE: sizeof (long) == 4 on win64. */ #define i386_get_debug_register_length() (sizeof (void *)) @@ -273,6 +276,9 @@ i386_insert_aligned_watchpoint (struct i386_debug_reg_state *state, { int i; + if (!i386_dr_low_can_set_addr () || !i386_dr_low_can_set_control ()) + return -1; + /* 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). */ diff --git a/gdb/i386-nat.c b/gdb/i386-nat.c index a64cdab..4282535 100644 --- a/gdb/i386-nat.c +++ b/gdb/i386-nat.c @@ -47,6 +47,19 @@ static int debug_hw_points; /* Low-level function vector. */ struct i386_dr_low_type i386_dr_low; +#define i386_dr_low_can_set_addr() (i386_dr_low.set_addr != NULL) +#define i386_dr_low_can_set_control() (i386_dr_low.set_control != NULL) + +#define i386_dr_low_set_addr(new_state, i) \ + (i386_dr_low.set_addr ((i), (new_state)->dr_mirror[(i)])) + +#define i386_dr_low_set_control(new_state) \ + (i386_dr_low.set_control ((new_state)->dr_control_mirror)) + +#define i386_dr_low_get_addr(i) (i386_dr_low.get_addr ((i))) +#define i386_dr_low_get_status() (i386_dr_low.get_status ()) +#define i386_dr_low_get_control() (i386_dr_low.get_control ()) + /* Debug register size, in bytes. */ #define i386_get_debug_register_length() \ (i386_dr_low.debug_register_length) @@ -379,7 +392,7 @@ i386_insert_aligned_watchpoint (struct i386_debug_reg_state *state, { int i; - if (!i386_dr_low.set_addr || !i386_dr_low.set_control) + if (!i386_dr_low_can_set_addr () || !i386_dr_low_can_set_control ()) return -1; /* First, look for an occupied debug register with the same address @@ -538,13 +551,13 @@ i386_update_inferior_debug_regs (struct i386_debug_reg_state *state, ALL_DEBUG_REGISTERS (i) { if (I386_DR_VACANT (new_state, i) != I386_DR_VACANT (state, i)) - i386_dr_low.set_addr (i, new_state->dr_mirror[i]); + i386_dr_low_set_addr (new_state, i); else gdb_assert (new_state->dr_mirror[i] == state->dr_mirror[i]); } if (new_state->dr_control_mirror != state->dr_control_mirror) - i386_dr_low.set_control (new_state->dr_control_mirror); + i386_dr_low_set_control (new_state); *state = *new_state; } @@ -698,7 +711,7 @@ i386_stopped_data_address (struct target_ops *ops, CORE_ADDR *addr_p) was running when we last changed watchpoints, the mirror no longer represents what was set in this thread's debug registers. */ - status = i386_dr_low.get_status (); + status = i386_dr_low_get_status (); ALL_DEBUG_REGISTERS (i) { @@ -707,7 +720,7 @@ i386_stopped_data_address (struct target_ops *ops, CORE_ADDR *addr_p) if (!control_p) { - control = i386_dr_low.get_control (); + control = i386_dr_low_get_control (); control_p = 1; } @@ -718,7 +731,7 @@ i386_stopped_data_address (struct target_ops *ops, CORE_ADDR *addr_p) paranoiac. */ if (I386_DR_GET_RW_LEN (control, i) != 0) { - addr = i386_dr_low.get_addr (i); + addr = i386_dr_low_get_addr (i); rc = 1; if (debug_hw_points) i386_show_dr (state, "watchpoint_hit", addr, -1, hw_write);