From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 89276 invoked by alias); 5 Jul 2018 14:55:42 -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 89259 invoked by uid 89); 5 Jul 2018 14:55:42 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.2 required=5.0 tests=AWL,BAYES_00,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,KAM_NUMSUBJECT,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=no version=3.3.2 spammy=Would, Gary, gary, intuitively X-HELO: mail-wm0-f41.google.com Received: from mail-wm0-f41.google.com (HELO mail-wm0-f41.google.com) (74.125.82.41) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 05 Jul 2018 14:55:40 +0000 Received: by mail-wm0-f41.google.com with SMTP id z6-v6so3015510wma.0 for ; Thu, 05 Jul 2018 07:55:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=plGRir+HuLaNbRvn2dp+8ocIO9MVRKEYCaTLXl4TCCk=; b=kA3XzieLhAeBayJRUe1j87OYHLqBfHZ2iRyb4nY/N1RTvuZZQZJkT5I1jLQRunaX6C BbXgt0SpW4HfjEtqQCloatkcBBWH5DT4H373TEVrWtCXfVHdSJa0w/JKkXA1r/1BiBIc FTROYla8JZLH9fAH+9c9FP2MgLrCNbuXdA5c6NfsaKpHHe9g1jOFeTgVsgbUYGZw7PCl CXliBPlxreOaU8QXeCLs2ex3olxx1oNs/WI64KTbrQ6w0STh8Cfv/VHpIdhBmzSj8VJZ 9Dm8iRfUXNABOSE+JbVlGJL/vgnSAN8faotX9LNEbK8zkSeMxXpd9ZJcnPQ30SN7CKSz 0ELg== MIME-Version: 1.0 Received: by 2002:a1c:3ec2:0:0:0:0:0 with HTTP; Thu, 5 Jul 2018 07:55:38 -0700 (PDT) In-Reply-To: <20180705144659.GA29169@blade.nx> References: <20180705144659.GA29169@blade.nx> From: Ruslan Kabatsayev Date: Thu, 05 Jul 2018 14:55:00 -0000 Message-ID: Subject: Re: gdb -batch always exits with status 0 To: Gary Benson Cc: gdb@sourceware.org Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2018-07/txt/msg00010.txt.bz2 Hi, On 5 July 2018 at 17:47, Gary Benson wrote: > Hi all, > > I've been working on fixing PR gdb/13000, which is that GDB in batch > mode always exits with status 0 despite the manual saying it should > exit with nonzero status on error. The latter is what I'd intuitively > expect, so I'm looking at fixing GDB to match the docs rather than > fixing the docs to match GDB. > > A narrow fix to make GDB match the docs is actually fairly simple, > but I'm bothered that not only does gdb -batch always exit with > status 0, it actually continues over any number of errors before > doing so. So you can do something like: > > bash$ echo nonsense > cmds > bash$ echo garbage > .gdbinit > bash$ gdb -batch -iex invalid-command -ex also-invalid \ > -cd /no/such/directory -p 1 -batch -ix /does/not/exist \ > -x cmds > Undefined command: "invalid-command". Try "help". > warning: /does/not/exist: No such file or directory > /no/such/directory: No such file or directory. > ptrace: Operation not permitted. > .gdbinit:1: Error in sourced command file: > Undefined command: "garbage". Try "help". > Undefined command: "also-invalid". Try "help". > cmds:1: Error in sourced command file: > Undefined command: "nonsense". Try "help". > bash$ echo $? > 0 > > Would anybody object to my changing GDB's behaviour to terminate > on the first error in batch mode? On the one hand, this totally makes sense. But on the other, can we prevent exit if we e.g. expect a possible error and do the necessary steps to fix it? An example use case: before starti command appeared, it could be simulated by the following: b *0 r d 1 The above (unconditional!) sequence of commands would error on `r`, but the side effect of the whole sequence would be the same as the modern starti command. Your change would invalidate similar use cases in batch mode. > > (I'd also like to remove the 'Try "help".' suffix when in batch mode, > though I'd likely do that in a separate patch.) > > Cheers, > Gary > > -- > https://gbenson.net/