]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
gdbserver: allow gnu style arguments to gdbserver
authorAndrew Burgess <aburgess@redhat.com>
Fri, 1 Aug 2025 11:22:38 +0000 (12:22 +0100)
committerAndrew Burgess <aburgess@redhat.com>
Tue, 23 Sep 2025 17:40:00 +0000 (18:40 +0100)
commitce1b10c1ab3fc6f32621f1f23cc116ee8e39d473
tree93053d73bab4de237b89c04a318763c720099dd7
parentc87df013cbc2c5072f1ef95626ed493e2b54506c
gdbserver: allow gnu style arguments to gdbserver

Now that we use getopt_long for argument processing in gdbserver, it
is relatively easy to support GNU style arguments, that is, arguments
passed without an '=' between the argument and the value.

As support for GNU style arguments is the default from getopt_long,
the first part of this commit is to remove the code which deliberately
disables the GNU argument support.

With that done, we now need to consider optional arguments.  In this
case, getopt_long doesn't automatically grab the next word from ARGV
to be the argument value, so I've added some code to do this.

I've also tried to make this code a little smart.  As the first
argument passed to gdbserver that doesn't have a '--' at the start is
the PORT number, the new code block I've added tries to spot if the
argument value might be the port number.  If it is, then we don't
allow the port number to become the argument value, and instead, we
pretend the argument value is missing.  This seems to give better
error messages.

There are going to be UI changes in how gdbserver handles incorrect
arguments after this commit.  However, the behaviour for valid
command lines should be unchanged.

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