Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Joel Brobecker <brobecker@adacore.com>
To: gdb-patches@sourceware.org
Cc: Joel Brobecker <brobecker@adacore.com>
Subject: [commit] LynxOS: Resume the same thread when receiving a thread create/exit event.
Date: Mon, 17 Dec 2012 11:26:00 -0000	[thread overview]
Message-ID: <1355743597-15380-1-git-send-email-brobecker@adacore.com> (raw)

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  <brobecker@adacore.com>
 
+	* 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  <brobecker@adacore.com>
+
 	* 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


             reply	other threads:[~2012-12-17 11:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-17 11:26 Joel Brobecker [this message]
2012-12-17 11:33 ` Joel Brobecker
2013-01-04 20:59 ` Pedro Alves
2013-01-07 11:52   ` Joel Brobecker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1355743597-15380-1-git-send-email-brobecker@adacore.com \
    --to=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox