Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [pushed 3/3] [gdb/testsuite] Fix gdb.mi/pr11022.exp on big endian
Date: Sun,  1 Nov 2026 16:51:53 +0100	[thread overview]
Message-ID: <20261101155153.640893-4-tdevries@suse.de> (raw)
In-Reply-To: <20261101155153.640893-1-tdevries@suse.de>

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


      parent reply	other threads:[~2026-11-01 15:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261101155153.640893-4-tdevries@suse.de \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox