Remove buildsym_init
[deliverable/binutils-gdb.git] / gdb / darwin-nat.c
index 6fb108846d0b921fb09ff585832843c9faf66946..bb46cfbfcfa53dc9b16f6c596b7dad807c4d1b2b 100644 (file)
@@ -342,7 +342,7 @@ darwin_check_new_threads (struct inferior *inf)
          pti->msg_state = DARWIN_RUNNING;
 
          /* Add the new thread.  */
-         add_thread_with_info (ptid_build (inf->pid, 0, new_id), pti);
+         add_thread_with_info (ptid_t (inf->pid, 0, new_id), pti);
          new_thread_vec.push_back (pti);
          new_ix++;
          continue;
@@ -351,7 +351,7 @@ darwin_check_new_threads (struct inferior *inf)
        {
          /* A thread was removed.  */
          struct thread_info *thr
-           = find_thread_ptid (ptid_build (inf->pid, 0, old_id));
+           = find_thread_ptid (ptid_t (inf->pid, 0, old_id));
          delete_thread (thr);
          kret = mach_port_deallocate (gdb_task, old_id);
          MACH_CHECK_ERROR (kret);
@@ -809,13 +809,24 @@ darwin_send_reply (struct inferior *inf, darwin_thread_t *thread)
   priv->pending_messages--;
 }
 
+/* Wrapper around the __pthread_kill syscall.  We use this instead of the
+   pthread_kill function to be able to send a signal to any kind of thread,
+   including GCD threads.  */
+
+static int
+darwin_pthread_kill (darwin_thread_t *thread, int nsignal)
+{
+  DIAGNOSTIC_PUSH;
+  DIAGNOSTIC_IGNORE_DEPRECATED_DECLARATIONS;
+  int res = syscall (SYS___pthread_kill, thread->gdb_port, nsignal);
+  DIAGNOSTIC_POP;
+  return res;
+}
+
 static void
 darwin_resume_thread (struct inferior *inf, darwin_thread_t *thread,
                      int step, int nsignal)
 {
-  kern_return_t kret;
-  int res;
-
   inferior_debug
     (3, _("darwin_resume_thread: state=%d, thread=0x%x, step=%d nsignal=%d\n"),
      thread->msg_state, thread->gdb_port, step, nsignal);
@@ -827,8 +838,8 @@ darwin_resume_thread (struct inferior *inf, darwin_thread_t *thread,
          && thread->event.ex_data[0] == EXC_SOFT_SIGNAL)
        {
          /* Either deliver a new signal or cancel the signal received.  */
-         res = PTRACE (PT_THUPDATE, inf->pid,
-                       (caddr_t) (uintptr_t) thread->gdb_port, nsignal);
+         int res = PTRACE (PT_THUPDATE, inf->pid,
+                           (caddr_t) (uintptr_t) thread->gdb_port, nsignal);
          if (res < 0)
            inferior_debug (1, _("ptrace THUP: res=%d\n"), res);
        }
@@ -836,7 +847,7 @@ darwin_resume_thread (struct inferior *inf, darwin_thread_t *thread,
        {
          /* Note: ptrace is allowed only if the process is stopped.
             Directly send the signal to the thread.  */
-         res = syscall (SYS___pthread_kill, thread->gdb_port, nsignal);
+         int res = darwin_pthread_kill (thread, nsignal);
          inferior_debug (4, _("darwin_resume_thread: kill 0x%x %d: %d\n"),
                          thread->gdb_port, nsignal, res);
          thread->signaled = 1;
@@ -856,7 +867,7 @@ darwin_resume_thread (struct inferior *inf, darwin_thread_t *thread,
       break;
 
     case DARWIN_STOPPED:
-      kret = thread_resume (thread->gdb_port);
+      kern_return_t kret = thread_resume (thread->gdb_port);
       MACH_CHECK_ERROR (kret);
 
       thread->msg_state = DARWIN_RUNNING;
@@ -930,7 +941,7 @@ darwin_nat_target::resume (ptid_t ptid, int step, enum gdb_signal signal)
 
   inferior_debug
     (2, _("darwin_resume: pid=%d, tid=0x%lx, step=%d, signal=%d\n"),
-     ptid_get_pid (ptid), ptid_get_tid (ptid), step, signal);
+     ptid.pid (), ptid.tid (), step, signal);
 
   if (signal == GDB_SIGNAL_0)
     nsignal = 0;
@@ -942,7 +953,7 @@ darwin_nat_target::resume (ptid_t ptid, int step, enum gdb_signal signal)
     ptid = inferior_ptid;
 
   /* minus_one_ptid is RESUME_ALL.  */
-  if (ptid_equal (ptid, minus_one_ptid))
+  if (ptid == minus_one_ptid)
     {
       struct resume_inferior_threads_param param;
 
@@ -957,7 +968,7 @@ darwin_nat_target::resume (ptid_t ptid, int step, enum gdb_signal signal)
   else
     {
       struct inferior *inf = find_inferior_ptid (ptid);
-      long tid = ptid_get_tid (ptid);
+      long tid = ptid.tid ();
 
       /* Stop the inferior (should be useless).  */
       darwin_suspend_inferior (inf);
@@ -1074,7 +1085,7 @@ darwin_decode_message (mach_msg_header_t *hdr,
          break;
        }
 
-      return ptid_build (inf->pid, 0, thread->gdb_port);
+      return ptid_t (inf->pid, 0, thread->gdb_port);
     }
   else if (hdr->msgh_id == 0x48)
     {
@@ -1134,7 +1145,7 @@ darwin_decode_message (mach_msg_header_t *hdr,
              /* Looks necessary on Leopard and harmless...  */
              wait4 (inf->pid, &wstatus, 0, NULL);
 
-             inferior_ptid = ptid_build (inf->pid, 0, 0);
+             inferior_ptid = ptid_t (inf->pid, 0, 0);
              return inferior_ptid;
            }
          else
@@ -1142,7 +1153,7 @@ darwin_decode_message (mach_msg_header_t *hdr,
              inferior_debug (4, _("darwin_wait: pid=%d\n"), inf->pid);
              status->kind = TARGET_WAITKIND_EXITED;
              status->value.integer = 0; /* Don't know.  */
-             return ptid_build (inf->pid, 0, 0);
+             return ptid_t (inf->pid, 0, 0);
            }
        }
     }
@@ -1172,7 +1183,7 @@ cancel_breakpoint (ptid_t ptid)
   if (breakpoint_inserted_here_p (regcache->aspace (), pc))
     {
       inferior_debug (4, "cancel_breakpoint for thread 0x%lx\n",
-                     (unsigned long) ptid_get_tid (ptid));
+                     (unsigned long) ptid.tid ());
 
       /* Back up the PC if necessary.  */
       if (gdbarch_decr_pc_after_break (gdbarch))
@@ -1199,7 +1210,7 @@ darwin_wait (ptid_t ptid, struct target_waitstatus *status)
 
   inferior_debug
     (2, _("darwin_wait: waiting for a message pid=%d thread=%lx\n"),
-     ptid_get_pid (ptid), ptid_get_tid (ptid));
+     ptid.pid (), ptid.tid ());
 
   /* Handle fake stop events at first.  */
   if (darwin_inf_fake_stop != NULL)
@@ -1213,7 +1224,7 @@ darwin_wait (ptid_t ptid, struct target_waitstatus *status)
       status->value.sig = GDB_SIGNAL_TRAP;
       thread = priv->threads[0];
       thread->msg_state = DARWIN_STOPPED;
-      return ptid_build (inf->pid, 0, thread->gdb_port);
+      return ptid_t (inf->pid, 0, thread->gdb_port);
     }
 
   do
@@ -1244,7 +1255,7 @@ darwin_wait (ptid_t ptid, struct target_waitstatus *status)
        darwin_dump_message (hdr, darwin_debug_flag > 11);
 
       res = darwin_decode_message (hdr, &thread, &inf, status);
-      if (ptid_equal (res, minus_one_ptid))
+      if (res == minus_one_ptid)
        continue;
 
       /* Early return in case an inferior has exited.  */
@@ -1285,7 +1296,7 @@ darwin_wait (ptid_t ptid, struct target_waitstatus *status)
          && thread->event.ex_type == EXC_BREAKPOINT)
        {
          if (thread->single_step
-             || cancel_breakpoint (ptid_build (inf->pid, 0, thread->gdb_port)))
+             || cancel_breakpoint (ptid_t (inf->pid, 0, thread->gdb_port)))
            {
              gdb_assert (thread->msg_state == DARWIN_MESSAGE);
              darwin_send_reply (inf, thread);
@@ -1517,7 +1528,7 @@ darwin_nat_target::kill ()
   int status;
   int res;
 
-  if (ptid_equal (inferior_ptid, null_ptid))
+  if (inferior_ptid == null_ptid)
     return;
 
   gdb_assert (inf != NULL);
@@ -1662,8 +1673,7 @@ darwin_attach_pid (struct inferior *inf)
     }
   CATCH (ex, RETURN_MASK_ALL)
     {
-      inf->pid = 0;
-      inf->priv.reset ();
+      exit_inferior (inf);
       inferior_ptid = null_ptid;
 
       throw_exception (ex);
@@ -1881,10 +1891,10 @@ darwin_nat_target::attach (const char *args, int from_tty)
 
       if (exec_file)
        printf_unfiltered (_("Attaching to program: %s, %s\n"), exec_file,
-                          target_pid_to_str (pid_to_ptid (pid)));
+                          target_pid_to_str (ptid_t (pid)));
       else
        printf_unfiltered (_("Attaching to %s\n"),
-                          target_pid_to_str (pid_to_ptid (pid)));
+                          target_pid_to_str (ptid_t (pid)));
 
       gdb_flush (gdb_stdout);
     }
@@ -1893,7 +1903,7 @@ darwin_nat_target::attach (const char *args, int from_tty)
     error (_("Can't attach to process %d: %s (%d)"),
            pid, safe_strerror (errno), errno);
 
-  inferior_ptid = pid_to_ptid (pid);
+  inferior_ptid = ptid_t (pid);
   inf = current_inferior ();
   inferior_appeared (inf, pid);
   inf->attach_flag = 1;
@@ -1906,7 +1916,7 @@ darwin_nat_target::attach (const char *args, int from_tty)
 
   darwin_inferior *priv = get_darwin_inferior (inf);
 
-  darwin_check_osabi (priv, ptid_get_tid (inferior_ptid));
+  darwin_check_osabi (priv, inferior_ptid.tid ());
 
   darwin_setup_fake_stop_event (inf);
 
@@ -1924,7 +1934,7 @@ darwin_nat_target::attach (const char *args, int from_tty)
 void
 darwin_nat_target::detach (inferior *inf, int from_tty)
 {
-  pid_t pid = ptid_get_pid (inferior_ptid);
+  pid_t pid = inferior_ptid.pid ();
   darwin_inferior *priv = get_darwin_inferior (inf);
   kern_return_t kret;
   int res;
@@ -1962,12 +1972,12 @@ const char *
 darwin_nat_target::pid_to_str (ptid_t ptid)
 {
   static char buf[80];
-  long tid = ptid_get_tid (ptid);
+  long tid = ptid.tid ();
 
   if (tid != 0)
     {
       snprintf (buf, sizeof (buf), _("Thread 0x%lx of process %u"),
-               tid, ptid_get_pid (ptid));
+               tid, ptid.pid ());
       return buf;
     }
 
@@ -2223,7 +2233,7 @@ static void
 set_enable_mach_exceptions (const char *args, int from_tty,
                            struct cmd_list_element *c)
 {
-  if (!ptid_equal (inferior_ptid, null_ptid))
+  if (inferior_ptid != null_ptid)
     {
       struct inferior *inf = current_inferior ();
       darwin_inferior *priv = get_darwin_inferior (inf);
@@ -2272,7 +2282,7 @@ darwin_nat_target::get_ada_task_ptid (long lwp, long thread)
   for (darwin_thread_t *t : priv->threads)
     {
       if (t->inf_port == lwp)
-       return ptid_build (ptid_get_pid (inferior_ptid), 0, t->gdb_port);
+       return ptid_t (inferior_ptid.pid (), 0, t->gdb_port);
     }
 
   /* Maybe the port was never extract.  Do it now.  */
@@ -2316,7 +2326,7 @@ darwin_nat_target::get_ada_task_ptid (long lwp, long thread)
                  names_count * sizeof (mach_port_t));
 
   if (res)
-    return ptid_build (ptid_get_pid (inferior_ptid), 0, res);
+    return ptid_t (inferior_ptid.pid (), 0, res);
   else
     return null_ptid;
 }
This page took 0.028981 seconds and 4 git commands to generate.