+2013-10-18 Andrew Burgess <aburgess@broadcom.com>
+
+ * breakpoint.c (update_watchpoint): If hardware watchpoints are
+ forced off, downgrade them to software watchpoints if possible,
+ and error out if not possible.
+ (watch_command_1): Move watchpoint type selection closer to
+ watchpoint creation, and extend the comments.
+
2013-10-18 Pedro Alves <palves@redhat.com>
PR gdb/16062
don't try to insert watchpoint. We don't automatically delete
such watchpoint, though, since failure to parse expression
is different from out-of-scope watchpoint. */
- if ( !target_has_execution)
+ if (!target_has_execution)
{
/* Without execution, memory can't change. No use to try and
set watchpoint locations. The watchpoint will be reset when
the target gains execution, through breakpoint_re_set. */
+ if (!can_use_hw_watchpoints)
+ {
+ if (b->base.ops->works_in_software_mode (&b->base))
+ b->base.type = bp_watchpoint;
+ else
+ error (_("Software read/access watchpoints not supported."));
+ }
}
else if (within_current_scope && b->exp)
{
if (*tok)
error (_("Junk at end of command."));
- if (accessflag == hw_read)
- bp_type = bp_read_watchpoint;
- else if (accessflag == hw_access)
- bp_type = bp_access_watchpoint;
- else
- bp_type = bp_hardware_watchpoint;
-
frame = block_innermost_frame (exp_valid_block);
/* If the expression is "local", then set up a "watchpoint scope"
}
}
- /* Now set up the breakpoint. */
+ /* Now set up the breakpoint. We create all watchpoints as hardware
+ watchpoints here even if hardware watchpoints are turned off, a call
+ to update_watchpoint later in this function will cause the type to
+ drop back to bp_watchpoint (software watchpoint) if required. */
+
+ if (accessflag == hw_read)
+ bp_type = bp_read_watchpoint;
+ else if (accessflag == hw_access)
+ bp_type = bp_access_watchpoint;
+ else
+ bp_type = bp_hardware_watchpoint;
w = XCNEW (struct watchpoint);
b = &w->base;
return -1
}
+with_test_prefix "before inferior start" {
+ # Ensure that if we turn off hardware watchpoints and set a watch point
+ # before starting the inferior the watchpoint created will not be a
+ # hardware watchpoint.
+ gdb_test_no_output "set can-use-hw-watchpoints 0" ""
+ gdb_test "watch ival1" "Watchpoint \[0-9\]+: ival1" \
+ "create watchpoint"
+
+ # The next tests are written to match the current state of gdb: access
+ # and read watchpoints require hardware watchpoint support, with this
+ # turned off these can't be created.
+ gdb_test "awatch ival1" \
+ "Software read/access watchpoints not supported." \
+ "create access watchpoint"
+ gdb_test "rwatch ival1" \
+ "Software read/access watchpoints not supported." \
+ "create read watchpoint"
+}
+
+ # This will turn hardware watchpoints back on and delete the watchpoint
+ # we just created.
+ clean_restart ${binfile}
+
# Disable hardware watchpoints if necessary.
if [target_info exists gdb,no_hardware_watchpoints] {
gdb_test_no_output "set can-use-hw-watchpoints 0" ""