From patchwork Thu Nov 24 16:04:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 61084 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 CBB193830B22 for ; Thu, 24 Nov 2022 16:05:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CBB193830B22 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1669305950; bh=QeQE/MCabBXf0rQr7pn6z0MFGQ4L6owabsxhOj6DXTk=; 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=nqfkfBaknWKQQ7tZGBP98JOfTMqPLU2Mi/qeT696JuP+kEL/5QxTD65oXxYYT6RQ0 79o5YdYLQ07th4Str5aWgHAa0zq5YTi2vAYJmeOSDb5QUktD3KiNVZCkzUCdfH+3x3 dC2zqUDv7H9I7Y6p4lDb0YrqID/wCbDJ/ZKghsAg= 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 979A43830B29 for ; Thu, 24 Nov 2022 16:04:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 979A43830B29 X-ASG-Debug-ID: 1669305869-0c856e02a1306190001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id eQJKgHsaupjC8cAX (version=TLSv1 cipher=AES128-SHA bits=128 verify=NO); Thu, 24 Nov 2022 11:04:29 -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 7DE70441D65; Thu, 24 Nov 2022 11:04:29 -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: Simon Marchi Subject: [PATCH 2/5] gdb: add inferior parameter to set_target_gdbarch, rename to set_inferior_gdbarch Date: Thu, 24 Nov 2022 11:04:25 -0500 X-ASG-Orig-Subj: [PATCH 2/5] gdb: add inferior parameter to set_target_gdbarch, rename to set_inferior_gdbarch Message-Id: <20221124160428.83804-3-simon.marchi@efficios.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221124160428.83804-1-simon.marchi@efficios.com> References: <20221124160428.83804-1-simon.marchi@efficios.com> MIME-Version: 1.0 X-Barracuda-Connect: smtp.ebox.ca[96.127.255.82] X-Barracuda-Start-Time: 1669305869 X-Barracuda-Encrypted: AES128-SHA X-Barracuda-URL: https://96.127.255.19:443/cgi-mod/mark.cgi X-Barracuda-BRTS-Status: 1 X-Virus-Scanned: by bsmtpd at ebox.ca X-Barracuda-Scan-Msg-Size: 2720 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.102368 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- X-Spam-Status: No, score=-3498.4 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: Simon Marchi Add an inferior parameter, so it doesn't depend on the current inferior. While at it, rename to set_inferior_gdbarch, I think that's a better name than "target". The sole observer of the architecture_changed observable, pyuw_on_new_gdbarch, doesn't seem to depend on the current inferior. Neither does registers_changed. Update callers to pass the current inferior, no change in behavior is expected. Change-Id: I276e28eafd4740c94bc5233c81a86c01b4a6ae90 --- gdb/arch-utils.c | 16 ++++++++-------- gdb/gdbarch.h | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c index dc67c632155..92caa5c3c4a 100644 --- a/gdb/arch-utils.c +++ b/gdb/arch-utils.c @@ -617,7 +617,7 @@ gdbarch_update_p (struct gdbarch_info info) "New architecture %s (%s) selected\n", host_address_to_string (new_gdbarch), gdbarch_bfd_arch_info (new_gdbarch)->printable_name); - set_target_gdbarch (new_gdbarch); + set_inferior_gdbarch (current_inferior (), new_gdbarch); return 1; } @@ -649,7 +649,7 @@ set_gdbarch_from_file (bfd *abfd) if (gdbarch == NULL) error (_("Architecture of file not recognized.")); - set_target_gdbarch (gdbarch); + set_inferior_gdbarch (current_inferior (), gdbarch); } /* Initialize the current architecture. Update the ``set @@ -1427,15 +1427,15 @@ gdbarch_find_by_info (struct gdbarch_info info) return new_gdbarch; } -/* Make the specified architecture current. */ +/* See gdbarch.h. */ void -set_target_gdbarch (struct gdbarch *new_gdbarch) +set_inferior_gdbarch (inferior *inf, gdbarch *gdbarch) { - gdb_assert (new_gdbarch != NULL); - gdb_assert (new_gdbarch->initialized_p); - current_inferior ()->gdbarch = new_gdbarch; - gdb::observers::architecture_changed.notify (new_gdbarch); + gdb_assert (gdbarch != nullptr); + gdb_assert (gdbarch->initialized_p); + inf->gdbarch = gdbarch; + gdb::observers::architecture_changed.notify (gdbarch); registers_changed (); } diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h index f2ba5f97765..76ffddfe0ff 100644 --- a/gdb/gdbarch.h +++ b/gdb/gdbarch.h @@ -342,9 +342,9 @@ extern int gdbarch_update_p (struct gdbarch_info info); extern struct gdbarch *gdbarch_find_by_info (struct gdbarch_info info); -/* Helper function. Set the target gdbarch to "gdbarch". */ +/* Set INF's the target gdbarch to "gdbarch". */ -extern void set_target_gdbarch (struct gdbarch *gdbarch); +extern void set_inferior_gdbarch (inferior *inf, gdbarch *gdbarch); /* A registry adaptor for gdbarch. This arranges to store the