aboutsummaryrefslogtreecommitdiff
path: root/gdb/i386-nat.c
diff options
context:
space:
mode:
authorDaniel Jacobowitz <drow@false.org>2008-03-01 04:39:36 +0000
committerDaniel Jacobowitz <drow@false.org>2008-03-01 04:39:36 +0000
commitc03374d554a6d5f326a0d356a2e0918961bc1cfb (patch)
tree5e78e840af0460012c9368fbc4189b90654e407d /gdb/i386-nat.c
parent16fb4e2d3a147568e4e6b00c82adcf447ba10ffe (diff)
downloadgdb-c03374d554a6d5f326a0d356a2e0918961bc1cfb.zip
gdb-c03374d554a6d5f326a0d356a2e0918961bc1cfb.tar.gz
gdb-c03374d554a6d5f326a0d356a2e0918961bc1cfb.tar.bz2
* Makefile.in (i386-nat.o): Update.
* amd64-linux-nat.c (_initialize_amd64_linux_nat): Call i386_use_watchpoints. * i386-linux-nat.c (_initialize_i386_linux_nat): Call i386_use_watchpoints. * i386-nat.c (i386_stopped_data_address): Take two arguments. (i386_stopped_by_watchpoint): Update call. (i386_can_use_hw_breakpoint, i386_use_watchpoints): New. * config/i386/nm-i386.h: Conditionalize definitions on ! I386_WATCHPOINTS_IN_TARGET_VECTOR. (i386_use_watchpoints): Declare. (i386_stopped_data_address): Update. * config/i386/nm-linux.h (I386_WATCHPOINTS_IN_TARGET_VECTOR): Define. * config/i386/nm-linux64.h (I386_WATCHPOINTS_IN_TARGET_VECTOR): Define.
Diffstat (limited to 'gdb/i386-nat.c')
-rw-r--r--gdb/i386-nat.c46
1 files changed, 44 insertions, 2 deletions
diff --git a/gdb/i386-nat.c b/gdb/i386-nat.c
index 349541f..f6ae5bf 100644
--- a/gdb/i386-nat.c
+++ b/gdb/i386-nat.c
@@ -21,6 +21,7 @@
#include "breakpoint.h"
#include "command.h"
#include "gdbcmd.h"
+#include "target.h"
/* Support for hardware watchpoints and breakpoints using the i386
debug registers.
@@ -563,7 +564,7 @@ i386_region_ok_for_watchpoint (CORE_ADDR addr, int len)
Otherwise, return zero. */
int
-i386_stopped_data_address (CORE_ADDR *addr_p)
+i386_stopped_data_address (struct target_ops *ops, CORE_ADDR *addr_p)
{
CORE_ADDR addr = 0;
int i;
@@ -599,7 +600,7 @@ int
i386_stopped_by_watchpoint (void)
{
CORE_ADDR addr = 0;
- return i386_stopped_data_address (&addr);
+ return i386_stopped_data_address (&current_target, &addr);
}
/* Return non-zero if the inferior has some break/watchpoint that
@@ -654,6 +655,47 @@ i386_remove_hw_breakpoint (struct bp_target_info *bp_tgt)
return retval;
}
+/* Returns the number of hardware watchpoints of type TYPE that we can
+ set. Value is positive if we can set CNT watchpoints, zero if
+ setting watchpoints of type TYPE is not supported, and negative if
+ CNT is more than the maximum number of watchpoints of type TYPE
+ that we can support. TYPE is one of bp_hardware_watchpoint,
+ bp_read_watchpoint, bp_write_watchpoint, or bp_hardware_breakpoint.
+ CNT is the number of such watchpoints used so far (including this
+ one). OTHERTYPE is non-zero if other types of watchpoints are
+ currently enabled.
+
+ We always return 1 here because we don't have enough information
+ about possible overlap of addresses that they want to watch. As an
+ extreme example, consider the case where all the watchpoints watch
+ the same address and the same region length: then we can handle a
+ virtually unlimited number of watchpoints, due to debug register
+ sharing implemented via reference counts in i386-nat.c. */
+
+static int
+i386_can_use_hw_breakpoint (int type, int cnt, int othertype)
+{
+ return 1;
+}
+
+void
+i386_use_watchpoints (struct target_ops *t)
+{
+ /* After a watchpoint trap, the PC points to the instruction after the
+ one that caused the trap. Therefore we don't need to step over it.
+ But we do need to reset the status register to avoid another trap. */
+ t->to_have_continuable_watchpoint = 1;
+
+ t->to_can_use_hw_breakpoint = i386_can_use_hw_breakpoint;
+ t->to_region_ok_for_hw_watchpoint = i386_region_ok_for_watchpoint;
+ t->to_stopped_by_watchpoint = i386_stopped_by_watchpoint;
+ t->to_stopped_data_address = i386_stopped_data_address;
+ t->to_insert_watchpoint = i386_insert_watchpoint;
+ t->to_remove_watchpoint = i386_remove_watchpoint;
+ t->to_insert_hw_breakpoint = i386_insert_hw_breakpoint;
+ t->to_remove_hw_breakpoint = i386_remove_hw_breakpoint;
+}
+
#endif /* I386_USE_GENERIC_WATCHPOINTS */