aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2020-06-18 21:28:24 +0100
committerPedro Alves <palves@redhat.com>2020-06-18 23:08:14 +0100
commit0ac553107c601cc9c4c340338e0fc7e0ce8375cc (patch)
tree88f159eaad394c47aecc79314be75eb4fdb136aa
parent5233f39b8b999f2675fb9493149e878c281e1d60 (diff)
downloadgdb-0ac553107c601cc9c4c340338e0fc7e0ce8375cc.zip
gdb-0ac553107c601cc9c4c340338e0fc7e0ce8375cc.tar.gz
gdb-0ac553107c601cc9c4c340338e0fc7e0ce8375cc.tar.bz2
Don't write to inferior_ptid in remote.c
gdb/ChangeLog: 2020-06-18 Pedro Alves <palves@redhat.com> * remote.c (remote_target::remote_notice_new_inferior): Use switch_to_thread instead of writing to inferior_ptid directly. (remote_target::add_current_inferior_and_thread): Use switch_to_no_thread instead of writing to inferior_ptid directly. (extended_remote_target::attach): Use switch_to_inferior_no_thread and switch_to_thread instead of using set_current_inferior or writing to inferior_ptid directly.
-rw-r--r--gdb/ChangeLog10
-rw-r--r--gdb/remote.c34
2 files changed, 28 insertions, 16 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index b02a576..334c227 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,15 @@
2020-06-18 Pedro Alves <palves@redhat.com>
+ * remote.c (remote_target::remote_notice_new_inferior): Use
+ switch_to_thread instead of writing to inferior_ptid directly.
+ (remote_target::add_current_inferior_and_thread): Use
+ switch_to_no_thread instead of writing to inferior_ptid directly.
+ (extended_remote_target::attach): Use switch_to_inferior_no_thread
+ and switch_to_thread instead of using set_current_inferior or
+ writing to inferior_ptid directly.
+
+2020-06-18 Pedro Alves <palves@redhat.com>
+
* tracectf.c (ctf_target_open): Switch to added thread instead of
writing to inferior_ptid directly.
(ctf_target::close): Use switch_to_no_thread instead of writing to
diff --git a/gdb/remote.c b/gdb/remote.c
index c73eb6e..fd89f2c 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -2493,8 +2493,9 @@ remote_target::remote_notice_new_inferior (ptid_t currthread, int executing)
thread_change_ptid (this, inferior_ptid, currthread);
else
{
- remote_add_thread (currthread, running, executing);
- inferior_ptid = currthread;
+ thread_info *thr
+ = remote_add_thread (currthread, running, executing);
+ switch_to_thread (thr);
}
return;
}
@@ -4346,9 +4347,10 @@ remote_target::add_current_inferior_and_thread (char *wait_status)
struct remote_state *rs = get_remote_state ();
bool fake_pid_p = false;
- inferior_ptid = null_ptid;
+ switch_to_no_thread ();
- /* Now, if we have thread information, update inferior_ptid. */
+ /* Now, if we have thread information, update the current thread's
+ ptid. */
ptid_t curr_ptid = get_current_thread (wait_status);
if (curr_ptid != null_ptid)
@@ -5760,7 +5762,7 @@ remote_target::remote_detach_1 (inferior *inf, int from_tty)
}
else
{
- inferior_ptid = null_ptid;
+ switch_to_no_thread ();
detach_inferior (current_inferior ());
}
}
@@ -5906,33 +5908,33 @@ extended_remote_target::attach (const char *args, int from_tty)
target_pid_to_str (ptid_t (pid)).c_str ());
}
- set_current_inferior (remote_add_inferior (false, pid, 1, 0));
+ switch_to_inferior_no_thread (remote_add_inferior (false, pid, 1, 0));
inferior_ptid = ptid_t (pid);
if (target_is_non_stop_p ())
{
- struct thread_info *thread;
-
/* Get list of threads. */
update_thread_list ();
- thread = first_thread_of_inferior (current_inferior ());
- if (thread)
- inferior_ptid = thread->ptid;
- else
- inferior_ptid = ptid_t (pid);
+ thread_info *thread = first_thread_of_inferior (current_inferior ());
+ if (thread != nullptr)
+ switch_to_thread (thread);
/* Invalidate our notion of the remote current thread. */
record_currthread (rs, minus_one_ptid);
}
else
{
- /* Now, if we have thread information, update inferior_ptid. */
- inferior_ptid = remote_current_thread (inferior_ptid);
+ /* Now, if we have thread information, update the main thread's
+ ptid. */
+ ptid_t curr_ptid = remote_current_thread (ptid_t (pid));
/* Add the main thread to the thread list. */
- thread_info *thr = add_thread_silent (this, inferior_ptid);
+ thread_info *thr = add_thread_silent (this, curr_ptid);
+
+ switch_to_thread (thr);
+
/* Don't consider the thread stopped until we've processed the
saved stop reply. */
set_executing (this, thr->ptid, true);