[PATCH 3/3] gdbserver/linux-low: replace direct assignment to current_thread
Tankut Baris Aktemur
tankut.baris.aktemur@intel.com
Wed Dec 1 17:49:47 GMT 2021
Use scoped_restore_current_thread and switch_to_thread in
linux_process_target::wait_for_sigstop.
---
gdbserver/linux-low.cc | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index e79ccb5ab0e..9f74de43344 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -3814,16 +3814,11 @@ lwp_is_marked_dead (struct lwp_info *lwp)
void
linux_process_target::wait_for_sigstop ()
{
- struct thread_info *saved_thread;
- ptid_t saved_tid;
+ thread_info *saved_thread = current_thread;
int wstat;
int ret;
- saved_thread = current_thread;
- if (saved_thread != NULL)
- saved_tid = saved_thread->id;
- else
- saved_tid = null_ptid; /* avoid bogus unused warning */
+ scoped_restore_current_thread restore_thread;
if (debug_threads)
debug_printf ("wait_for_sigstop: pulling events\n");
@@ -3834,8 +3829,8 @@ linux_process_target::wait_for_sigstop ()
ret = wait_for_event_filtered (minus_one_ptid, null_ptid, &wstat, __WALL);
gdb_assert (ret == -1);
- if (saved_thread == NULL || mythread_alive (saved_tid))
- current_thread = saved_thread;
+ if (saved_thread == nullptr || mythread_alive (saved_thread->id))
+ return;
else
{
if (debug_threads)
@@ -3844,7 +3839,8 @@ linux_process_target::wait_for_sigstop ()
/* We can't change the current inferior behind GDB's back,
otherwise, a subsequent command may apply to the wrong
process. */
- current_thread = NULL;
+ restore_thread.dont_restore ();
+ switch_to_thread (nullptr);
}
}
--
2.33.1
Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
More information about the Gdb-patches
mailing list