This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 1/3] Move core_bfd to program space
On 05/04/2018 04:41 PM, Tom Tromey wrote:
>>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:
>
> Pedro> This moves the core_bfd global to be a field of the program space. It
> Pedro> then replaces core_bfd with a macro to avoid a massive patch -- the
> Pedro> same approach taken for various other program space fields.
>
> I am curious to know whether you would want to remove this macro in the
> future. I don't mean that you should do it -- just more a question of
> what direction to go. There are other macros like this too:
> symfile_objfile, object_files, exec_bfd, ...
Yeah, I have no plans to do that myself, but I wouldn't oppose
changing it.
> Also, I can't remember why I moved core_bfd to the progspace. Would it
> be better to have it just be a member of the target? Or maybe in your
> design these end up being basically equivalent, because core targets are
> inherently single-process?
Yeah, I guess program space just felt natural given exec_bfd is there
too. Not sure about putting it in the target. Making it a data field of
target_ops I think would be odd. It might work if we replaced it
with something like (in the multi-target branch):
bfd *
core_bfd ()
{
if (core_target *core
= dynamic_cast<core_target *>
(current_inferior ()->process_target ()))
return core->core_bfd;
return nullptr;
}
though that's a bit smelly, and when I see dynamic_cast
I can't avoid thinking about how inefficient it is. :-)
Alternatively, we could make core_bfd() a virtual method of
target_ops instead, that has most targets except the
core_target target return NULL.
Not sure. Putting it in program space just seemed like an
easy and OK thing to do.
Thanks,
Pedro Alves