Remove make_cleanup_restore_current_thread from gdbserver
authorTom Tromey <tom@tromey.com>
Mon, 5 Feb 2018 09:59:52 +0000 (10:59 +0100)
committerTom Tromey <tom@tromey.com>
Thu, 8 Feb 2018 18:46:55 +0000 (11:46 -0700)
This removes make_cleanup_restore_current_thread from gdbserver,
replacing it with a use of scoped_restore.

2018-02-08  Tom Tromey  <tom@tromey.com>

* linux-low.c (install_software_single_step_breakpoints): Use
make_scoped_restore.
* inferiors.c (make_cleanup_restore_current_thread): Remove.
(do_restore_current_thread_cleanup): Remove.
* gdbthread.h (make_cleanup_restore_current_thread): Don't
declare.

gdb/gdbserver/ChangeLog
gdb/gdbserver/gdbthread.h
gdb/gdbserver/inferiors.c
gdb/gdbserver/linux-low.c

index 145ba440cbc9f942a6dc4f038be2d5bbeecc2f19..b80d82058eaf032b4479ab89d376154bdd9c89df 100644 (file)
@@ -1,3 +1,12 @@
+2018-02-08  Tom Tromey  <tom@tromey.com>
+
+       * linux-low.c (install_software_single_step_breakpoints): Use
+       make_scoped_restore.
+       * inferiors.c (make_cleanup_restore_current_thread): Remove.
+       (do_restore_current_thread_cleanup): Remove.
+       * gdbthread.h (make_cleanup_restore_current_thread): Don't
+       declare.
+
 2018-02-08  Tom Tromey  <tom@tromey.com>
 
        * mem-break.c (set_raw_breakpoint_at): Use
index 9a8c72e780e696feb7b7cd56a3a325bc30ac7f1d..0edf870c56f4c9acc12cbe8fbe6b185a396830d4 100644 (file)
@@ -224,7 +224,4 @@ lwpid_of (const thread_info *thread)
   return thread->id.lwp ();
 }
 
-/* Create a cleanup to restore current_thread.  */
-struct cleanup *make_cleanup_restore_current_thread (void);
-
 #endif /* GDB_THREAD_H */
index 600bf201bff2c673e8284c3a00950094e12c1d85..ad3df648f5b1c90c6d5d20c68ee89b0c02133d21 100644 (file)
@@ -213,18 +213,6 @@ current_process (void)
   return get_thread_process (current_thread);
 }
 
-static void
-do_restore_current_thread_cleanup (void *arg)
-{
-  current_thread = (struct thread_info *) arg;
-}
-
-struct cleanup *
-make_cleanup_restore_current_thread (void)
-{
-  return make_cleanup (do_restore_current_thread_cleanup, current_thread);
-}
-
 /* See common/common-gdbthread.h.  */
 
 void
index 38142bba03d2b707fdd1f6d8341a5d18e4a0199d..b6b660ea9608357cc7565c98177b3cd28d5e6472 100644 (file)
@@ -50,6 +50,7 @@
 #include "common-inferior.h"
 #include "nat/fork-inferior.h"
 #include "environ.h"
+#include "common/scoped_restore.h"
 #ifndef ELFMAG0
 /* Don't include <linux/elf.h> here.  If it got included by gdb_proc_service.h
    then ELFMAG0 will have been defined.  If it didn't get included by
@@ -4207,15 +4208,14 @@ install_software_single_step_breakpoints (struct lwp_info *lwp)
 {
   struct thread_info *thread = get_lwp_thread (lwp);
   struct regcache *regcache = get_thread_regcache (thread, 1);
-  struct cleanup *old_chain = make_cleanup_restore_current_thread ();
+
+  scoped_restore save_current_thread = make_scoped_restore (&current_thread);
 
   current_thread = thread;
   std::vector<CORE_ADDR> next_pcs = the_low_target.get_next_pcs (regcache);
 
   for (CORE_ADDR pc : next_pcs)
     set_single_step_breakpoint (pc, current_ptid);
-
-  do_cleanups (old_chain);
 }
 
 /* Single step via hardware or software single step.