xref: /illumos-gate/usr/src/cmd/smbsrv/dtrace/smbsrv.d (revision 5328fc53d11d7151861fa272e4fb0248b8f0e145)
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  * Developer dtrace program for smbsrv
19  * Usage: dtrace -s smbsrv.d
20  */
21 
22 self int trace;
23 self int mask;
24 
25 /*
26  * Trace almost everything
27  */
28 fbt:smbsrv::entry
29 {
30 	self->trace++;
31 }
32 
33 /*
34  * If traced and not masked, print entry/return
35  */
36 fbt:smbsrv::entry
37 /self->trace > 0 && self->mask == 0/
38 {
39 	printf("\t0x%x", arg0);
40 	printf("\t0x%x", arg1);
41 	printf("\t0x%x", arg2);
42 	printf("\t0x%x", arg3);
43 	printf("\t0x%x", arg4);
44 	printf("\t0x%x", arg5);
45 }
46 
47 /*
48  * Mask (don't print) all function calls below these functions.
49  * These make many boring, repetitive function calls like
50  * smb_mbtowc, mbc_marshal_...
51  */
52 fbt::smb_mbc_vdecodef:entry,
53 fbt::smb_mbc_vencodef:entry,
54 fbt::smb_msgbuf_decode:entry,
55 fbt::smb_msgbuf_encode:entry,
56 fbt::smb_strlwr:entry,
57 fbt::smb_strupr:entry,
58 fbt::smb_wcequiv_strlen:entry
59 {
60 	self->mask++;
61 }
62 
63 /*
64  * Now inverses of above, unwind order.
65  */
66 
67 fbt::smb_mbc_vdecodef:return,
68 fbt::smb_mbc_vencodef:return,
69 fbt::smb_msgbuf_decode:return,
70 fbt::smb_msgbuf_encode:return,
71 fbt::smb_strlwr:return,
72 fbt::smb_strupr:return,
73 fbt::smb_wcequiv_strlen:return
74 {
75 	self->mask--;
76 }
77 
78 fbt:smbsrv::return
79 /self->trace > 0 && self->mask == 0/
80 {
81 	printf("\t0x%x", arg1);
82 }
83 
84 fbt:smbsrv::return
85 {
86 	self->trace--;
87 }
88 
89 /*
90  * Use the "smb", "smb2" dtrace providers.
91  */
92 
93 smb:::op-*-start,
94 smb2:::op-*-start
95 {
96 	printf("clnt=%s mid=0x%x uid=0x%x tid=0x%x\n",
97 	       args[0]->ci_remote,
98 	       args[1]->soi_mid,
99 	       args[1]->soi_uid,
100 	       args[1]->soi_tid);
101 }
102 
103 smb:::op-*-done,
104 smb2:::op-*-done
105 {
106 	printf("clnt=%s mid=0x%x status=0x%x\n",
107 	       args[0]->ci_remote,
108 	       args[1]->soi_mid,
109 	       args[1]->soi_status);
110 }
111