From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9042 invoked by alias); 17 Dec 2012 11:26:45 -0000 Received: (qmail 9015 invoked by uid 22791); 17 Dec 2012 11:26:44 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00,RCVD_IN_HOSTKARMA_NO,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 17 Dec 2012 11:26:39 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 932A02E415; Mon, 17 Dec 2012 06:26:38 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id uha8ltTYBcNr; Mon, 17 Dec 2012 06:26:38 -0500 (EST) Received: from kwai.gnat.com (kwai.gnat.com [205.232.38.4]) by rock.gnat.com (Postfix) with ESMTP id 671B02E40D; Mon, 17 Dec 2012 06:26:38 -0500 (EST) Received: by kwai.gnat.com (Postfix, from userid 4233) id 655243FF09; Mon, 17 Dec 2012 06:26:38 -0500 (EST) From: Joel Brobecker To: gdb-patches@sourceware.org Cc: Joel Brobecker Subject: [commit] LynxOS: Resume the same thread when receiving a thread create/exit event. Date: Mon, 17 Dec 2012 11:26:00 -0000 Message-Id: <1355743597-15380-1-git-send-email-brobecker@adacore.com> Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-12/txt/msg00547.txt.bz2 Before this patch, the ptid passed to lynx_resume was completely ignored, and we used the current_inferior. This resulted in trying to resume the inferior execution using the wrong ptid after having received a thread create/exit event, because the inferior_ptid was still set to the ptid prior to receiving the signal. gdb/gdbserver/ChangeLog: * lynx-low.c (lynx_resume): Use the resume_info parameter to determine the ptid for the lynx_ptrace call, unless it is equal to minus_one_ptid, in which case we use the ptid of the current_inferior. (lynx_wait_1): After having received a thread create/exit event, resume the inferior's execution using the signaling thread's ptid, rather than the old ptid. Tested on ppc-lynx5. I hesitated a little before self-approving. But it seemed sufficiently straightforward and enough of an improvement (in lynx_resume) that I allowed myself to go ahead. I will handle comments right away, if any. Checked in. Thanks, -- Joel --- gdb/gdbserver/ChangeLog | 10 ++++++++++ gdb/gdbserver/lynx-low.c | 11 +++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index 8ba20b0..40bcbab 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,5 +1,15 @@ 2012-12-17 Joel Brobecker + * lynx-low.c (lynx_resume): Use the resume_info parameter + to determine the ptid for the lynx_ptrace call, unless + it is equal to minus_one_ptid, in which case we use the + ptid of the current_inferior. + (lynx_wait_1): After having received a thread create/exit + event, resume the inferior's execution using the signaling + thread's ptid, rather than the old ptid. + +2012-12-17 Joel Brobecker + * lynx-low.c (lynx_wait_1): Add debug trace before adding new thread. diff --git a/gdb/gdbserver/lynx-low.c b/gdb/gdbserver/lynx-low.c index 644ff35..3173e3a 100644 --- a/gdb/gdbserver/lynx-low.c +++ b/gdb/gdbserver/lynx-low.c @@ -349,14 +349,17 @@ lynx_attach (unsigned long pid) static void lynx_resume (struct thread_resume *resume_info, size_t n) { - ptid_t inferior_ptid = thread_to_gdb_id (current_inferior); /* FIXME: Assume for now that n == 1. */ + ptid_t ptid = resume_info[0].thread; const int request = (resume_info[0].kind == resume_step ? PTRACE_SINGLESTEP : PTRACE_CONT); const int signal = resume_info[0].sig; + if (ptid_equal (ptid, minus_one_ptid)) + ptid = thread_to_gdb_id (current_inferior); + regcache_invalidate (); - lynx_ptrace (request, inferior_ptid, 1, signal, 0); + lynx_ptrace (request, ptid, 1, signal, 0); } /* Resume the execution of the given PTID. */ @@ -497,12 +500,12 @@ retry: case SIGNEWTHREAD: /* We just added the new thread above. No need to do anything further. Just resume the execution again. */ - lynx_continue (ptid); + lynx_continue (new_ptid); goto retry; case SIGTHREADEXIT: remove_thread (find_thread_ptid (new_ptid)); - lynx_continue (ptid); + lynx_continue (new_ptid); goto retry; } } -- 1.7.0.4