> * Steven Rostedt (
rostedt@goodmis.org) wrote:
> > On Fri, 2010-04-30 at 15:06 -0400, Mathieu Desnoyers wrote:
> >
> > > > If it is possible sure, but that's the point. Where do you add the
> > > > check? The typecast is in the C code that is constant for all trace
> > > > events.
> > >
> > > You can add the call to the static inline type check directly within the
> > > generated probe function, right after the local variable declarations.
> >
> > Well, one thing, the callback is not going to be the same as the
> > DECLARE_TRACE() because the prototype ends with "void *data", and the
> > function being called actually uses the type of that data.
> >
> > We now will have:
> >
> > DEFINE_TRACE(mytracepoint, int myarg, myarg);
> >
> > void mycallback(int myarg, struct mystuct *mydata);
> >
> > register_trace_mytracepoint_data(mycallback, mydata)
> >
> > There's no place in DEFINE_TRACE to be able to test the type of data
> > that is being passed back. I could make the calling function be:
> >
> > void mycallback(int myarg, void *data)
> > {
> > struct mystruct *mydata = data;
> > [...]
> >
> > Because the data is defined uniquely by the caller that registers a
> > callback. Each function can register its own data type.
>
> Yep. There would need to be a cast from void * to struct mystruct *
> at the beginning of the callback as you propose here. I prefer this cast
> to be explicit (as proposed here) rather than hidden within the entire
> function call (void *) cast.
>