public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Pedro Alves <pedro@palves.net>
To: Andrew Burgess <aburgess@redhat.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH 1/2] gdb: fix failures in gdb.mi/mi-exec-run.exp with native-extended-gdbserver
Date: Wed, 27 Apr 2022 19:42:48 +0100	[thread overview]
Message-ID: <b0bd2a2a-9624-443e-6813-959486bd3190@palves.net> (raw)
In-Reply-To: <7e541f1c625c73f20694ac37f3c326e57f95c11d.1651083290.git.aburgess@redhat.com>

On 2022-04-27 19:17, Andrew Burgess via Gdb-patches wrote:
> When running the gdb.mi/mi-exec-run.exp test using the
> native-extended-gdbserver I see failures like this:
> 
>   FAIL: gdb.mi/mi-exec-run.exp: inferior-tty=main: mi=main: force-fail=1: run failure detected
>   FAIL: gdb.mi/mi-exec-run.exp: inferior-tty=main: mi=separate: force-fail=1: run failure detected
>   FAIL: gdb.mi/mi-exec-run.exp: inferior-tty=separate: mi=separate: force-fail=1: run failure detected
> 
> There's a race condition here, so you might see a slightly different
> set of failures, but I always see some from the 'run failure detected'
> test.
> 
> NOTE: I also see an additional test failure:
> 
>  FAIL: gdb.mi/mi-exec-run.exp: inferior-tty=separate: mi=separate: force-fail=0: breakpoint hit reported on console (timeout)
> 
> but that is a completely different issue, and is not being addressed
> in this commit.
> 
> The problem for the 'run failure detected' test is that we end up
> in gdb_expect looking for output from two spawn-ids, one from
> gdbserver, and one from gdb.  We're looking for one output pattern
> from each spawn-id, and for the test to pass we need to see both
> patterns.
> 
> Now, if gdb exits then this is a test failure (this would indicate gdb
> crashing, which is bad), so we have the eof pattern associated with
> the gdb spawn-id.
> 
> However, in this particular test we expect gdbserver to fail to
> execute the binary (the test binary is set non-executable), and so we
> get an error message from gdbserver (which matches the pattern), and
> then gdbserver exits, this is expected.
> 
> In our gdb_expect call we don't have an eof pattern for gdbserver, and
> so, when gdbserver exits, expect sees eof and drops out of the
> gdb_expect call.
> 
> If both the gdbserver AND gdb patterns are seen before the gdbserver
> eof triggers then everything is fine.
> 
> But, if expect sees gdbserver's eof before seeing the output from gdb
> then we will exit the gdb_expect call, and (as we have not seen both
> patterns) we will call 'fail'.
> 
> I initially tried to fix this by adding a new eof pattern for the
> gdbserver spawn-id that called exp_continue, however, this causes
> expect to throw an error, it is not happy to have '-i' options that
> make use of a closed spawn-id.
> 

I suspect this will look simpler if you use an indirect spawd id.  Did you try that?

From the expect man page:

  "The -i flag may also name a global variable in which case the variable is read for a
   list of spawn ids. The variable is reread whenever it changes. This provides a way of
   changing the I/O source while the command is in execution. Spawn ids provided this way
   are called "indirect" spawn ids."

Some other testcases use this technique to handle scenarios similar to what you
describe, of not wanting to expect output out of a spawn_id anymore.
E.g., gdb.base/interrupt.exp has:

        set spawn_list "$inferior_spawn_id"

        gdb_test_multiple "" $msg {
            -i spawn_list -re "end of file" {
                set saw_end_of_file 1
                verbose -log "saw \"end of file\""
                if {!$saw_inferior_exit} {
                    # When $inferior_spawn_id != $gdb_spawn_id, such
                    # as when testing with gdbserver, we may see the
                    # eof (the process exit, not the string just
                    # matched) for $inferior_spawn_id before the
                    # expected gdb output.  Clear this so we no longer
                    # expect anything out of $inferior_spawn_id.
                    set spawn_list ""
                    exp_continue
                }
            }
       [...]

  reply	other threads:[~2022-04-27 18:42 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-27 18:17 [PATCH 0/2] Fix mi-exec-run.exp " Andrew Burgess
2022-04-27 18:17 ` [PATCH 1/2] gdb: fix failures in gdb.mi/mi-exec-run.exp " Andrew Burgess
2022-04-27 18:42   ` Pedro Alves [this message]
2022-04-27 18:17 ` [PATCH 2/2] gdb/testsuite: fix native-extended-gdbserver failure in mi-exec-run.exp Andrew Burgess
2022-04-28 11:27 ` [PATCHv2 0/2] Fix mi-exec-run.exp with native-extended-gdbserver Andrew Burgess
2022-04-28 11:27   ` [PATCHv2 1/2] gdb: fix failures in gdb.mi/mi-exec-run.exp " Andrew Burgess
2022-04-29 13:52     ` Pedro Alves
2022-04-28 11:27   ` [PATCHv2 2/2] gdb/testsuite: fix native-extended-gdbserver failure in mi-exec-run.exp Andrew Burgess
2022-04-29 14:13     ` Pedro Alves
2022-04-29 18:15       ` [PATCHv3 0/3] gdb/testsuite: fix mi-exec-run.exp Andrew Burgess
2022-04-29 18:15         ` [PATCHv3 1/3] gdb/testsuite: fix mi-exec-run.exp with native-extended-gdbserver board Andrew Burgess
2022-04-29 18:15         ` [PATCHv3 2/3] gdb/testsuite: change mi_gdb_start to take a list of flags Andrew Burgess
2022-04-29 18:15         ` [PATCHv3 3/3] gdb/testsuite: small cleanup in mi-break-qualified.exp Andrew Burgess
2022-05-02 16:37         ` [PATCHv3 0/3] gdb/testsuite: fix mi-exec-run.exp Pedro Alves
2022-05-03  9:49           ` 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=b0bd2a2a-9624-443e-6813-959486bd3190@palves.net \
    --to=pedro@palves.net \
    --cc=aburgess@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).