From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-sender-0.a4lg.com (mail-sender.a4lg.com [153.120.152.154]) by sourceware.org (Postfix) with ESMTPS id 1564B3858423 for ; Sun, 6 Feb 2022 02:10:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1564B3858423 From: Tsukasa OI To: Tsukasa OI Cc: binutils@sourceware.org Subject: [RFC PATCH v2 1/2] gdb, opcodes: Add non-enum disassembler options Date: Sun, 6 Feb 2022 11:10:36 +0900 Message-Id: In-Reply-To: References: Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TO_EQ_FM_DIRECT_MX, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Feb 2022 02:11:01 -0000 This commit adds support for non-enum disassembler options that allow arbitrary argument (not including ","). This is identified by `NULL' value of disasm_option_arg_t.values. gdb/ChangeLog: * gdb/disasm.c (set_disassembler_options): Add support for non-enum disassembler options. (show_disassembler_options_sfunc): Likewise. include/ChangeLog: * dis-asm.h (disasm_option_arg_t): Update comment of `values' to allow non-enum disassembler options. opcodes/ChangeLog: * 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. --- gdb/disasm.c | 4 ++++ include/dis-asm.h | 3 ++- opcodes/arc-dis.c | 2 ++ opcodes/mips-dis.c | 2 ++ opcodes/riscv-dis.c | 2 ++ 5 files changed, 12 insertions(+), 1 deletion(-) diff --git a/gdb/disasm.c b/gdb/disasm.c index 5cd1f5adbd2..eb7e2fec9fe 100644 --- a/gdb/disasm.c +++ b/gdb/disasm.c @@ -1009,6 +1009,8 @@ set_disassembler_options (const char *prospective_options) if (memcmp (opt, valid_options->name[i], len) != 0) continue; arg = opt + len; + if (valid_options->arg[i]->values == NULL) + break; for (j = 0; valid_options->arg[i]->values[j] != NULL; j++) if (disassembler_options_cmp (arg, valid_options->arg[i]->values[j]) == 0) @@ -1130,6 +1132,8 @@ The following disassembler options are supported for use with the\n\ for (i = 0; valid_args[i].name != NULL; i++) { + if (valid_args[i].values == NULL) + continue; fprintf_filtered (file, _("\n\ For the options above, the following values are supported for \"%s\":\n "), valid_args[i].name); diff --git a/include/dis-asm.h b/include/dis-asm.h index 317592448a2..1826fe97ba7 100644 --- a/include/dis-asm.h +++ b/include/dis-asm.h @@ -239,7 +239,8 @@ typedef struct /* Option argument name to use in descriptions. */ const char *name; - /* 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; diff --git a/opcodes/arc-dis.c b/opcodes/arc-dis.c index 771f786d18e..41371967c3b 100644 --- a/opcodes/arc-dis.c +++ b/opcodes/arc-dis.c @@ -1555,6 +1555,8 @@ print_arc_disassembler_options (FILE *stream) for (i = 0; args[i].name != NULL; ++i) { size_t len = 3; + if (args[i].values == 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 separated by commas):\n\n")); for (i = 0; args[i].name != NULL; i++) { + if (args[i].values == 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 34724d4aec5..13ddff01c52 100644 --- a/opcodes/riscv-dis.c +++ b/opcodes/riscv-dis.c @@ -1132,6 +1132,8 @@ with the -M switch (multiple options should be separated by commas):\n")); for (i = 0; args[i].name != NULL; i++) { + if (args[i].values == NULL) + continue; fprintf (stream, _("\n\ For the options above, the following values are supported for \"%s\":\n "), args[i].name); -- 2.32.0