This is the mail archive of the
mailing list for the GDB project.
Re: [PATCH v4 3/9] add target method delegation
- From: Pedro Alves <palves at redhat dot com>
- To: Tom Tromey <tromey at redhat dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Fri, 08 Nov 2013 16:30:57 +0000
- Subject: Re: [PATCH v4 3/9] add target method delegation
- Authentication-results: sourceware.org; auth=none
- References: <1382464769-2465-1-git-send-email-tromey at redhat dot com> <1382464769-2465-4-git-send-email-tromey at redhat dot com> <526E8B54 dot 8040104 at redhat dot com> <87eh75cmig dot fsf at fleche dot redhat dot com>
On 10/28/2013 05:51 PM, Tom Tromey wrote:
>>>>>> "Pedro" == Pedro Alves <email@example.com> writes:
> Pedro> Could you please split out the patch for the second problem? I
> Pedro> think it'll be a small one.
> Pedro> What's the plan for the existing target methods that
> Pedro> currently already do a similar beneath lookup? I'd like it that
> Pedro> there's be at least a plan, so we don't end up with yet another
> Pedro> way of doing things, two incomplete transitions, and no clear direction.
> Do you mean things like target_detach?
> If so, then I think these are two different things.
> target.h declares things both for users of the target API and for the
> implementation of targets.
> Something like target_detach is a public API. My understanding of the
> current scheme is that a public-facing method can either be implemented
> by a function like target_detach, which encodes all the needed logic; or
> by a macro that just calls into the target_ops, in which case the method
> must use the inherit/default machinery.
Right. I'm thinking the public functions that do the run
time target beneath walk, instead of the inherit/default
mechanism, and about having them defer to the delegation version,
avoiding the need to implement basically the same twice.
Like, to take a simple example:
struct target_ops *t;
for (t = current_target.beneath; t != NULL; t = t->beneath)
if (t->to_has_all_memory (t))
#define target_has_all_memory_1 \
target_detach becomes (completely untested):
target_detach (char *args, int from_tty)
struct target_ops* t;
if (gdbarch_has_global_breakpoints (target_gdbarch ()))
/* Don't remove global breakpoints here. They're removed on
disconnection from the target. */
/* If we're in breakpoints-always-inserted mode, have to remove
them before detaching. */
remove_breakpoints_pid (ptid_get_pid (inferior_ptid));
target_delegate_detach (¤t_target, args, from_tty);
fprintf_unfiltered (gdb_stdlog, "target_detach (%s, %d)\n",
etc. So basically, whether that was in the plan. Is
there something about the delegate mechanism that would
make this not work? If so, could we make it work? Having
this considered was the sort of plan thing I had in mind.