From bc09b0c14fb713a9aec25e09b78499f3bc2441b5 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Fri, 19 Jan 2018 11:48:11 -0500 Subject: Make linux_nat_detach/thread_db_detach use the inferior parameter This patch makes these two functions actually use the inferior parameter added by the previous patch, instead of reading inferior_ptid. I chose these two, because they are the one actually used when I detach on my GNU/Linux system, so they were easy to test. I took the opportunity to pass the inferior being detached to inf_ptrace_detach_success, so it could use it too. From there, it made sense to add an overload of detach_inferior that takes the inferior directly rather than the pid, to avoid having to pass inf->pid only for the callee to look up the inferior structure by pid. gdb/ChangeLog: * inf-ptrace.c (inf_ptrace_detach): Adjust call to inf_ptrace_detach_success. (inf_ptrace_detach_success): Add inferior parameter, use it instead of inferior_ptid, pass it to detach_inferior. * inf-ptrace.h (inf_ptrace_detach_success): Add inferior parameter. * inferior.c (detach_inferior): Add overload that takes an inferior object. * inferior.h (detach_inferior): Likewise. * linux-nat.c (linux_nat_detach): Use the inf parameter, don't use inferior_ptid, adjust call to inf_ptrace_detach_success. * linux-thread-db.c (thread_db_detach): Use inf parameter. --- gdb/inf-ptrace.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'gdb/inf-ptrace.c') diff --git a/gdb/inf-ptrace.c b/gdb/inf-ptrace.c index aa8b17f..72aa334 100644 --- a/gdb/inf-ptrace.c +++ b/gdb/inf-ptrace.c @@ -263,18 +263,16 @@ inf_ptrace_detach (struct target_ops *ops, inferior *inf, int from_tty) error (_("This system does not support detaching from a process")); #endif - inf_ptrace_detach_success (ops); + inf_ptrace_detach_success (ops, inf); } /* See inf-ptrace.h. */ void -inf_ptrace_detach_success (struct target_ops *ops) +inf_ptrace_detach_success (struct target_ops *ops, inferior *inf) { - pid_t pid = ptid_get_pid (inferior_ptid); - inferior_ptid = null_ptid; - detach_inferior (pid); + detach_inferior (inf); inf_child_maybe_unpush_target (ops); } -- cgit v1.1