xref: /illumos-gate/usr/src/cmd/smbsrv/dtrace/smbd-all.d (revision 66582b606a8194f7f3ba5b3a3a6dca5b0d346361)
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 2018 Nexenta Systems, Inc.  All rights reserved.
15  */
16 
17 /*
18  * User-level dtrace for smbd.  Watch everything it does.
19  * Usage: dtrace -s smbd-all.d -p `pgrep smbd`
20  */
21 
22 #pragma D option flowindent
23 
24 self int trace;
25 self int mask;
26 
27 /*
28  * Trace everything in smbd
29  */
30 pid$target:*smbd::entry,
31 pid$target:libmlsvc.so.1::entry,
32 pid$target:libmlrpc.so.2::entry,
33 pid$target:libsmbns.so.1::entry,
34 pid$target:libsmb.so.1::entry,
35 pid$target:libads.so.1::entry
36 {
37 	self->trace++;
38 }
39 
40 /*
41  * If traced and not masked, print entry/return
42  */
43 pid$target:*smbd::entry,
44 pid$target:libmlsvc.so.1::entry,
45 pid$target:libmlrpc.so.2::entry,
46 pid$target:libsmbns.so.1::entry,
47 pid$target:libsmb.so.1::entry,
48 pid$target:libads.so.1::entry
49 /self->trace > 0 && self->mask == 0/
50 {
51 	printf("\t0x%x", arg0);
52 	printf("\t0x%x", arg1);
53 	printf("\t0x%x", arg2);
54 	printf("\t0x%x", arg3);
55 	printf("\t0x%x", arg4);
56 	printf("\t0x%x", arg5);
57 }
58 
59 /*
60  * Mask (don't print) all function calls below these functions.
61  * These make many boring, repetitive function calls like
62  * smb_mbtowc, smb_msgbuf_has_space, ...
63  *
64  * Also, libmlrpc has rather deep call stacks, particularly under
65  * ndr_encode_decode_common(), so this stops traces below there.
66  * Remove that from the mask actions to see the details.
67  */
68 pid$target::ht_findfirst:entry,
69 pid$target::ht_findnext:entry,
70 pid$target::ndr_encode_decode_common:entry,
71 pid$target::smb_msgbuf_decode:entry,
72 pid$target::smb_msgbuf_encode:entry,
73 pid$target::smb_strlwr:entry,
74 pid$target::smb_strupr:entry,
75 pid$target::smb_wcequiv_strlen:entry
76 {
77 	self->mask++;
78 }
79 
80 /*
81  * Get some of the smbd debug messages, etc.
82  */
83 pid$target:libsmb.so.1:smb_trace:entry
84 /self->trace > 0 && self->mask == 0/
85 {
86 	printf("%s", copyinstr(arg0));
87 }
88 
89 pid$target:libsmb.so.1:smb_syslog:entry
90 /self->trace > 0 && self->mask == 0/
91 {
92 	printf("%s", copyinstr(arg1));
93 }
94 
95 pid$target:libc_hwcap1.so.1:syslog:entry
96 /self->trace > 0 && self->mask == 0/
97 {
98 	printf("%s", copyinstr(arg1));
99 }
100 
101 /*
102  * Now inverses of above, unwind order.
103  */
104 
105 pid$target::ht_findfirst:return,
106 pid$target::ht_findnext:return,
107 pid$target::ndr_encode_decode_common:return,
108 pid$target::smb_msgbuf_decode:return,
109 pid$target::smb_msgbuf_encode:return,
110 pid$target::smb_strlwr:return,
111 pid$target::smb_strupr:return,
112 pid$target::smb_wcequiv_strlen:return
113 {
114 	self->mask--;
115 }
116 
117 pid$target:*smbd::return,
118 pid$target:libmlsvc.so.1::return,
119 pid$target:libmlrpc.so.2::return,
120 pid$target:libsmbns.so.1::return,
121 pid$target:libsmb.so.1::return,
122 pid$target:libads.so.1::return
123 /self->trace > 0 && self->mask == 0/
124 {
125 	printf("\t0x%x", arg1);
126 }
127 
128 pid$target:*smbd::return,
129 pid$target:libmlsvc.so.1::return,
130 pid$target:libmlrpc.so.2::return,
131 pid$target:libsmbns.so.1::return,
132 pid$target:libsmb.so.1::return,
133 pid$target:libads.so.1::return
134 {
135 	self->trace--;
136 }
137