Hi et al

I’m receiving multiple DTrace errors on a script which I’m having trouble 
debugging…..

dtrace: error on enabled probe ID 2 (ID 1035: syscall::connectx:entry): invalid 
address (0x0) in action #1 at DIF offset 32

running under : Darwin Darwin Kernel Version 13.1.0: Thu Jan 16 19:40:37 PST 
2014; root:xnu-2422.90.20~2/RELEASE_X86_64

yet running under : Darwin Darwin Kernel Version 12.5.0: Sun Sep 29 13:33:47 
PDT 2013; root:xnu-2050.48.12~1/RELEASE_X86_64

There are no problems with the script.

Any ideas ?

#!/usr/sbin/dtrace -s

#pragma D option quiet
#pragma D option switchrate=10hz

inline int af_inet = 2;         /* AF_INET defined in bsd/sys/socket.h */
inline int af_inet6 = 30;       /* AF_INET6 defined in bsd/sys/socket.h */

dtrace:::BEGIN
{
        /* Add translations as desired from /usr/include/sys/errno.h */
        err[0]            = "Success";
        err[EINTR]        = "Interrupted syscall";
        err[EIO]          = "I/O error";
        err[EACCES]       = "Permission denied";
        err[ENETDOWN]     = "Network is down";
        err[ENETUNREACH]  = "Network unreachable";
        err[ECONNRESET]   = "Connection reset";
        err[ECONNREFUSED] = "Connection refused";
        err[ETIMEDOUT]    = "Timed out";
        err[EHOSTDOWN]    = "Host down";
        err[EHOSTUNREACH] = "No route to host";
        err[EINPROGRESS]  = "In progress";

        printf("%-6s %-16s %-3s %-16s %-5s %8s %s\n", "PID", "PROCESS", "FAM",
            "ADDRESS", "PORT", "LAT(us)", "RESULT");
}

syscall::connect*:entry
{
        /* assume this is sockaddr_in until we can examine family */
        this->s = (struct sockaddr_in *)copyin(arg1, sizeof (struct sockaddr));
        this->f = this->s->sin_family;
}

syscall::connect*:entry
/this->f == af_inet/
{
        self->family = this->f;

        /* Convert port to host byte order without ntohs() being available. */
        self->port = (this->s->sin_port & 0xFF00) >> 8;
        self->port |= (this->s->sin_port & 0xFF) << 8;

        /*
         * Convert an IPv4 address into a dotted quad decimal string.
         * Until the inet_ntoa() functions are available from DTrace, this is
         * converted using the existing strjoin() and lltostr().  It's done in
         * two parts to avoid exhausting DTrace registers in one line of code.
         */
        this->a = (uint8_t *)&this->s->sin_addr;
        this->addr1 = strjoin(lltostr(this->a[0] + 0ULL), strjoin(".",
            strjoin(lltostr(this->a[1] + 0ULL), ".")));
        this->addr2 = strjoin(lltostr(this->a[2] + 0ULL), strjoin(".",
            lltostr(this->a[3] + 0ULL)));
        self->address = strjoin(this->addr1, this->addr2);

        self->start = timestamp;
}

syscall::connect*:return
/self->start/
{
        this->delta = (timestamp - self->start) / 1000;
        this->errstr = err[errno] != NULL ? err[errno] : lltostr(errno);
        printf("%-6d %-16s %-3d %-16s %-5d %8d %s\n", pid, execname,
            self->family, self->address, self->port, this->delta, this->errstr);
        self->family = 0;
        self->address = 0;
        self->port = 0;
        self->start = 0;
}




_______________________________________________
msosug mailing list
[email protected]
http://mexico.purplecow.org/m/listinfo/msosug

Reply via email to