One Quickie


Fixing DIF offset error (DTrace->General)
Sometimes you might see this error when using copyin or copyinstr:
invalid address (0x10c86e3ce) in action #2 at DIF offset
This happens because the page in question hasn't been faulted in yet, or in general isn't available to the kernel or DTrace at this moment. This can happen if you're accessing the data in an :::entry clause before the data is used.

To work around this, let the function you're tracing do its work, cause the fault of the data into memory, then access the data in the :::return clause. You'll need to hang on the pointer because the function arguments are not passed to :::return:

syscall::open:entry
{
    self->filename = arg0;
}

syscall::open:return
/self->filename/
{
    @files[copyinstr(self->filename)] = count();
    self->filename = 0;
}

END
{
    trunc(@files, 5);
}



borkware home | products | miniblog | rants | quickies | cocoaheads
Advanced Mac OS X Programming book

webmonster@borkware.com