Introduce switch_to_inferior_no_thread
authorPedro Alves <palves@redhat.com>
Fri, 10 Jan 2020 20:05:47 +0000 (20:05 +0000)
committerPedro Alves <palves@redhat.com>
Fri, 10 Jan 2020 20:05:47 +0000 (20:05 +0000)
Several places want to switch context to an inferior and its pspace,
while at the same time switch to "no thread selected".  This commit
adds a function that does that, and uses it in a few places.

gdb/ChangeLog:
2020-01-10  Pedro Alves <palves@redhat.com>

* inferior.c (switch_to_inferior_no_thread): New function,
factored out from ...
(inferior_command): ... here.
* inferior.h (switch_to_inferior_no_thread): Declare.
* mi/mi-main.c (run_one_inferior): Use
switch_to_inferior_no_thread.

gdb/ChangeLog
gdb/inferior.c
gdb/inferior.h
gdb/mi/mi-main.c

index 3b5f9aab48cf7161ae93b34ad9953b38455f74a9..50c56c95c69103a9406abaa4968c2dcb1dcc5611 100644 (file)
@@ -1,3 +1,12 @@
+2020-01-10  Pedro Alves <palves@redhat.com>
+
+       * inferior.c (switch_to_inferior_no_thread): New function,
+       factored out from ...
+       (inferior_command): ... here.
+       * inferior.h (switch_to_inferior_no_thread): Declare.
+       * mi/mi-main.c (run_one_inferior): Use
+       switch_to_inferior_no_thread.
+
 2020-01-10  Pedro Alves  <palves@redhat.com>
 
        * infcmd.c (kill_command): Remove dead code.
index 3969ace13a848a411b6944ef45cf9cbfe0f7fcf8..0c5e2c74d4ea63ae29fc417b1f284690c03cb6b4 100644 (file)
@@ -575,6 +575,16 @@ kill_inferior_command (const char *args, int from_tty)
   bfd_cache_close_all ();
 }
 
+/* See inferior.h.  */
+
+void
+switch_to_inferior_no_thread (inferior *inf)
+{
+  set_current_inferior (inf);
+  switch_to_no_thread ();
+  set_current_program_space (inf->pspace);
+}
+
 static void
 inferior_command (const char *args, int from_tty)
 {
@@ -605,9 +615,7 @@ inferior_command (const char *args, int from_tty)
     }
   else
     {
-      set_current_inferior (inf);
-      switch_to_no_thread ();
-      set_current_program_space (inf->pspace);
+      switch_to_inferior_no_thread (inf);
 
       gdb::observers::user_selected_context_changed.notify
        (USER_SELECTED_INFERIOR);
@@ -737,11 +745,8 @@ add_inferior_command (const char *args, int from_tty)
       if (exec != NULL)
        {
          /* Switch over temporarily, while reading executable and
-            symbols.q.  */
-         set_current_program_space (inf->pspace);
-         set_current_inferior (inf);
-         switch_to_no_thread ();
-
+            symbols.  */
+         switch_to_inferior_no_thread (inf);
          exec_file_attach (exec.get (), from_tty);
          symbol_file_add_main (exec.get (), add_flags);
        }
index fe94a01784df221c5d857ee97f2e2474ce4d2605..a9baa52355ef06a566740a15019f51f028c50260 100644 (file)
@@ -308,6 +308,10 @@ extern inferior *current_inferior ();
 
 extern void set_current_inferior (inferior *);
 
+/* Switch inferior (and program space) to INF, and switch to no thread
+   selected.  */
+extern void switch_to_inferior_no_thread (inferior *inf);
+
 /* GDB represents the state of each program execution with an object
    called an inferior.  An inferior typically corresponds to a process
    but is more general and applies also to targets that do not have a
index e67738193bbc792bd71b90a789bcce6cf297a6a1..24daf3f883883433856cd0a0ab67e81abad37252 100644 (file)
@@ -414,11 +414,7 @@ run_one_inferior (struct inferior *inf, void *arg)
       switch_to_thread (tp);
     }
   else
-    {
-      set_current_inferior (inf);
-      switch_to_no_thread ();
-      set_current_program_space (inf->pspace);
-    }
+    switch_to_inferior_no_thread (inf);
   mi_execute_cli_command (run_cmd, async_p,
                          async_p ? "&" : NULL);
   return 0;
This page took 0.027029 seconds and 4 git commands to generate.