From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id mBvjHYjEDmPgMDAAWB0awg (envelope-from ) for ; Tue, 30 Aug 2022 22:16:40 -0400 Received: by simark.ca (Postfix, from userid 112) id 77BB91E4A7; Tue, 30 Aug 2022 22:16:40 -0400 (EDT) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=ZuK94M97; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 3004E1E222 for ; Tue, 30 Aug 2022 22:16:40 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D48C938233C0 for ; Wed, 31 Aug 2022 02:16:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D48C938233C0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1661912199; bh=V5Ks0Ok9I1Z7abdNGXWw3unpw2dA4qKwnx3nXL5Xlr0=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=ZuK94M97iOGKu53EF4qp5CIbrKRGkWvkVLL1VALtpmUwHyZubCVT+xqf9RZEX7W8v ++6rscVgQBlIXJJVHu9u6TL1W7npBuItGGUzjeyC8AzpuaUUg6n0+OeCIprE3ZTp94 HE4oDXv+plzCBJIGdM9xDlykEcjeZYAQbu/dLirI= 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 1ECF23838143; Wed, 31 Aug 2022 02:16:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1ECF23838143 Received: from [127.0.0.1] (localhost [127.0.0.1]) by mail-sender-0.a4lg.com (Postfix) with ESMTPSA id 5DB58300089; Wed, 31 Aug 2022 02:15:58 +0000 (UTC) To: Tsukasa OI , Andrew Burgess , Palmer Dabbelt , Claudiu Zissulescu , Chenghua Xu , Nelson Chu Subject: [PATCH 2/2] gdb: Add non-enum disassembler options Date: Wed, 31 Aug 2022 02:15:32 +0000 Message-Id: In-Reply-To: References: Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Tsukasa OI via Gdb-patches Reply-To: Tsukasa OI Cc: binutils@sourceware.org, gdb-patches@sourceware.org Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" This is paired with "opcodes: 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. --- gdb/disasm.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gdb/disasm.c b/gdb/disasm.c index db6724757ac..fe4eed2d524 100644 --- a/gdb/disasm.c +++ b/gdb/disasm.c @@ -1270,6 +1270,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) @@ -1391,6 +1393,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; gdb_printf (file, _("\n\ For the options above, the following values are supported for \"%s\":\n "), valid_args[i].name); -- 2.34.1