[pushed] Adjust "maint info program-spaces" to per-inferior target stack

Message ID 20200828235828.14789-1-pedro@palves.net
State New
Headers show
Series
  • [pushed] Adjust "maint info program-spaces" to per-inferior target stack
Related show

Commit Message

Pedro Alves Aug. 28, 2020, 11:58 p.m.
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/progspace.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)


base-commit: 8f57f343104b8d3632e65ac1fbb12ee69891ef5f
-- 
2.14.5

Patch

diff --git a/gdb/progspace.c b/gdb/progspace.c
index 462083ce1f6..3f512161215 100644
--- a/gdb/progspace.c
+++ b/gdb/progspace.c
@@ -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;