01917d
http://sourceware.org/ml/gdb-cvs/2013-06/msg00013.html
01917d
01917d
### src/gdb/ChangeLog	2013/06/04 12:50:20	1.15681
01917d
### src/gdb/ChangeLog	2013/06/04 12:53:33	1.15682
01917d
## -1,5 +1,24 @@
01917d
 2013-06-04  Gary Benson  <gbenson@redhat.com>
01917d
 
01917d
+	* objfiles.h (inhibit_section_map_updates): New function
01917d
+	declaration.
01917d
+	(resume_section_map_updates): Likewise.
01917d
+	(resume_section_map_updates_cleanup): Likewise.
01917d
+	* objfiles.c (objfile_pspace_info): Removed field
01917d
+	"objfiles_changed_p".  New fields "new_objfiles_available",
01917d
+	"section_map_dirty" and "inhibit_updates".
01917d
+	(allocate_objfile): Set new_objfiles_available.
01917d
+	(free_objfile): Set section_map_dirty.
01917d
+	(objfile_relocate1): Likewise.
01917d
+	(in_plt_section): Likewise.
01917d
+	(find_pc_section): Update the conditions under which the
01917d
+	section map will be updated.
01917d
+	(inhibit_section_map_updates): New function.
01917d
+	(resume_section_map_updates): Likewise.
01917d
+	(resume_section_map_updates_cleanup): Likewise.
01917d
+
01917d
+2013-06-04  Gary Benson  <gbenson@redhat.com>
01917d
+
01917d
 	* probe.h (get_probe_argument_count): New declaration.
01917d
 	(evaluate_probe_argument): Likewise.
01917d
 	* probe.c (get_probe_argument_count): New function.
01917d
--- src/gdb/objfiles.c	2013/05/06 19:15:17	1.160
01917d
+++ src/gdb/objfiles.c	2013/06/04 12:53:34	1.161
01917d
@@ -67,9 +67,18 @@
01917d
 
01917d
 struct objfile_pspace_info
01917d
 {
01917d
-  int objfiles_changed_p;
01917d
   struct obj_section **sections;
01917d
   int num_sections;
01917d
+
01917d
+  /* Nonzero if object files have been added since the section map
01917d
+     was last updated.  */
01917d
+  int new_objfiles_available;
01917d
+
01917d
+  /* Nonzero if the section map MUST be updated before use.  */
01917d
+  int section_map_dirty;
01917d
+
01917d
+  /* Nonzero if section map updates should be inhibited if possible.  */
01917d
+  int inhibit_updates;
01917d
 };
01917d
 
01917d
 /* Per-program-space data key.  */
01917d
@@ -317,7 +326,7 @@
01917d
   objfile->flags |= flags;
01917d
 
01917d
   /* Rebuild section map next time we need it.  */
01917d
-  get_objfile_pspace_data (objfile->pspace)->objfiles_changed_p = 1;
01917d
+  get_objfile_pspace_data (objfile->pspace)->new_objfiles_available = 1;
01917d
 
01917d
   return objfile;
01917d
 }
01917d
@@ -646,7 +655,7 @@
01917d
   obstack_free (&objfile->objfile_obstack, 0);
01917d
 
01917d
   /* Rebuild section map next time we need it.  */
01917d
-  get_objfile_pspace_data (objfile->pspace)->objfiles_changed_p = 1;
01917d
+  get_objfile_pspace_data (objfile->pspace)->section_map_dirty = 1;
01917d
 
01917d
   xfree (objfile);
01917d
 }
01917d
@@ -826,7 +835,7 @@
01917d
   }
01917d
 
01917d
   /* Rebuild section map next time we need it.  */
01917d
-  get_objfile_pspace_data (objfile->pspace)->objfiles_changed_p = 1;
01917d
+  get_objfile_pspace_data (objfile->pspace)->section_map_dirty = 1;
01917d
 
01917d
   /* Update the table in exec_ops, used to read memory.  */
01917d
   ALL_OBJFILE_OSECTIONS (objfile, s)
01917d
@@ -1291,11 +1300,14 @@
01917d
 update_section_map (struct program_space *pspace,
01917d
 		    struct obj_section ***pmap, int *pmap_size)
01917d
 {
01917d
+  struct objfile_pspace_info *pspace_info;
01917d
   int alloc_size, map_size, i;
01917d
   struct obj_section *s, **map;
01917d
   struct objfile *objfile;
01917d
 
01917d
-  gdb_assert (get_objfile_pspace_data (pspace)->objfiles_changed_p != 0);
01917d
+  pspace_info = get_objfile_pspace_data (pspace);
01917d
+  gdb_assert (pspace_info->section_map_dirty != 0
01917d
+	      || pspace_info->new_objfiles_available != 0);
01917d
 
01917d
   map = *pmap;
01917d
   xfree (map);
01917d
@@ -1365,7 +1377,9 @@
01917d
     return s;
01917d
 
01917d
   pspace_info = get_objfile_pspace_data (current_program_space);
01917d
-  if (pspace_info->objfiles_changed_p != 0)
01917d
+  if (pspace_info->section_map_dirty
01917d
+      || (pspace_info->new_objfiles_available
01917d
+	  && !pspace_info->inhibit_updates))
01917d
     {
01917d
       update_section_map (current_program_space,
01917d
 			  &pspace_info->sections,
01917d
@@ -1373,7 +1387,8 @@
01917d
 
01917d
       /* Don't need updates to section map until objfiles are added,
01917d
          removed or relocated.  */
01917d
-      pspace_info->objfiles_changed_p = 0;
01917d
+      pspace_info->new_objfiles_available = 0;
01917d
+      pspace_info->section_map_dirty = 0;
01917d
     }
01917d
 
01917d
   /* The C standard (ISO/IEC 9899:TC2) requires the BASE argument to
01917d
@@ -1414,14 +1429,38 @@
01917d
 }
01917d
 
01917d
 
01917d
-/* Set objfiles_changed_p so section map will be rebuilt next time it
01917d
+/* Set section_map_dirty so section map will be rebuilt next time it
01917d
    is used.  Called by reread_symbols.  */
01917d
 
01917d
 void
01917d
 objfiles_changed (void)
01917d
 {
01917d
   /* Rebuild section map next time we need it.  */
01917d
-  get_objfile_pspace_data (current_program_space)->objfiles_changed_p = 1;
01917d
+  get_objfile_pspace_data (current_program_space)->section_map_dirty = 1;
01917d
+}
01917d
+
01917d
+/* See comments in objfiles.h.  */
01917d
+
01917d
+void
01917d
+inhibit_section_map_updates (struct program_space *pspace)
01917d
+{
01917d
+  get_objfile_pspace_data (pspace)->inhibit_updates = 1;
01917d
+}
01917d
+
01917d
+/* See comments in objfiles.h.  */
01917d
+
01917d
+void
01917d
+resume_section_map_updates (struct program_space *pspace)
01917d
+{
01917d
+  get_objfile_pspace_data (pspace)->inhibit_updates = 0;
01917d
+}
01917d
+
01917d
+/* See comments in objfiles.h.  */
01917d
+
01917d
+void
01917d
+resume_section_map_updates_cleanup (void *arg)
01917d
+{
01917d
+  resume_section_map_updates (arg);
01917d
 }
01917d
 
01917d
 /* The default implementation for the "iterate_over_objfiles_in_search_order"
01917d
--- src/gdb/objfiles.h	2013/05/06 19:15:17	1.106
01917d
+++ src/gdb/objfiles.h	2013/06/04 12:53:34	1.107
01917d
@@ -501,6 +501,22 @@
01917d
    modules.  */
01917d
 DECLARE_REGISTRY(objfile);
01917d
 
01917d
+/* In normal use, the section map will be rebuilt by find_pc_section
01917d
+   if objfiles have been added, removed or relocated since it was last
01917d
+   called.  Calling inhibit_section_map_updates will inhibit this
01917d
+   behavior until resume_section_map_updates is called.  If you call
01917d
+   inhibit_section_map_updates you must ensure that every call to
01917d
+   find_pc_section in the inhibited region relates to a section that
01917d
+   is already in the section map and has not since been removed or
01917d
+   relocated.  */
01917d
+extern void inhibit_section_map_updates (struct program_space *pspace);
01917d
+
01917d
+/* Resume automatically rebuilding the section map as required.  */
01917d
+extern void resume_section_map_updates (struct program_space *pspace);
01917d
+
01917d
+/* Version of the above suitable for use as a cleanup.  */
01917d
+extern void resume_section_map_updates_cleanup (void *arg);
01917d
+
01917d
 extern void default_iterate_over_objfiles_in_search_order
01917d
   (struct gdbarch *gdbarch,
01917d
    iterate_over_objfiles_in_search_order_cb_ftype *cb,