On Thu, 2015-10-29 at 16:59 -0700, Tony Lee wrote:
// Replace all instance of calling of egl_*() function with the
following block:
{
// local static that control and if the special diag code will be
call.
static struct { int control; int value; char* file=__FILE__; int
line=__LINE__; } oCtrl;
if (oCtrl->control==NOT_REGISTER) my_diag_register(oCtrl);
else if (oCtrl->control==LOG_DIAG) my_diag_call(oCtrl);
egl_*(....) // call the same function usb_*() function
}
With this, I like to dynamically turn on/off the call to
my_diag_call() at run time.
If it is possible, is there any similar "code transformation" .py
script I can follow to figure out how to do this myself?
Thanks
-Tony
p.s. On a related note, I love to see a sample gcc-plugin .py script
that wrap C function() call with profiling code that collect call
count and call duration with rdtsc, etc.
Sadly, the gcc-python-plugin doesn't yet support modifying the code
being compiled, just inspecting it.
I'd be in favor of patches that add such support, but am swamped with
other work right now (feature freeze for gcc 6 is in a week and a
half...).
FWIW, if you're on Linux you might be able to achieve some of your
instrumentation goals using SystemTap; this allows you to instrument
calls to specific user-space library functions from within the kernel,
with programatic control.
Hope this is helpful
Dave