From patchwork Tue Dec 6 13:57:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 61551 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9C8D6384698E for ; Tue, 6 Dec 2022 13:58:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9C8D6384698E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1670335112; bh=o+nFVdy18KDv55GffZsDtke4GyqDjT5rUb+WosrLGUk=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=LV+TwDAJRlkS/4hMrLh+E4zAhjt66M42s5PyqCZe5ql5rg+/Hmwhm/cVT9xekYFC7 ZCQE4cf1CVUvrTTh6gssXScSu1/4gc3DdEvD8KHkfMQ3e+5Xg0jTTVZT8dExc5J+Bi yENp8eqVsyC/5yQDURvyoRW/x/MDToSERti850YE= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from barracuda.ebox.ca (barracuda.ebox.ca [96.127.255.19]) by sourceware.org (Postfix) with ESMTPS id 102223864A39 for ; Tue, 6 Dec 2022 13:57:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 102223864A39 X-ASG-Debug-ID: 1670335052-0c856e762a1bac0001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id xgh41RbmzuQflF7y (version=TLSv1 cipher=AES128-SHA bits=128 verify=NO); Tue, 06 Dec 2022 08:57:32 -0500 (EST) X-Barracuda-Envelope-From: simon.marchi@efficios.com X-Barracuda-RBL-Trusted-Forwarder: 96.127.255.82 Received: from epycamd.internal.efficios.com (192-222-180-24.qc.cable.ebox.net [192.222.180.24]) by smtp.ebox.ca (Postfix) with ESMTP id 05B55441D65; Tue, 6 Dec 2022 08:57:32 -0500 (EST) X-Barracuda-RBL-IP: 192.222.180.24 X-Barracuda-Effective-Source-IP: 192-222-180-24.qc.cable.ebox.net[192.222.180.24] X-Barracuda-Apparent-Source-IP: 192.222.180.24 To: gdb-patches@sourceware.org Cc: Lancelot SIX , Simon Marchi Subject: [PATCH 01/12] gdb: add supports_arch_info callback to gdbarch_register Date: Tue, 6 Dec 2022 08:57:18 -0500 X-ASG-Orig-Subj: [PATCH 01/12] gdb: add supports_arch_info callback to gdbarch_register Message-Id: <20221206135729.3937767-2-simon.marchi@efficios.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221206135729.3937767-1-simon.marchi@efficios.com> References: <20221206135729.3937767-1-simon.marchi@efficios.com> MIME-Version: 1.0 X-Barracuda-Connect: smtp.ebox.ca[96.127.255.82] X-Barracuda-Start-Time: 1670335052 X-Barracuda-Encrypted: AES128-SHA X-Barracuda-URL: https://96.127.255.19:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at ebox.ca X-Barracuda-Scan-Msg-Size: 3230 X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=5.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.102644 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- X-Spam-Status: No, score=-3498.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_SOFTFAIL, 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 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: , X-Patchwork-Original-From: Simon Marchi via Gdb-patches From: Simon Marchi Reply-To: Simon Marchi Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" 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 --- 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 60ffdc5e16a..dbe78647d5e 100644 --- a/gdb/arch-utils.c +++ b/gdb/arch-utils.c @@ -1211,6 +1211,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; }; @@ -1234,7 +1235,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); @@ -1247,7 +1250,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; @@ -1280,6 +1284,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 f2ba5f97765..aea6c4335d9 100644 --- a/gdb/gdbarch.h +++ b/gdb/gdbarch.h @@ -268,10 +268,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