gdb: add process_target_ops_ref

This is just a more specifically typed version of target_ops_ref, which
avoids needing some as_process_stratum_target calls.

Change-Id: I9d0d7954bebd3a8b947961752e4816fbced06eb5
Approved-By: Andrew Burgess <aburgess@redhat.com>
This commit is contained in:
Simon Marchi 2026-04-20 14:38:41 -04:00
parent a2dd0aa39f
commit a879e037b2
3 changed files with 9 additions and 8 deletions

View file

@ -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 ();
}

View file

@ -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

View file

@ -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"