summaryrefslogtreecommitdiff
path: root/gdb/remote.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/remote.c')
-rw-r--r--gdb/remote.c75
1 files changed, 21 insertions, 54 deletions
diff --git a/gdb/remote.c b/gdb/remote.c
index 39b3823ffc4..82021bf8be1 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -3785,8 +3785,6 @@ remote_target::update_thread_list ()
|| remote_get_threads_with_qthreadinfo (&context)
|| remote_get_threads_with_ql (&context))
{
- struct thread_info *tp, *tmp;
-
got_list = 1;
if (context.items.empty ()
@@ -3803,7 +3801,7 @@ remote_target::update_thread_list ()
/* CONTEXT now holds the current thread list on the remote
target end. Delete GDB-side threads no longer found on the
target. */
- ALL_THREADS_SAFE (tp, tmp)
+ for (thread_info *tp : all_threads_safe ())
{
if (!context.contains_thread (tp->ptid))
{
@@ -4385,8 +4383,6 @@ void
remote_target::process_initial_stop_replies (int from_tty)
{
int pending_stop_replies = stop_reply_queue_length ();
- struct inferior *inf;
- struct thread_info *thread;
struct thread_info *selected = NULL;
struct thread_info *lowest_stopped = NULL;
struct thread_info *first = NULL;
@@ -4454,16 +4450,13 @@ remote_target::process_initial_stop_replies (int from_tty)
/* "Notice" the new inferiors before anything related to
registers/memory. */
- ALL_INFERIORS (inf)
+ for (inferior *inf : all_non_exited_inferiors ())
{
- if (inf->pid == 0)
- continue;
-
inf->needs_setup = 1;
if (non_stop)
{
- thread = any_live_thread_of_inferior (inf);
+ thread_info *thread = any_live_thread_of_inferior (inf);
notice_new_inferior (thread, thread->state == THREAD_RUNNING,
from_tty);
}
@@ -4478,14 +4471,11 @@ remote_target::process_initial_stop_replies (int from_tty)
/* If all threads of an inferior were already stopped, we
haven't setup the inferior yet. */
- ALL_INFERIORS (inf)
+ for (inferior *inf : all_non_exited_inferiors ())
{
- if (inf->pid == 0)
- continue;
-
if (inf->needs_setup)
{
- thread = any_live_thread_of_inferior (inf);
+ thread_info *thread = any_live_thread_of_inferior (inf);
switch_to_thread_no_regs (thread);
setup_inferior (0);
}
@@ -4495,7 +4485,7 @@ remote_target::process_initial_stop_replies (int from_tty)
/* Now go over all threads that are stopped, and print their current
frame. If all-stop, then if there's a signalled thread, pick
that as current. */
- ALL_NON_EXITED_THREADS (thread)
+ for (thread_info *thread : all_non_exited_threads ())
{
if (first == NULL)
first = thread;
@@ -4522,7 +4512,7 @@ remote_target::process_initial_stop_replies (int from_tty)
others with their status pending. */
if (!non_stop)
{
- thread = selected;
+ thread_info *thread = selected;
if (thread == NULL)
thread = lowest_stopped;
if (thread == NULL)
@@ -4532,7 +4522,7 @@ remote_target::process_initial_stop_replies (int from_tty)
}
/* For "info program". */
- thread = inferior_thread ();
+ thread_info *thread = inferior_thread ();
if (thread->state == THREAD_STOPPED)
set_last_target_status (inferior_ptid, thread->suspend.waitstatus);
}
@@ -4731,7 +4721,7 @@ remote_target::start_remote (int from_tty, int extended_p)
"warning: couldn't determine remote "
"current thread; picking first in list.\n");
- inferior_ptid = thread_list->ptid;
+ inferior_ptid = inferior_list->thread_list->ptid;
}
}
@@ -5613,9 +5603,6 @@ remote_target::open_1 (const char *name, int from_tty, int extended_p)
/* First delete any symbols previously loaded from shared libraries. */
no_shared_libraries (NULL, 0);
- /* Start afresh. */
- init_thread_list ();
-
/* Start the remote connection. If error() or QUIT, discard this
target (we'd otherwise be in an inconsistent state) and then
propogate the error on up the exception chain. This ensures that
@@ -6113,11 +6100,8 @@ char *
remote_target::append_pending_thread_resumptions (char *p, char *endp,
ptid_t ptid)
{
- struct thread_info *thread;
-
- ALL_NON_EXITED_THREADS (thread)
- if (thread->ptid.matches (ptid)
- && inferior_ptid != thread->ptid
+ for (thread_info *thread : all_non_exited_threads (ptid))
+ if (inferior_ptid != thread->ptid
&& thread->suspend.stop_signal != GDB_SIGNAL_0)
{
p = append_resumption (p, endp, thread->ptid,
@@ -6137,7 +6121,6 @@ remote_target::remote_resume_with_hc (ptid_t ptid, int step,
gdb_signal siggnal)
{
struct remote_state *rs = get_remote_state ();
- struct thread_info *thread;
char *buf;
rs->last_sent_signal = siggnal;
@@ -6150,7 +6133,7 @@ remote_target::remote_resume_with_hc (ptid_t ptid, int step,
else
set_continue_thread (ptid);
- ALL_NON_EXITED_THREADS (thread)
+ for (thread_info *thread : all_non_exited_threads ())
resume_clear_thread_private_info (thread);
buf = rs->buf;
@@ -6458,8 +6441,6 @@ vcont_builder::push_action (ptid_t ptid, bool step, gdb_signal siggnal)
void
remote_target::commit_resume ()
{
- struct inferior *inf;
- struct thread_info *tp;
int any_process_wildcard;
int may_global_wildcard_vcont;
@@ -6522,7 +6503,7 @@ remote_target::commit_resume ()
may_global_wildcard_vcont = 1;
/* And assume every process is individually wildcard-able too. */
- ALL_NON_EXITED_INFERIORS (inf)
+ for (inferior *inf : all_non_exited_inferiors ())
{
remote_inferior *priv = get_remote_inferior (inf);
@@ -6533,7 +6514,7 @@ remote_target::commit_resume ()
disable process and global wildcard resumes appropriately. */
check_pending_events_prevent_wildcard_vcont (&may_global_wildcard_vcont);
- ALL_NON_EXITED_THREADS (tp)
+ for (thread_info *tp : all_non_exited_threads ())
{
/* If a thread of a process is not meant to be resumed, then we
can't wildcard that process. */
@@ -6562,7 +6543,7 @@ remote_target::commit_resume ()
struct vcont_builder vcont_builder (this);
/* Threads first. */
- ALL_NON_EXITED_THREADS (tp)
+ for (thread_info *tp : all_non_exited_threads ())
{
remote_thread_info *remote_thr = get_remote_thread_info (tp);
@@ -6591,7 +6572,7 @@ remote_target::commit_resume ()
supposed to be resumed. */
any_process_wildcard = 0;
- ALL_NON_EXITED_INFERIORS (inf)
+ for (inferior *inf : all_non_exited_inferiors ())
{
if (get_remote_inferior (inf)->may_wildcard_vcont)
{
@@ -6612,7 +6593,7 @@ remote_target::commit_resume ()
}
else
{
- ALL_NON_EXITED_INFERIORS (inf)
+ for (inferior *inf : all_non_exited_inferiors ())
{
if (get_remote_inferior (inf)->may_wildcard_vcont)
{
@@ -7019,13 +7000,12 @@ is_pending_fork_parent_thread (struct thread_info *thread)
void
remote_target::remove_new_fork_children (threads_listing_context *context)
{
- struct thread_info * thread;
int pid = -1;
struct notif_client *notif = &notif_client_stop;
/* For any threads stopped at a fork event, remove the corresponding
fork child threads from the CONTEXT list. */
- ALL_NON_EXITED_THREADS (thread)
+ for (thread_info *thread : all_non_exited_threads ())
{
struct target_waitstatus *ws = thread_pending_fork_status (thread);
@@ -9717,12 +9697,11 @@ void
remote_target::kill_new_fork_children (int pid)
{
remote_state *rs = get_remote_state ();
- struct thread_info *thread;
struct notif_client *notif = &notif_client_stop;
/* Kill the fork child threads of any threads in process PID
that are stopped at a fork event. */
- ALL_NON_EXITED_THREADS (thread)
+ for (thread_info *thread : all_non_exited_threads ())
{
struct target_waitstatus *ws = &thread->pending_follow;
@@ -10164,15 +10143,6 @@ Remote replied unexpectedly while setting startup-with-shell: %s"),
extended_remote_restart ();
}
- if (!have_inferiors ())
- {
- /* Clean up from the last time we ran, before we mark the target
- running again. This will mark breakpoints uninserted, and
- get_offsets may insert breakpoints. */
- init_thread_list ();
- init_wait_for_inferior ();
- }
-
/* vRun's success return is a stop reply. */
stop_reply = run_worked ? rs->buf : NULL;
add_current_inferior_and_thread (stop_reply);
@@ -13781,7 +13751,6 @@ void
remote_target::remote_btrace_maybe_reopen ()
{
struct remote_state *rs = get_remote_state ();
- struct thread_info *tp;
int btrace_target_pushed = 0;
#if !defined (HAVE_LIBIPT)
int warned = 0;
@@ -13789,7 +13758,7 @@ remote_target::remote_btrace_maybe_reopen ()
scoped_restore_current_thread restore_thread;
- ALL_NON_EXITED_THREADS (tp)
+ for (thread_info *tp : all_non_exited_threads ())
{
set_general_thread (tp->ptid);
@@ -14073,9 +14042,7 @@ remote_target::thread_handle_to_thread_info (const gdb_byte *thread_handle,
int handle_len,
inferior *inf)
{
- struct thread_info *tp;
-
- ALL_NON_EXITED_THREADS (tp)
+ for (thread_info *tp : all_non_exited_threads ())
{
remote_thread_info *priv = get_remote_thread_info (tp);