Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH v2 12/16] Change remove_target_sections to method on program_space
Date: Mon, 19 Oct 2020 15:44:25 -0600	[thread overview]
Message-ID: <20201019214429.13815-13-tom@tromey.com> (raw)
In-Reply-To: <20201019214429.13815-1-tom@tromey.com>

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-19  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   |  7 +++++++
 gdb/exec.c      | 15 ++++++---------
 gdb/exec.h      |  4 ----
 gdb/progspace.h |  3 +++
 gdb/solib.c     |  6 +++---
 gdb/symfile.c   |  2 +-
 6 files changed, 20 insertions(+), 17 deletions(-)

diff --git a/gdb/exec.c b/gdb/exec.c
index 4a82b38ea41..8952a99bf1a 100644
--- a/gdb/exec.c
+++ b/gdb/exec.c
@@ -651,31 +651,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)
+	  if (inf->pspace != this)
 	    continue;
 
 	  if (!inf->pspace->target_sections.empty ())
diff --git a/gdb/exec.h b/gdb/exec.h
index 8590e78710a..d5b3cff3855 100644
--- a/gdb/exec.h
+++ b/gdb/exec.h
@@ -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.  */
 
diff --git a/gdb/progspace.h b/gdb/progspace.h
index fa5247f8ac2..f4e1107c6ec 100644
--- a/gdb/progspace.h
+++ b/gdb/progspace.h
@@ -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;
 
diff --git a/gdb/solib.c b/gdb/solib.c
index baa1801635b..64b2035cd89 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -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);
 	}
 
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 493411fa417..504132754b0 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -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".
-- 
2.17.2


  parent reply	other threads:[~2020-10-19 21:44 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-19 21:44 [PATCH v2 00/16] Remove some macros from exec.h and progspace.h Tom Tromey
2020-10-19 21:44 ` [PATCH v2 01/16] Add target_section constructor Tom Tromey
2020-10-19 21:44 ` [PATCH v2 02/16] Remove exec_filename macro Tom Tromey
2020-10-19 21:44 ` [PATCH v2 03/16] Change exec_close to be a method on program_space Tom Tromey
2020-10-19 21:44 ` [PATCH v2 04/16] Remove commented-out code from gcore.c Tom Tromey
2020-10-20 14:01   ` [PP?] " Simon Marchi
2020-10-29  1:19     ` Tom Tromey
2020-10-19 21:44 ` [PATCH v2 05/16] Remove exec_bfd_mtime define Tom Tromey
2020-10-19 21:44 ` [PATCH v2 06/16] Remove current_target_sections macro Tom Tromey
2020-10-19 21:44 ` [PATCH v2 07/16] Remove the exec_bfd macro Tom Tromey
2020-10-20 14:24   ` Simon Marchi
2020-10-20 21:20     ` Tom Tromey
2020-10-20 21:34       ` Simon Marchi
2020-10-19 21:44 ` [PATCH v2 08/16] Change program_space::ebfd to a gdb_bfd_ref_ptr Tom Tromey
2020-10-19 21:44 ` [PATCH v2 09/16] Remove symfile_objfile macro Tom Tromey
2020-10-19 21:44 ` [PATCH v2 10/16] Change clear_program_space_solib_cache to method on program_space Tom Tromey
2020-10-19 21:44 ` [PATCH v2 11/16] Change program_space_empty_p " Tom Tromey
2020-10-19 21:44 ` Tom Tromey [this message]
2020-10-20 14:40   ` [PP?] [PATCH v2 12/16] Change remove_target_sections " Simon Marchi
2020-10-29  1:24     ` Tom Tromey
2020-10-19 21:44 ` [PATCH v2 13/16] Change add_target_sections " Tom Tromey
2020-10-19 21:44 ` [PATCH v2 14/16] Change add_target_sections_of_objfile " Tom Tromey
2020-10-19 21:44 ` [PATCH v2 15/16] Don't change current program space in exec_target::close Tom Tromey
2020-10-19 21:44 ` [PATCH v2 16/16] Remove call to exec_close Tom Tromey
2020-10-20 14:46 ` [PP?] [PATCH v2 00/16] Remove some macros from exec.h and progspace.h Simon Marchi
2020-10-29 21:06   ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201019214429.13815-13-tom@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox