From patchwork Wed Jun 18 15:22:54 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gary Benson X-Patchwork-Id: 1559 Received: (qmail 8666 invoked by alias); 18 Jun 2014 15:23: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 8646 invoked by uid 89); 18 Jun 2014 15:23:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD 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 (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 18 Jun 2014 15:23:05 +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 s5IFN3bN018116 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 18 Jun 2014 11:23:04 -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 s5IFN2Oo021075 for ; Wed, 18 Jun 2014 11:23:03 -0400 Received: from blade.nx (localhost [127.0.0.1]) by blade.nx (Postfix) with ESMTP id 03A0926249B for ; Wed, 18 Jun 2014 16:23:02 +0100 (BST) From: Gary Benson To: gdb-patches@sourceware.org Subject: [PATCH 2/4 v2] Refactor i386_{insert,remove}_hw_breakpoint Date: Wed, 18 Jun 2014 16:22:54 +0100 Message-Id: <1403104976-2492-3-git-send-email-gbenson@redhat.com> In-Reply-To: <1403104976-2492-1-git-send-email-gbenson@redhat.com> References: <1403104976-2492-1-git-send-email-gbenson@redhat.com> X-IsSubscribed: yes This commit refactors i386_{insert,remove}_hw_breakpoint to call i386_{insert,remove}_watchpoint rather than duplicating functionality. gdb/ 2014-06-18 Gary Benson * i386-nat.c (i386_insert_hw_breakpoint): Use i386_insert_watchpoint. (i386_remove_hw_breakpoint): Use i386_remove_watchpoint. --- gdb/ChangeLog | 6 ++++++ gdb/i386-nat.c | 39 +++++---------------------------------- 2 files changed, 11 insertions(+), 34 deletions(-) diff --git a/gdb/i386-nat.c b/gdb/i386-nat.c index 3ff0711..c956583 100644 --- a/gdb/i386-nat.c +++ b/gdb/i386-nat.c @@ -738,27 +738,13 @@ i386_stopped_by_watchpoint (struct target_ops *ops) /* Insert a hardware-assisted breakpoint at BP_TGT->placed_address. Return 0 on success, EBUSY on failure. */ + static int i386_insert_hw_breakpoint (struct target_ops *self, struct gdbarch *gdbarch, struct bp_target_info *bp_tgt) { - struct i386_debug_reg_state *state - = i386_debug_reg_state (ptid_get_pid (inferior_ptid)); - unsigned len_rw = i386_length_and_rw_bits (1, hw_execute); - CORE_ADDR addr = bp_tgt->placed_address; - /* Work on a local copy of the debug registers, and on success, - commit the change back to the inferior. */ - struct i386_debug_reg_state local_state = *state; - int retval = i386_insert_aligned_watchpoint (&local_state, - addr, len_rw) ? EBUSY : 0; - - if (retval == 0) - i386_update_inferior_debug_regs (state, &local_state); - - if (debug_hw_points) - i386_show_dr (state, "insert_hwbp", addr, 1, hw_execute); - - return retval; + return i386_insert_watchpoint (self, bp_tgt->placed_address, 1, + hw_execute, NULL) ? EBUSY : 0; } /* Remove a hardware-assisted breakpoint at BP_TGT->placed_address. @@ -768,23 +754,8 @@ static int i386_remove_hw_breakpoint (struct target_ops *self, struct gdbarch *gdbarch, struct bp_target_info *bp_tgt) { - struct i386_debug_reg_state *state - = i386_debug_reg_state (ptid_get_pid (inferior_ptid)); - unsigned len_rw = i386_length_and_rw_bits (1, hw_execute); - CORE_ADDR addr = bp_tgt->placed_address; - /* Work on a local copy of the debug registers, and on success, - commit the change back to the inferior. */ - struct i386_debug_reg_state local_state = *state; - int retval = i386_remove_aligned_watchpoint (&local_state, - addr, len_rw); - - if (retval == 0) - i386_update_inferior_debug_regs (state, &local_state); - - if (debug_hw_points) - i386_show_dr (state, "remove_hwbp", addr, 1, hw_execute); - - return retval; + return i386_remove_watchpoint (self, bp_tgt->placed_address, 1, + hw_execute, NULL); } /* Returns the number of hardware watchpoints of type TYPE that we can