[dtrace-discuss] file offset monitoring weirdness

Glenn Skinner glenn.skinner at sun.com
Thu Jan 29 14:22:49 PST 2009


    Date: Thu, 29 Jan 2009 16:05:44 -0600
    From: Nicolas Williams <Nicolas.Williams at sun.com>
    Subject: Re: [dtrace-discuss] file offset monitoring weirdness

    On Thu, Jan 29, 2009 at 01:48:05PM -0800, Glenn Skinner wrote:
    > syscall::write:entry
    > /pid == $target && arg0 == 1/
    > {
    > 	interesting = 1;
    > 	printf("writing 0x%x bytes to stdout at 0x%x\n",
    > 		arg2, fds[1].fi_offset);
    > }
    > 
    > syscall::write:return
    > /pid == $target && interesting == 1/
    > {
    > 	printf("wrote 0x%x bytes\n", arg0);
    > }
    > 
    > syscall:::entry
    > /pid == $target && interesting == 1/
    > {
    > }

    The last probe does very little.  And the second one catches
    write() returns other than the ones you want.

Understood.  I originally wrote it as you suggest, but then wanted to
verify that no other threads were making calls that could affect the
write sequence (e.g., lseek).  Hence the last probe.  Changing from
self->interesting to interesting does indeed make the second probe
catch more than desired, but it's easy enough to screen out false
positives.

    Perhaps you meant something like:

    syscall::write:entry
    /pid == $target && arg0 == 1/
    {
	self->interesting = 1;
	printf("writing 0x%x bytes to stdout at 0x%x\n",
		arg2, fds[1].fi_offset);
    }

    syscall::write:return
    /pid == $target && self->interesting == 1/
    {
	printf("wrote 0x%x bytes\n", arg0);
    }

But the central mystery remains.  Why aren't the file offsets
increasing?  Am I misusing the fds array in some way?

		-- Glenn




More information about the dtrace-discuss mailing list