SunOS griffin 5.10 Generic_118833-17 sun4u sparc SUNW,Netra-T4

I've attached a script that attempts to capture the fd, size, and
buffer contents for  the write() system call.
I also capture the return code (i.e. number of bytes read) and the
errno value (which should be 0, if healthy).

Most of the output looks to be as expected, but some writes show
buffer contents that is noticeably smaller than
the passed in size value.

Below is some good and bad DTrace output and a copy of the DTrace
script.

Any clue as to what I'm doing wrong would be much appreciated.  DTrace
rocks!

  Thanks

---------------------------------------
First, some good output where size matches the size of the buffer
contents:

2007 Nov 16 20:15:36: FmMain(PID:1004) called write(rc=1, errno=0)
with fd=8, size=1, and
buf="-"

2007 Nov 16 20:15:36: FmMain(PID:1004) called write(rc=81, errno=0)
with fd=7, size=81, and
buf="ALWAYS:2007/11/16 20:15:36.880351 FmMain.cpp:189(fm:1) ifconfig
down iad-logical
"

---------------------------------------
Now, some bad output where the buffer contents is smalle
r than the returned size by write(),
or where the end of the buffer looks messed up (e.g. no trailing
double-quote delimiter):

2007 Nov 16 20:15:36: init(PID:1004) called write(rc=372, errno=0)
with fd=4, size=372, and
buf="su"

2007 Nov 16 20:15:36: ifconfig(PID:1011) called write(rc=10, errno=0)
with fd=2, size=10, and
buf="ifconfig: lVÂ

2007 Nov 16 20:15:38: gzip(PID:1023) called write(rc=1683, errno=0)
with fd=3, size=1683, and
buf!:>G"

2007 Nov 16 20:15:38: gzip(PID:1029) called write(rc=5146, errno=0)
with fd=3, size=5146, and
bufû;>G"

2007 Nov 16 20:15:44: ifconfig(PID:1053) called write(rc=1235,
errno=0) with fd=1, size=1235, and
buf="lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL>
mtu 8232 index 1
        inet 127.0.0.1 netmask ff000000
eri0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500
index 2
        inet 10.160.139.74 netmask ffffff00 broadcast 10.160.139.255
        et"

----------------------------------------------
#!/usr/sbin/dtrace -qs
#pragma D option quiet

/* Traces all write system calls executed by $1 input argument. */
/* INPUTS:  $1 is the name of the process to trace
*/

BEGIN /* The BEGIN probe fires once when tracing starts */
{
        printf("%Y: %s BEGIN\n", walltimestamp, $0);

}

syscall::write:entry
/pid != $pid && (execname == $$1 || ($$1 == "" && execname !=
"dtrace"))/
{
        self->desc = arg0; /* file descriptor passed to write() */
        self->bufp = arg1; /* buffer pointer passed to write()  */
        self->size = arg2; /* size, in bytes passed to write()  */

}

syscall::write:return
/pid != $pid && (execname == $$1 || ($$1 == "" && execname !=
"dtrace"))/
{
        printf("%Y: ", walltimestamp);

        printf("%s(PID:%d) called %s(rc=%d, errno=%d) with fd=%d, size=
%d, and \nbuf=\"%s\"\n\n",
                execname, pid, probefunc, arg0, errno, self->desc,
self->size, stringof(copyin(self->bufp, self->size)));

        self->desc = 0;
        self->bufp = 0;
        self->size = 0;

}

END /* The END probe fires once when tracing is completed */
{
        printf("%Y: %s END\n", walltimestamp, $0); 
}


--
This message posted from opensolaris.org
_______________________________________________
dtrace-discuss mailing list
[email protected]

Reply via email to