Remove resume_section_map_updates_cleanup
authorTom Tromey <tom@tromey.com>
Tue, 29 May 2018 19:51:58 +0000 (13:51 -0600)
committerTom Tromey <tom@tromey.com>
Mon, 18 Jun 2018 19:16:45 +0000 (13:16 -0600)
This removes resume_section_map_updates_cleanup, replacing it with a
scoped_restore.

Tested by the buildbot.

gdb/ChangeLog
2018-06-18  Tom Tromey  <tom@tromey.com>

* objfiles.h (inhibit_section_map_updates): Update.
(resume_section_map_updates, resume_section_map_updates_cleanup):
Remove.
* solib-svr4.c (svr4_handle_solib_event): Update.
* objfiles.c (inhibit_section_map_updates): Return
scoped_restore_tmpl<int>.
(resume_section_map_updates, resume_section_map_updates_cleanup):
Remove.

gdb/ChangeLog
gdb/objfiles.c
gdb/objfiles.h
gdb/solib-svr4.c

index 8b09a72737b00155e2cb80029ca651da19152e52..553bc8a2380def3cc9cfd224a19dc700dc55c37b 100644 (file)
@@ -1,3 +1,14 @@
+2018-06-18  Tom Tromey  <tom@tromey.com>
+
+       * objfiles.h (inhibit_section_map_updates): Update.
+       (resume_section_map_updates, resume_section_map_updates_cleanup):
+       Remove.
+       * solib-svr4.c (svr4_handle_solib_event): Update.
+       * objfiles.c (inhibit_section_map_updates): Return
+       scoped_restore_tmpl<int>.
+       (resume_section_map_updates, resume_section_map_updates_cleanup):
+       Remove.
+
 2018-06-18  Tom Tromey  <tom@tromey.com>
 
        * valprint.h (read_string): Update.
index 0432ce620807c03c0e81441253886bdcb0b12e25..95c39cf4a95acf120f1342fb1b237b25599fd1ff 100644 (file)
@@ -1455,26 +1455,11 @@ objfiles_changed (void)
 
 /* See comments in objfiles.h.  */
 
-void
+scoped_restore_tmpl<int>
 inhibit_section_map_updates (struct program_space *pspace)
 {
-  get_objfile_pspace_data (pspace)->inhibit_updates = 1;
-}
-
-/* See comments in objfiles.h.  */
-
-void
-resume_section_map_updates (struct program_space *pspace)
-{
-  get_objfile_pspace_data (pspace)->inhibit_updates = 0;
-}
-
-/* See comments in objfiles.h.  */
-
-void
-resume_section_map_updates_cleanup (void *arg)
-{
-  resume_section_map_updates ((struct program_space *) arg);
+  return scoped_restore_tmpl<int>
+    (&get_objfile_pspace_data (pspace)->inhibit_updates, 1);
 }
 
 /* Return 1 if ADDR maps into one of the sections of OBJFILE and 0
index 28e66eca3627db8af863c853ea7321c29123367b..7a9087b015817757c155ad433ab3c5b9aca3b513 100644 (file)
@@ -551,18 +551,13 @@ DECLARE_REGISTRY(objfile);
 /* In normal use, the section map will be rebuilt by find_pc_section
    if objfiles have been added, removed or relocated since it was last
    called.  Calling inhibit_section_map_updates will inhibit this
-   behavior until resume_section_map_updates is called.  If you call
-   inhibit_section_map_updates you must ensure that every call to
-   find_pc_section in the inhibited region relates to a section that
-   is already in the section map and has not since been removed or
-   relocated.  */
-extern void inhibit_section_map_updates (struct program_space *pspace);
-
-/* Resume automatically rebuilding the section map as required.  */
-extern void resume_section_map_updates (struct program_space *pspace);
-
-/* Version of the above suitable for use as a cleanup.  */
-extern void resume_section_map_updates_cleanup (void *arg);
+   behavior until the returned scoped_restore object is destroyed.  If
+   you call inhibit_section_map_updates you must ensure that every
+   call to find_pc_section in the inhibited region relates to a
+   section that is already in the section map and has not since been
+   removed or relocated.  */
+extern scoped_restore_tmpl<int> inhibit_section_map_updates
+    (struct program_space *pspace);
 
 extern void default_iterate_over_objfiles_in_search_order
   (struct gdbarch *gdbarch,
index d012f082b848553ab7b46cf5ed8f860f92a8d666..6f48c6863209dcd23c50177eba1277e5d5d7b686 100644 (file)
@@ -1858,7 +1858,7 @@ 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, *usm_chain;
+  struct cleanup *old_chain;
   struct value *val = NULL;
   CORE_ADDR pc, debug_base, lm = 0;
   struct frame_info *frame = get_current_frame ();
@@ -1902,72 +1902,73 @@ svr4_handle_solib_event (void)
      so we can guarantee that the dynamic linker's sections are in the
      section map.  We can therefore inhibit section map updates across
      these calls to evaluate_argument and save a lot of time.  */
-  inhibit_section_map_updates (current_program_space);
-  usm_chain = make_cleanup (resume_section_map_updates_cleanup,
-                           current_program_space);
+  {
+    scoped_restore inhibit_updates
+      = inhibit_section_map_updates (current_program_space);
 
-  TRY
-    {
-      val = pa->prob->evaluate_argument (1, frame);
-    }
-  CATCH (ex, RETURN_MASK_ERROR)
-    {
-      exception_print (gdb_stderr, ex);
-      val = NULL;
-    }
-  END_CATCH
+    TRY
+      {
+       val = pa->prob->evaluate_argument (1, frame);
+      }
+    CATCH (ex, RETURN_MASK_ERROR)
+      {
+       exception_print (gdb_stderr, ex);
+       val = NULL;
+      }
+    END_CATCH
 
-  if (val == NULL)
-    {
-      do_cleanups (old_chain);
-      return;
-    }
+    if (val == NULL)
+      {
+       do_cleanups (old_chain);
+       return;
+      }
 
-  debug_base = value_as_address (val);
-  if (debug_base == 0)
-    {
-      do_cleanups (old_chain);
-      return;
-    }
+    debug_base = value_as_address (val);
+    if (debug_base == 0)
+      {
+       do_cleanups (old_chain);
+       return;
+      }
 
-  /* Always locate the debug struct, in case it moved.  */
-  info->debug_base = 0;
-  if (locate_base (info) == 0)
-    {
-      do_cleanups (old_chain);
-      return;
-    }
+    /* Always locate the debug struct, in case it moved.  */
+    info->debug_base = 0;
+    if (locate_base (info) == 0)
+      {
+       do_cleanups (old_chain);
+       return;
+      }
 
-  /* GDB does not currently support libraries loaded via dlmopen
-     into namespaces other than the initial one.  We must ignore
-     any namespace other than the initial namespace here until
-     support for this is added to GDB.  */
-  if (debug_base != info->debug_base)
-    action = DO_NOTHING;
+    /* GDB does not currently support libraries loaded via dlmopen
+       into namespaces other than the initial one.  We must ignore
+       any namespace other than the initial namespace here until
+       support for this is added to GDB.  */
+    if (debug_base != info->debug_base)
+      action = DO_NOTHING;
 
-  if (action == UPDATE_OR_RELOAD)
-    {
-      TRY
-       {
-         val = pa->prob->evaluate_argument (2, frame);
-       }
-      CATCH (ex, RETURN_MASK_ERROR)
-       {
-         exception_print (gdb_stderr, ex);
-         do_cleanups (old_chain);
-         return;
-       }
-      END_CATCH
+    if (action == UPDATE_OR_RELOAD)
+      {
+       TRY
+         {
+           val = pa->prob->evaluate_argument (2, frame);
+         }
+       CATCH (ex, RETURN_MASK_ERROR)
+         {
+           exception_print (gdb_stderr, ex);
+           do_cleanups (old_chain);
+           return;
+         }
+       END_CATCH
 
-      if (val != NULL)
-       lm = value_as_address (val);
+       if (val != NULL)
+         lm = value_as_address (val);
 
-      if (lm == 0)
-       action = FULL_RELOAD;
-    }
+       if (lm == 0)
+         action = FULL_RELOAD;
+      }
 
-  /* Resume section map updates.  */
-  do_cleanups (usm_chain);
+    /* Resume section map updates.  Closing the scope is
+       sufficient.  */
+  }
 
   if (action == UPDATE_OR_RELOAD)
     {
This page took 0.040613 seconds and 4 git commands to generate.