From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-sender-0.a4lg.com (mail-sender-0.a4lg.com [IPv6:2401:2500:203:30b:4000:6bfe:4757:0]) by sourceware.org (Postfix) with ESMTPS id 8B5A4383CCDB; Wed, 31 Aug 2022 02:15:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8B5A4383CCDB Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=irq.a4lg.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=irq.a4lg.com Received: from [127.0.0.1] (localhost [127.0.0.1]) by mail-sender-0.a4lg.com (Postfix) with ESMTPSA id C9ABE300089; Wed, 31 Aug 2022 02:15:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irq.a4lg.com; s=2017s01; t=1661912148; bh=Zy+el3dkjtAkDSGkIktOnv4Xruqdptq9WQ+Jt7cFds4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Mime-Version:Content-Transfer-Encoding; b=fl+PzMiHtHMZHmQdI9weRIqRw6aljdwwwPixjI1V7x0MTNB5FvHowMCuGN+vjFcVz xKpyjKqFqxL18+IsDryP7MRAk7V6/kZOCPwnefFNfCw8BksWQV5j1T/Nh//al30upd NIzZEJf352Ylow7G5x5Rl6MdHc42HvveJKXZVbok= From: Tsukasa OI To: Tsukasa OI , Andrew Burgess , Palmer Dabbelt , Claudiu Zissulescu , Chenghua Xu , Nelson Chu Cc: binutils@sourceware.org, gdb-patches@sourceware.org Subject: [PATCH 1/2] opcodes: Add non-enum disassembler options Date: Wed, 31 Aug 2022 02:15:31 +0000 Message-Id: <0113f0dec90cf9a92551d952ff2ec93592ea04fa.1661912099.git.research_trasio@irq.a4lg.com> In-Reply-To: References: Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,GIT_PATCH_0,KAM_MANYTO,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: This is paired with "gdb: Add non-enum disassembler options". There is a portable mechanism for disassembler options and used on some architectures: - ARC - Arm - MIPS - PowerPC - RISC-V - S/390 However, it only supports following forms: - [NAME] - [NAME]=[ENUM_VALUE] Valid values for [ENUM_VALUE] must be predefined in `disasm_option_arg_t.values'. For instance, for -M cpu=[CPU] in ARC architecture, opcodes/arc-dis.c builds valid CPU model list from include/elf/arc-cpu.def. In this commit, it adds following format: - [NAME]=[ARBITRARY_VALUE] (cannot contain "," though) This is identified by NULL' value of disasm_option_arg_t.values' (normally, this is a non-NULL pointer to a NULL-terminated list). 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. --- 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; - /* 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 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 = 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 164fd209dbd..b2debd3dd97 100644 --- a/opcodes/riscv-dis.c +++ b/opcodes/riscv-dis.c @@ -1181,6 +1181,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.34.1