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: Re: [PATCH] [gdb/testsuite] Fix gdb.mi/pr11022.exp on big endian
Date: Thu, 29 Oct 2026 19:53:17 +0100	[thread overview]
Message-ID: <9ef9c70b-e4a9-45be-bce0-5d14e1a88967@suse.de> (raw)
In-Reply-To: <20261028231313.1835272-1-tdevries@suse.de>

On 10/29/26 12:13 AM, Tom de Vries wrote:
> 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.
> 
> While we're at it, reduce unnecessary escaping.
> 

In retrospect perhaps it was not the best idea to submit this as one patch.

I'll try to split it up into two patches, one simplification patch, and 
one fix.

Thanks,
- Tom

> Tested on x86_64-linux and s390x-linux.
> ---
>   gdb/testsuite/gdb.mi/pr11022.c   |  7 +++++--
>   gdb/testsuite/gdb.mi/pr11022.exp | 31 ++++++++++++++++++++-----------
>   2 files changed, 25 insertions(+), 13 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 35e31af95b1..b72db25a270 100644
> --- a/gdb/testsuite/gdb.mi/pr11022.exp
> +++ b/gdb/testsuite/gdb.mi/pr11022.exp
> @@ -25,7 +25,7 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
>        return
>   }
>   
> -proc test_memory_changed_observer { mi_command } {
> +proc test_memory_changed_observer { var mi_command } {
>       with_test_prefix "${mi_command}" {
>   	global srcfile binfile
>   
> @@ -37,29 +37,38 @@ 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"
> +	    { "" {disp="keep"} } "breakpoint hit"
> +
> +	set re_0 {0( '[^\r\n]*')?}
> +	set re_1 {1( '[^\r\n]*')?}
> +	set re_42 {42( '[^\r\n]*')?}
>   
>   	mi_execute_to "exec-continue" "watchpoint-trigger" "main" "" ".*" ".*" \
> -	    { "" "wpt=\{number=\"3\",exp=\"x\"\},value=\{old=\"0\",new=\"42\"\}" } \
> +	    [list \
> +		 "" \
> +		 [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"
> +	    { "" {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" "" ".*" ".*" \
> -	    { "" "wpt=\{number=\"3\",exp=\"x\"\},value=\{old=\"1\",new=\"42\"\}" } \
> +	    [list \
> +		 "" \
> +		 [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\""
> -# 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 b {data-write-memory-bytes &b "01"}
> +
> +test_memory_changed_observer x {data-write-memory &x x 4 "01"}
> 
> base-commit: aeed64b39aed57729f66ad51560d8964e8201e6e


  reply	other threads:[~2026-10-29 18:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-28 23:13 Tom de Vries
2026-10-29 18:53 ` Tom de Vries [this message]
2026-11-01 15:54   ` Tom de Vries

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=9ef9c70b-e4a9-45be-bce0-5d14e1a88967@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