From c9657e708a03cb06ad92ce81bf17c68d28e57689 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Mon, 15 Dec 2014 12:00:55 -0500 Subject: Introduce utility function find_inferior_ptid This patch introduces find_inferior_ptid to replace the common idiom find_inferior_pid (ptid_get_pid (...)); It replaces all the instances of that idiom that I found with the new function. No significant changes before/after the patch in the regression suite on amd64 linux. gdb/ChangeLog: * inferior.c (find_inferior_ptid): New function. * inferior.h (find_inferior_ptid): New declaration. * ada-tasks.c (ada_get_task_number): Use find_inferior_ptid. * corelow.c (core_pid_to_str): Same. * darwin-nat.c (darwin_resume): Same. * infrun.c (fetch_inferior_event): Same. (get_inferior_stop_soon): Same. (handle_inferior_event): Same. (handle_signal_stop): Same. * linux-nat.c (resume_lwp): Same. (stop_wait_callback): Same. * mi/mi-interp.c (mi_new_thread): Same. (mi_thread_exit): Same. * proc-service.c (ps_pglobal_lookup): Same. * record-btrace.c (record_btrace_step_thread): Same. * remote-sim.c (gdbsim_close_inferior): Same. (gdbsim_resume): Same. (gdbsim_stop): Same. * sol2-tdep.c (sol2_core_pid_to_str): Same. * target.c (memory_xfer_partial_1): Same. (default_thread_address_space): Same. * thread.c (thread_change_ptid): Same. (switch_to_thread): Same. (do_restore_current_thread_cleanup): Same. --- gdb/remote-sim.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'gdb/remote-sim.c') diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c index 8901548..92c41ad 100644 --- a/gdb/remote-sim.c +++ b/gdb/remote-sim.c @@ -774,7 +774,7 @@ gdbsim_close_inferior (struct inferior *inf, void *arg) Thus we need to verify the existence of an inferior using the pid in question before setting inferior_ptid via switch_to_thread() or mourning the inferior. */ - if (find_inferior_pid (ptid_get_pid (ptid)) != NULL) + if (find_inferior_ptid (ptid) != NULL) { switch_to_thread (ptid); generic_mourn_inferior (); @@ -881,7 +881,7 @@ gdbsim_resume (struct target_ops *ops, either have multiple inferiors to resume or an error condition. */ if (sim_data) - gdbsim_resume_inferior (find_inferior_pid (ptid_get_pid (ptid)), &rd); + gdbsim_resume_inferior (find_inferior_ptid (ptid), &rd); else if (ptid_equal (ptid, minus_one_ptid)) iterate_over_inferiors (gdbsim_resume_inferior, &rd); else @@ -928,7 +928,7 @@ gdbsim_stop (struct target_ops *self, ptid_t ptid) } else { - struct inferior *inf = find_inferior_pid (ptid_get_pid (ptid)); + struct inferior *inf = find_inferior_ptid (ptid); if (inf == NULL) error (_("Can't stop pid %d. No inferior found."), -- cgit v1.1