From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 5176E3858D35 for ; Thu, 5 Jan 2023 20:02:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5176E3858D35 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=polymtl.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=polymtl.ca Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 305K2dwJ009506 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 5 Jan 2023 15:02:44 -0500 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 305K2dwJ009506 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=polymtl.ca; s=default; t=1672948964; bh=QxL5e2/LszWLIOKxNa90fOMyK0RTY9mvbN8XC2E34jE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wq4SkIjS6T2csXKXmWmgdl60mXAhp3vspp5RrmWa0oQ/f9gLY56u6YsZrouM4I4i7 BcmhgitMW4amzQftChM3QlEpbAqRPMHTs4dJGxsQgh8N9axvJIcHdPLzQIENexyGzN 31l3rEI+oaWYijGjB/eu49s7S1jno0hFvOlHSnS0= Received: from simark.localdomain (unknown [217.28.27.60]) (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 ESMTPSA id 297A21E15D; Thu, 5 Jan 2023 15:02:38 -0500 (EST) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Lancelot SIX , Simon Marchi , Andrew Burgess Subject: [PATCH v2 1/8] gdb: add supports_arch_info callback to gdbarch_register Date: Thu, 5 Jan 2023 15:02:30 -0500 Message-Id: <20230105200237.987771-2-simon.marchi@polymtl.ca> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230105200237.987771-1-simon.marchi@polymtl.ca> References: <20230105200237.987771-1-simon.marchi@polymtl.ca> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Thu, 5 Jan 2023 20:02:39 +0000 X-Spam-Status: No, score=-3189.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS,TXREP 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: From: Lancelot SIX In the ROCm GDB port, there are some amdgcn architectures known by BFD that we don't actually support in GDB. We don't want gdbarch_printable_names to return these architectures. gdbarch_printable_names is used for a few things: - completion of the "set architecture" command - the gdb.architecture_names function in Python - foreach-arch selftests Add an optional callback to gdbarch_register that is a predicate indicating whether the gdbarch supports the given bfd_arch_info. by default, it is nullptr, meaning that the gdbarch accepts all "mach"s for that architecture known by BFD. Change-Id: I712f94351b0b34ed1f42e5cf7fc7ba051315d860 Co-Authored-By: Simon Marchi Approved-By: Andrew Burgess --- gdb/arch-utils.c | 9 +++++++-- gdb/gdbarch.h | 4 +++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c index 67968126488e..617768225d32 100644 --- a/gdb/arch-utils.c +++ b/gdb/arch-utils.c @@ -1237,6 +1237,7 @@ struct gdbarch_registration enum bfd_architecture bfd_architecture; gdbarch_init_ftype *init; gdbarch_dump_tdep_ftype *dump_tdep; + gdbarch_supports_arch_info_ftype *supports_arch_info; struct gdbarch_list *arches; struct gdbarch_registration *next; }; @@ -1260,7 +1261,9 @@ gdbarch_printable_names () internal_error (_("gdbarch_architecture_names: multi-arch unknown")); do { - arches.push_back (ap->printable_name); + if (rego->supports_arch_info == nullptr + || rego->supports_arch_info (ap)) + arches.push_back (ap->printable_name); ap = ap->next; } while (ap != NULL); @@ -1273,7 +1276,8 @@ gdbarch_printable_names () void gdbarch_register (enum bfd_architecture bfd_architecture, gdbarch_init_ftype *init, - gdbarch_dump_tdep_ftype *dump_tdep) + gdbarch_dump_tdep_ftype *dump_tdep, + gdbarch_supports_arch_info_ftype *supports_arch_info) { struct gdbarch_registration **curr; const struct bfd_arch_info *bfd_arch_info; @@ -1306,6 +1310,7 @@ gdbarch_register (enum bfd_architecture bfd_architecture, (*curr)->bfd_architecture = bfd_architecture; (*curr)->init = init; (*curr)->dump_tdep = dump_tdep; + (*curr)->supports_arch_info = supports_arch_info; (*curr)->arches = NULL; (*curr)->next = NULL; } diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h index a1167f21ecac..f4efd8c0bc78 100644 --- a/gdb/gdbarch.h +++ b/gdb/gdbarch.h @@ -270,10 +270,12 @@ struct gdbarch_info typedef struct gdbarch *(gdbarch_init_ftype) (struct gdbarch_info info, struct gdbarch_list *arches); typedef void (gdbarch_dump_tdep_ftype) (struct gdbarch *gdbarch, struct ui_file *file); +typedef bool (gdbarch_supports_arch_info_ftype) (const struct bfd_arch_info *); extern void gdbarch_register (enum bfd_architecture architecture, gdbarch_init_ftype *init, - gdbarch_dump_tdep_ftype *dump_tdep = nullptr); + gdbarch_dump_tdep_ftype *dump_tdep = nullptr, + gdbarch_supports_arch_info_ftype *supports_arch_info = nullptr); /* Return a vector of the valid architecture names. Since architectures are -- 2.39.0