|
From: Nicholas N. <n.n...@gm...> - 2009-05-17 22:42:56
|
On Mon, May 18, 2009 at 8:33 AM, Julian Seward <js...@ac...> wrote:
>>
>> It's probably nicer to allow NULL to be passed as the before_pp()
>> function, to save writing functions like this. Passing NULL works
>> with at least some of the other initialisation functions, eg.
>> VG_(track_*)().
>
> Oh, definitely. I just wasn't sure if that was allowable style
> (or even if it's possible). Since we have
>
> #define VG_TDICT_CALL(fn, args...) \
> ( tl_assert2(VG_(tdict).fn, \
> "you forgot to set VgToolInterface function '" #fn "'"), \
> VG_(tdict).fn(args) )
>
> then I'd have to test the fn at the call points, hence,
>
> VG_TDICT_CALL( tool_before_pp_Error, err );
>
> would become
>
> if (VG_(tdict).tool_before_pp_Error)
> VG_TDICT_CALL( tool_before_pp_Error, err );
>
> In short I wasn't aware of any macros to support checking whether a
> particular dictionary function is NULL or not. So played safe.
We have this:
#define VG_TRACK(fn, args...) \
do { \
if (VG_(tdict).track_##fn) \
VG_(tdict).track_##fn(args); \
} while(0)
It only applies to the VG_(track_*) functions. For most (all?) of the
others the function is mandatory, but in this case doing the test
should be fine. If you want to generalise, you could create a
VG_TDICT_CALL_OPTIONAL macro.
Hmm, I see that the print_extra_suppression_info() and
read_extra_suppression_info() functions are similar, but they don't
accept NULL. Perhaps they should, and then the empty functions could
be removed from Helgrind and DRD.
N
|