return; /* write_size8twice_return */
}
+static void
+read_size8twice (void)
+{
+ static uint64_t volatile first;
+ static uint64_t volatile second;
+
+ first = data.u.size8twice[offset];
+ second = data.u.size8twice[offset + 1];
+
+ /* Setting a breakpoint on an instruction after an instruction triggering a
+ watchpoint makes it ambiguous which one will be reported.
+ Insert a dummy instruction inbetween to make sure the watchpoint gets
+ reported. */
+ volatile_dummy = 1;
+
+ return; /* read_size8twice_return */
+}
+
int
main (void)
{
assert (sizeof (data) == 8 + 3 * 8);
write_size8twice ();
+ read_size8twice ();
while (size)
{
gdb_assert $got_hit $test
}
-proc size8twice { function offset index } {
+proc size8twice { function cmd offset index } {
clean_restart $::testfile
if { ![runto $function] } {
# Set a hardware watchpoint.
set watch_index [expr $offset + $index]
- set test "watch data.u.size8twice\[$watch_index\]"
+ set test "$cmd data.u.size8twice\[$watch_index\]"
set wpnum 0
gdb_test_multiple $test "" {
- -re -wrap "Hardware watchpoint ($::decimal): .*" {
- set wpnum $expect_out(1,string)
+ -re -wrap "Hardware (read )?watchpoint ($::decimal): .*" {
+ set wpnum $expect_out(2,string)
pass $gdb_test_name
}
-re -wrap "Watchpoint ($::decimal): .*" {
gdb_test_multiple "continue" "" {
-re -wrap "\r\nCould not insert hardware watchpoint .*" {
}
- -re -wrap "Hardware watchpoint $wpnum:.*New value = .*" {
+ -re -wrap "Hardware (read )?watchpoint $wpnum:.*(New value|Value) = .*" {
set got_hit 1
send_gdb "continue\n"
exp_continue
-re -wrap " $bp_src_string .*" {
}
}
- gdb_assert $got_hit "size8twice write"
+ gdb_assert { $got_hit }
return $got_hit
}
# For each case, check setting a watchpoint at:
# - the first written element (index == 0), and
# - the second element (index == 1).
-foreach_with_prefix offset { 0 1 } {
- foreach_with_prefix index { 0 1 } {
- if { [size8twice write_size8twice $offset $index] != 1 } {
- return
+foreach_with_prefix fun { write_size8twice read_size8twice } {
+ if { $fun == "write_size8twice" } {
+ set cmd "watch"
+ } else {
+ set cmd "rwatch"
+ }
+ foreach_with_prefix offset { 0 1 } {
+ foreach_with_prefix index { 0 1 } {
+ set res [size8twice $fun $cmd $offset $index]
+ if { $res != 1 } {
+ break
+ }
+ }
+ if { $res != 1 } {
+ break
}
}
}