gdb: infrun: move stop_soon variable to inner scoped in handle_inferior_event
authorSimon Marchi <simon.marchi@polymtl.ca>
Wed, 3 Feb 2021 19:36:54 +0000 (14:36 -0500)
committerSimon Marchi <simon.marchi@polymtl.ca>
Wed, 3 Feb 2021 19:37:27 +0000 (14:37 -0500)
Moving it to an inner scope makes it clearer where it's used (only while
handling the TARGET_WAITKIND_LOADED event).

gdb/ChangeLog:

* infrun.c (handle_inferior_event): Move stop_soon variable to
inner scope.

Change-Id: Ic57685a21714cfbb38f1487ee96cea1d12b44652

gdb/ChangeLog
gdb/infrun.c

index 4a02a64e71b04c8adec1155e40d5fa3a37126f78..4ac326be1639ea5e3f5c63781cd585bbb501a40e 100644 (file)
@@ -1,3 +1,8 @@
+2021-02-03  Simon Marchi  <simon.marchi@polymtl.ca>
+
+       * infrun.c (handle_inferior_event): Move stop_soon variable to
+       inner scope.
+
 2021-02-03  Pedro Alves  <pedro@palves.net>
 
        * infcmd.c (detach_command): Hold strong reference to target, and
index f2abfe4a7c251fcc130851d26194bc8c74b08fec..6ec269adaa8c5b127197ff85615f26ea15de9d15 100644 (file)
@@ -5023,8 +5023,6 @@ handle_inferior_event (struct execution_control_state *ecs)
      end.  */
   scoped_value_mark free_values;
 
-  enum stop_kind stop_soon;
-
   infrun_debug_printf ("%s", target_waitstatus_to_string (&ecs->ws).c_str ());
 
   if (ecs->ws.kind == TARGET_WAITKIND_IGNORE)
@@ -5118,80 +5116,82 @@ handle_inferior_event (struct execution_control_state *ecs)
   switch (ecs->ws.kind)
     {
     case TARGET_WAITKIND_LOADED:
-      context_switch (ecs);
-      /* Ignore gracefully during startup of the inferior, as it might
-        be the shell which has just loaded some objects, otherwise
-        add the symbols for the newly loaded objects.  Also ignore at
-        the beginning of an attach or remote session; we will query
-        the full list of libraries once the connection is
-        established.  */
-
-      stop_soon = get_inferior_stop_soon (ecs);
-      if (stop_soon == NO_STOP_QUIETLY)
-       {
-         struct regcache *regcache;
-
-         regcache = get_thread_regcache (ecs->event_thread);
+      {
+       context_switch (ecs);
+       /* Ignore gracefully during startup of the inferior, as it might
+          be the shell which has just loaded some objects, otherwise
+          add the symbols for the newly loaded objects.  Also ignore at
+          the beginning of an attach or remote session; we will query
+          the full list of libraries once the connection is
+          established.  */
+
+       stop_kind stop_soon = get_inferior_stop_soon (ecs);
+       if (stop_soon == NO_STOP_QUIETLY)
+         {
+           struct regcache *regcache;
 
-         handle_solib_event ();
+           regcache = get_thread_regcache (ecs->event_thread);
 
-         ecs->event_thread->control.stop_bpstat
-           = bpstat_stop_status (regcache->aspace (),
-                                 ecs->event_thread->suspend.stop_pc,
-                                 ecs->event_thread, &ecs->ws);
+           handle_solib_event ();
 
-         if (handle_stop_requested (ecs))
-           return;
+           ecs->event_thread->control.stop_bpstat
+             = bpstat_stop_status (regcache->aspace (),
+                                   ecs->event_thread->suspend.stop_pc,
+                                   ecs->event_thread, &ecs->ws);
 
-         if (bpstat_causes_stop (ecs->event_thread->control.stop_bpstat))
-           {
-             /* A catchpoint triggered.  */
-             process_event_stop_test (ecs);
+           if (handle_stop_requested (ecs))
              return;
-           }
 
-         /* If requested, stop when the dynamic linker notifies
-            gdb of events.  This allows the user to get control
-            and place breakpoints in initializer routines for
-            dynamically loaded objects (among other things).  */
-         ecs->event_thread->suspend.stop_signal = GDB_SIGNAL_0;
-         if (stop_on_solib_events)
-           {
-             /* Make sure we print "Stopped due to solib-event" in
-                normal_stop.  */
-             stop_print_frame = true;
+           if (bpstat_causes_stop (ecs->event_thread->control.stop_bpstat))
+             {
+               /* A catchpoint triggered.  */
+               process_event_stop_test (ecs);
+               return;
+             }
 
-             stop_waiting (ecs);
-             return;
-           }
-       }
+           /* If requested, stop when the dynamic linker notifies
+              gdb of events.  This allows the user to get control
+              and place breakpoints in initializer routines for
+              dynamically loaded objects (among other things).  */
+           ecs->event_thread->suspend.stop_signal = GDB_SIGNAL_0;
+           if (stop_on_solib_events)
+             {
+               /* Make sure we print "Stopped due to solib-event" in
+                  normal_stop.  */
+               stop_print_frame = true;
 
-      /* If we are skipping through a shell, or through shared library
-        loading that we aren't interested in, resume the program.  If
-        we're running the program normally, also resume.  */
-      if (stop_soon == STOP_QUIETLY || stop_soon == NO_STOP_QUIETLY)
-       {
-         /* Loading of shared libraries might have changed breakpoint
-            addresses.  Make sure new breakpoints are inserted.  */
-         if (stop_soon == NO_STOP_QUIETLY)
-           insert_breakpoints ();
-         resume (GDB_SIGNAL_0);
-         prepare_to_wait (ecs);
-         return;
-       }
+               stop_waiting (ecs);
+               return;
+             }
+         }
 
-      /* But stop if we're attaching or setting up a remote
-        connection.  */
-      if (stop_soon == STOP_QUIETLY_NO_SIGSTOP
-         || stop_soon == STOP_QUIETLY_REMOTE)
-       {
-         infrun_debug_printf ("quietly stopped");
-         stop_waiting (ecs);
-         return;
-       }
+       /* If we are skipping through a shell, or through shared library
+          loading that we aren't interested in, resume the program.  If
+          we're running the program normally, also resume.  */
+       if (stop_soon == STOP_QUIETLY || stop_soon == NO_STOP_QUIETLY)
+         {
+           /* Loading of shared libraries might have changed breakpoint
+              addresses.  Make sure new breakpoints are inserted.  */
+           if (stop_soon == NO_STOP_QUIETLY)
+             insert_breakpoints ();
+           resume (GDB_SIGNAL_0);
+           prepare_to_wait (ecs);
+           return;
+         }
 
-      internal_error (__FILE__, __LINE__,
-                     _("unhandled stop_soon: %d"), (int) stop_soon);
+       /* But stop if we're attaching or setting up a remote
+          connection.  */
+       if (stop_soon == STOP_QUIETLY_NO_SIGSTOP
+           || stop_soon == STOP_QUIETLY_REMOTE)
+         {
+           infrun_debug_printf ("quietly stopped");
+           stop_waiting (ecs);
+           return;
+         }
+
+       internal_error (__FILE__, __LINE__,
+                       _("unhandled stop_soon: %d"), (int) stop_soon);
+      }
 
     case TARGET_WAITKIND_SPURIOUS:
       if (handle_stop_requested (ecs))