From patchwork Thu Oct 5 17:35:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 23363 Received: (qmail 126060 invoked by alias); 5 Oct 2017 17:35:12 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 126050 invoked by uid 89); 5 Oct 2017 17:35:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 05 Oct 2017 17:35:10 +0000 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DDAC2820F7 for ; Thu, 5 Oct 2017 17:35:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DDAC2820F7 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=palves@redhat.com Received: from cascais.lan (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6188F600C8 for ; Thu, 5 Oct 2017 17:35:08 +0000 (UTC) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [pushed] Fix fork-related regressions on GNU/Linux Date: Thu, 5 Oct 2017 18:35:07 +0100 Message-Id: <1507224907-11680-1-git-send-email-palves@redhat.com> 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 * 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 | 6 ++++++ gdb/linux-nat.c | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index f70aa8a..59eb04a 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2017-10-05 Pedro Alves + + * 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 * ax.h: Do not include "doublest.h". diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c index 0f340ee..6080415 100644 --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c @@ -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)