public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Luis Machado <luis.machado@arm.com>
To: "Alexandra Hájková" <ahajkova@redhat.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH] gdb.base/watchpoint-unaligned.exp: Fix TCL error.
Date: Thu, 13 Apr 2023 14:55:54 +0100	[thread overview]
Message-ID: <cdb71326-82f5-093e-e3aa-0e8d8a9c6c7d@arm.com> (raw)
In-Reply-To: <20230412210846.127441-1-ahajkova@redhat.com>

On 4/12/23 22:08, Alexandra Hájková via Gdb-patches wrote:
> From: Alexandra Hajkova <ahajkova@redhat.com>
> 
> When running this test on aarch64 I've got TCL error:
> ERROR:  can't read "wpoffset_to_wpnum(1)": no such element in array
> ERROR:  tcl error code TCL READ VARNAME
> ERROR:  tcl error info:
> can't read "wpoffset_to_wpnum(1)": no such element in array ...
> 
> This patch adds checks whether the wpoffset_to_wpnum array member
> exists to avoid the error.
> 
> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30340
> ---
>   .../gdb.base/watchpoint-unaligned.exp         | 38 ++++++++++---------
>   1 file changed, 21 insertions(+), 17 deletions(-)
> 
> diff --git a/gdb/testsuite/gdb.base/watchpoint-unaligned.exp b/gdb/testsuite/gdb.base/watchpoint-unaligned.exp
> index ce5a1e5bf66..d470368a6e3 100644
> --- a/gdb/testsuite/gdb.base/watchpoint-unaligned.exp
> +++ b/gdb/testsuite/gdb.base/watchpoint-unaligned.exp
> @@ -121,27 +121,31 @@ foreach wpcount {4 7} {
>       gdb_test_no_output -nopass "set variable offset = 1"
>       set test "continue"
>       set got_hit 0
> -    gdb_test_multiple $test $test {
> -	-re "\r\nCould not insert hardware watchpoint .*\r\n$gdb_prompt $" {
> -	}
> -	-re "$rwatch_exp $wpoffset_to_wpnum(1):.*alue = .*\r\n$gdb_prompt $" {
> -	    set got_hit 1
> -	    send_gdb "continue\n"
> -	    exp_continue
> -	}
> -	-re " start_again .*\r\n$gdb_prompt $" {
> -	}
> +    if {[info exists wpoffset_to_wpnum(1)]} {
> +	    gdb_test_multiple $test $test {
> +		    -re "\r\nCould not insert hardware watchpoint .*\r\n$gdb_prompt $" {
> +		    }
> +		    -re "$rwatch_exp $wpoffset_to_wpnum(1):.*alue = .*\r\n$gdb_prompt $" {
> +			    set got_hit 1
> +			    send_gdb "continue\n"
> +			    exp_continue
> +		    }
> +		    -re " start_again .*\r\n$gdb_prompt $" {
> +		    }
> +	    }
>       }
>       for {set wpoffset 1} {$wpoffset <= $wpcount} {incr wpoffset} {
> -	if {$wpoffset_to_wpnum($wpoffset)} {
> -	    gdb_test_no_output "delete $wpoffset_to_wpnum($wpoffset)" ""
> -	}
> +	    if {[info exists wpoffset_to_wpnum($wpoffset)] &&
> +		    $wpoffset_to_wpnum($wpoffset)} {
> +		    gdb_test_no_output "delete $wpoffset_to_wpnum($wpoffset)" ""
> +	    }
>       }
>       set test "wpcount($wpcount)"
> -    if {!$wpoffset_to_wpnum([expr $wpcount - 1])} {
> -	untested $test
> -	continue
> -    }
> +    if {[info exists wpoffset_to_wpnum([expr $wpcount - 1])] &&
> +	    !$wpoffset_to_wpnum([expr $wpcount - 1])} {
> +		    untested $test
> +		    continue
> +	    }
>       if {$wpcount > 4} {
>   	if {![istarget "s390*-*-*"]} {
>   	    setup_kfail tdep/22389 *-*-*

As I commented on the bug ticket, I think a better approach is to check for errors and then bail out of the test if one is found.

If we can't insert watchpoints, it is probably not worth continuing to run checks. We will end up with a pile of failures.

  reply	other threads:[~2023-04-13 13:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-12 21:08 Alexandra Hájková
2023-04-13 13:55 ` Luis Machado [this message]
2023-04-25 10:47 ` [PATCH v2] gdb.base/watchpoint-unaligned.exp: Always initialize wpoffset_to_wpnum Alexandra Hájková
2023-05-02 11:34   ` Luis Machado
2023-05-02 13:50   ` Andrew Burgess
2023-05-02 14:53     ` Tom Tromey
2023-05-05 16:23       ` Andrew Burgess

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=cdb71326-82f5-093e-e3aa-0e8d8a9c6c7d@arm.com \
    --to=luis.machado@arm.com \
    --cc=ahajkova@redhat.com \
    --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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).