From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 121009 invoked by alias); 17 Aug 2018 10:59:29 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 120991 invoked by uid 89); 17 Aug 2018 10:59:29 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-3.4 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=silver, cloud, lining X-HELO: mx1.redhat.com Received: from mx3-rdu2.redhat.com (HELO mx1.redhat.com) (66.187.233.73) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 17 Aug 2018 10:59:27 +0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0CC298011454; Fri, 17 Aug 2018 10:59:26 +0000 (UTC) Received: from blade.nx (ovpn-117-165.ams2.redhat.com [10.36.117.165]) by smtp.corp.redhat.com (Postfix) with ESMTP id B38EB10EE6CD; Fri, 17 Aug 2018 10:59:25 +0000 (UTC) Received: by blade.nx (Postfix, from userid 1000) id F2FE280AFCC4; Fri, 17 Aug 2018 11:59:24 +0100 (BST) Date: Fri, 17 Aug 2018 10:59:00 -0000 From: Gary Benson To: Tom Tromey Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] Indicate batch mode failures by exiting with nonzero status Message-ID: <20180817105923.GA32726@blade.nx> References: <1534425783-11599-1-git-send-email-gbenson@redhat.com> <87r2ix98pk.fsf@tromey.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87r2ix98pk.fsf@tromey.com> X-IsSubscribed: yes X-SW-Source: 2018-08/txt/msg00423.txt.bz2 Tom Tromey wrote: > >>>>> "Gary" == Gary Benson writes: > > Gary> +/* Did the last invocation of catch_command_errors throw an error? */ > Gary> + > Gary> +static bool last_command_failed = false; > > catch_command_errors seems to return a boolean, so I think a global > shouldn't be necessary. True. It was a hang up from a previous version of the patch. I can change it. > Also, why just the last command? I mean, I guess I don't really know > what I would expect, but maybe if any command failed, gdb should exit? That was my thinking, to have GDB exit 1 on the first error in batch mode, but people objected; see the followups to: https://sourceware.org/ml/gdb/2018-07/msg00009.html The last command thing was something that Pedro wanted. The patch would originally exit 1 if _any_ error occurred, but Pedro reasoned that the last operation is the thing you wanted to happen and earlier failures might be spurious, e.g. bad commands in gdbinit files. Though you have situations like: bash$ gdb -batch -p 12345 -ex "info sharedlibrary" ptrace: No such process. No shared libraries loaded at this time. bash$ echo $? 0 > Right now there seems to be a discrepancy where if you do "gdb -ex > fail -ex fail -ex fail", each one will be run; but if you put the > commands into a file and "gdb -x file", then only the first one will > be run. I'm not sure if this is good or bad. Yeah, it's inconsistent and I hate it :/ I wonder if people would accept me changing the default behaviour to exit 1 on the first error, with an option e.g. -batch-ignore-errors to revert to the current behaviour. I might reply to the original thread suggesting that. > I suppose one nice thing about the "last command only" approach is > that you could ignore failures by tacking on one more -ex with some > sort of no-op. Every cloud has a silver lining :) Cheers, Gary