gdbserver: When attaching, add process before lwps
[binutils-gdb.git] / gdb / gdbserver / linux-low.c
index 44016d2310534cf96c7da0509266ca43aeb70bf9..c6d94172356cd1a4590e280215cc6aba9da623bd 100644 (file)
@@ -1188,6 +1188,8 @@ linux_attach (unsigned long pid)
   ptid_t ptid = ptid_t (pid, pid, 0);
   int err;
 
+  proc = linux_add_process (pid, 1);
+
   /* Attach to PID.  We will check for other threads
      soon.  */
   err = linux_attach_lwp (ptid);
@@ -1198,8 +1200,6 @@ linux_attach (unsigned long pid)
       error ("Cannot attach to process %ld: %s", pid, reason.c_str ());
     }
 
-  proc = linux_add_process (pid, 1);
-
   /* Don't ignore the initial SIGSTOP if we just attached to this
      process.  It will be collected by wait shortly.  */
   initial_thread = find_thread_ptid (ptid_t (pid, pid, 0));