From patchwork Thu Nov 13 19:14:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 3716 Received: (qmail 23423 invoked by alias); 13 Nov 2014 19:14:17 -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 23410 invoked by uid 89); 13 Nov 2014 19:14:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 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 (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 13 Nov 2014 19:14:15 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sADJEBS5004265 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 13 Nov 2014 14:14:11 -0500 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id sADJE9FH027682; Thu, 13 Nov 2014 14:14:10 -0500 Message-ID: <54650301.7070200@redhat.com> Date: Thu, 13 Nov 2014 19:14:09 +0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.1.1 MIME-Version: 1.0 To: Don Breazeal , gdb-patches@sourceware.org Subject: Re: [PATCH 00/16 v3] Linux extended-remote fork and exec events References: <1408580964-27916-1-git-send-email-donb@codesourcery.com> <1414798134-11536-1-git-send-email-donb@codesourcery.com> In-Reply-To: <1414798134-11536-1-git-send-email-donb@codesourcery.com> On 10/31/2014 11:28 PM, Don Breazeal wrote: > > - gdb.threads/thread-execl.exp gives a couple of failures related to > scheduler locking. As with the previous item, after spending some > time on this I concluded that pursuing it further now would be > feature-creep, and that this should be tracked with a bug report. These really are problems with the series that should be fixed. The next problem I saw with thread-execl.exp after fixing the stale threads issue was that the inferior would sometimes crash after execing. Funny, because I hit this similar problem on the linux-nat.c target when working on all-stop-on-top-of-non-stop (but I haven't posted a fix for the linux-nat.c side yet). From 3ee65262da9d72ab6efd97aed538f1f436436c3d Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Thu, 13 Nov 2014 17:52:38 +0000 Subject: [PATCH] stale thread state and regcaches when a non-leader thread execs --- gdb/gdbserver/linux-low.c | 12 ++++++++++++ gdb/remote.c | 10 ++++++++++ 2 files changed, 22 insertions(+) diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c index 316b302..e4e4231 100644 --- a/gdb/gdbserver/linux-low.c +++ b/gdb/gdbserver/linux-low.c @@ -546,6 +546,18 @@ handle_extended_wait (struct lwp_info *event_child, int *wstatp) lwpid_of (event_thr)); } + /* This may have been a non-leader thread execing, while the + previous incarnation of the leader was stopped (e.g., we + resumed the thread that execs with schedlock on). Clear the + now stale register cache. */ + get_thread_regcache (event_thr, 0)->registers_valid = 0; + /* ... and mark the thread as resumed, as otherwise we'd + consider that GDB had explicitly interrupted it. */ + event_thr->last_resume_kind = resume_continue; + /* and clear this so we don't confuse things like decr_pc + adjustment. */ + event_child->stepping = 0; + event_child->waitstatus.kind = TARGET_WAITKIND_EXECD; event_child->waitstatus.value.execd_pathname = xstrdup (linux_pid_to_exec_file (NULL, lwpid_of (event_thr))); diff --git a/gdb/remote.c b/gdb/remote.c index 9623bd6..c529a37 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -5973,6 +5973,16 @@ process_stop_reply (struct stop_reply *stop_reply, if (ptid_equal (ptid, null_ptid)) ptid = inferior_ptid; + if (status->kind == TARGET_WAITKIND_EXECD) + { + /* This may have been a non-leader thread execing, while the + previous incarnation of the leader was stopped (e.g., we + resumed the thread that execs with schedlock on). Clear the + now stale register cache before re-filling with the expedite + registers. */ + registers_changed_ptid (ptid); + } + if (status->kind != TARGET_WAITKIND_EXITED && status->kind != TARGET_WAITKIND_SIGNALLED) {