+/* Adjust inferior data when a new task was created. */
+
+static struct inferior *
+darwin_find_new_inferior (task_t task_port, thread_t thread_port)
+{
+ int task_pid;
+ struct inferior *inf;
+ kern_return_t kret;
+ mach_port_t prev;
+
+ /* Find the corresponding pid. */
+ kret = pid_for_task (task_port, &task_pid);
+ if (kret != KERN_SUCCESS)
+ {
+ MACH_CHECK_ERROR (kret);
+ return NULL;
+ }
+
+ /* Find the inferior for this pid. */
+ inf = darwin_find_inferior_by_pid (task_pid);
+ if (inf == NULL)
+ return NULL;
+
+ /* Deallocate saved exception ports. */
+ darwin_deallocate_exception_ports (inf->priv);
+
+ /* No need to remove dead_name notification, but still... */
+ kret = mach_port_request_notification (gdb_task, inf->priv->task,
+ MACH_NOTIFY_DEAD_NAME, 0,
+ MACH_PORT_NULL,
+ MACH_MSG_TYPE_MAKE_SEND_ONCE,
+ &prev);
+ if (kret != KERN_INVALID_ARGUMENT)
+ MACH_CHECK_ERROR (kret);
+
+ /* Replace old task port. */
+ kret = mach_port_deallocate (gdb_task, inf->priv->task);
+ MACH_CHECK_ERROR (kret);
+ inf->priv->task = task_port;
+
+ darwin_setup_request_notification (inf);
+ darwin_setup_exceptions (inf);
+
+ return inf;
+}
+
+/* Check data representation. */
+
+static int
+darwin_check_message_ndr (NDR_record_t *ndr)
+{
+ if (ndr->mig_vers != NDR_PROTOCOL_2_0
+ || ndr->if_vers != NDR_PROTOCOL_2_0
+ || ndr->mig_encoding != NDR_record.mig_encoding
+ || ndr->int_rep != NDR_record.int_rep
+ || ndr->char_rep != NDR_record.char_rep
+ || ndr->float_rep != NDR_record.float_rep)
+ return -1;
+ return 0;
+}
+
+/* Decode an exception message. */
+