From f25e28c3fe3f9e2293875012b36b2644179ac06b Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Wed, 3 Sep 2025 10:49:59 -0400 Subject: [PATCH] gdb: change thread_step_over_list_iterator to yield references Same rationale as the previous patches. Change-Id: Ic46e2e6b81b17173f4137ff4a0970c84aab4de61 Approved-By: Tom Tromey --- gdb/gdbthread.h | 5 +---- gdb/infrun.c | 60 ++++++++++++++++++++++++------------------------- gdb/progspace.h | 1 + 3 files changed, 32 insertions(+), 34 deletions(-) diff --git a/gdb/gdbthread.h b/gdb/gdbthread.h index 759034f332e..a22210951c4 100644 --- a/gdb/gdbthread.h +++ b/gdb/gdbthread.h @@ -35,7 +35,6 @@ struct symtab; #include "gdbsupport/forward-scope-exit.h" #include "displaced-stepping.h" #include "gdbsupport/intrusive_list.h" -#include "gdbsupport/reference-to-pointer-iterator.h" #include "thread-fsm.h" #include "language.h" @@ -974,10 +973,8 @@ using thread_step_over_list_node = intrusive_member_node; using thread_step_over_list = intrusive_list; -using thread_step_over_list_iterator - = reference_to_pointer_iterator; using thread_step_over_list_safe_iterator - = basic_safe_iterator; + = basic_safe_iterator; using thread_step_over_list_safe_range = iterator_range; diff --git a/gdb/infrun.c b/gdb/infrun.c index 77859c7b5a2..239ede968ef 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -2184,14 +2184,14 @@ start_step_over (void) thread_step_over_list_safe_range range = make_thread_step_over_list_safe_range (threads_to_step); - for (thread_info *tp : range) + for (thread_info &tp : range) { step_over_what step_what; int must_be_in_line; - gdb_assert (!tp->stop_requested); + gdb_assert (!tp.stop_requested); - if (tp->inf->displaced_step_state.unavailable) + if (tp.inf->displaced_step_state.unavailable) { /* The arch told us to not even try preparing another displaced step for this inferior. Just leave the thread in THREADS_TO_STEP, it @@ -2199,7 +2199,7 @@ start_step_over (void) continue; } - if (tp->inf->thread_waiting_for_vfork_done != nullptr) + if (tp.inf->thread_waiting_for_vfork_done != nullptr) { /* When we stop all threads, handling a vfork, any thread in the step over chain remains there. A user could also try to continue a @@ -2215,36 +2215,36 @@ start_step_over (void) step over chain indefinitely if something goes wrong when resuming it If the error is intermittent and it still needs a step over, it will get enqueued again when we try to resume it normally. */ - threads_to_step.erase (threads_to_step.iterator_to (*tp)); + threads_to_step.erase (threads_to_step.iterator_to (tp)); - step_what = thread_still_needs_step_over (tp); + step_what = thread_still_needs_step_over (&tp); must_be_in_line = ((step_what & STEP_OVER_WATCHPOINT) || ((step_what & STEP_OVER_BREAKPOINT) - && !use_displaced_stepping (tp))); + && !use_displaced_stepping (&tp))); /* We currently stop all threads of all processes to step-over in-line. If we need to start a new in-line step-over, let any pending displaced steps finish first. */ if (must_be_in_line && displaced_step_in_progress_any_thread ()) { - global_thread_step_over_chain_enqueue (tp); + global_thread_step_over_chain_enqueue (&tp); continue; } - if (tp->control.trap_expected - || tp->resumed () - || tp->executing ()) + if (tp.control.trap_expected + || tp.resumed () + || tp.executing ()) { internal_error ("[%s] has inconsistent state: " "trap_expected=%d, resumed=%d, executing=%d\n", - tp->ptid.to_string ().c_str (), - tp->control.trap_expected, - tp->resumed (), - tp->executing ()); + tp.ptid.to_string ().c_str (), + tp.control.trap_expected, + tp.resumed (), + tp.executing ()); } infrun_debug_printf ("resuming [%s] for step-over", - tp->ptid.to_string ().c_str ()); + tp.ptid.to_string ().c_str ()); /* keep_going_pass_signal skips the step-over if the breakpoint is no longer inserted. In all-stop, we want to keep looking @@ -2255,8 +2255,8 @@ start_step_over (void) if (!target_is_non_stop_p () && !step_what) continue; - switch_to_thread (tp); - execution_control_state ecs (tp); + switch_to_thread (&tp); + execution_control_state ecs (&tp); keep_going_pass_signal (&ecs); if (!ecs.wait_some_more) @@ -2264,23 +2264,23 @@ start_step_over (void) /* If the thread's step over could not be initiated because no buffers were available, it was re-added to the global step over chain. */ - if (tp->resumed ()) + if (tp.resumed ()) { infrun_debug_printf ("[%s] was resumed.", - tp->ptid.to_string ().c_str ()); - gdb_assert (!thread_is_in_step_over_chain (tp)); + tp.ptid.to_string ().c_str ()); + gdb_assert (!thread_is_in_step_over_chain (&tp)); } else { infrun_debug_printf ("[%s] was NOT resumed.", - tp->ptid.to_string ().c_str ()); - gdb_assert (thread_is_in_step_over_chain (tp)); + tp.ptid.to_string ().c_str ()); + gdb_assert (thread_is_in_step_over_chain (&tp)); } /* If we started a new in-line step-over, we're done. */ if (step_over_info_valid_p ()) { - gdb_assert (tp->control.trap_expected); + gdb_assert (tp.control.trap_expected); started = true; break; } @@ -2289,8 +2289,8 @@ start_step_over (void) { /* On all-stop, shouldn't have resumed unless we needed a step over. */ - gdb_assert (tp->control.trap_expected - || tp->step_after_step_resume_breakpoint); + gdb_assert (tp.control.trap_expected + || tp.step_after_step_resume_breakpoint); /* With remote targets (at least), in all-stop, we can't issue any further remote commands until the program stops @@ -4284,12 +4284,12 @@ prepare_for_detach (void) thread_step_over_list_safe_range range = make_thread_step_over_list_safe_range (global_thread_step_over_list); - for (thread_info *tp : range) - if (tp->inf == inf) + for (thread_info &tp : range) + if (tp.inf == inf) { infrun_debug_printf ("removing thread %s from global step over chain", - tp->ptid.to_string ().c_str ()); - global_thread_step_over_chain_remove (tp); + tp.ptid.to_string ().c_str ()); + global_thread_step_over_chain_remove (&tp); } /* If we were already in the middle of an inline step-over, and the diff --git a/gdb/progspace.h b/gdb/progspace.h index 270a71d57c0..61e5211e857 100644 --- a/gdb/progspace.h +++ b/gdb/progspace.h @@ -30,6 +30,7 @@ #include "gdbsupport/owning_intrusive_list.h" #include "gdbsupport/refcounted-object.h" #include "gdbsupport/gdb_ref_ptr.h" +#include "gdbsupport/reference-to-pointer-iterator.h" #include struct target_ops; -- 2.47.3