From: Ruslan Kabatsayev <b7.10110111@gmail.com>
To: Gary Benson <gbenson@redhat.com>
Cc: gdb@sourceware.org
Subject: Re: gdb -batch always exits with status 0
Date: Thu, 05 Jul 2018 14:55:00 -0000 [thread overview]
Message-ID: <CAHEcG97VvgTChe-B=N3O5TtktrNdN_Xd9naimwgbN2MRdXKu-Q@mail.gmail.com> (raw)
In-Reply-To: <20180705144659.GA29169@blade.nx>
Hi,
On 5 July 2018 at 17:47, Gary Benson <gbenson@redhat.com> 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/
next prev parent reply other threads:[~2018-07-05 14:55 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-05 14:47 Gary Benson
2018-07-05 14:55 ` Ruslan Kabatsayev [this message]
2018-07-05 15:23 ` Paul Smith
2018-08-17 11:03 ` Gary Benson
2018-08-17 11:25 ` Ruslan Kabatsayev
2018-08-17 13:24 ` Paul Smith
2018-08-17 15:23 ` Gary Benson
2018-08-17 15:44 ` Ruslan Kabatsayev
2018-08-17 16:03 ` Gary Benson
2018-08-17 18:30 ` Pedro Alves
2018-08-22 9:07 ` Gary Benson
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='CAHEcG97VvgTChe-B=N3O5TtktrNdN_Xd9naimwgbN2MRdXKu-Q@mail.gmail.com' \
--to=b7.10110111@gmail.com \
--cc=gbenson@redhat.com \
--cc=gdb@sourceware.org \
/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