From: Gary Benson <gbenson@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 2/4 v2] Refactor i386_{insert,remove}_hw_breakpoint
Date: Wed, 18 Jun 2014 15:23:00 -0000 [thread overview]
Message-ID: <1403104976-2492-3-git-send-email-gbenson@redhat.com> (raw)
In-Reply-To: <1403104976-2492-1-git-send-email-gbenson@redhat.com>
This commit refactors i386_{insert,remove}_hw_breakpoint
to call i386_{insert,remove}_watchpoint rather than
duplicating functionality.
gdb/
2014-06-18 Gary Benson <gbenson@redhat.com>
* 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
--
1.7.1
next prev parent reply other threads:[~2014-06-18 15:23 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-18 15:23 [PATCH 0/4 v2] Refactor shared code in i386-{nat,low}.[ch] Gary Benson
2014-06-18 15:23 ` [PATCH 1/4 v2] Partially revert 4be83cc2b28ea09aa8ff789839e6520df60836f8 Gary Benson
2014-06-19 9:10 ` Pedro Alves
2014-06-18 15:23 ` Gary Benson [this message]
2014-06-19 9:10 ` [PATCH 2/4 v2] Refactor i386_{insert,remove}_hw_breakpoint Pedro Alves
2014-06-18 15:23 ` [PATCH 4/4 v2] Directly call i386-dregs functions Gary Benson
2014-06-19 9:11 ` Pedro Alves
2014-06-18 15:53 ` [PATCH 3/4 v2] Create nat/i386-dregs.c Gary Benson
2014-06-19 9:11 ` Pedro Alves
2014-06-18 16:06 ` [PATCH 0/4 v2] Refactor shared code in i386-{nat,low}.[ch] Mark Kettenis
2014-06-18 16:10 ` Pedro Alves
2014-06-18 17:48 ` Mark Kettenis
2014-06-18 18:01 ` Pedro Alves
2014-06-19 10:45 ` Pedro Alves
2014-06-19 10:07 ` [COMMITTED PATCH " 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=1403104976-2492-3-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