THREAD_EXITED,
};
-extern struct thread_info*
+struct thread_info*
inferior_thread (void)
{
struct thread_info *tp = find_thread_pid (inferior_ptid);
{
if (tp->state_ != THREAD_EXITED)
{
- if (!silent)
- observer_notify_thread_exit (tp);
+ observer_notify_thread_exit (tp, silent);
/* Tag it as exited. */
tp->state_ = THREAD_EXITED;
thread_list = tp->next;
/* Notify thread exit, but only if we haven't already. */
- if (!silent && tp->state_ != THREAD_EXITED)
- observer_notify_thread_exit (tp);
+ if (tp->state_ != THREAD_EXITED)
+ observer_notify_thread_exit (tp, silent);
free_thread (tp);
}
return 0; /* Never heard of 'im */
}
+/* Finds the first thread of the inferior given by PID. If PID is -1,
+ return the first thread in the list. */
+
+struct thread_info *
+first_thread_of_process (int pid)
+{
+ struct thread_info *tp, *ret = NULL;
+
+ for (tp = thread_list; tp; tp = tp->next)
+ if (pid == -1 || ptid_get_pid (tp->ptid) == pid)
+ if (ret == NULL || tp->num < ret->num)
+ ret = tp;
+
+ return ret;
+}
+
/* Print a list of thread ids currently known, and the total number of
threads. To be used from within catch_errors. */
static int
set_running (ptid_t ptid, int running)
{
struct thread_info *tp;
+ int all = ptid_equal (ptid, minus_one_ptid);
/* We try not to notify the observer if no thread has actually changed
the running state -- merely to reduce the number of messages to
frontend. Frontend is supposed to handle multiple *running just fine. */
- if (PIDGET (ptid) == -1)
+ if (all || ptid_is_pid (ptid))
{
int any_started = 0;
for (tp = thread_list; tp; tp = tp->next)
- {
- if (tp->state_ == THREAD_EXITED)
- continue;
- if (running && tp->state_ == THREAD_STOPPED)
- any_started = 1;
- tp->state_ = running ? THREAD_RUNNING : THREAD_STOPPED;
- }
+ if (all || ptid_get_pid (tp->ptid) == ptid_get_pid (ptid))
+ {
+ if (tp->state_ == THREAD_EXITED)
+ continue;
+ if (running && tp->state_ == THREAD_STOPPED)
+ any_started = 1;
+ tp->state_ = running ? THREAD_RUNNING : THREAD_STOPPED;
+ }
if (any_started)
observer_notify_target_resumed (ptid);
}
set_executing (ptid_t ptid, int executing)
{
struct thread_info *tp;
+ int all = ptid_equal (ptid, minus_one_ptid);
- if (PIDGET (ptid) == -1)
+ if (all || ptid_is_pid (ptid))
{
for (tp = thread_list; tp; tp = tp->next)
- tp->executing_ = executing;
+ if (all || ptid_get_pid (tp->ptid) == ptid_get_pid (ptid))
+ tp->executing_ = executing;
}
else
{
if (!ptid_equal (inferior_ptid, null_ptid)
&& !is_exited (ptid)
&& !is_executing (ptid))
- stop_pc = read_pc ();
+ stop_pc = regcache_read_pc (get_thread_regcache (ptid));
else
stop_pc = ~(CORE_ADDR) 0;
}
then don't revert back to it, but instead simply drop back to no
thread selected. */
if (tp
- && is_exited (tp->ptid)
- && find_inferior_pid (ptid_get_pid (tp->ptid)) == NULL)
- restore_current_thread (null_ptid);
- else
+ && find_inferior_pid (ptid_get_pid (tp->ptid)) != NULL)
restore_current_thread (old->inferior_ptid);
+ else
+ restore_current_thread (null_ptid);
/* The running state of the originally selected thread may have
changed, so we have to recheck it here. */