This is the mail archive of the
gdb-cvs@sourceware.org
mailing list for the GDB project.
[binutils-gdb] Special-case wildcard requests in ravenscar-thread.c
- From: Tom Tromey <tromey at sourceware dot org>
- To: gdb-cvs at sourceware dot org
- Date: 15 Feb 2019 20:54:52 -0000
- Subject: [binutils-gdb] Special-case wildcard requests in ravenscar-thread.c
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=485b851b68ea035e3c49234dafcddb97c4f54a30
commit 485b851b68ea035e3c49234dafcddb97c4f54a30
Author: Tom Tromey <tromey@adacore.com>
Date: Wed Feb 6 15:14:40 2019 +0100
Special-case wildcard requests in ravenscar-thread.c
ravenscar-thread.c intercepts resume and wait target requests and
replaces the requested ptid with the ptid of the underlying CPU.
However, this is incorrect when a request is made with a wildcard
ptid.
This patch adds a special case to ravenscar-thread.c for
minus_one_ptid. I don't believe a special case for process wildcards
is necessary, so I have not added that.
Joel's description explains the bug well:
At the user level, we noticed the issue because we had a test were
we insert a breakpoint one some code which is only run from, say,
CPU #2, whereas we unfortunately resumed the execution after having
stopped somewhere in CPU #1. As a result, we sent an order to resume
CPU #1, which starves CPU #2 forever, because the code in CPU #1
waits for some of the Ada tasks allocated to CPU #2 (and we never
reach our breakpoint either).
gdb/ChangeLog
2019-02-15 Tom Tromey <tromey@adacore.com>
* ravenscar-thread.c (ravenscar_thread_target::resume)
(ravenscar_thread_target::wait): Special case wildcard requests.
Diff:
---
gdb/ChangeLog | 5 +++++
gdb/ravenscar-thread.c | 12 ++++++++++--
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 28762cc..3ef09fd 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
2019-02-15 Tom Tromey <tromey@adacore.com>
+ * ravenscar-thread.c (ravenscar_thread_target::resume)
+ (ravenscar_thread_target::wait): Special case wildcard requests.
+
+2019-02-15 Tom Tromey <tromey@adacore.com>
+
* ravenscar-thread.c (base_ptid): Remove.
(struct ravenscar_thread_target) <close>: New method.
<m_base_ptid>: New member.
diff --git a/gdb/ravenscar-thread.c b/gdb/ravenscar-thread.c
index 186345d..05a8320 100644
--- a/gdb/ravenscar-thread.c
+++ b/gdb/ravenscar-thread.c
@@ -323,8 +323,12 @@ void
ravenscar_thread_target::resume (ptid_t ptid, int step,
enum gdb_signal siggnal)
{
+ /* If we see a wildcard resume, we simply pass that on. Otherwise,
+ arrange to resume the base ptid. */
inferior_ptid = m_base_ptid;
- beneath ()->resume (m_base_ptid, step, siggnal);
+ if (ptid != minus_one_ptid)
+ ptid = m_base_ptid;
+ beneath ()->resume (ptid, step, siggnal);
}
ptid_t
@@ -335,7 +339,9 @@ ravenscar_thread_target::wait (ptid_t ptid,
ptid_t event_ptid;
inferior_ptid = m_base_ptid;
- event_ptid = beneath ()->wait (m_base_ptid, status, 0);
+ if (ptid != minus_one_ptid)
+ ptid = m_base_ptid;
+ event_ptid = beneath ()->wait (ptid, status, 0);
/* Find any new threads that might have been created, and update
inferior_ptid to the active thread.
@@ -350,6 +356,8 @@ ravenscar_thread_target::wait (ptid_t ptid,
this->update_thread_list ();
this->update_inferior_ptid ();
}
+ else
+ inferior_ptid = m_base_ptid;
return inferior_ptid;
}