DTrace is impressive, powerful tracing system originally from Solaris, but it is ported to FreeBSD and Mac OSX.
DTrace uses a high-level language called D not unlike AWK or C. Here is an example:
io:::start
/pid == $1/
{
printf("file %s offset %d size %d block %llu\n", args[2]->fi_pathname,
args[2]->fi_offset, args[0]->b_bcount, args[0]->b_blkno);
}
Using the command line sudo dtrace -q -s <name>.d <pid>
all IOs originated from that process are logged.
My question is if and how it is possible to call custom C functions from a DTrace script to do advanced operations with that tracing data during the tracing itself.