|
From: Julian S. <js...@ac...> - 2005-03-28 15:24:31
|
> > The registration-based scheme feels cluttered to me, because there are
> > more names and storage locations (global state) to keep track of. For
> > example, the tool makes a registration call:
> >
> > + VG_(basic_tool_funcs) (TL_(post_clo_init),
> > + TL_(instrument),
> > + TL_(fini));
> >
> > Now in the core, if I want to call one of these, first I have to find the
> > global variables that those pointers got stored in -- probably using
> > grep.
>
> Global variables? There are no global variables, the function pointers
> will all get stored in the single VgToolInterface struct.
Ah. I didn't realise that the struct exists on the core side; I thought
it only existed on the core side. (== I didn't understand that). That
zaps some of my objections.
> I think the patch is a lot closer to what you described and want than you
> realise. Perhaps it's unclear because it's only a first step and there's
> more cruft to remove (eg. the double-meaning of TL_). But it has a single
> struct, which I think is the main thing you want.
Yes, you could be right.
> Another confusing aspect currently is that vg_toolint.c defines lots of
> TL_ functions like this:
>
> void TL_(fini)(Int exitcode)
> {
> return (*VG_(tool_interface).tool_fini)(exitcode);
> }
>
> where TL_ here means "vgToolInternal_" and so is different to the TL_
> within the tools. So this is just a short-cut for your "tdict->fini(x)"
> example which the core can call. We could get rid of these, and just
> always use "tdict->fini(x)" to make it explicit. And then there are the
> VG_(defined_*) and VG_(missing_*) functions which further clutter things,
> and could possibly be removed.
That would be a nice clarification. I'd prefer to directly call
(*VG_(tool_interface).tool_fini)(exitcode)
rather than
TL_(fini)(Int exitcode)
even though it's more verbose -- less layers of abstraction is good.
Part of the reason I didn't even realise there was a tool_interface
struct on the core side was as a result of this hiding.
J
|