From patchwork Tue Nov 22 15:55:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 60983 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E422D385800C for ; Tue, 22 Nov 2022 15:56:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E422D385800C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1669132607; bh=QkPlQ3MNYobHhaRKUIxTM2SlBjn9NFXfRpngGZa4HDM=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=WhlKvK0AoSMbfMrr7bYc3wT8sP31df/m5AFeo283pvEHOKJ8E1tUbNOs5czSPjA/r 7f9ZDe21Y6N+Ggrk6y47CLlS8VBHm23M4dmASbN+v/iE7WntvaduD0MONhiYW8SX8U KmuqfEl/qyod7QdBslDk07sV/o0AuPk6LwNMli64= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from barracuda.ebox.ca (barracuda.ebox.ca [96.127.255.19]) by sourceware.org (Postfix) with ESMTPS id 44CD03858D35 for ; Tue, 22 Nov 2022 15:56:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 44CD03858D35 X-ASG-Debug-ID: 1669132548-0c856e02a126e660001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id fq5A3LyehVQ3YbHV (version=TLSv1 cipher=AES128-SHA bits=128 verify=NO); Tue, 22 Nov 2022 10:55:48 -0500 (EST) X-Barracuda-Envelope-From: simon.marchi@efficios.com X-Barracuda-RBL-Trusted-Forwarder: 96.127.255.82 Received: from smarchi-efficios.internal.efficios.com (192-222-180-24.qc.cable.ebox.net [192.222.180.24]) by smtp.ebox.ca (Postfix) with ESMTP id 0FB4A441B21; Tue, 22 Nov 2022 10:55:48 -0500 (EST) X-Barracuda-RBL-IP: 192.222.180.24 X-Barracuda-Effective-Source-IP: 192-222-180-24.qc.cable.ebox.net[192.222.180.24] X-Barracuda-Apparent-Source-IP: 192.222.180.24 To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 1/2] =?utf-8?q?gdb/testsuite=3A_make_gdb=5Ftest=5Fmultiple_r?= =?utf-8?q?eturn_immediately_if=C2=A0send=5Fgdb_fails?= Date: Tue, 22 Nov 2022 10:55:45 -0500 X-ASG-Orig-Subj: [PATCH 1/2] =?utf-8?q?gdb/testsuite=3A_make_gdb=5Ftest=5Fmu?= =?utf-8?q?ltiple_return_immediately_if=C2=A0send=5Fgdb_fails?= Message-Id: <20221122155546.599061-1-simon.marchi@efficios.com> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 X-Barracuda-Connect: smtp.ebox.ca[96.127.255.82] X-Barracuda-Start-Time: 1669132548 X-Barracuda-Encrypted: AES128-SHA X-Barracuda-URL: https://96.127.255.19:443/cgi-mod/mark.cgi X-Barracuda-BRTS-Status: 1 X-Virus-Scanned: by bsmtpd at ebox.ca X-Barracuda-Scan-Msg-Size: 2971 X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=5.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.102320 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- X-Spam-Status: No, score=-3498.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_SOFTFAIL, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Simon Marchi via Gdb-patches From: Simon Marchi Reply-To: Simon Marchi Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" From: Simon Marchi In the failure seen by Philippe here: https://inbox.sourceware.org/gdb-patches/20221120173024.3647464-1-philippe.waroquiers@skynet.be/ ... 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. 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). 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 of the not-so-useful-in-my-opinion TCL backtrace. Before, it looks like: 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 And after: Couldn't send python print(objfile.filename) to GDB. UNRESOLVED: gdb.python/py-objfile.exp: objfile.filename after objfile is unloaded Change-Id: I72af8dc0d687826fc3f76911c27a9e5f91b677ba --- 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 7d05fbe557bb..fcd54c88f251 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"] != "" } { - 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" != "" } { if { [send_gdb "$string"] != "" } { - perror "Couldn't send $command to GDB." + verbose -log "Couldn't send $command to GDB." + unresolved $message + return -1 } } } From patchwork Tue Nov 22 15:55:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 60984 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DE48338582BC for ; Tue, 22 Nov 2022 15:56:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DE48338582BC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1669132608; bh=ftUFWoOqC3p+eKHW4NUiG+hkS1JDO7WOFu/yp/rtjTQ=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=rqD/xSDuUClMdg5RdztCkkOZa9HE9ZJOae2dClExf6ZcrROUSI8PPo1DchnALFawB eI3a1ZJVZxsLgk/qNDiD45PkNFZlcxx0KqY7JIiVwjJNakosWxCdeUv5Bwf6YJIQL4 q1LsCZYCq17PavddQJklMtMF9JYiNhpdyz3Ihqk0= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from barracuda.ebox.ca (barracuda.ebox.ca [96.127.255.19]) by sourceware.org (Postfix) with ESMTPS id 557323858C50 for ; Tue, 22 Nov 2022 15:56:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 557323858C50 X-ASG-Debug-ID: 1669132548-0c856e02a026e550001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id OBLCZNgryjO58dT5 (version=TLSv1 cipher=AES128-SHA bits=128 verify=NO); Tue, 22 Nov 2022 10:55:48 -0500 (EST) X-Barracuda-Envelope-From: simon.marchi@efficios.com X-Barracuda-RBL-Trusted-Forwarder: 96.127.255.82 Received: from smarchi-efficios.internal.efficios.com (192-222-180-24.qc.cable.ebox.net [192.222.180.24]) by smtp.ebox.ca (Postfix) with ESMTP id 2DFB8441D64; Tue, 22 Nov 2022 10:55:48 -0500 (EST) X-Barracuda-RBL-IP: 192.222.180.24 X-Barracuda-Effective-Source-IP: 192-222-180-24.qc.cable.ebox.net[192.222.180.24] X-Barracuda-Apparent-Source-IP: 192.222.180.24 To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 2/2] gdb/testsuite: make gdb_unload use gdb_test_multiple Date: Tue, 22 Nov 2022 10:55:46 -0500 X-ASG-Orig-Subj: [PATCH 2/2] gdb/testsuite: make gdb_unload use gdb_test_multiple Message-Id: <20221122155546.599061-2-simon.marchi@efficios.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221122155546.599061-1-simon.marchi@efficios.com> References: <20221122155546.599061-1-simon.marchi@efficios.com> MIME-Version: 1.0 X-Barracuda-Connect: smtp.ebox.ca[96.127.255.82] X-Barracuda-Start-Time: 1669132548 X-Barracuda-Encrypted: AES128-SHA X-Barracuda-URL: https://96.127.255.19:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at ebox.ca X-Barracuda-Scan-Msg-Size: 5492 X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=5.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.102320 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- X-Spam-Status: No, score=-3498.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_SOFTFAIL, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Simon Marchi via Gdb-patches From: Simon Marchi Reply-To: Simon Marchi Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" From: Simon Marchi In the failure seen by Philippe here: https://inbox.sourceware.org/gdb-patches/20221120173024.3647464-1-philippe.waroquiers@skynet.be/ gdb_unload crashed GDB, leaving no trace in the test results. Change it to use gdb_test_multiple, so that it leaves an UNRESOLVED result. I think it is good practice anyway. Make it return the result of gdb_test_multiple directly, change gdb.python/py-objfile.exp accordingly. Change gdb.base/endian.exp as well to avoid duplicate test names. Change gdb.base/gnu-debugdata.exp to avoid recording a test result, since gdb_unload does it already now. Change-Id: I59a1e4947691330797e6ce23277942547c437a48 --- gdb/testsuite/gdb.base/endian.exp | 6 ++--- gdb/testsuite/gdb.base/gnu-debugdata.exp | 7 ++--- gdb/testsuite/gdb.python/py-objfile.exp | 9 ++++--- gdb/testsuite/lib/gdb.exp | 34 ++++++++++-------------- 4 files changed, 24 insertions(+), 32 deletions(-) diff --git a/gdb/testsuite/gdb.base/endian.exp b/gdb/testsuite/gdb.base/endian.exp index 05cf1280bad0..daa49b516545 100644 --- a/gdb/testsuite/gdb.base/endian.exp +++ b/gdb/testsuite/gdb.base/endian.exp @@ -59,7 +59,7 @@ if { [gdb_test_multiple "show endian" "$test" { # Now check that the automatic endianness is updated # according to the executable selected. -gdb_unload +gdb_unload "unload 1" gdb_test "set endian big" "$en_set big endian\\." \ "override target endianness big" gdb_test "set endian auto" "$en_auto \\\(currently big endian\\\)\\." \ @@ -69,7 +69,7 @@ gdb_file_cmd $binfile gdb_test "show endian" "$en_auto \\\(currently $endian endian\\\)\\." \ "previously big default executable endianness" -gdb_unload +gdb_unload "unload 2" gdb_test "show endian" "$en_auto \\\(currently $endian endian\\\)\\." \ "previously big default no executable endianness" gdb_test "set endian little" "$en_set little endian\\." \ @@ -81,6 +81,6 @@ gdb_file_cmd $binfile gdb_test "show endian" "$en_auto \\\(currently $endian endian\\\)\\." \ "previously little default executable endianness" -gdb_unload +gdb_unload "unload 3" gdb_test "show endian" "$en_auto \\\(currently $endian endian\\\)\\." \ "previously little default no executable endianness" diff --git a/gdb/testsuite/gdb.base/gnu-debugdata.exp b/gdb/testsuite/gdb.base/gnu-debugdata.exp index 732eadcbd306..0900e2fc2d86 100644 --- a/gdb/testsuite/gdb.base/gnu-debugdata.exp +++ b/gdb/testsuite/gdb.base/gnu-debugdata.exp @@ -150,10 +150,7 @@ if {$gdb_file_cmd_debug_info == "lzma"} { } # Be sure to test the 'close' method on the MiniDebugInfo BFD. -if {[gdb_unload]} { - fail "unload MiniDebugInfo" -} else { - pass "unload MiniDebugInfo" -} +# gdb_unload records a pass/fail. +gdb_unload gdb_exit diff --git a/gdb/testsuite/gdb.python/py-objfile.exp b/gdb/testsuite/gdb.python/py-objfile.exp index 9565c16af96b..f42bc5fb9f0f 100644 --- a/gdb/testsuite/gdb.python/py-objfile.exp +++ b/gdb/testsuite/gdb.python/py-objfile.exp @@ -92,7 +92,9 @@ gdb_test "python print (objfile.progspace)" "" \ "Get objfile program space" gdb_test "python print (objfile.is_valid())" "True" \ "Get objfile validity" -gdb_unload + +gdb_unload "unload 1" + gdb_test "python print (objfile.is_valid())" "False" \ "Get objfile validity after unload" @@ -103,9 +105,8 @@ gdb_test "python print (objfile.random_attribute)" "42" \ # Verify invalid objfile handling. -if { [gdb_unload] < 0 } { - fail "unload all files" - return -1 +if { [gdb_unload "unload 2"] != 0 } { + return } gdb_test "python print(objfile.filename)" "None" \ diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index fcd54c88f251..264d3ff435b3 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -311,38 +311,32 @@ proc gdb_version { } { return [default_gdb_version] } -# # gdb_unload -- unload a file if one is loaded -# Return 0 on success, -1 on error. # +# Returns the same as gdb_test_multiple. -proc gdb_unload {} { +proc gdb_unload { {msg "file"} } { global GDB global gdb_prompt - send_gdb "file\n" - gdb_expect 60 { - -re "No executable file now\[^\r\n\]*\[\r\n\]" { exp_continue } - -re "No symbol file now\[^\r\n\]*\[\r\n\]" { exp_continue } - -re "A program is being debugged already.*Are you sure you want to change the file.*y or n. $" { + return [gdb_test_multiple "file" $msg { + -re "A program is being debugged already.\r\nAre you sure you want to change the file. .y or n. $" { send_gdb "y\n" answer exp_continue } - -re "Discard symbol table from .*y or n.*$" { - send_gdb "y\n" answer + + -re "No executable file now\\.\r\n" { exp_continue } - -re "$gdb_prompt $" {} - -re "A problem internal to GDB has been detected" { - perror "Couldn't unload file in $GDB (GDB internal error)." - gdb_internal_error_resync - return -1 + + -re "Discard symbol table from `.*'. .y or n. $" { + send_gdb "y\n" answer + exp_continue } - timeout { - perror "couldn't unload file in $GDB (timeout)." - return -1 + + -re -wrap "No symbol file now\\." { + pass $gdb_test_name } - } - return 0 + }] } # Many of the tests depend on setting breakpoints at various places and