Remove cleanup from solib-svr4.c
authorTom Tromey <tom@tromey.com>
Thu, 24 Jan 2019 05:23:15 +0000 (22:23 -0700)
committerTom Tromey <tom@tromey.com>
Wed, 6 Mar 2019 23:04:31 +0000 (16:04 -0700)
This removes a cleanup from solib-svr4.c, replacing it with
make_scope_exit.

2019-03-06  Tom Tromey  <tom@tromey.com>

* solib-svr4.c (disable_probes_interface): Remove parameter.
(svr4_handle_solib_event): Use make_scope_exit.

gdb/ChangeLog
gdb/solib-svr4.c

index 2d7e328..e7c6a18 100644 (file)
@@ -1,5 +1,10 @@
 2019-03-06  Tom Tromey  <tom@tromey.com>
 
+       * solib-svr4.c (disable_probes_interface): Remove parameter.
+       (svr4_handle_solib_event): Use make_scope_exit.
+
+2019-03-06  Tom Tromey  <tom@tromey.com>
+
        * remote.c (struct stop_reply_deleter): Remove.
        (stop_reply_up): Update.
        (struct stop_reply): Derive from notif_event.  Don't typedef.
index 787b98b..2b370ef 100644 (file)
@@ -1826,7 +1826,7 @@ solist_update_incremental (struct svr4_info *info, CORE_ADDR lm)
    ones set up for the probes-based interface are adequate.  */
 
 static void
-disable_probes_interface_cleanup (void *arg)
+disable_probes_interface ()
 {
   struct svr4_info *info = get_svr4_info ();
 
@@ -1847,7 +1847,6 @@ svr4_handle_solib_event (void)
   struct svr4_info *info = get_svr4_info ();
   struct probe_and_action *pa;
   enum probe_action action;
-  struct cleanup *old_chain;
   struct value *val = NULL;
   CORE_ADDR pc, debug_base, lm = 0;
   struct frame_info *frame = get_current_frame ();
@@ -1858,26 +1857,20 @@ svr4_handle_solib_event (void)
 
   /* If anything goes wrong we revert to the original linker
      interface.  */
-  old_chain = make_cleanup (disable_probes_interface_cleanup, NULL);
+  auto cleanup = make_scope_exit (disable_probes_interface);
 
   pc = regcache_read_pc (get_current_regcache ());
   pa = solib_event_probe_at (info, pc);
   if (pa == NULL)
-    {
-      do_cleanups (old_chain);
-      return;
-    }
+    return;
 
   action = solib_event_probe_action (pa);
   if (action == PROBES_INTERFACE_FAILED)
-    {
-      do_cleanups (old_chain);
-      return;
-    }
+    return;
 
   if (action == DO_NOTHING)
     {
-      discard_cleanups (old_chain);
+      cleanup.release ();
       return;
     }
 
@@ -1907,25 +1900,16 @@ svr4_handle_solib_event (void)
     END_CATCH
 
     if (val == NULL)
-      {
-       do_cleanups (old_chain);
-       return;
-      }
+      return;
 
     debug_base = value_as_address (val);
     if (debug_base == 0)
-      {
-       do_cleanups (old_chain);
-       return;
-      }
+      return;
 
     /* Always locate the debug struct, in case it moved.  */
     info->debug_base = 0;
     if (locate_base (info) == 0)
-      {
-       do_cleanups (old_chain);
-       return;
-      }
+      return;
 
     /* GDB does not currently support libraries loaded via dlmopen
        into namespaces other than the initial one.  We must ignore
@@ -1943,7 +1927,6 @@ svr4_handle_solib_event (void)
        CATCH (ex, RETURN_MASK_ERROR)
          {
            exception_print (gdb_stderr, ex);
-           do_cleanups (old_chain);
            return;
          }
        END_CATCH
@@ -1968,13 +1951,10 @@ svr4_handle_solib_event (void)
   if (action == FULL_RELOAD)
     {
       if (!solist_update_full (info))
-       {
-         do_cleanups (old_chain);
-         return;
-       }
+       return;
     }
 
-  discard_cleanups (old_chain);
+  cleanup.release ();
 }
 
 /* Helper function for svr4_update_solib_event_breakpoints.  */