Change remove_target_sections to method on program_space
authorTom Tromey <tom@tromey.com>
Thu, 29 Oct 2020 21:04:33 +0000 (15:04 -0600)
committerTom Tromey <tom@tromey.com>
Thu, 29 Oct 2020 21:04:39 +0000 (15:04 -0600)
This changes remove_target_sections to be a method on program_space.
This makes sense because this function manipulates data that is
attached to the program space.

gdb/ChangeLog
2020-10-29  Tom Tromey  <tom@tromey.com>

* progspace.h (struct program_space) <remove_target_sections>:
Declare.
* exec.c (program_space::remove_target_sections): Now a method.
* exec.h (remove_target_sections): Don't declare.

gdb/ChangeLog
gdb/exec.c
gdb/exec.h
gdb/progspace.h
gdb/solib.c
gdb/symfile.c

index 1286d579505bffe5b76e280650e90fba06d9e74c..ce9c19363cec6cd847379ffbe8dfe3c0b88b701a 100644 (file)
@@ -1,3 +1,10 @@
+2020-10-29  Tom Tromey  <tom@tromey.com>
+
+       * progspace.h (struct program_space) <remove_target_sections>:
+       Declare.
+       * exec.c (program_space::remove_target_sections): Now a method.
+       * exec.h (remove_target_sections): Don't declare.
+
 2020-10-29  Tom Tromey  <tom@tromey.com>
 
        * inferior.c (delete_inferior): Update.
index 684f4dfc04164f8d7e1eacfbe9e37efb0206fea3..49a41967fc1b61197aa12c638b4a01cfe6ed3136 100644 (file)
@@ -653,34 +653,28 @@ add_target_sections_of_objfile (struct objfile *objfile)
    OWNER must be the same value passed to add_target_sections.  */
 
 void
-remove_target_sections (void *owner)
+program_space::remove_target_sections (void *owner)
 {
-  target_section_table *table = &current_program_space->target_sections;
-
   gdb_assert (owner != NULL);
 
-  auto it = std::remove_if (table->begin (),
-                           table->end (),
+  auto it = std::remove_if (target_sections.begin (),
+                           target_sections.end (),
                            [&] (target_section &sect)
                            {
                              return sect.owner == owner;
                            });
-  table->erase (it, table->end ());
+  target_sections.erase (it, target_sections.end ());
 
   /* If we don't have any more sections to read memory from,
      remove the file_stratum target from the stack of each
      inferior sharing the program space.  */
-  if (table->empty ())
+  if (target_sections.empty ())
     {
       scoped_restore_current_pspace_and_thread restore_pspace_thread;
-      program_space *curr_pspace = current_program_space;
 
       for (inferior *inf : all_inferiors ())
        {
-         if (inf->pspace != curr_pspace)
-           continue;
-
-         if (!inf->pspace->target_sections.empty ())
+         if (inf->pspace != this)
            continue;
 
          switch_to_inferior_no_thread (inf);
index 8590e78710ac50efb2f6c509af490a15631ecde9..d5b3cff38550a3800994a9e9a33f04e2a871b3b3 100644 (file)
@@ -92,10 +92,6 @@ extern enum target_xfer_status
 /* Set the loaded address of a section.  */
 extern void exec_set_section_address (const char *, int, CORE_ADDR);
 
-/* Remove all target sections owned by OWNER.  */
-
-extern void remove_target_sections (void *owner);
-
 /* Add the sections array defined by [SECTIONS..SECTIONS_END[ to the
    current set of target sections.  */
 
index fa5247f8ac209778474da073346019ce87292fab..f4e1107c6ece26d21456e75e1fc124f0e9981f23 100644 (file)
@@ -297,6 +297,9 @@ struct program_space
      space.  */
   bool empty ();
 
+  /* Remove all target sections owned by OWNER.  */
+  void remove_target_sections (void *owner);
+
   /* Unique ID number.  */
   int num = 0;
 
index baa1801635b7cbbdd99a96dff92f4955b474d5f0..64b2035cd895c51197c384b6cd209424b26077b9 100644 (file)
@@ -824,7 +824,7 @@ update_solib_list (int from_tty)
 
          /* Some targets' section tables might be referring to
             sections from so->abfd; remove them.  */
-         remove_target_sections (gdb);
+         current_program_space->remove_target_sections (gdb);
 
          free_so (gdb);
          gdb = *gdb_link;
@@ -1175,7 +1175,7 @@ clear_solib (void)
 
       current_program_space->so_list = so->next;
       gdb::observers::solib_unloaded.notify (so);
-      remove_target_sections (so);
+      current_program_space->remove_target_sections (so);
       free_so (so);
     }
 
@@ -1295,7 +1295,7 @@ reload_shared_libraries_1 (int from_tty)
          if (so->objfile && ! (so->objfile->flags & OBJF_USERLOADED)
              && !solib_used (so))
            so->objfile->unlink ();
-         remove_target_sections (so);
+         current_program_space->remove_target_sections (so);
          clear_so (so);
        }
 
index 493411fa417b95052189e43747292aa1e117b0d7..504132754b050d60729c0cc0c5907d5f36eb1160 100644 (file)
@@ -3709,7 +3709,7 @@ symfile_free_objfile (struct objfile *objfile)
 {
   /* Remove the target sections owned by this objfile.  */
   if (objfile != NULL)
-    remove_target_sections ((void *) objfile);
+    current_program_space->remove_target_sections ((void *) objfile);
 }
 
 /* Wrapper around the quick_symbol_functions expand_symtabs_matching "method".
This page took 0.037671 seconds and 4 git commands to generate.