From: Markus Metzger <markus.t.metzger@intel.com>
To: palves@redhat.com
Cc: gdb-patches@sourceware.org
Subject: [PATCH 09/17] btrace: resume all requested threads
Date: Wed, 09 Sep 2015 10:36:00 -0000 [thread overview]
Message-ID: <1441794909-32718-10-git-send-email-markus.t.metzger@intel.com> (raw)
In-Reply-To: <1441794909-32718-1-git-send-email-markus.t.metzger@intel.com>
The record targets are implicitly schedlocked. They only step the current
thread and keep other threads where they are.
Change record btrace to step all requested threads in to_resume.
For maintenance and debugging, we keep the old behaviour when the target below
is not non-stop. Enable with "maint set target-non-stop on".
2015-09-09 Markus Metzger <markus.t.metzger@intel.com>
gdb/
* record-btrace.c (record_btrace_resume_thread): A move request
overwrites a previous move request.
(record_btrace_find_resume_thread): Removed.
(record_btrace_resume): Resume all requested threads.
---
gdb/record-btrace.c | 73 ++++++++++++++++++++++++++---------------------------
1 file changed, 36 insertions(+), 37 deletions(-)
diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index 0ce8825..64c8132 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -1699,31 +1699,14 @@ record_btrace_resume_thread (struct thread_info *tp,
btinfo = &tp->btrace;
- if ((btinfo->flags & BTHR_MOVE) != 0)
- error (_("Thread already moving."));
-
/* Fetch the latest branch trace. */
btrace_fetch (tp);
- /* A resume request overwrites a preceding stop request. */
- btinfo->flags &= ~BTHR_STOP;
+ /* A resume request overwrites a preceding resume or stop request. */
+ btinfo->flags &= ~(BTHR_MOVE | BTHR_STOP);
btinfo->flags |= flag;
}
-/* Find the thread to resume given a PTID. */
-
-static struct thread_info *
-record_btrace_find_resume_thread (ptid_t ptid)
-{
- struct thread_info *tp;
-
- /* When asked to resume everything, we pick the current thread. */
- if (ptid_equal (minus_one_ptid, ptid) || ptid_is_pid (ptid))
- ptid = inferior_ptid;
-
- return find_thread_ptid (ptid);
-}
-
/* Start replaying a thread. */
static struct btrace_insn_iterator *
@@ -1865,30 +1848,50 @@ static void
record_btrace_resume (struct target_ops *ops, ptid_t ptid, int step,
enum gdb_signal signal)
{
- struct thread_info *tp, *other;
+ struct thread_info *tp;
enum btrace_thread_flag flag;
+ ptid_t orig_ptid;
DEBUG ("resume %s: %s%s", target_pid_to_str (ptid),
execution_direction == EXEC_REVERSE ? "reverse-" : "",
step ? "step" : "cont");
- /* Store the execution direction of the last resume. */
+ orig_ptid = ptid;
+
+ /* Store the execution direction of the last resume.
+
+ If there is more than one to_resume call, we have to rely on infrun
+ to not change the execution direction in-between. */
record_btrace_resume_exec_dir = execution_direction;
- tp = record_btrace_find_resume_thread (ptid);
- if (tp == NULL)
- error (_("Cannot find thread to resume."));
+ /* For non-stop targets... */
+ if (!target_is_non_stop_p ())
+ {
+ /* ...we pick the current thread when asked to resume an entire process
+ or everything. */
+ if (ptid_equal (minus_one_ptid, ptid) || ptid_is_pid (ptid))
+ ptid = inferior_ptid;
+
+ tp = find_thread_ptid (ptid);
+ if (tp == NULL)
+ error (_("Cannot find thread to resume."));
+
+ /* ...and we stop replaying other threads if the thread to resume is not
+ replaying. */
+ if (!btrace_is_replaying (tp) && execution_direction != EXEC_REVERSE)
+ ALL_NON_EXITED_THREADS (tp)
+ record_btrace_stop_replaying (tp);
+ }
- /* Stop replaying other threads if the thread to resume is not replaying. */
- if (!btrace_is_replaying (tp) && execution_direction != EXEC_REVERSE)
- ALL_NON_EXITED_THREADS (other)
- record_btrace_stop_replaying (other);
+ /* As long as we're not replaying, just forward the request.
- /* As long as we're not replaying, just forward the request. */
+ For non-stop targets this means that no thread is replaying. In order to
+ make progress, we may need to explicitly move replaying threads to the end
+ of their execution history. */
if (!record_btrace_is_replaying (ops) && execution_direction != EXEC_REVERSE)
{
ops = ops->beneath;
- return ops->to_resume (ops, ptid, step, signal);
+ return ops->to_resume (ops, orig_ptid, step, signal);
}
/* Compute the btrace thread flag for the requested move. */
@@ -1897,15 +1900,11 @@ record_btrace_resume (struct target_ops *ops, ptid_t ptid, int step,
else
flag = execution_direction == EXEC_REVERSE ? BTHR_RSTEP : BTHR_STEP;
- /* At the moment, we only move a single thread. We could also move
- all threads in parallel by single-stepping each resumed thread
- until the first runs into an event.
- When we do that, we would want to continue all other threads.
- For now, just resume one thread to not confuse to_wait. */
- record_btrace_resume_thread (tp, flag);
-
/* We just indicate the resume intent here. The actual stepping happens in
record_btrace_wait below. */
+ ALL_NON_EXITED_THREADS (tp)
+ if (ptid_match (tp->ptid, ptid))
+ record_btrace_resume_thread (tp, flag);
/* Async support. */
if (target_can_async_p ())
--
1.8.3.1
next prev parent reply other threads:[~2015-09-09 10:36 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-09 10:36 [PATCH 00/17] record btrace: non-stop and ASNS Markus Metzger
2015-09-09 10:35 ` [PATCH 05/17] btrace: split record_btrace_step_thread Markus Metzger
2015-09-09 10:35 ` [PATCH 15/17] btrace: allow full memory and register access for non-replaying threads Markus Metzger
2015-09-09 11:57 ` Pedro Alves
2015-09-09 10:35 ` [PATCH 08/17] btrace: lock-step Markus Metzger
2015-09-09 10:35 ` [PATCH 10/17] btrace: temporarily set inferior_ptid in record_btrace_start_replaying Markus Metzger
2015-09-09 10:35 ` [PATCH 04/17] btrace: extract the breakpoint check from record_btrace_step_thread Markus Metzger
2015-09-09 10:35 ` [PATCH 01/17] btrace: fix non-stop check in to_wait Markus Metzger
2015-09-09 10:35 ` [PATCH 14/17] target, record: add PTID argument to to_record_is_replaying Markus Metzger
2015-09-09 10:35 ` [PATCH 12/17] infrun: switch to NO_HISTORY thread Markus Metzger
2015-09-09 10:35 ` [PATCH 11/17] btrace: async Markus Metzger
2015-09-09 10:35 ` [PATCH 03/17] btrace: improve stepping debugging Markus Metzger
2015-09-09 10:36 ` [PATCH 02/17] btrace: support to_stop Markus Metzger
2015-09-09 10:36 ` [PATCH 17/17] infrun: scheduler-locking reverse Markus Metzger
2015-09-09 13:54 ` Pedro Alves
2015-09-12 19:43 ` Jan Kratochvil
2015-09-15 9:29 ` Metzger, Markus T
2015-09-15 17:19 ` Jan Kratochvil
2015-09-16 7:59 ` Metzger, Markus T
2015-09-16 12:44 ` Metzger, Markus T
2015-09-16 13:23 ` Pedro Alves
2015-09-16 13:21 ` Pedro Alves
2015-09-17 8:39 ` Jan Kratochvil
2015-09-17 8:48 ` Metzger, Markus T
2015-09-17 10:11 ` Eli Zaretskii
2015-09-09 10:36 ` Markus Metzger [this message]
2015-09-09 12:06 ` [PATCH 09/17] btrace: resume all requested threads Pedro Alves
2015-09-09 13:06 ` Metzger, Markus T
2015-09-09 10:36 ` [PATCH 13/17] btrace: non-stop Markus Metzger
2015-09-09 11:54 ` Pedro Alves
2015-09-09 12:20 ` Metzger, Markus T
2015-09-09 13:47 ` Pedro Alves
2015-09-09 14:10 ` Metzger, Markus T
2015-09-09 14:51 ` Pedro Alves
2015-09-10 7:49 ` Metzger, Markus T
2015-09-10 11:05 ` Pedro Alves
2015-09-10 11:19 ` Metzger, Markus T
2015-09-10 11:32 ` Pedro Alves
2015-09-10 11:37 ` Metzger, Markus T
2015-09-10 12:48 ` Pedro Alves
2015-09-09 10:36 ` [PATCH 07/17] btrace: add missing NO_HISTORY Markus Metzger
2015-09-09 10:36 ` [PATCH 06/17] btrace: move breakpoint checking into stepping functions Markus Metzger
2015-09-09 10:36 ` [PATCH 16/17] target: add to_record_stop_replaying target method Markus Metzger
2015-09-09 11:59 ` Pedro Alves
2015-09-09 13:56 ` [PATCH 00/17] record btrace: non-stop and ASNS Pedro Alves
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=1441794909-32718-10-git-send-email-markus.t.metzger@intel.com \
--to=markus.t.metzger@intel.com \
--cc=gdb-patches@sourceware.org \
--cc=palves@redhat.com \
/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