diff options
author | Tom de Vries <tdevries@suse.de> | 2025-08-12 16:35:05 +0200 |
---|---|---|
committer | Tom de Vries <tdevries@suse.de> | 2025-08-12 16:35:05 +0200 |
commit | 3769fe5ed37ac05f78b9879a4bcbdf2e77f49d0f (patch) | |
tree | 39550f31f44f87ec78af5884af7a575473b45564 | |
parent | d737aae03b9e09e848260fc31c5b8b66de4a7a77 (diff) | |
download | binutils-3769fe5ed37ac05f78b9879a4bcbdf2e77f49d0f.zip binutils-3769fe5ed37ac05f78b9879a4bcbdf2e77f49d0f.tar.gz binutils-3769fe5ed37ac05f78b9879a4bcbdf2e77f49d0f.tar.bz2 |
[gdb/testsuite] Extend gdb.base/watchpoint-unaligned.exp
Extend the part of gdb.base/watchpoint-unaligned.exp handling
write_size8twice to also check read hardware watchpoints.
Tested on x86_64-linux.
Approved-By: Luis Machado <luis.machado.foss@gmail.com>
-rw-r--r-- | gdb/testsuite/gdb.base/watchpoint-unaligned.c | 19 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/watchpoint-unaligned.exp | 31 |
2 files changed, 40 insertions, 10 deletions
diff --git a/gdb/testsuite/gdb.base/watchpoint-unaligned.c b/gdb/testsuite/gdb.base/watchpoint-unaligned.c index a3b6b74..baa7ae0 100644 --- a/gdb/testsuite/gdb.base/watchpoint-unaligned.c +++ b/gdb/testsuite/gdb.base/watchpoint-unaligned.c @@ -65,6 +65,24 @@ write_size8twice (void) 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) { @@ -73,6 +91,7 @@ main (void) assert (sizeof (data) == 8 + 3 * 8); write_size8twice (); + read_size8twice (); while (size) { diff --git a/gdb/testsuite/gdb.base/watchpoint-unaligned.exp b/gdb/testsuite/gdb.base/watchpoint-unaligned.exp index ffa574b..85b1eb7 100644 --- a/gdb/testsuite/gdb.base/watchpoint-unaligned.exp +++ b/gdb/testsuite/gdb.base/watchpoint-unaligned.exp @@ -151,7 +151,7 @@ foreach_with_prefix wpcount {4 7} { gdb_assert $got_hit $test } -proc size8twice { function offset index } { +proc size8twice { function cmd offset index } { clean_restart $::testfile if { ![runto $function] } { @@ -169,11 +169,11 @@ proc size8twice { function offset index } { # 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): .*" { @@ -195,7 +195,7 @@ proc size8twice { function offset index } { 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 @@ -203,7 +203,7 @@ proc size8twice { function offset index } { -re -wrap " $bp_src_string .*" { } } - gdb_assert $got_hit "size8twice write" + gdb_assert { $got_hit } return $got_hit } @@ -215,10 +215,21 @@ proc size8twice { function offset index } { # 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 } } } |