[PATCH 2/3] gdbserver: replace direct assignments to current_thread

Aktemur, Tankut Baris tankut.baris.aktemur@intel.com
Thu Dec 9 08:07:30 GMT 2021


On Friday, December 3, 2021 6:01 PM, Pedro Alves wrote:
> On 2021-12-01 17:49, Tankut Baris Aktemur via Gdb-patches wrote:
> > Replace the direct assignments to current_thread with
> > switch_to_thread.  Use scoped_restore_current_thread when appropriate.
> > There is one instance remaining in linux-low.cc's wait_for_sigstop.
> > This will be handled in a separate patch.
> >
> > Regression-tested on X86-64 Linux using the native-gdbserver and
> > native-extended-gdbserver board files.
> 
> Cool, thanks!
> 
> > @@ -1971,10 +1957,7 @@ linux_process_target::low_get_thread_area (int lwpid, CORE_ADDR
> *addrp)
> >  bool
> >  linux_process_target::maybe_move_out_of_jump_pad (lwp_info *lwp, int *wstat)
> >  {
> > -  struct thread_info *saved_thread;
> > -
> > -  saved_thread = current_thread;
> > -  current_thread = get_lwp_thread (lwp);
> > +  switch_to_thread (get_lwp_thread (lwp));
> 
> Aren't we missing a scoped_restore here?

Ah, yes, right.  Here is the new diff for this hunk:

@@ -1971,10 +1957,8 @@ linux_process_target::low_get_thread_area (int lwpid, CORE_ADDR *addrp)
 bool
 linux_process_target::maybe_move_out_of_jump_pad (lwp_info *lwp, int *wstat)
 {
-  struct thread_info *saved_thread;
-
-  saved_thread = current_thread;
-  current_thread = get_lwp_thread (lwp);
+  scoped_restore_current_thread restore_thread;
+  switch_to_thread (get_lwp_thread (lwp));

   if ((wstat == NULL
        || (WIFSTOPPED (*wstat) && WSTOPSIG (*wstat) != SIGTRAP))


-Baris


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