]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
gdb: PR 33384 invalid disassembler option message
authorAlan Modra <amodra@gmail.com>
Fri, 3 Oct 2025 23:14:58 +0000 (08:44 +0930)
committerAlan Modra <amodra@gmail.com>
Sat, 4 Oct 2025 00:09:02 +0000 (09:39 +0930)
commit58a722afdb64a2c4b2ce606d4628214b890705d3
treef7278e52e605234620ccb91d439ab71650031687
parent3fc9616817eb5467dcd23bf4b00a95b752c20554
gdb: PR 33384 invalid disassembler option message

This is the gdb part of fixing PR33384, where it is noted that an
error in a disassembler option prints the rest of the comma separated
option string rather than just the option in error.

Removing FOR_EACH_DISASSEMBLER_OPTION seemed a good idea to me, as we
then expose the strchr there which is useful in zero terminating the
option, and in the case of arm-tdep.c, to replace strcspn.  Also, if
the option is zero terminated we don't need disassembler_options_cmp.

Alternatively, you could do similarly to arm-tdep.c in disasm.c by
changing the error message to use %.*s with a length found by strcspn.
I rejected that smaller patch on the grounds that it makes for churn
in message translation.  I also prefer to see code using the standard
string functions.

Regression tested on x86_64-linux.  Message behaviour tested on
powerpc64le-linux and arm-linux-eabi.

* arm-tdep.c (show_disassembly_style_sfunc): Don't use
FOR_EACH_DISASSEMBLER_OPTION.  Use strchr needed for loop
control to size option len.
* disasm.c (set_disassembler_options): Don't use
FOR_EACH_DISASSEMBLER_OPTION.  Overwrite comma in options with
a zero.  Replace disassembler_options_cmp with strcmp.
gdb/arm-tdep.c
gdb/disasm.c