* [pushed 1/3] [gdb/testsuite] Clean up gdb.mi/pr11022.exp
2026-11-01 15:51 [pushed 0/3] [gdb/testsuite] Some gdb.mi/pr11022.exp fixes Tom de Vries
@ 2026-11-01 15:51 ` Tom de Vries
2026-11-01 15:51 ` [pushed 2/3] [gdb/testsuite] Refactor gdb.mi/pr11022.exp Tom de Vries
2026-11-01 15:51 ` [pushed 3/3] [gdb/testsuite] Fix gdb.mi/pr11022.exp on big endian Tom de Vries
2 siblings, 0 replies; 4+ messages in thread
From: Tom de Vries @ 2026-11-01 15:51 UTC (permalink / raw)
To: gdb-patches
Clean up test-case gdb.mi/pr11022.exp:
- use build_executable instead of gdb_compile
- remove double spaces
- fix indentation
- don't use global
- remove unnecessary escaping
Tested on x86_64-linux.
---
gdb/testsuite/gdb.mi/pr11022.exp | 25 +++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)
diff --git a/gdb/testsuite/gdb.mi/pr11022.exp b/gdb/testsuite/gdb.mi/pr11022.exp
index 35e31af95b1..8644fadf7ed 100644
--- a/gdb/testsuite/gdb.mi/pr11022.exp
+++ b/gdb/testsuite/gdb.mi/pr11022.exp
@@ -20,46 +20,47 @@ set MIFLAGS "-i=mi"
standard_testfile .c
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
- untested "failed to compile"
- return
+if {[build_executable "failed to prepare" $testfile]} {
+ return
}
proc test_memory_changed_observer { mi_command } {
with_test_prefix "${mi_command}" {
- global srcfile binfile
-
mi_clean_restart $::testfile
mi_runto_main
set line_number [gdb_get_line_number "break here"]
- mi_gdb_test "-break-insert ${srcfile}:${line_number}" \
+ mi_gdb_test "-break-insert $::srcfile:$line_number" \
{\^done,bkpt=.number="2",type="breakpoint".*\}} \
"set breakpoint"
mi_gdb_test "watch x" ".*" "set watchpoint"
mi_execute_to "exec-continue" "breakpoint-hit" "main" "" ".*" ".*" \
- { "" "disp=\"keep\"" } "breakpoint hit"
+ { "" {disp="keep"} } "breakpoint hit"
mi_execute_to "exec-continue" "watchpoint-trigger" "main" "" ".*" ".*" \
- { "" "wpt=\{number=\"3\",exp=\"x\"\},value=\{old=\"0\",new=\"42\"\}" } \
+ [list \
+ "" \
+ {wpt={number="3",exp="x"},value={old="0",new="42"}}] \
"watchpoint hit"
mi_execute_to "exec-continue" "breakpoint-hit" "main" "" ".*" ".*" \
- { "" "disp=\"keep\"" } "breakpoint hit 2"
+ { "" {disp="keep"} } "breakpoint hit 2"
mi_gdb_test "-${mi_command}" {\^done} "set x"
mi_execute_to "exec-continue" "watchpoint-trigger" "main" "" ".*" ".*" \
- { "" "wpt=\{number=\"3\",exp=\"x\"\},value=\{old=\"1\",new=\"42\"\}" } \
+ [list \
+ "" \
+ {wpt={number="3",exp="x"},value={old="1",new="42"}}] \
"watchpoint hit 2"
mi_gdb_exit
}
}
-test_memory_changed_observer "data-write-memory-bytes &x \"01\""
+test_memory_changed_observer {data-write-memory-bytes &x "01"}
# We want to trigger a target memory write here, so the word size (4 or 8)
# is not that important.
-test_memory_changed_observer "data-write-memory &x x 4 \"01\""
+test_memory_changed_observer {data-write-memory &x x 4 "01"}
--
2.51.0
^ permalink raw reply [flat|nested] 4+ messages in thread* [pushed 2/3] [gdb/testsuite] Refactor gdb.mi/pr11022.exp
2026-11-01 15:51 [pushed 0/3] [gdb/testsuite] Some gdb.mi/pr11022.exp fixes Tom de Vries
2026-11-01 15:51 ` [pushed 1/3] [gdb/testsuite] Clean up gdb.mi/pr11022.exp Tom de Vries
@ 2026-11-01 15:51 ` Tom de Vries
2026-11-01 15:51 ` [pushed 3/3] [gdb/testsuite] Fix gdb.mi/pr11022.exp on big endian Tom de Vries
2 siblings, 0 replies; 4+ messages in thread
From: Tom de Vries @ 2026-11-01 15:51 UTC (permalink / raw)
To: gdb-patches
Refactor test-case gdb.mi/pr11022.exp, to minimize changes in the following
patch:
- add variable parameter to test_memory_changed_observer
- factor out 0/1/42 value regexp
Tested on x86_64-linux.
---
gdb/testsuite/gdb.mi/pr11022.exp | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/gdb/testsuite/gdb.mi/pr11022.exp b/gdb/testsuite/gdb.mi/pr11022.exp
index 8644fadf7ed..f3987da4d75 100644
--- a/gdb/testsuite/gdb.mi/pr11022.exp
+++ b/gdb/testsuite/gdb.mi/pr11022.exp
@@ -24,7 +24,7 @@ if {[build_executable "failed to prepare" $testfile]} {
return
}
-proc test_memory_changed_observer { mi_command } {
+proc test_memory_changed_observer { var mi_command } {
with_test_prefix "${mi_command}" {
mi_clean_restart $::testfile
mi_runto_main
@@ -34,33 +34,39 @@ proc test_memory_changed_observer { mi_command } {
{\^done,bkpt=.number="2",type="breakpoint".*\}} \
"set breakpoint"
- mi_gdb_test "watch x" ".*" "set watchpoint"
+ mi_gdb_test "watch $var" ".*" "set watchpoint"
mi_execute_to "exec-continue" "breakpoint-hit" "main" "" ".*" ".*" \
{ "" {disp="keep"} } "breakpoint hit"
+ set re_0 "0"
+ set re_1 "1"
+ set re_42 "42"
+
mi_execute_to "exec-continue" "watchpoint-trigger" "main" "" ".*" ".*" \
[list \
"" \
- {wpt={number="3",exp="x"},value={old="0",new="42"}}] \
+ [subst_vars \
+ {wpt={number="3",exp="$var"},value={old="$re_0",new="$re_42"}}]] \
"watchpoint hit"
mi_execute_to "exec-continue" "breakpoint-hit" "main" "" ".*" ".*" \
{ "" {disp="keep"} } "breakpoint hit 2"
- mi_gdb_test "-${mi_command}" {\^done} "set x"
+ mi_gdb_test "-${mi_command}" {\^done} "set $var"
mi_execute_to "exec-continue" "watchpoint-trigger" "main" "" ".*" ".*" \
[list \
"" \
- {wpt={number="3",exp="x"},value={old="1",new="42"}}] \
+ [subst_vars \
+ {wpt={number="3",exp="$var"},value={old="$re_1",new="$re_42"}}]] \
"watchpoint hit 2"
mi_gdb_exit
}
}
-test_memory_changed_observer {data-write-memory-bytes &x "01"}
+test_memory_changed_observer x {data-write-memory-bytes &x "01"}
# We want to trigger a target memory write here, so the word size (4 or 8)
# is not that important.
-test_memory_changed_observer {data-write-memory &x x 4 "01"}
+test_memory_changed_observer x {data-write-memory &x x 4 "01"}
--
2.51.0
^ permalink raw reply [flat|nested] 4+ messages in thread* [pushed 3/3] [gdb/testsuite] Fix gdb.mi/pr11022.exp on big endian
2026-11-01 15:51 [pushed 0/3] [gdb/testsuite] Some gdb.mi/pr11022.exp fixes Tom de Vries
2026-11-01 15:51 ` [pushed 1/3] [gdb/testsuite] Clean up gdb.mi/pr11022.exp Tom de Vries
2026-11-01 15:51 ` [pushed 2/3] [gdb/testsuite] Refactor gdb.mi/pr11022.exp Tom de Vries
@ 2026-11-01 15:51 ` Tom de Vries
2 siblings, 0 replies; 4+ messages in thread
From: Tom de Vries @ 2026-11-01 15:51 UTC (permalink / raw)
To: gdb-patches
On s390x-linux, with test-case gdb.mi/pr11022.exp I run into:
...
FAIL: $exp: data-write-memory-bytes &x "01": \
watchpoint hit 2 (unknown output after running)
...
The problem is that we're writing a byte to the start address of an int,
which gets different results on big and little endian.
Fix this by writing to an int8_t instead.
Likewise, make sure that the 4-byte write writes to a 4-byte int by using
int32_t instead of int.
Tested on x86_64-linux and s390x-linux.
---
gdb/testsuite/gdb.mi/pr11022.c | 7 +++++--
gdb/testsuite/gdb.mi/pr11022.exp | 11 +++++------
2 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/gdb/testsuite/gdb.mi/pr11022.c b/gdb/testsuite/gdb.mi/pr11022.c
index 676506c2849..240f50b8750 100644
--- a/gdb/testsuite/gdb.mi/pr11022.c
+++ b/gdb/testsuite/gdb.mi/pr11022.c
@@ -15,7 +15,10 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-int x;
+#include <stdint.h>
+
+int32_t x;
+int8_t b;
int
main ()
@@ -24,7 +27,7 @@ main ()
for (i = 0; i < 500; ++i) {
j = 0; /* break here */
- x = 42;
+ x = b = 42;
j = i; /* expect HW watchpoint stop */
}
return 0;
diff --git a/gdb/testsuite/gdb.mi/pr11022.exp b/gdb/testsuite/gdb.mi/pr11022.exp
index f3987da4d75..66ad6348c7a 100644
--- a/gdb/testsuite/gdb.mi/pr11022.exp
+++ b/gdb/testsuite/gdb.mi/pr11022.exp
@@ -39,9 +39,10 @@ proc test_memory_changed_observer { var mi_command } {
mi_execute_to "exec-continue" "breakpoint-hit" "main" "" ".*" ".*" \
{ "" {disp="keep"} } "breakpoint hit"
- set re_0 "0"
- set re_1 "1"
- set re_42 "42"
+ set re_char {( '[^'\r\n]+')?}
+ set re_0 "0$re_char"
+ set re_1 "1$re_char"
+ set re_42 "42$re_char"
mi_execute_to "exec-continue" "watchpoint-trigger" "main" "" ".*" ".*" \
[list \
@@ -66,7 +67,5 @@ proc test_memory_changed_observer { var mi_command } {
}
}
-test_memory_changed_observer x {data-write-memory-bytes &x "01"}
-# We want to trigger a target memory write here, so the word size (4 or 8)
-# is not that important.
+test_memory_changed_observer b {data-write-memory-bytes &b "01"}
test_memory_changed_observer x {data-write-memory &x x 4 "01"}
--
2.51.0
^ permalink raw reply [flat|nested] 4+ messages in thread