From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id MSgjK4sDvF8pUgAAWB0awg (envelope-from ) for ; Mon, 23 Nov 2020 13:46:35 -0500 Received: by simark.ca (Postfix, from userid 112) id A37141F0AB; Mon, 23 Nov 2020 13:46:35 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_NONE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from sourceware.org (unknown [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 34DE21E552 for ; Mon, 23 Nov 2020 13:46:35 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6DBDD38708EC; Mon, 23 Nov 2020 18:46:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6DBDD38708EC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1606157194; bh=D8WEy+L85vCCnV6GsMNVYanaH7oRNPvJvT3AMF/8Jgo=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=OY9u6h2+vYA0G82yf4HQgKH1Ft9393kjK8uHC2OvVgUFoZgZ6e4A0m6NUWa40+vmd +CNeiOFsJbsHU0tCqX9mxKRNkQqhHuE4ngEBYR6LZiMTmAC00zvRum9xZ+yvGGlJnG qTqmjVOcN1Jl7H+5ND7JwuJ9K1gNTG9ntAIRYtOs= Received: from mail-qt1-x844.google.com (mail-qt1-x844.google.com [IPv6:2607:f8b0:4864:20::844]) by sourceware.org (Postfix) with ESMTPS id 24967385802D for ; Mon, 23 Nov 2020 18:46:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 24967385802D Received: by mail-qt1-x844.google.com with SMTP id m65so14086043qte.11 for ; Mon, 23 Nov 2020 10:46:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=D8WEy+L85vCCnV6GsMNVYanaH7oRNPvJvT3AMF/8Jgo=; b=hvXPFEqXXuxjkDglCabhLyhkYHNIzuUUnfAPpX7UwJEkd8nPhNwjujmtzEXviAHd4b xf/7hdbAQrhf3/E4U64ZDxrd1N8+NmRMY+ksJf2OLCYEa0au5peEZtD/Mxr2kjVjfZAS MI90/D3JUnZbV18NkGtltHfbfDhtoOeFlESOe13ZyabKopTlM7ojfn+4vACVeVu9A5Rq ankWh17zQd4fhJADo0U/TgI4uG7rwPMtmhsvHSnfY8PcyESuvp/gV2KlTNC+i/OSVolV 6/WVGgpYDDmjX5QYF9BSAL1cnB/6fuV2SWDqrsrL2Dc5YKqLoy6WLyEidGBkgGFOtq62 EHog== X-Gm-Message-State: AOAM530nKnG+CpOoWPxVaKcLOFEiBOjJ52Tzx1dItYOZvpIvDGhDp8To DPgU8L8u1ziaE7sAdqvHTBDVobW4MQuHZA== X-Google-Smtp-Source: ABdhPJyS8BU0HReMkT8xmDFw/2KhscqDZNTmM/dmGWR8LmTzufdHjLVu1spVkj+146qA73SfeGn7RQ== X-Received: by 2002:aed:214b:: with SMTP id 69mr536006qtc.302.1606157191509; Mon, 23 Nov 2020 10:46:31 -0800 (PST) Received: from ?IPv6:2804:7f0:8284:370e:18fe:65d7:a5d3:1acf? ([2804:7f0:8284:370e:18fe:65d7:a5d3:1acf]) by smtp.gmail.com with ESMTPSA id w54sm11154509qtb.0.2020.11.23.10.46.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 23 Nov 2020 10:46:31 -0800 (PST) Subject: Re: [PATCH] gdb/testsuite: show evaluation errors in gdb_assert To: Simon Marchi , gdb-patches@sourceware.org References: <20201123183550.1346281-1-simon.marchi@efficios.com> Message-ID: Date: Mon, 23 Nov 2020 15:46:27 -0300 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: <20201123183550.1346281-1-simon.marchi@efficios.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit 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: Luis Machado via Gdb-patches Reply-To: Luis Machado Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" 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.