From: Andrew Burgess Date: Sat, 12 Jul 2025 12:29:19 +0000 (+0100) Subject: gdbserver: exit with code 1 after missing packet name X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=190e5f3ca7dee0b5271483f412defac0c1566835;p=thirdparty%2Fbinutils-gdb.git 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 --- diff --git a/gdbserver/server.cc b/gdbserver/server.cc index a59f9416053..c7720808f6f 100644 --- a/gdbserver/server.cc +++ b/gdbserver/server.cc @@ -4216,7 +4216,7 @@ captured_main (int argc, char *argv[]) else if (strcmp (*next_arg, "--disable-packet") == 0) { gdbserver_show_disableable (stdout); - exit (0); + exit (1); } else if (startswith (*next_arg, "--disable-packet=")) {