+2016-09-19  Sergio Durigan Junior  <sergiodj@redhat.com>
+
+       * darwin-nat.c (darwin_kill_inferior): Adjusting call to
+       target_mourn_inferior to include ptid_t argument.
+       * fork-child.c (startup_inferior): Likewise.
+       * gnu-nat.c (gnu_kill_inferior): Likewise.
+       * inf-ptrace.c (inf_ptrace_kill): Likewise.
+       * infrun.c (handle_inferior_event_1): Likewise.
+       * linux-nat.c (linux_nat_attach): Likewise.
+       (linux_nat_kill): Likewise.
+       * nto-procfs.c (interrupt_query): Likewise.
+       (procfs_interrupt): Likewise.
+       (procfs_kill_inferior): Likewise.
+       * procfs.c (procfs_kill_inferior): Likewise.
+       * record.c (record_mourn_inferior): Likewise.
+       * remote-sim.c (gdbsim_kill): Likewise.
+       * remote.c (remote_detach_1): Likewise.
+       (remote_kill): Likewise.
+       * target.c (target_mourn_inferior): Change declaration to accept
+       new ptid_t argument; use gdb_assert on it.
+       * target.h (target_mourn_inferior): Move function prototype from
+       here...
+       * target/target.h (target_mourn_inferior): ... to here.  Adjust it
+       to accept new ptid_t argument.
+       * windows-nat.c (get_windows_debug_event): Adjusting call to
+       target_mourn_inferior to include ptid_t argument.
+
 2016-09-18  Pedro Alves  <palves@redhat.com>
 
        * s390-linux-nat.c: Include <algorithm>.
 
     warning (_("Failed to kill inferior: kill (%d, 9) returned [%s]"),
             inf->pid, safe_strerror (errno));
 
-  target_mourn_inferior ();
+  target_mourn_inferior (inferior_ptid);
 }
 
 static void
 
 
          case TARGET_WAITKIND_SIGNALLED:
            target_terminal_ours ();
-           target_mourn_inferior ();
+           target_mourn_inferior (resume_ptid);
            error (_("During startup program terminated with signal %s, %s."),
                   gdb_signal_to_name (ws.value.sig),
                   gdb_signal_to_string (ws.value.sig));
 
          case TARGET_WAITKIND_EXITED:
            target_terminal_ours ();
-           target_mourn_inferior ();
+           target_mourn_inferior (resume_ptid);
            if (ws.value.integer)
              error (_("During startup program exited with code %d."),
                     ws.value.integer);
 
+2016-09-19  Sergio Durigan Junior  <sergiodj@redhat.com>
+
+       * server.c (start_inferior): Call target_mourn_inferior instead of
+       mourn_inferior; pass ptid_t argument to it.
+       (resume): Likewise.
+       (handle_target_event): Likewise.
+       * target.c (target_mourn_inferior): New function.
+       * target.h (mourn_inferior): Delete macro.
+
 2016-09-16  Andreas Arnez  <arnez@linux.vnet.ibm.com>
 
        * linux-low.c (lwp_is_stepping): New function.
 
       current_thread->last_status = last_status;
     }
   else
-    mourn_inferior (find_process_pid (ptid_get_pid (last_ptid)));
+    target_mourn_inferior (last_ptid);
 
   return signal_pid;
 }
 
       if (last_status.kind == TARGET_WAITKIND_EXITED
           || last_status.kind == TARGET_WAITKIND_SIGNALLED)
-        mourn_inferior (find_process_pid (ptid_get_pid (last_ptid)));
+        target_mourn_inferior (last_ptid);
     }
 }
 
          || last_status.kind == TARGET_WAITKIND_SIGNALLED)
        {
          mark_breakpoints_out (process);
-         mourn_inferior (process);
+         target_mourn_inferior (last_ptid);
        }
       else if (last_status.kind == TARGET_WAITKIND_THREAD_EXITED)
        ;
 
 
 /* See target/target.h.  */
 
+void
+target_mourn_inferior (ptid_t ptid)
+{
+  (*the_target->mourn) (find_process_pid (ptid_get_pid (ptid)));
+}
+
+/* See target/target.h.  */
+
 void
 target_continue_no_signal (ptid_t ptid)
 {
 
 #define detach_inferior(pid) \
   (*the_target->detach) (pid)
 
-#define mourn_inferior(PROC) \
-  (*the_target->mourn) (PROC)
-
 #define mythread_alive(pid) \
   (*the_target->thread_alive) (pid)
 
 
       task_terminate (task->port);
       inf_set_pid (gnu_current_inf, -1);
     }
-  target_mourn_inferior ();
+  target_mourn_inferior (inferior_ptid);
 }
 
 /* Clean up after the inferior dies.  */
 
   ptrace (PT_KILL, pid, (PTRACE_TYPE_ARG3)0, 0);
   waitpid (pid, &status, 0);
 
-  target_mourn_inferior ();
+  target_mourn_inferior (inferior_ptid);
 }
 
 /* Interrupt the inferior.  */
 
        }
 
       gdb_flush (gdb_stdout);
-      target_mourn_inferior ();
+      target_mourn_inferior (inferior_ptid);
       stop_print_frame = 0;
       stop_waiting (ecs);
       return;
 
          int exit_code = WEXITSTATUS (status);
 
          target_terminal_ours ();
-         target_mourn_inferior ();
+         target_mourn_inferior (inferior_ptid);
          if (exit_code == 0)
            error (_("Unable to attach: program exited normally."));
          else
          enum gdb_signal signo;
 
          target_terminal_ours ();
-         target_mourn_inferior ();
+         target_mourn_inferior (inferior_ptid);
 
          signo = gdb_signal_from_host (WTERMSIG (status));
          error (_("Unable to attach: program terminated with signal "
       iterate_over_lwps (ptid, kill_wait_callback, NULL);
     }
 
-  target_mourn_inferior ();
+  target_mourn_inferior (inferior_ptid);
 }
 
 static void
 
   if (query (_("Interrupted while waiting for the program.\n\
 Give up (and stop debugging it)? ")))
     {
-      target_mourn_inferior ();
+      target_mourn_inferior (inferior_ptid);
       quit ();
     }
 }
 static void
 procfs_kill_inferior (struct target_ops *ops)
 {
-  target_mourn_inferior ();
+  target_mourn_inferior (inferior_ptid);
 }
 
 /* Fill buf with regset and return devctl cmd to do the setting.  Return
 
 
       if (pi)
        unconditionally_kill_inferior (pi);
-      target_mourn_inferior ();
+      target_mourn_inferior (inferior_ptid);
     }
 }
 
 
      threads are discarded.  */
   record_unpush (t);
 
-  target_mourn_inferior ();
+  target_mourn_inferior (inferior_ptid);
 }
 
 /* See record.h.  */
 
 
   /* There is no need to `kill' running simulator - the simulator is
      not running.  Mourning it is enough.  */
-  target_mourn_inferior ();
+  target_mourn_inferior (inferior_ptid);
 }
 
 /* Load an executable file into the target process.  This is expected to
 
   /* If doing detach-on-fork, we don't mourn, because that will delete
      breakpoints that should be available for the followed inferior.  */
   if (!is_fork_parent)
-    target_mourn_inferior ();
+    target_mourn_inferior (inferior_ptid);
   else
     {
       inferior_ptid = null_ptid;
       res = remote_vkill (pid, rs);
       if (res == 0)
        {
-         target_mourn_inferior ();
+         target_mourn_inferior (inferior_ptid);
          return;
        }
     }
         not in extended mode, mourning the inferior also unpushes
         remote_ops from the target stack, which closes the remote
         connection.  */
-      target_mourn_inferior ();
+      target_mourn_inferior (inferior_ptid);
 
       return;
     }
 
 }
 
 void
-target_mourn_inferior (void)
+target_mourn_inferior (ptid_t ptid)
 {
+  gdb_assert (ptid_equal (ptid, inferior_ptid));
   current_target.to_mourn_inferior (¤t_target);
 
   /* We no longer need to keep handles on any of the object files.
 
    be defined by those targets that require the debugger to perform
    cleanup or internal state changes in response to the process event.  */
 
-/* The inferior process has died.  Do what is right.  */
-
-void target_mourn_inferior (void);
+/* For target_mourn_inferior see target/target.h.  */
 
 /* Does target have enough data to do a run or attach command? */
 
 
 extern ptid_t target_wait (ptid_t ptid, struct target_waitstatus *status,
                           int options);
 
+/* The inferior process has died.  Do what is right.  */
+
+extern void target_mourn_inferior (ptid_t ptid);
+
 #endif /* TARGET_COMMON_H */
 
       if (!windows_initialization_done)
        {
          target_terminal_ours ();
-         target_mourn_inferior ();
+         target_mourn_inferior (inferior_ptid);
          error (_("During startup program exited with code 0x%x."),
                 (unsigned int) current_event.u.ExitProcess.dwExitCode);
        }