From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7896) id A73353858C2F; Tue, 6 Sep 2022 02:27:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A73353858C2F Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tsukasa OI To: bfd-cvs@sourceware.org Subject: [binutils-gdb] opcodes: Add non-enum disassembler options X-Act-Checkin: binutils-gdb X-Git-Author: Tsukasa OI X-Git-Refname: refs/heads/master X-Git-Oldrev: a49fdb49c8d6bb2a2c2d200ea9e83ae688e67e22 X-Git-Newrev: 9869e2e5c7964039328013a283461d1826dbf96c Message-Id: <20220906022753.A73353858C2F@sourceware.org> Date: Tue, 6 Sep 2022 02:27:53 +0000 (GMT) X-BeenThere: binutils-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Sep 2022 02:27:53 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D9869e2e5c796= 4039328013a283461d1826dbf96c commit 9869e2e5c7964039328013a283461d1826dbf96c Author: Tsukasa OI Date: Tue Aug 30 12:20:30 2022 +0000 opcodes: Add non-enum disassembler options =20 This is paired with "gdb: Add non-enum disassembler options". =20 There is a portable mechanism for disassembler options and used on some architectures: =20 - ARC - Arm - MIPS - PowerPC - RISC-V - S/390 =20 However, it only supports following forms: =20 - [NAME] - [NAME]=3D[ENUM_VALUE] =20 Valid values for [ENUM_VALUE] must be predefined in disasm_option_arg_t.values. For instance, for -M cpu=3D[CPU] in ARC architecture, opcodes/arc-dis.c builds valid CPU model list from include/elf/arc-cpu.def. =20 In this commit, it adds following format: =20 - [NAME]=3D[ARBITRARY_VALUE] (cannot contain "," though) =20 This is identified by NULL value of disasm_option_arg_t.values (normally, this is a non-NULL pointer to a NULL-terminated list). =20 include/ChangeLog: =20 * dis-asm.h (disasm_option_arg_t): Update comment of values to allow non-enum disassembler options. =20 opcodes/ChangeLog: =20 * riscv-dis.c (print_riscv_disassembler_options): Support non-enum disassembler options on printing disassembler help. * arc-dis.c (print_arc_disassembler_options): Likewise. * mips-dis.c (print_mips_disassembler_options): Likewise. Diff: --- include/dis-asm.h | 3 ++- opcodes/arc-dis.c | 2 ++ opcodes/mips-dis.c | 2 ++ opcodes/riscv-dis.c | 2 ++ 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/include/dis-asm.h b/include/dis-asm.h index f1a83dc84e5..4921c040710 100644 --- a/include/dis-asm.h +++ b/include/dis-asm.h @@ -318,7 +318,8 @@ typedef struct /* Option argument name to use in descriptions. */ const char *name; =20 - /* Vector of acceptable option argument values, NULL-terminated. */ + /* Vector of acceptable option argument values, NULL-terminated. + NULL if any values are accepted. */ const char **values; } disasm_option_arg_t; =20 diff --git a/opcodes/arc-dis.c b/opcodes/arc-dis.c index 3490bad4f66..c8dc525f64d 100644 --- a/opcodes/arc-dis.c +++ b/opcodes/arc-dis.c @@ -1611,6 +1611,8 @@ print_arc_disassembler_options (FILE *stream) for (i =3D 0; args[i].name !=3D NULL; ++i) { size_t len =3D 3; + if (args[i].values =3D=3D NULL) + continue; fprintf (stream, _("\n\ For the options above, the following values are supported for \"%s\":\n = "), args[i].name); diff --git a/opcodes/mips-dis.c b/opcodes/mips-dis.c index 9db604ffb39..faeebccfc3b 100644 --- a/opcodes/mips-dis.c +++ b/opcodes/mips-dis.c @@ -2809,6 +2809,8 @@ with the -M switch (multiple options should be separa= ted by commas):\n\n")); =20 for (i =3D 0; args[i].name !=3D NULL; i++) { + if (args[i].values =3D=3D NULL) + continue; fprintf (stream, _("\n\ For the options above, the following values are supported for \"%s\":\n = "), args[i].name); diff --git a/opcodes/riscv-dis.c b/opcodes/riscv-dis.c index 160cc40f865..7ae6e709290 100644 --- a/opcodes/riscv-dis.c +++ b/opcodes/riscv-dis.c @@ -1195,6 +1195,8 @@ with the -M switch (multiple options should be separa= ted by commas):\n")); =20 for (i =3D 0; args[i].name !=3D NULL; i++) { + if (args[i].values =3D=3D NULL) + continue; fprintf (stream, _("\n\ For the options above, the following values are supported for \"%s\":\n = "), args[i].name);