Adjust "maint info program-spaces" to per-inferior target stack
authorPedro Alves <pedro@palves.net>
Fri, 28 Aug 2020 23:11:35 +0000 (00:11 +0100)
committerPedro Alves <pedro@palves.net>
Fri, 28 Aug 2020 23:55:58 +0000 (00:55 +0100)
By inspection, I noticed that print_program_space is calling
target_pid_to_str on the wrong target stack.  Most targets print a
process pid the same way, so it isn't actually visible.

gdb/ChangeLog:

* progspace.c (print_program_space): Use all_inferiors.  Switch to
the inferior before calling target_pid_to_str.

gdb/ChangeLog
gdb/progspace.c

index b9f4d48856ca183db866d2cab53d4d44529d7c23..1ff47c3355dc10f5af4913b0a39ad26caab93c48 100644 (file)
@@ -1,3 +1,8 @@
+2020-08-29  Pedro Alves  <pedro@palves.net>
+
+       * progspace.c (print_program_space): Use all_inferiors.  Switch to
+       the inferior before calling target_pid_to_str.
+
 2020-08-28  Tom Tromey  <tom@tromey.com>
 
        * xcoffread.c (xcoff_end_psymtab): Update comment.
index 462083ce1f6d444789950434f2b0b8ce556694be..3f5121612154751d480f2648df7c483df571fc71 100644 (file)
@@ -302,7 +302,6 @@ print_program_space (struct ui_out *uiout, int requested)
 
   for (struct program_space *pspace : program_spaces)
     {
-      struct inferior *inf;
       int printed_header;
 
       if (requested != -1 && requested != pspace->num)
@@ -328,9 +327,16 @@ print_program_space (struct ui_out *uiout, int requested)
         e.g., both parent/child inferiors in a vfork, or, on targets
         that share pspaces between inferiors.  */
       printed_header = 0;
-      for (inf = inferior_list; inf; inf = inf->next)
+
+      /* We're going to switch inferiors.  */
+      scoped_restore_current_thread restore_thread;
+
+      for (inferior *inf : all_inferiors ())
        if (inf->pspace == pspace)
          {
+           /* Switch to inferior in order to call target methods.  */
+           switch_to_inferior_no_thread (inf);
+
            if (!printed_header)
              {
                printed_header = 1;