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;
{
/* 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);
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);
&& 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);
}
{
/* 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;
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;
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;
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;
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);
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)
{
/* 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
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);
}
}
}
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))
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)
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
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. */
&& 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);
int status;
int res;
- if (ptid_equal (inferior_ptid, null_ptid))
+ if (inferior_ptid == null_ptid)
return;
gdb_assert (inf != NULL);
}
CATCH (ex, RETURN_MASK_ALL)
{
- inf->pid = 0;
- inf->priv.reset ();
+ exit_inferior (inf);
inferior_ptid = null_ptid;
throw_exception (ex);
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);
}
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;
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);
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;
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;
}
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);
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. */
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;
}