Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Gary Benson <gbenson@redhat.com>
To: Tom Tromey <tom@tromey.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] Indicate batch mode failures by exiting with nonzero status
Date: Fri, 17 Aug 2018 10:59:00 -0000	[thread overview]
Message-ID: <20180817105923.GA32726@blade.nx> (raw)
In-Reply-To: <87r2ix98pk.fsf@tromey.com>

Tom Tromey wrote:
> >>>>> "Gary" == Gary Benson <gbenson@redhat.com> 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


  reply	other threads:[~2018-08-17 10:59 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-16 13:23 Gary Benson
2018-08-16 23:46 ` Tom Tromey
2018-08-17 10:59   ` Gary Benson [this message]
2018-08-17 14:28     ` Pedro Alves
2018-08-17 15:38       ` Gary Benson
2018-08-19 15:35     ` Tom Tromey
2018-08-25 19:52       ` Philippe Waroquiers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180817105923.GA32726@blade.nx \
    --to=gbenson@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tom@tromey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox