Dtrace snippets for observing USCSI
// This was useful for troubleshooting invalid pointer addresses from userspace.
dtrace -qn '::scsi_uscsi_handle_cmd:entry /args[2]->uscsi_bufaddr != 0 && args[2]->uscsi_bufaddr < (caddr_t)0xfffffff/
{
self->p1 = (unsigned long)args[2]->uscsi_bufaddr;
self->p2 = args[2]->uscsi_cdb[0];
self->flags = args[2]->uscsi_flags;
self->cdbl = args[2]->uscsi_cdblen;
self->bufl = args[2]->uscsi_buflen;
self->to = args[2]->uscsi_timeout;
}
::scsi_uscsi_handle_cmd:return /self->p1 || self->p2/ {
printf("Prog: %s *buf: %p cdb[0]: %p cdblen: %d buflen: %d flags: %d time: %d\n",
execname, self->p1, self->p2,
self->cdbl, self->bufl, self->flags, self->to);
self->p1 = 0; self->p2 = 0;
self->cdbl = 0; self->to = 0;
self->bufl = 0; self->flags = 0;
}'
dtrace -qn '::scsi_uscsi_handle_cmd:entry /args[2]->uscsi_bufaddr != 0 && args[2]->uscsi_bufaddr < (caddr_t)0xfffffff/
{
this->u = (union scsi_cdb *)args[2]->uscsi_cdb;
print((*this->u).cdb_un);
}'
// Dump out CDBs from uscsi_cmd structs.
dtrace -qn '::scsi_uscsi_handle_cmd:entry
/execname == "sg_raw" && args[2]->uscsi_cdblen == 0x6/
{
this->x = args[2]->uscsi_cdb;
printf("cdb[6]: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n",
this->x[0], this->x[1], this->x[2], this->x[3], this->x[4], this->x[5]);
}
::scsi_uscsi_handle_cmd:entry
/execname == "sg_raw" && args[2]->uscsi_cdblen == 0xa/
{
this->x = args[2]->uscsi_cdb;
printf("cdb[10]: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n",
this->x[0], this->x[1], this->x[2], this->x[3], this->x[4],
this->x[5], this->x[6], this->x[7], this->x[8], this->x[9]);
}'