From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id +Bx5F1A3vF+zVgAAWB0awg (envelope-from ) for ; Mon, 23 Nov 2020 17:27:28 -0500 Received: by simark.ca (Postfix, from userid 112) id 52FE11F0AC; Mon, 23 Nov 2020 17:27:28 -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.0 required=5.0 tests=MAILING_LIST_MULTI 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 B8BD31F0A9 for ; Mon, 23 Nov 2020 17:27:27 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7B4E3384B823; Mon, 23 Nov 2020 22:27:27 +0000 (GMT) Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id CAFE03858009 for ; Mon, 23 Nov 2020 22:27:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org CAFE03858009 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark@simark.ca Received: from [172.16.0.95] (192-222-181-218.qc.cable.ebox.net [192.222.181.218]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 5581B1E552; Mon, 23 Nov 2020 17:27:25 -0500 (EST) Subject: Re: [PATCH] gdb/testsuite: show evaluation errors in gdb_assert To: Luis Machado , Simon Marchi , gdb-patches@sourceware.org References: <20201123183550.1346281-1-simon.marchi@efficios.com> From: Simon Marchi Message-ID: <057aced7-ee69-f20c-6fac-568b50725fd9@simark.ca> Date: Mon, 23 Nov 2020 17:27:24 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: tl Content-Transfer-Encoding: 8bit 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: , Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" On 2020-11-23 1:46 p.m., Luis Machado via Gdb-patches wrote: > On 11/23/20 3:35 PM, Simon Marchi via Gdb-patches wrote: >> 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 >> > > Looks OK to me. That's good to have more meaningful output. Thanks for the review, I pushed it. Simon