From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1726) id 52DAC3858C51; Tue, 3 May 2022 09:48:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 52DAC3858C51 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Andrew Burgess To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb: fix failures in gdb.mi/mi-exec-run.exp with native-extended-gdbserver X-Act-Checkin: binutils-gdb X-Git-Author: Andrew Burgess X-Git-Refname: refs/heads/master X-Git-Oldrev: 79b6c88404d2597f420f2a91c1248e887d3425c1 X-Git-Newrev: a56c63f78ebd158972882b4f8c183d70e9ef1cfd Message-Id: <20220503094848.52DAC3858C51@sourceware.org> Date: Tue, 3 May 2022 09:48:48 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 May 2022 09:48:48 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Da56c63f78ebd= 158972882b4f8c183d70e9ef1cfd commit a56c63f78ebd158972882b4f8c183d70e9ef1cfd Author: Andrew Burgess Date: Wed Apr 27 15:40:39 2022 +0100 gdb: fix failures in gdb.mi/mi-exec-run.exp with native-extended-gdbser= ver =20 When running the gdb.mi/mi-exec-run.exp test using the native-extended-gdbserver I see failures like this: =20 FAIL: gdb.mi/mi-exec-run.exp: inferior-tty=3Dmain: mi=3Dmain: force-f= ail=3D1: run failure detected FAIL: gdb.mi/mi-exec-run.exp: inferior-tty=3Dmain: mi=3Dseparate: for= ce-fail=3D1: run failure detected FAIL: gdb.mi/mi-exec-run.exp: inferior-tty=3Dseparate: mi=3Dseparate:= force-fail=3D1: run failure detected =20 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. =20 NOTE: I also see an additional test failure: =20 FAIL: gdb.mi/mi-exec-run.exp: inferior-tty=3Dseparate: mi=3Dseparate: = force-fail=3D0: breakpoint hit reported on console (timeout) =20 but that is a completely different issue, and is not being addressed in this commit. =20 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. =20 Now, if gdb exits then this is a test failure (this would indicate gdb crashing, which is bad), so we have an eof pattern associated with the gdb spawn-id. =20 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. =20 The problem is that after spotting the pattern from gdbserver, we often see the eof from gdbserver before we see the pattern from gdb. If this happens then we drop out of the gdb_expect without ever seeing the pattern from gdb, and fail the test. =20 In this commit, I place the spawn-id of gdbserver into a global variable, and then use this global variable as the -i option within the gdb_expect. =20 Now, once we have seen the expected pattern on the gdbserver spawn-id, the global variable is cleared. After this the gdb_expect no longer checks the gdbserver spawn-id for additional output, and so never sees the eof event. This leaves the gdb_expect running, which allows the pattern from gdb to be seen, and for the test to pass. =20 I now see no failures relating to 'run failure detected'. Diff: --- gdb/testsuite/gdb.mi/mi-exec-run.exp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/gdb/testsuite/gdb.mi/mi-exec-run.exp b/gdb/testsuite/gdb.mi/mi= -exec-run.exp index f397159078f..ffbe6bcd36e 100644 --- a/gdb/testsuite/gdb.mi/mi-exec-run.exp +++ b/gdb/testsuite/gdb.mi/mi-exec-run.exp @@ -93,10 +93,27 @@ proc test {inftty_mode mi_mode force_fail} { set test "run failure detected" send_gdb "-exec-run --start\n" =20 + # Redirect through SPAWN_LIST global. If the + # inferior_spawn_id is not the same as gdb_spawn_id, e.g. when + # testing with gdbserver, the gdbserver can exit after + # emitting it's error message. + # + # If inferior_spawn_id exits then we may see the eof from that + # spawn-id before we see the pattern from the gdb_spawn_id, + # which will kick us out of the gdb_expect, and cause us to + # fail the test. + # + # Instead we clean SPAWN_LIST once we've seen the expected + # pattern from that spawn-id, and after that we no longer care + # when gdbserver exits. + global spawn_list + set spawn_list "$inferior_spawn_id" + gdb_expect { - -i "$inferior_spawn_id" + -i spawn_list -re ".*Cannot exec.*Permission denied" { set saw_perm_error 1 + set spawn_list "" verbose -log "saw perm error" if {!$saw_mi_error} { exp_continue