From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id p+7yMAsBvF95UQAAWB0awg (envelope-from ) for ; Mon, 23 Nov 2020 13:35:55 -0500 Received: by simark.ca (Postfix, from userid 112) id BC7DD1F0AB; Mon, 23 Nov 2020 13:35:55 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 30A891E552 for ; Mon, 23 Nov 2020 13:35:55 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7100E383F84B; Mon, 23 Nov 2020 18:35:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7100E383F84B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1606156554; bh=sncLwc7UF6f0S1fdzTK0E+rtQYI9BGC5VhS1vlM2cZ4=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=yNaHHEnRWZUP16+/MWcF6kaYIqJzC3dl7/qZDcVSb4RoZmHoaJNwF0/NYYfV0FkUZ H1PdRKe6ZLNYxYSd81Dm4+JcTIaOZFyRBq1+16NXLTYyDLW2YRBH6RY4U+1rmHKkFx D95SI79TBH+pLACcfsztqEPJO8x3sJZvE8D7g/po= Received: from barracuda.ebox.ca (barracuda.ebox.ca [96.127.255.19]) by sourceware.org (Postfix) with ESMTPS id D7851383F84B for ; Mon, 23 Nov 2020 18:35:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D7851383F84B X-ASG-Debug-ID: 1606156550-0c856e6cd61ce560001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id ujG1cdMLYmBPeApq (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 23 Nov 2020 13:35:50 -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-181-218.qc.cable.ebox.net [192.222.181.218]) by smtp.ebox.ca (Postfix) with ESMTP id C92AF441B21; Mon, 23 Nov 2020 13:35:50 -0500 (EST) X-Barracuda-RBL-IP: 192.222.181.218 X-Barracuda-Effective-Source-IP: 192-222-181-218.qc.cable.ebox.net[192.222.181.218] X-Barracuda-Apparent-Source-IP: 192.222.181.218 To: gdb-patches@sourceware.org Subject: [PATCH] gdb/testsuite: show evaluation errors in gdb_assert Date: Mon, 23 Nov 2020 13:35:50 -0500 X-ASG-Orig-Subj: [PATCH] gdb/testsuite: show evaluation errors in gdb_assert Message-Id: <20201123183550.1346281-1-simon.marchi@efficios.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Barracuda-Connect: smtp.ebox.ca[96.127.255.82] X-Barracuda-Start-Time: 1606156550 X-Barracuda-Encrypted: DHE-RSA-AES256-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: 1494 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=8.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.86074 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 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: , From: Simon Marchi via Gdb-patches Reply-To: Simon Marchi Cc: Simon Marchi Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" Let's say you put this gdb_assert in a test: gdb_assert "some invalid tcl code" You just get: FAIL: gdb.base/template.exp: some invalid tcl code That's not very easy to debug, since you don't know what's invalid in your code. Change gdb_assert to print the error message when catch's return code is 1 (TCL_ERROR). The "warning" is shown both on stdout and in the log file. Mark the test as unresolved, because the evaluation error means we couldn't reach a valid pass/fail conclusion. gdb/testsuite/ChangeLog: * lib/gdb.exp (gdb_assert): Show error message on error. Change-Id: Ie6477859554e909ed8d07fb2769c6f2f55e7cce6 --- gdb/testsuite/lib/gdb.exp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index c42933b3f41e..f2954fd5192b 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -1728,7 +1728,14 @@ proc gdb_assert { condition {message ""} } { } set code [catch {uplevel 1 expr $condition} res] - if {$code != 0 || !$res} { + if {$code == 1} { + # If code is 1 (TCL_ERROR), it means evaluation failed and res contains + # an error message. Print the error message, and set res to 0 since we + # want to return a boolean. + warning "While evaluating expression in gdb_assert: $res" + unresolved $message + set res 0 + } elseif { !$res } { fail $message } else { pass $message -- 2.26.2