Re: [PATCH 5/9] Remove current_target_sections macro

Simon Marchi
2020-07-22T12:21:02Z

On 2020-07-21 11:34 p.m., Tom Tromey wrote:
> 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 ();

I hoped that the call to set_current_program_space could be removed, but no. exec_close
ends up calling remove_target_sections, which uses current_program_space.

But once we make remove_target_sections take a program_space parameter, I think it will
be fine to remove it.

Simon