]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: change thread_step_over_list_iterator to yield references
authorSimon Marchi <simon.marchi@polymtl.ca>
Wed, 3 Sep 2025 14:49:59 +0000 (10:49 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Tue, 7 Oct 2025 20:22:15 +0000 (16:22 -0400)
Same rationale as the previous patches.

Change-Id: Ic46e2e6b81b17173f4137ff4a0970c84aab4de61
Approved-By: Tom Tromey <tom@tromey.com>
gdb/gdbthread.h
gdb/infrun.c
gdb/progspace.h

index 759034f332eb08ebb852b6ae00ac7a256228e7a9..a22210951c49619be738be156080803d3148e96d 100644 (file)
@@ -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<thread_info, &thread_info::step_over_list_node>;
 using thread_step_over_list
   = intrusive_list<thread_info, thread_step_over_list_node>;
-using thread_step_over_list_iterator
-  = reference_to_pointer_iterator<thread_step_over_list::iterator>;
 using thread_step_over_list_safe_iterator
-  = basic_safe_iterator<thread_step_over_list_iterator>;
+  = basic_safe_iterator<thread_step_over_list::iterator>;
 using thread_step_over_list_safe_range
   = iterator_range<thread_step_over_list_safe_iterator>;
 
index 77859c7b5a29fd53c376f1bcb8fa332cc7c73d16..239ede968efb7a6d54c4ad75e88710fa665970fe 100644 (file)
@@ -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
index 270a71d57c06a43c0dcd655df9c703e6ab15c900..61e5211e857f8ee0d36c2791acf2cd681240539d 100644 (file)
@@ -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 <vector>
 
 struct target_ops;