Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@efficios.com>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: [PATCH] gdb: add process_target_ops_ref
Date: Mon, 20 Apr 2026 14:38:41 -0400	[thread overview]
Message-ID: <20260420183843.340801-1-simon.marchi@efficios.com> (raw)

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, target_ops_ref_policy> target_ops_ref;
+using target_ops_ref = gdb::ref_ptr<target_ops, target_ops_ref_policy>;
+using process_target_ops_ref
+  = gdb::ref_ptr<process_stratum_target, target_ops_ref_policy>;
 
 /* 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


             reply	other threads:[~2026-04-20 18:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-20 18:38 Simon Marchi [this message]
2026-04-21  9:26 ` Andrew Burgess
2026-04-21 14:27   ` Simon Marchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260420183843.340801-1-simon.marchi@efficios.com \
    --to=simon.marchi@efficios.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox