xref: /illumos-gate/usr/src/cmd/smbsrv/fksmbd/Watch-all.d (revision 8a2b682e57a046b828f37bcde1776f131ef4629f)
1 #!/usr/sbin/dtrace -s
2 /*
3  * This file and its contents are supplied under the terms of the
4  * Common Development and Distribution License ("CDDL"), version 1.0.
5  * You may only use this file in accordance with the terms of version
6  * 1.0 of the CDDL.
7  *
8  * A full copy of the text of the CDDL should have accompanied this
9  * source.  A copy of the CDDL is also available via the Internet at
10  * http://www.illumos.org/license/CDDL.
11  */
12 
13 /*
14  * Copyright 2017 Nexenta Systems, Inc.  All rights reserved.
15  */
16 
17 /*
18  * User-level dtrace for fksmbd
19  * Usage: dtrace -s Watch-all.d -p $PID
20  */
21 
22 self int trace;
23 self int mask;
24 
25 /*
26  * Trace almost everything
27  */
28 pid$target:fksmbd::entry,
29 pid$target:libfksmbsrv.so.1::entry,
30 pid$target:libmlsvc.so.1::entry,
31 pid$target:libmlrpc.so.2::entry,
32 pid$target:libsmbns.so.1::entry,
33 pid$target:libsmb.so.1::entry
34 {
35 	self->trace++;
36 }
37 
38 /*
39  * If traced and not masked, print entry/return
40  */
41 pid$target:fksmbd::entry,
42 pid$target:libfksmbsrv.so.1::entry,
43 pid$target:libmlsvc.so.1::entry,
44 pid$target:libmlrpc.so.2::entry,
45 pid$target:libsmbns.so.1::entry,
46 pid$target:libsmb.so.1::entry
47 /self->trace > 0 && self->mask == 0/
48 {
49 	printf("\t0x%x", arg0);
50 	printf("\t0x%x", arg1);
51 	printf("\t0x%x", arg2);
52 	printf("\t0x%x", arg3);
53 	printf("\t0x%x", arg4);
54 	printf("\t0x%x", arg5);
55 }
56 
57 /*
58  * Mask (don't print) all function calls below these functions.
59  * These make many boring, repetitive function calls like
60  * smb_mbtowc, mbc_marshal_...
61  */
62 pid$target::fop__getxvattr:entry,
63 pid$target::fop__setxvattr:entry,
64 pid$target::smb_mbc_vdecodef:entry,
65 pid$target::smb_mbc_vencodef:entry,
66 pid$target::smb_msgbuf_decode:entry,
67 pid$target::smb_msgbuf_encode:entry,
68 pid$target::smb_strlwr:entry,
69 pid$target::smb_strupr:entry,
70 pid$target::smb_wcequiv_strlen:entry
71 {
72 	self->mask++;
73 }
74 
75 /*
76  * Now inverses of above, unwind order.
77  */
78 
79 pid$target::fop__getxvattr:return,
80 pid$target::fop__setxvattr:return,
81 pid$target::smb_mbc_vdecodef:return,
82 pid$target::smb_mbc_vencodef:return,
83 pid$target::smb_msgbuf_decode:return,
84 pid$target::smb_msgbuf_encode:return,
85 pid$target::smb_strlwr:return,
86 pid$target::smb_strupr:return,
87 pid$target::smb_wcequiv_strlen:return
88 {
89 	self->mask--;
90 }
91 
92 pid$target:fksmbd::return,
93 pid$target:libfksmbsrv.so.1::return,
94 pid$target:libmlsvc.so.1::return,
95 pid$target:libmlrpc.so.2::return,
96 pid$target:libsmbns.so.1::return,
97 pid$target:libsmb.so.1::return
98 /self->trace > 0 && self->mask == 0/
99 {
100 	printf("\t0x%x", arg1);
101 }
102 
103 pid$target:fksmbd::return,
104 pid$target:libfksmbsrv.so.1::return,
105 pid$target:libmlsvc.so.1::return,
106 pid$target:libmlrpc.so.2::return,
107 pid$target:libsmbns.so.1::return,
108 pid$target:libsmb.so.1::return
109 {
110 	self->trace--;
111 }
112 
113 /*
114  * fksmb dtrace provder
115  */
116 
117 fksmb$target:::smb_start
118 {
119 	this->pn = copyinstr(arg0);
120 	this->sr = (userland pid`smb_request_t *)arg1;
121 
122 	printf(" %s mid=0x%x uid=0x%x tid=0x%x\n",
123 	    this->pn,
124 	    this->sr->smb_mid,
125 	    this->sr->smb_uid,
126 	    this->sr->smb_tid);
127 }
128 
129 fksmb$target:::smb_done
130 {
131 	this->pn = copyinstr(arg0);
132 	this->sr = (userland pid`smb_request_t *)arg1;
133 
134 	printf(" %s mid=0x%x status=0x%x\n",
135 	    this->pn,
136 	    this->sr->smb_mid,
137 	    this->sr->smb_error.status);
138 }
139 
140 fksmb$target:::smb2_start
141 {
142 	this->pn = copyinstr(arg0);
143 	this->sr = (userland pid`smb_request_t *)arg1;
144 
145 	printf(" %s mid=0x%x uid=0x%x tid=0x%x\n",
146 	    this->pn,
147 	    this->sr->smb2_messageid,
148 	    this->sr->smb2_ssnid,
149 	    this->sr->smb_tid);
150 }
151 
152 fksmb$target:::smb2_done
153 {
154 	this->pn = copyinstr(arg0);
155 	this->sr = (userland pid`smb_request_t *)arg1;
156 
157 	printf(" %s mid=0x%x status=0x%x\n",
158 	    this->pn,
159 	    this->sr->smb2_messageid,
160 	    this->sr->smb2_status);
161 }
162