]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
gdbserver: exit with code 1 after missing packet name
authorAndrew Burgess <aburgess@redhat.com>
Sat, 12 Jul 2025 12:29:19 +0000 (13:29 +0100)
committerAndrew Burgess <aburgess@redhat.com>
Fri, 1 Aug 2025 09:15:31 +0000 (10:15 +0100)
commit190e5f3ca7dee0b5271483f412defac0c1566835
tree4b1c26611d6ba505813a9f110b02a570860b8c40
parent7a45c8e03020e8fbe5284e5ffa6d4c710c6fd876
gdbserver: exit with code 1 after missing packet name

When using the command:

  $ gdbserver --disable-packet

gdbserver lists all the packets that can be disabled, and then exits.
I think that this output is a helpful error message that is printed
when the user has forgotten to entry a packet name.  We get similar
output if we run the command:

  $ gdbserver --disable-packet=foo

where gdbserver tells us that 'foo' is invalid, and then lists the
packets that we can use.

The difference is that, in the first case, gdbserver exits with a code
of 0, and in the second, gdbserver exits with a code of 1.

I think both these cases should exit with a code of 1.

With the exception of '--help' and '--version', where we are asking
gdbserver to print some message then exit (which are, and should exit
with a code of 0), in all other cases where we do an early exit, I
think this is an indication that the user has done something
wrong (entered and invalid argument, or missed an argument value), and
gdbserver should exit with a non-zero exit code to indicate this.

This commit updates the exit code in the above case from 0 to 1.

Approved-By: Tom Tromey <tom@tromey.com>
gdbserver/server.cc