- 论坛徽章:
- 0
|
1. Trace returned data in isoc callback
#!/usr/sbin/dtrace -Fs
/*
uhci_insert_isoc_td:entry
{
}
uhci_insert_isoc_td:return
{
printf("%d",(int)arg1);
}
uhci_hcdi_pipe_isoc_xfer:entry
{
}
uhci_hcdi_pipe_isoc_xfer:return
{
printf("%d",(int)arg1);
}
*/
/*
fbt:usba:ugen_epx_req:entry
{
self->flag = 1;
}
fbt:usba:ugen_epx_req:return
{
self->flag = 0;
}
ugen_epx_isoc_IN_req_cb:entry
{
self->flag2 = 1;
}
ugen_epx_isoc_IN_req_cb:return
{
self->flag2 = 0;
}
fbt:usba:ugen_epx_isoc_*:entry,
fbt:usba:ugen_epx_isoc_*:return
/ self->flag2 == 1/
{
}
*/
unsigned char *p;
int len;
ugen_epx_isoc_IN_req_cb:entry
{
printf("cn:%d tolen:%d pktlen:%d cr:%d ",args[1]->isoc_pkts_count,
args[1]->isoc_pkts_length,
args[1]->isoc_data->b_wptr - args[1]->isoc_data->b_rptr,
args[1]->isoc_completion_reason);/*, args[1]->isoc_data->b_rptr[8],
args[1]->isoc_data->b_rptr[9], args[1]->isoc_data->b_rptr[9]);*/
len = args[1]->isoc_data->b_wptr - args[1]->isoc_data->b_rptr;
p = args[1]->isoc_data->b_rptr;
printf("\ndata:\n");
printf("%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x",p[0],p[1],p[2],
p[3],p[4],p[5],p[6],p[7],p[8],p[9]);
}
ugen_epx_isoc_IN_req_cb:return
{
}
2. Trace open(2) path:
#!/usr/sbin/dtrace -Fs
syscall::open:entry
/execname == $$1/
{
printf("%s",copyinstr(arg0));
self->flag = 1;
}
entry,
return
/self->flag == 1/
{
}
syscall::open:return
{
self->flag = 0;
}
3. Trace a routine's running time
#!/usr/sbin/dtrace -Fs
clock:entry
{
self->time = vtimestamp;
}
clock:return
/self->time/
{
/*printf("elapsing:%d", vtimestamp - self->time);*/
@ar = avg(vtimestamp - self->time);
@mx = max(vtimestamp - self->time);
@mn = min(vtimestamp - self->time);
@sm = sum(vtimestamp - self->time);
++cnt;
self->ts = 0;
}
END
{
printa(@ar);
printa(@mx);
printa(@mn);
printa(@sm);
printf("%d ticks\n",cnt);
}
4. Trace who's paging most heavily
#!/usr/sbin/dtrace -qCs
execpgin,
fspgin,
anonpgin,
maj_fault,
pgpgin,
pgrec,
pgswapin,
zfod
/pid != $pid/
{
@[execname, probename] = count();
}
END
{
printf("EXEC\tFUNC\tCOUNT\n");
printa("%8s %8s %@d\n",@);
}
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/24393/showart_374212.html |
|