From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 97341 invoked by alias); 17 Aug 2018 18:30:04 -0000 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Received: (qmail 97284 invoked by uid 89); 17 Aug 2018 18:30:02 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00,KAM_NUMSUBJECT,SPF_HELO_PASS autolearn=no version=3.3.2 spammy=sourcing, discussing 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 18:30:01 +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 73C9A40241D8; Fri, 17 Aug 2018 18:29:59 +0000 (UTC) Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id CE90B1010435; Fri, 17 Aug 2018 18:29:57 +0000 (UTC) Subject: Re: gdb -batch always exits with status 0 To: Gary Benson , Ruslan Kabatsayev References: <20180705144659.GA29169@blade.nx> <2c7ad73e90cc7417bd23b4529261d8c737668571.camel@gnu.org> <20180817110354.GB32726@blade.nx> <20180817152345.GA2920@blade.nx> <20180817160325.GA12274@blade.nx> Cc: psmith@gnu.org, gdb@sourceware.org From: Pedro Alves Message-ID: <3408f7e7-91c9-1230-dbf1-51a3bdd0c6f6@redhat.com> Date: Fri, 17 Aug 2018 18:30:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <20180817160325.GA12274@blade.nx> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2018-08/txt/msg00039.txt.bz2 On 08/17/2018 05:03 PM, Gary Benson wrote: > Ruslan Kabatsayev wrote: >> On Fri, 17 Aug 2018 at 18:23, Gary Benson wrote: >>> >>> It would be the least impactful way, sure, but my point is that >>> GDB doesn't operate in an intuitive way, and my view is that >>> whatever is intuitive should be the default. Having to request it >>> with a special flag makes GDB harder for new users. >> >> Not sure about intuitiveness of early exit, but we have an example >> of the converse: bash (and other shells). Namely, by default it >> executes all the commands, exits with the exit status of the last >> command executed. But you can `set -e`, and then first failing >> command will stop processing. But then, there do exist means to >> suppress failure (e.g. `badCommand && true`), which GDB doesn't seem >> to have. > > Shells are the only example I could think of. And I wonder what > proportion of shell scripts start with 'set -e' :) Having to add > that is the kind of thing I mean about making things harder for > new users. To me, it feels like you're not discussing the real issue. GDB _does_ stop processing scripts on first error. $ cat file1 fail1 fail2 fail3 $ cat file2 fail4 fail5 fail6 $ gdb -q -x file1 -x file2 file1:1: Error in sourced command file: Undefined command: "fail1". Try "help". file2:1: Error in sourced command file: Undefined command: "fail4". Try "help". (gdb) Note, fail2, fail3, fail5 and fail6 were not run. What GDB does not do is consider an error from inside a script sourced from the shell command line as reason to fail out. So for example above, I think Gary is arguing that GDB should have behaved like this: $ gdb -q -x file1 -x file2 file1:1: Error in sourced command file: Undefined command: "fail1". Try "help". (gdb) I.e., "file2" was not sourced. In this aspect, "-ex" behaves exactly like "-x" -- you can think of -ex as gdb internally pasting the -ex command in a script and then sourcing it with -x. Thanks, Pedro Alves