From: Simon Marchi <simark@simark.ca>
To: Tom Tromey <tom@tromey.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH v2 07/16] Remove the exec_bfd macro
Date: Tue, 20 Oct 2020 10:24:56 -0400 [thread overview]
Message-ID: <8c4c1ec0-cdc9-ebc9-26fa-216f59493d9b@simark.ca> (raw)
In-Reply-To: <20201019214429.13815-8-tom@tromey.com>
On 2020-10-19 5:44 p.m., Tom Tromey wrote:
> This removes the exec_bfd macro, in favor of new accessors on
> program_space. In one spot the accessor can't be used; but this is
> still a big improvement over the macro, IMO.
Maybe just check for lines that are too long after the replacement.
A quick way I use is:
$ git show | sed 's|\t| |' | less
And when in less, I search for:
^\+.{81}
That highlights the lines that are added that are too long.
> @@ -480,18 +482,20 @@ exec_file_attach (const char *filename, int from_tty)
> gdb_bfd_errmsg (bfd_get_error (), matching).c_str ());
> }
>
> - target_section_table sections = build_section_table (exec_bfd);
> + target_section_table sections
> + = build_section_table (current_program_space->exec_bfd ());
>
> - current_program_space->ebfd_mtime = bfd_get_mtime (exec_bfd);
> + current_program_space->ebfd_mtime
> + = bfd_get_mtime (current_program_space->exec_bfd ());
>
> validate_files ();
>
> - set_gdbarch_from_file (exec_bfd);
> + set_gdbarch_from_file (current_program_space->exec_bfd ());
>
> /* Add the executable's sections to the current address spaces'
> list of sections. This possibly pushes the exec_ops
> target. */
> - add_target_sections (&exec_bfd, sections);
> + add_target_sections (¤t_program_space->ebfd, sections);
It's odd that the owner of these sections is the address of the ebfd
field in the program_space structure, and not the bfd pointer itself.
Do you know if this is done on purpose?
The only reason I would see is if we wanted a stable "owner" value even
when the exec bfd changes. But I don't see any comment to that effect.
Looking at the code, it looks like adding and removing the target
sections is tied to setting and unsetting the exec bfd.
- exec_file_attach sets the exec bfd and adds the corresponding target
sections
- program_space::close unsets the exec bfd and removes the
corresponding target sections
I don't see anything that could change the value of exec bfd in the mean
time, that would make the "owner" value of these sections stale. So I
believe it would be safe to use `current_program_space->exec_bfd ()` as
the owner.
Otherwise, this patch LGTM.
Simon
next prev parent reply other threads:[~2020-10-20 14:25 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 [this message]
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=8c4c1ec0-cdc9-ebc9-26fa-216f59493d9b@simark.ca \
--to=simark@simark.ca \
--cc=gdb-patches@sourceware.org \
--cc=tom@tromey.com \
/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