From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1879) id E2DB03858D1E; Tue, 29 Nov 2022 16:44:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E2DB03858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1669740255; bh=QqCQuTzbuA4mEvtiFNbDaQY/sMt5aWd4VIyPK94UNa0=; h=From:To:Subject:Date:From; b=hUQfXaUR7WlXaqUg1doOfA4MLnbJHq80IwTRWAlRKbeaEREI9ZFY39rKFK2dtJ7Ds II2XKElgBRt2uI5kof/kD6WHvE5AwjvmMKUPGNw4z9w0+xzM/2dbqzbwj0rplJ8gyt qxCq5+r4wy+gQwNPAssYsBB6dYWbHnS6RPqsJjSQ= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Simon Marchi To: gdb-cvs@sourceware.org Subject: =?utf-8?q?=5Bbinutils-gdb=5D_gdb/testsuite=3A_make_gdb=5Ftest=5Fmultiple_ret?= =?utf-8?q?urn_immediately_if=C2=A0send=5Fgdb_fails?= X-Act-Checkin: binutils-gdb X-Git-Author: Simon Marchi X-Git-Refname: refs/heads/master X-Git-Oldrev: 5a4020d4d4082f0a853631ca69c6944c94575457 X-Git-Newrev: d56614a9925791b15d7052eb4c798ab24a724611 Message-Id: <20221129164415.E2DB03858D1E@sourceware.org> Date: Tue, 29 Nov 2022 16:44:15 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Dd56614a99257= 91b15d7052eb4c798ab24a724611 commit d56614a9925791b15d7052eb4c798ab24a724611 Author: Simon Marchi Date: Mon Nov 21 09:41:08 2022 -0500 gdb/testsuite: make gdb_test_multiple return immediately if=C2=A0send_g= db fails =20 In the failure seen by Philippe here: =20 https://inbox.sourceware.org/gdb-patches/20221120173024.3647464-1-phi= lippe.waroquiers@skynet.be/ =20 ... the testsuite only outputs PASSes, and an ERROR, resulting from an uncaught exception. This is a bit sneaky, because ERRORs are not reported in the test summary. In certain circumstances, it can be easy to miss. =20 Normally, gdb_test_multiple outputs an UNRESOLVED when GDB crashes. But this is only if it manages to send the command, and it's that command that crashes GDB. Here, the ERROR is due to the fact that GDB had already crashed by the time we entered gdb_test_multiple and tried to send a command. GDB was crashed by the previous "file" command, sent by gdb_unload. Because gdb_unload uses bare expect, it didn't record a test failure when crashing GDB (this will be addressed separately). =20 In this patch, I propose to make gdb_test_multiple call unresolved directly and return -1 send_gdb fails. This way, if GDB is already crashed by the time we enter gdb_test_multiple, it will leave a trace in the test results in the form of an UNRESOLVED. It will also spare us the not-so-useful-in-my-opinion TCL backtrace. =20 Before, it looks like: =20 ERROR: Couldn't send python print(objfile.filename) to GDB. ERROR: : spawn id exp9 not open while executing "expect { -i exp9 -timeout 10 -re ".*A problem internal to GDB has been detected" { fail "$message (GDB internal error)" gdb_internal_error..." ("uplevel" body line 1) invoked from within "uplevel $body" NONE : spawn id exp9 not open =20 And after: =20 Couldn't send python print(objfile.filename) to GDB. UNRESOLVED: gdb.python/py-objfile.exp: objfile.filename after objfi= le is unloaded =20 Change-Id: I72af8dc0d687826fc3f76911c27a9e5f91b677ba Approved-By: Tom de Vries Diff: --- gdb/testsuite/lib/gdb.exp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index b4d4e46d492..e193a20768c 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -1161,7 +1161,9 @@ proc gdb_test_multiple { command message args } { if { $foo < [expr $len - 1] } { set str [string range "$string" 0 $foo] if { [send_gdb "$str"] !=3D "" } { - perror "Couldn't send $command to GDB." + verbose -log "Couldn't send $command to GDB." + unresolved $message + return -1 } # since we're checking if each line of the multi-line # command are 'accepted' by GDB here, @@ -1180,7 +1182,9 @@ proc gdb_test_multiple { command message args } { } if { "$string" !=3D "" } { if { [send_gdb "$string"] !=3D "" } { - perror "Couldn't send $command to GDB." + verbose -log "Couldn't send $command to GDB." + unresolved $message + return -1 } } }