GNU Binutils with patches for OS216
修订版 | 0ac553107c601cc9c4c340338e0fc7e0ce8375cc (tree) |
---|---|
时间 | 2020-06-19 07:08:14 |
作者 | Pedro Alves <palves@redh...> |
Commiter | Pedro Alves |
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.
@@ -1,5 +1,15 @@ | ||
1 | 1 | 2020-06-18 Pedro Alves <palves@redhat.com> |
2 | 2 | |
3 | + * remote.c (remote_target::remote_notice_new_inferior): Use | |
4 | + switch_to_thread instead of writing to inferior_ptid directly. | |
5 | + (remote_target::add_current_inferior_and_thread): Use | |
6 | + switch_to_no_thread instead of writing to inferior_ptid directly. | |
7 | + (extended_remote_target::attach): Use switch_to_inferior_no_thread | |
8 | + and switch_to_thread instead of using set_current_inferior or | |
9 | + writing to inferior_ptid directly. | |
10 | + | |
11 | +2020-06-18 Pedro Alves <palves@redhat.com> | |
12 | + | |
3 | 13 | * tracectf.c (ctf_target_open): Switch to added thread instead of |
4 | 14 | writing to inferior_ptid directly. |
5 | 15 | (ctf_target::close): Use switch_to_no_thread instead of writing to |
@@ -2493,8 +2493,9 @@ remote_target::remote_notice_new_inferior (ptid_t currthread, int executing) | ||
2493 | 2493 | thread_change_ptid (this, inferior_ptid, currthread); |
2494 | 2494 | else |
2495 | 2495 | { |
2496 | - remote_add_thread (currthread, running, executing); | |
2497 | - inferior_ptid = currthread; | |
2496 | + thread_info *thr | |
2497 | + = remote_add_thread (currthread, running, executing); | |
2498 | + switch_to_thread (thr); | |
2498 | 2499 | } |
2499 | 2500 | return; |
2500 | 2501 | } |
@@ -4346,9 +4347,10 @@ remote_target::add_current_inferior_and_thread (char *wait_status) | ||
4346 | 4347 | struct remote_state *rs = get_remote_state (); |
4347 | 4348 | bool fake_pid_p = false; |
4348 | 4349 | |
4349 | - inferior_ptid = null_ptid; | |
4350 | + switch_to_no_thread (); | |
4350 | 4351 | |
4351 | - /* Now, if we have thread information, update inferior_ptid. */ | |
4352 | + /* Now, if we have thread information, update the current thread's | |
4353 | + ptid. */ | |
4352 | 4354 | ptid_t curr_ptid = get_current_thread (wait_status); |
4353 | 4355 | |
4354 | 4356 | if (curr_ptid != null_ptid) |
@@ -5760,7 +5762,7 @@ remote_target::remote_detach_1 (inferior *inf, int from_tty) | ||
5760 | 5762 | } |
5761 | 5763 | else |
5762 | 5764 | { |
5763 | - inferior_ptid = null_ptid; | |
5765 | + switch_to_no_thread (); | |
5764 | 5766 | detach_inferior (current_inferior ()); |
5765 | 5767 | } |
5766 | 5768 | } |
@@ -5906,33 +5908,33 @@ extended_remote_target::attach (const char *args, int from_tty) | ||
5906 | 5908 | target_pid_to_str (ptid_t (pid)).c_str ()); |
5907 | 5909 | } |
5908 | 5910 | |
5909 | - set_current_inferior (remote_add_inferior (false, pid, 1, 0)); | |
5911 | + switch_to_inferior_no_thread (remote_add_inferior (false, pid, 1, 0)); | |
5910 | 5912 | |
5911 | 5913 | inferior_ptid = ptid_t (pid); |
5912 | 5914 | |
5913 | 5915 | if (target_is_non_stop_p ()) |
5914 | 5916 | { |
5915 | - struct thread_info *thread; | |
5916 | - | |
5917 | 5917 | /* Get list of threads. */ |
5918 | 5918 | update_thread_list (); |
5919 | 5919 | |
5920 | - thread = first_thread_of_inferior (current_inferior ()); | |
5921 | - if (thread) | |
5922 | - inferior_ptid = thread->ptid; | |
5923 | - else | |
5924 | - inferior_ptid = ptid_t (pid); | |
5920 | + thread_info *thread = first_thread_of_inferior (current_inferior ()); | |
5921 | + if (thread != nullptr) | |
5922 | + switch_to_thread (thread); | |
5925 | 5923 | |
5926 | 5924 | /* Invalidate our notion of the remote current thread. */ |
5927 | 5925 | record_currthread (rs, minus_one_ptid); |
5928 | 5926 | } |
5929 | 5927 | else |
5930 | 5928 | { |
5931 | - /* Now, if we have thread information, update inferior_ptid. */ | |
5932 | - inferior_ptid = remote_current_thread (inferior_ptid); | |
5929 | + /* Now, if we have thread information, update the main thread's | |
5930 | + ptid. */ | |
5931 | + ptid_t curr_ptid = remote_current_thread (ptid_t (pid)); | |
5933 | 5932 | |
5934 | 5933 | /* Add the main thread to the thread list. */ |
5935 | - thread_info *thr = add_thread_silent (this, inferior_ptid); | |
5934 | + thread_info *thr = add_thread_silent (this, curr_ptid); | |
5935 | + | |
5936 | + switch_to_thread (thr); | |
5937 | + | |
5936 | 5938 | /* Don't consider the thread stopped until we've processed the |
5937 | 5939 | saved stop reply. */ |
5938 | 5940 | set_executing (this, thr->ptid, true); |