Fix fork-related regressions on GNU/Linux
authorPedro Alves <palves@redhat.com>
Thu, 5 Oct 2017 17:33:22 +0000 (18:33 +0100)
committerPedro Alves <palves@redhat.com>
Thu, 5 Oct 2017 17:33:22 +0000 (18:33 +0100)
Commit 5cd63fda035d ("Fix "Remote 'g' packet reply is too long"
problems with multiple inferiors") caused a number of regressions on
native GNU/Linux, all related to follow-fork support.  E.g.:

  src/gdb/target.c:3141: internal-error: gdbarch* default_thread_architecture(target_ops*, ptid_t): Assertion `inf != NULL' failed.
  A problem internal to GDB has been detected,
  further debugging may prove unreliable.
  Quit this debugging session? (y or n)
  Resyncing due to internal error.
  FAIL: gdb.base/catch-signal-fork.exp: got SIGHUP after fork (GDB internal error)

This commit fixes it.

gdb/ChangeLog:
2017-10-05  Pedro Alves  <palves@redhat.com>

* linux-nat.c (linux_child_follow_fork): When following the parent
and detaching the child, consult the parent thread's architecture
instead of the child's.

gdb/ChangeLog
gdb/linux-nat.c

index f70aa8af9f5368a35e93ef429e672736bf50323f..59eb04a9d6a9d10d3e00097738b2d3beffd977bf 100644 (file)
@@ -1,3 +1,9 @@
+2017-10-05  Pedro Alves  <palves@redhat.com>
+
+       * linux-nat.c (linux_child_follow_fork): When following the parent
+       and detaching the child, consult the parent thread's architecture
+       instead of the child's.
+
 2017-10-05  Ulrich Weigand  <uweigand@de.ibm.com>
 
        * ax.h: Do not include "doublest.h".
index 0f340ee1a0d618cb2fb990186163d46c7de4b011..60804159f1aad18c16b7ffbcfd941b50a5cde62d 100644 (file)
@@ -510,8 +510,11 @@ linux_child_follow_fork (struct target_ops *ops, int follow_child,
             To work around this, single step the child process
             once before detaching to clear the flags.  */
 
+         /* Note that we consult the parent's architecture instead of
+            the child's because there's no inferior for the child at
+            this point.  */
          if (!gdbarch_software_single_step_p (target_thread_architecture
-                                              (child_lp->ptid)))
+                                              (parent_ptid)))
            {
              linux_disable_event_reporting (child_pid);
              if (ptrace (PTRACE_SINGLESTEP, child_pid, 0, 0) < 0)