aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2020-01-10 20:05:41 +0000
committerPedro Alves <palves@redhat.com>2020-01-10 20:05:41 +0000
commitec506636cc0c56d4229b00d5e439c0610970f84d (patch)
tree3d01f04f7b4fb3ed19797d16503b07d80c094f2a
parent873657b9e824943ae44c12966c29cbbcd21c986f (diff)
downloadgdb-ec506636cc0c56d4229b00d5e439c0610970f84d.zip
gdb-ec506636cc0c56d4229b00d5e439c0610970f84d.tar.gz
gdb-ec506636cc0c56d4229b00d5e439c0610970f84d.tar.bz2
Don't rely on inferior_ptid in record_full_wait
The multi-target patch sets inferior_ptid to null_ptid before handling a target event, and thus before calling target_wait, in order to catch places in target_ops::wait implementations that are incorrectly relying on inferior_ptid (which could otherwise be a ptid of a different target, for example). That caught this instance in record-full.c. Fix it by saving the last resumed ptid, and then using it in record_full_wait_1, just like how the last "step" argument passed to record_full_target::resume is handled too. gdb/ChangeLog: 2020-01-10 Pedro Alves <palves@redhat.com> * record-full.c (record_full_resume_ptid): New global. (record_full_target::resume): Set it. (record_full_wait_1): Use record_full_resume_ptid instead of inferior_ptid.
-rw-r--r--gdb/ChangeLog7
-rw-r--r--gdb/record-full.c7
-rw-r--r--gdb/target.h7
3 files changed, 20 insertions, 1 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 541683f..dba48a5 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,12 @@
2020-01-10 Pedro Alves <palves@redhat.com>
+ * record-full.c (record_full_resume_ptid): New global.
+ (record_full_target::resume): Set it.
+ (record_full_wait_1): Use record_full_resume_ptid instead of
+ inferior_ptid.
+
+2020-01-10 Pedro Alves <palves@redhat.com>
+
* gdbthread.h (scoped_restore_current_thread)
<dont_restore, restore, m_dont_restore>: Declare.
* thread.c (thread_alive): Add assertion. Return bool.
diff --git a/gdb/record-full.c b/gdb/record-full.c
index 056b03b..c5ef590 100644
--- a/gdb/record-full.c
+++ b/gdb/record-full.c
@@ -1036,6 +1036,9 @@ record_full_base_target::async (int enable)
beneath ()->async (enable);
}
+/* The PTID and STEP arguments last passed to
+ record_full_target::resume. */
+static ptid_t record_full_resume_ptid = null_ptid;
static int record_full_resume_step = 0;
/* True if we've been resumed, and so each record_full_wait call should
@@ -1064,6 +1067,7 @@ static enum exec_direction_kind record_full_execution_dir = EXEC_FORWARD;
void
record_full_target::resume (ptid_t ptid, int step, enum gdb_signal signal)
{
+ record_full_resume_ptid = inferior_ptid;
record_full_resume_step = step;
record_full_resumed = 1;
record_full_execution_dir = ::execution_direction;
@@ -1190,7 +1194,8 @@ record_full_wait_1 (struct target_ops *ops,
/* This is not a single step. */
ptid_t ret;
CORE_ADDR tmp_pc;
- struct gdbarch *gdbarch = target_thread_architecture (inferior_ptid);
+ struct gdbarch *gdbarch
+ = target_thread_architecture (record_full_resume_ptid);
while (1)
{
diff --git a/gdb/target.h b/gdb/target.h
index a8e551c..1ec7b90 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -478,6 +478,13 @@ struct target_ops
TARGET_DEFAULT_NORETURN (noprocess ());
virtual void commit_resume ()
TARGET_DEFAULT_IGNORE ();
+ /* See target_wait's description. Note that implementations of
+ this method must not assume that inferior_ptid on entry is
+ pointing at the thread or inferior that ends up reporting an
+ event. The reported event could be for some other thread in
+ the current inferior or even for a different process of the
+ current target. inferior_ptid may also be null_ptid on
+ entry. */
virtual ptid_t wait (ptid_t, struct target_waitstatus *,
int TARGET_DEBUG_PRINTER (target_debug_print_options))
TARGET_DEFAULT_FUNC (default_target_wait);