Fix follow-fork latent bug
authorPedro Alves <palves@redhat.com>
Thu, 13 Apr 2017 15:15:34 +0000 (16:15 +0100)
committerPedro Alves <palves@redhat.com>
Thu, 13 Apr 2017 15:18:16 +0000 (16:18 +0100)
A later patch in the series adds an assertion to switch_to_thread that
the resulting inferior_ptid always matches the "current_inferior()"
inferior.  This exposed a latent bug in the follow-fork code, where
we're building the fork child inferior.  We're switching
inferior_ptid, but not the current inferior object...

gdb/ChangeLog:
2017-04-13  Pedro Alves  <palves@redhat.com>

* infrun.c (follow_fork_inferior): Also switch the current
inferior.

gdb/ChangeLog
gdb/infrun.c

index acf59e5abb813bc35fd3a0c9e18d03e357f65836..4160e9f44d490866232e46a1b138bae0442e9bbe 100644 (file)
@@ -1,3 +1,8 @@
+2017-04-13  Pedro Alves  <palves@redhat.com>
+
+       * infrun.c (follow_fork_inferior): Also switch the current
+       inferior.
+
 2017-04-13  Pedro Alves  <palves@redhat.com>
 
        * breakpoint.c (watch_command_1): Save watchpoint-frame info
index b5eb4abbdd9e6abad5b1704240e8fe7b4d26d865..c7298a3979a9f2565c3e21da4c00d225a864b908 100644 (file)
@@ -498,11 +498,11 @@ holding the child stopped.  Try \"set detach-on-fork\" or \
          child_inf->gdbarch = parent_inf->gdbarch;
          copy_inferior_target_desc_info (child_inf, parent_inf);
 
-         old_chain = save_inferior_ptid ();
-         save_current_program_space ();
+         old_chain = save_current_space_and_thread ();
 
          inferior_ptid = child_ptid;
          add_thread (inferior_ptid);
+         set_current_inferior (child_inf);
          child_inf->symfile_flags = SYMFILE_NO_READ;
 
          /* If this is a vfork child, then the address-space is
@@ -631,6 +631,7 @@ holding the child stopped.  Try \"set detach-on-fork\" or \
 
       inferior_ptid = child_ptid;
       add_thread (inferior_ptid);
+      set_current_inferior (child_inf);
 
       /* If this is a vfork child, then the address-space is shared
         with the parent.  If we detached from the parent, then we can