[dtrace-discuss] dtrace
Chip Bennett
cbennett at laurustech.com
Mon Jul 30 05:42:21 PDT 2007
Vivek Joshi wrote:
> ...
>
> syscall::stat:entry
> {
> printf("%s\n",stringof(copyinstr(arg0)));
> }
> ...
This will work most of the time, but you should also put off translating
the pointer with copyinstr, until you can be sure the string is paged
in. Something like:
syscall::stat:entry
{
self->statpath = arg0;
}
syscall::stat:return
/ self->statpath /
{
printf ("%s\n", copyinstr (self->statpath));
self->statpath = 0;
}
D clauses run in kernel mode with interrupts turned off, so they can't
handle a page fault. Deferring handling arg0 until the stat call is
finished assures you that the pointer's been referenced and the string
is in memory.
Chip
More information about the dtrace-discuss
mailing list