Change add_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:40 +0000 (15:04 -0600)
This changes add_target_sections to be a method on program_space.
Like the earlier change to remove_target_sections, this makes sense
because this function is manipulating data that is stored on the
program space.

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

* solib.c (solib_map_sections): Update.
* exec.c (program_space::add_target_sections): Now a method.
(exec_file_attach): Update.
* exec.h (add_target_sections): Don't declare.
* progspace.h (struct program_space) <add_target_sections>:
Declare.

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

index ce9c19363cec6cd847379ffbe8dfe3c0b88b701a..3aeb0d12d1c527ac4121e76e7a7f9dccc058924c 100644 (file)
@@ -1,3 +1,12 @@
+2020-10-29  Tom Tromey  <tom@tromey.com>
+
+       * solib.c (solib_map_sections): Update.
+       * exec.c (program_space::add_target_sections): Now a method.
+       (exec_file_attach): Update.
+       * exec.h (add_target_sections): Don't declare.
+       * progspace.h (struct program_space) <add_target_sections>:
+       Declare.
+
 2020-10-29  Tom Tromey  <tom@tromey.com>
 
        * progspace.h (struct program_space) <remove_target_sections>:
index 49a41967fc1b61197aa12c638b4a01cfe6ed3136..a57399b0e34ab2bdc8abeba3f6c636a1cbfc0257 100644 (file)
@@ -497,7 +497,8 @@ exec_file_attach (const char *filename, int from_tty)
       /* Add the executable's sections to the current address spaces'
         list of sections.  This possibly pushes the exec_ops
         target.  */
-      add_target_sections (&current_program_space->ebfd, sections);
+      current_program_space->add_target_sections (&current_program_space->ebfd,
+                                                 sections);
 
       /* Tell display code (if any) about the changed file name.  */
       if (deprecated_exec_file_display_hook)
@@ -594,28 +595,25 @@ build_section_table (struct bfd *some_bfd)
    current set of target sections.  */
 
 void
-add_target_sections (void *owner,
-                    const target_section_table &sections)
+program_space::add_target_sections (void *owner,
+                                   const target_section_table &sections)
 {
-  target_section_table *table = &current_program_space->target_sections;
-
   if (!sections.empty ())
     {
       for (const target_section &s : sections)
        {
-         table->push_back (s);
-         table->back ().owner = owner;
+         target_sections.push_back (s);
+         target_sections.back ().owner = owner;
        }
 
       scoped_restore_current_pspace_and_thread restore_pspace_thread;
-      program_space *curr_pspace = current_program_space;
 
       /* If these are the first file sections we can provide memory
         from, push the file_stratum target.  Must do this in all
         inferiors sharing the program space.  */
       for (inferior *inf : all_inferiors ())
        {
-         if (inf->pspace != curr_pspace)
+         if (inf->pspace != this)
            continue;
 
          if (inf->target_is_pushed (&exec_ops))
index d5b3cff38550a3800994a9e9a33f04e2a871b3b3..3aa248527c9e9a680c0b749315bb3e7ff0c914e2 100644 (file)
@@ -92,12 +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);
 
-/* Add the sections array defined by [SECTIONS..SECTIONS_END[ to the
-   current set of target sections.  */
-
-extern void add_target_sections (void *owner,
-                                const target_section_table &sections);
-
 /* Add the sections of OBJFILE to the current set of target sections.
  * OBJFILE owns the new target sections.  */
 
index f4e1107c6ece26d21456e75e1fc124f0e9981f23..92a7942c560eaa7be9f3739ce7e0ad11402c13d7 100644 (file)
@@ -300,6 +300,11 @@ struct program_space
   /* Remove all target sections owned by OWNER.  */
   void remove_target_sections (void *owner);
 
+  /* Add the sections array defined by SECTIONS to the
+     current set of target sections.  */
+  void add_target_sections (void *owner,
+                           const target_section_table &sections);
+
   /* Unique ID number.  */
   int num = 0;
 
index 64b2035cd895c51197c384b6cd209424b26077b9..e7dbde6a7f64dd1e4944ebdc65ab4f96661a9b75 100644 (file)
@@ -578,7 +578,7 @@ solib_map_sections (struct so_list *so)
      section tables.  Do this immediately after mapping the object so
      that later nodes in the list can query this object, as is needed
      in solib-osf.c.  */
-  add_target_sections (so, *so->sections);
+  current_program_space->add_target_sections (so, *so->sections);
 
   return 1;
 }
This page took 0.03356 seconds and 4 git commands to generate.