[PATCH 5/9] Remove current_target_sections macro

Tom Tromey
2020-07-22T03:34:57Z

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

gdb/ChangeLog
2020-07-21 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 | 23 +++++++++++++----------
gdb/progspace.h | 4 ----
gdb/solib-dsbt.c | 6 +++---
gdb/solib-svr4.c | 6 +++---
5 files changed, 31 insertions(+), 20 deletions(-)

diff --git a/gdb/exec.c b/gdb/exec.c
index 6ca867ab53e..e2a0cae787c 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);
- clear_section_table (current_target_sections);
+ clear_section_table (&ss->target_sections);
ss->exec_close ();
}
}
@@ -660,7 +660,8 @@ add_target_sections (void *owner,
struct target_section *sections_end)
{
int count;
- struct target_section_table *table = current_target_sections;
+ struct target_section_table *table
+ = &current_program_space->target_sections;

count = sections_end - sections;

@@ -700,7 +701,8 @@ add_target_sections (void *owner,
void
add_target_sections_of_objfile (struct objfile *objfile)
{
- struct target_section_table *table = current_target_sections;
+ struct target_section_table *table
+ = &current_program_space->target_sections;
struct obj_section *osect;
int space;
unsigned count = 0;
@@ -747,7 +749,8 @@ void
remove_target_sections (void *owner)
{
struct target_section *src, *dest;
- struct target_section_table *table = current_target_sections;
+ struct target_section_table *table
+ = &current_program_space->target_sections;

gdb_assert (owner != NULL);

@@ -1006,7 +1009,7 @@ section_table_xfer_memory_partial (gdb_byte *readbuf, const gdb_byte *writebuf,
struct target_section_table *
exec_target::get_section_table ()
{
- return current_target_sections;
+ return &current_program_space->target_sections;
}

enum target_xfer_status
@@ -1105,7 +1108,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"));
}
@@ -1131,7 +1134,7 @@ set_section_command (const char *args, int from_tty)
/* Parse out new virtual address. */
secaddr = parse_and_eval_address (args);

- table = current_target_sections;
+ table = &current_program_space->target_sections;
for (p = table->sections; p < table->sections_end; p++)
{
if (!strncmp (secname, bfd_section_name (p->the_bfd_section), seclen)
@@ -1161,7 +1164,7 @@ exec_set_section_address (const char *filename, int index, CORE_ADDR address)
struct target_section *p;
struct target_section_table *table;

- table = current_target_sections;
+ table = &current_program_space->target_sections;
for (p = table->sections; p < table->sections_end; p++)
{
if (filename_cmp (filename,
@@ -1179,8 +1182,8 @@ exec_target::has_memory ()
{
/* We can provide memory if we have any file/target sections to read
from. */
- return (current_target_sections->sections
- != current_target_sections->sections_end);
+ return (current_program_space->target_sections.sections
+ != current_program_space->target_sections.sections_end);
}

char *
diff --git a/gdb/progspace.h b/gdb/progspace.h
index 777bef2e38e..ef39f8a1dab 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 94a6ac83754..ae76bb74c05 100644
--- a/gdb/solib-dsbt.c
+++ b/gdb/solib-dsbt.c
@@ -424,12 +424,12 @@ scan_dyntag (int dyntag, bfd *abfd, CORE_ADDR *ptr)
if (sect == NULL)
return 0;

- for (target_section = current_target_sections->sections;
- target_section < current_target_sections->sections_end;
+ for (target_section = current_program_space->target_sections->sections;
+ target_section < current_program_space->target_sections->sections_end;
target_section++)
if (sect == target_section->the_bfd_section)
break;
- if (target_section < current_target_sections->sections_end)
+ if (target_section < current_program_space->target_sections->sections_end)
dyn_addr = target_section->addr;
else
{
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
index 570450c5400..520d9e8ed12 100644
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -608,12 +608,12 @@ scan_dyntag (const int desired_dyntag, bfd *abfd, CORE_ADDR *ptr,
if (sect == NULL)
return 0;

- for (target_section = current_target_sections->sections;
- target_section < current_target_sections->sections_end;
+ for (target_section = current_program_space->target_sections.sections;
+ target_section < current_program_space->target_sections.sections_end;
target_section++)
if (sect == target_section->the_bfd_section)
break;
- if (target_section < current_target_sections->sections_end)
+ if (target_section < current_program_space->target_sections.sections_end)
dyn_addr = target_section->addr;
else
{
--
2.17.2