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 06/16] Remove current_target_sections macro
Date: Mon, 19 Oct 2020 15:44:19 -0600	[thread overview]
Message-ID: <20201019214429.13815-7-tom@tromey.com> (raw)
In-Reply-To: <20201019214429.13815-1-tom@tromey.com>

This removes the current_target_sections macro, replacing it with uses
of the appropriate member from current_program_space.

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

	* progspace.h (current_target_sections): Remove macro.
	* solib-svr4.c (scan_dyntag): Update.
	* solib-dsbt.c (scan_dyntag): Update.
	* exec.c (exec_target::close): Update.
	(add_target_sections, add_target_sections_of_objfile)
	(remove_target_sections, exec_target::get_section_table)
	(exec_target::files_info, set_section_command)
	(exec_set_section_address, exec_target::has_memory)
	(exec_target::has_memory): Update.
---
 gdb/ChangeLog    | 12 ++++++++++++
 gdb/exec.c       | 18 +++++++++---------
 gdb/progspace.h  |  4 ----
 gdb/solib-dsbt.c |  2 +-
 gdb/solib-svr4.c |  2 +-
 5 files changed, 23 insertions(+), 15 deletions(-)

diff --git a/gdb/exec.c b/gdb/exec.c
index 22be006a9c0..013fcfc1356 100644
--- a/gdb/exec.c
+++ b/gdb/exec.c
@@ -159,7 +159,7 @@ exec_target::close ()
   for (struct program_space *ss : program_spaces)
     {
       set_current_program_space (ss);
-      current_target_sections->clear ();
+      ss->target_sections.clear ();
       ss->exec_close ();
     }
 }
@@ -591,7 +591,7 @@ void
 add_target_sections (void *owner,
 		     const target_section_table &sections)
 {
-  target_section_table *table = current_target_sections;
+  target_section_table *table = &current_program_space->target_sections;
 
   if (!sections.empty ())
     {
@@ -626,7 +626,7 @@ add_target_sections (void *owner,
 void
 add_target_sections_of_objfile (struct objfile *objfile)
 {
-  target_section_table *table = current_target_sections;
+  target_section_table *table = &current_program_space->target_sections;
   struct obj_section *osect;
 
   gdb_assert (objfile != nullptr);
@@ -649,7 +649,7 @@ add_target_sections_of_objfile (struct objfile *objfile)
 void
 remove_target_sections (void *owner)
 {
-  target_section_table *table = current_target_sections;
+  target_section_table *table = &current_program_space->target_sections;
 
   gdb_assert (owner != NULL);
 
@@ -893,7 +893,7 @@ section_table_xfer_memory_partial (gdb_byte *readbuf, const gdb_byte *writebuf,
 target_section_table *
 exec_target::get_section_table ()
 {
-  return current_target_sections;
+  return &current_program_space->target_sections;
 }
 
 enum target_xfer_status
@@ -991,7 +991,7 @@ void
 exec_target::files_info ()
 {
   if (exec_bfd)
-    print_section_info (current_target_sections, exec_bfd);
+    print_section_info (&current_program_space->target_sections, exec_bfd);
   else
     puts_filtered (_("\t<no file loaded>\n"));
 }
@@ -1015,7 +1015,7 @@ set_section_command (const char *args, int from_tty)
   /* Parse out new virtual address.  */
   secaddr = parse_and_eval_address (args);
 
-  for (target_section &p : *current_target_sections)
+  for (target_section &p : current_program_space->target_sections)
     {
       if (!strncmp (secname, bfd_section_name (p.the_bfd_section), seclen)
 	  && bfd_section_name (p.the_bfd_section)[seclen] == '\0')
@@ -1041,7 +1041,7 @@ set_section_command (const char *args, int from_tty)
 void
 exec_set_section_address (const char *filename, int index, CORE_ADDR address)
 {
-  for (target_section &p : *current_target_sections)
+  for (target_section &p : current_program_space->target_sections)
     {
       if (filename_cmp (filename,
 			bfd_get_filename (p.the_bfd_section->owner)) == 0
@@ -1058,7 +1058,7 @@ exec_target::has_memory ()
 {
   /* We can provide memory if we have any file/target sections to read
      from.  */
-  return !current_target_sections->empty ();
+  return !current_program_space->target_sections.empty ();
 }
 
 char *
diff --git a/gdb/progspace.h b/gdb/progspace.h
index 6dcec9c96f7..03634034ba0 100644
--- a/gdb/progspace.h
+++ b/gdb/progspace.h
@@ -365,10 +365,6 @@ struct address_space
 
 #define symfile_objfile current_program_space->symfile_object_file
 
-/* The set of target sections matching the sections mapped into the
-   current program space.  */
-#define current_target_sections (&current_program_space->target_sections)
-
 /* The list of all program spaces.  There's always at least one.  */
 extern std::vector<struct program_space *>program_spaces;
 
diff --git a/gdb/solib-dsbt.c b/gdb/solib-dsbt.c
index 57c7ab18430..6f610c511e0 100644
--- a/gdb/solib-dsbt.c
+++ b/gdb/solib-dsbt.c
@@ -424,7 +424,7 @@ scan_dyntag (int dyntag, bfd *abfd, CORE_ADDR *ptr)
     return 0;
 
   bool found = false;
-  for (target_section &target_section : *current_target_sections)
+  for (target_section &target_section : current_program_space->target_sections)
     if (sect == target_section.the_bfd_section)
       {
 	dyn_addr = target_section.addr;
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
index a780f8d3467..faaba471a19 100644
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -608,7 +608,7 @@ scan_dyntag (const int desired_dyntag, bfd *abfd, CORE_ADDR *ptr,
     return 0;
 
   bool found = false;
-  for (target_section &target_section : *current_target_sections)
+  for (target_section &target_section : current_program_space->target_sections)
     if (sect == target_section.the_bfd_section)
       {
 	dyn_addr = target_section.addr;
-- 
2.17.2


  parent reply	other threads:[~2020-10-19 21:45 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 ` Tom Tromey [this message]
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 ` [PATCH v2 12/16] Change remove_target_sections " Tom Tromey
2020-10-20 14:40   ` [PP?] " 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-7-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