diff options
author | Andrew Burgess <aburgess@redhat.com> | 2025-07-08 14:28:03 +0100 |
---|---|---|
committer | Andrew Burgess <aburgess@redhat.com> | 2025-08-01 10:15:31 +0100 |
commit | 524b8916630bb39a5dfc464ea0ab7e4d88c5b890 (patch) | |
tree | c7bddfa06d5d3c4479be458bc942b5c5833d9f9d /gas/config/tc-m68hc11.c | |
parent | 190e5f3ca7dee0b5271483f412defac0c1566835 (diff) | |
download | binutils-master.zip binutils-master.tar.gz binutils-master.tar.bz2 |
Update gdbserver to use getopt_long for argument processing. This
turned out to be easier than I expected.
Interesting parts of this patch are:
I pass '+' as the OPTSTRING to getopt_long, this prevents getopt_long
from reordering the contents of ARGV. This is needed so that things
like this will work:
gdbserver :54321 program --arg1 --arg2
Without the '+', getopt_long will reorder ARGV, moving '--arg1' and
'--arg2' forward and handling them as arguments to gdbserver.
Because of this (not reordering) and to maintain backward
compatibility, we retain a special case to deal with '--attach' which
can appear after the PORT, like this:
gdbserver :54321 --attach PID
I did consider adding a warning to this special case, informing the
user that placing --attach after the PORT was deprecated, but in the
end I didn't want to really change the behaviour as part of this
commit, so I've left that as an optional change for the future.
The getopt_long function supports two value passing forms, there is
'--option=value', and also '--option value'. Traditionally, gdbserver
only supports the first of these. To maintain this behaviour, after
the call to getopt_long, I spot if '--option value' was used, and if
so, modify the state so that it seems that no value was passed, and
that 'value' is the next ARGV entry to be parsed. We could, possibly,
remove this code in the future, but that would be a functional change,
which is not something I want in this commit.
Handling of "-" for stdio connection has now moved out of the argument
processing loop as '-' isn't considered a valid option by getopt_long,
this is an improvement as all PORT handling is now in one place.
I've tried as much as possible to leave user visible functionality
unchanged after this commit, and as far as I can tell from testing,
nothing has changed.
Approved-By: Tom Tromey <tom@tromey.com>
Diffstat (limited to 'gas/config/tc-m68hc11.c')
0 files changed, 0 insertions, 0 deletions