From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id DJpZL85y5mmAHi0AWB0awg (envelope-from ) for ; Mon, 20 Apr 2026 14:39:10 -0400 Received: by simark.ca (Postfix, from userid 112) id AB5501E0C3; Mon, 20 Apr 2026 14:39:10 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.3 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 1A67A1E093 for ; Mon, 20 Apr 2026 14:39:10 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id A198D4BA2E0D for ; Mon, 20 Apr 2026 18:39:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A198D4BA2E0D Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 6B6BD4BA2E0D for ; Mon, 20 Apr 2026 18:38:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6B6BD4BA2E0D Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=efficios.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=efficios.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6B6BD4BA2E0D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776710326; cv=none; b=tIUFujiilKiuHU3wuFKz9ZLotftg46MsinfKaGj11s7ISuNpWp5AeZqcVVsRBtrJlFUQxBQ6QC8/GPQX0AP1ejke87JA2BQmRcVKsZdig+NG7f2yV6PUPjh08zHAtklbBDrC3LY+L12yRXY5Whi4wnAS0fEaAJ1ABYU6Htrlww4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776710326; c=relaxed/simple; bh=mX1C6MwRgiiygaW4HE6J66Kqaf4LewLaooywoso4Qsk=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=BxoZM1Cg5aIbG5AwQ8pHu0lW4tU3o6o9gH02eNY/sU+LVICHIEhMaQ35dK9jQkf3iHjVehJ/SI1wbiRPCU+H9Xb0gIM21UmsbqX8bEkAkwpsMeW9YsfgpWm1Re5fEn+YWy6wuSDorr9wTxoMIkdkKUf+PNJcgycHUGJZjGnqJgk= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6B6BD4BA2E0D Received: by simark.ca (Postfix) id 00EE21E093; Mon, 20 Apr 2026 14:38:43 -0400 (EDT) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH] gdb: add process_target_ops_ref Date: Mon, 20 Apr 2026 14:38:41 -0400 Message-ID: <20260420183843.340801-1-simon.marchi@efficios.com> X-Mailer: git-send-email 2.53.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org This is just a more specifically typed version of target_ops_ref, which avoids needing some as_process_stratum_target calls. Change-Id: I9d0d7954bebd3a8b947961752e4816fbced06eb5 --- gdb/infcmd.c | 5 +++-- gdb/target.c | 8 +++----- gdb/target.h | 4 +++- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/gdb/infcmd.c b/gdb/infcmd.c index 4a907ea8ce86..f3f15c9ae1d0 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -3042,7 +3042,8 @@ detach_command (const char *args, int from_tty) detaching the parent. Otherwise detaching could close the target. */ inferior *inf = current_inferior (); - auto target_ref = target_ops_ref::new_reference (inf->process_target ()); + auto target_ref + = process_target_ops_ref::new_reference (inf->process_target ()); /* Save this before detaching, since detaching may unpush the process_stratum target. */ @@ -3068,7 +3069,7 @@ detach_command (const char *args, int from_tty) deprecated_detach_hook (); if (!was_non_stop_p) - restart_after_all_stop_detach (as_process_stratum_target (target_ref.get ())); + restart_after_all_stop_detach (target_ref.get ()); disable_commit_resumed.reset_and_commit (); } diff --git a/gdb/target.c b/gdb/target.c index df2fe5cfd990..5d937f3ae858 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -2562,14 +2562,12 @@ target_detach (inferior *inf, int from_tty) /* Hold a strong reference because detaching may unpush the target. */ - auto proc_target_ref = target_ops_ref::new_reference (inf->process_target ()); + auto proc_target_ref + = process_target_ops_ref::new_reference (inf->process_target ()); current_inferior ()->top_target ()->detach (inf, from_tty); - process_stratum_target *proc_target - = as_process_stratum_target (proc_target_ref.get ()); - - registers_changed_ptid (proc_target, save_pid_ptid); + registers_changed_ptid (proc_target_ref.get (), save_pid_ptid); /* We have to ensure we have no frame cache left. Normally, registers_changed_ptid (save_pid_ptid) calls reinit_frame_cache when diff --git a/gdb/target.h b/gdb/target.h index 9fb29be01b69..81726849d1e7 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -1442,7 +1442,9 @@ struct target_ops_ref_policy }; /* A gdb::ref_ptr pointer to a target_ops. */ -typedef gdb::ref_ptr target_ops_ref; +using target_ops_ref = gdb::ref_ptr; +using process_target_ops_ref + = gdb::ref_ptr; /* Native target backends call this once at initialization time to inform the core about which is the target that can respond to "run" base-commit: 9b9cbb09d85e40adb9a22f3c97de74b6c9c5e205 -- 2.53.0