1*ed81dd52SAlek Pinchuk #!/usr/sbin/dtrace -s 2*ed81dd52SAlek Pinchuk /* 3*ed81dd52SAlek Pinchuk * This file and its contents are supplied under the terms of the 4*ed81dd52SAlek Pinchuk * Common Development and Distribution License ("CDDL"), version 1.0. 5*ed81dd52SAlek Pinchuk * You may only use this file in accordance with the terms of version 6*ed81dd52SAlek Pinchuk * 1.0 of the CDDL. 7*ed81dd52SAlek Pinchuk * 8*ed81dd52SAlek Pinchuk * A full copy of the text of the CDDL should have accompanied this 9*ed81dd52SAlek Pinchuk * source. A copy of the CDDL is also available via the Internet at 10*ed81dd52SAlek Pinchuk * http://www.illumos.org/license/CDDL. 11*ed81dd52SAlek Pinchuk */ 12*ed81dd52SAlek Pinchuk 13*ed81dd52SAlek Pinchuk /* 14*ed81dd52SAlek Pinchuk * Copyright 2014 Nexenta Systems, Inc. All rights reserved. 15*ed81dd52SAlek Pinchuk */ 16*ed81dd52SAlek Pinchuk 17*ed81dd52SAlek Pinchuk /* 18*ed81dd52SAlek Pinchuk * User-level dtrace for smbd 19*ed81dd52SAlek Pinchuk * Usage: dtrace -s smbd-doorsvc.d -p `pgrep smbd` 20*ed81dd52SAlek Pinchuk */ 21*ed81dd52SAlek Pinchuk 22*ed81dd52SAlek Pinchuk #pragma D option flowindent 23*ed81dd52SAlek Pinchuk 24*ed81dd52SAlek Pinchuk self int trace; 25*ed81dd52SAlek Pinchuk self int mask; 26*ed81dd52SAlek Pinchuk 27*ed81dd52SAlek Pinchuk /* 28*ed81dd52SAlek Pinchuk * smbd_door_dispatch_op() is the logical top of smbd door service calls. 29*ed81dd52SAlek Pinchuk */ 30*ed81dd52SAlek Pinchuk pid$target:*smbd:smbd_door_dispatch_op:entry 31*ed81dd52SAlek Pinchuk { 32*ed81dd52SAlek Pinchuk self->trace++; 33*ed81dd52SAlek Pinchuk } 34*ed81dd52SAlek Pinchuk 35*ed81dd52SAlek Pinchuk /* 36*ed81dd52SAlek Pinchuk * If traced and not masked, print entry/return 37*ed81dd52SAlek Pinchuk */ 38*ed81dd52SAlek Pinchuk pid$target:*smbd::entry, 39*ed81dd52SAlek Pinchuk pid$target:libmlsvc.so.1::entry, 40*ed81dd52SAlek Pinchuk pid$target:libmlrpc.so.1::entry, 41*ed81dd52SAlek Pinchuk pid$target:libsmbns.so.1::entry, 42*ed81dd52SAlek Pinchuk pid$target:libsmb.so.1::entry, 43*ed81dd52SAlek Pinchuk pid$target:libsmbfs.so.1::entry 44*ed81dd52SAlek Pinchuk /self->trace > 0 && self->mask == 0/ 45*ed81dd52SAlek Pinchuk { 46*ed81dd52SAlek Pinchuk printf("\t0x%x", arg0); 47*ed81dd52SAlek Pinchuk printf("\t0x%x", arg1); 48*ed81dd52SAlek Pinchuk printf("\t0x%x", arg2); 49*ed81dd52SAlek Pinchuk printf("\t0x%x", arg3); 50*ed81dd52SAlek Pinchuk printf("\t0x%x", arg4); 51*ed81dd52SAlek Pinchuk printf("\t0x%x", arg5); 52*ed81dd52SAlek Pinchuk } 53*ed81dd52SAlek Pinchuk 54*ed81dd52SAlek Pinchuk /* 55*ed81dd52SAlek Pinchuk * Mask (don't print) all function calls below these functions. 56*ed81dd52SAlek Pinchuk * These make many boring, repetitive function calls like 57*ed81dd52SAlek Pinchuk * smb_mbtowc, smb_msgbuf_has_space, ... 58*ed81dd52SAlek Pinchuk */ 59*ed81dd52SAlek Pinchuk pid$target::smb_msgbuf_decode:entry, 60*ed81dd52SAlek Pinchuk pid$target::smb_msgbuf_encode:entry, 61*ed81dd52SAlek Pinchuk pid$target::smb_strlwr:entry, 62*ed81dd52SAlek Pinchuk pid$target::smb_strupr:entry, 63*ed81dd52SAlek Pinchuk pid$target::smb_wcequiv_strlen:entry 64*ed81dd52SAlek Pinchuk { 65*ed81dd52SAlek Pinchuk self->mask++; 66*ed81dd52SAlek Pinchuk } 67*ed81dd52SAlek Pinchuk 68*ed81dd52SAlek Pinchuk /* 69*ed81dd52SAlek Pinchuk * Now inverses of above, unwind order. 70*ed81dd52SAlek Pinchuk */ 71*ed81dd52SAlek Pinchuk 72*ed81dd52SAlek Pinchuk pid$target::smb_msgbuf_decode:return, 73*ed81dd52SAlek Pinchuk pid$target::smb_msgbuf_encode:return, 74*ed81dd52SAlek Pinchuk pid$target::smb_strlwr:return, 75*ed81dd52SAlek Pinchuk pid$target::smb_strupr:return, 76*ed81dd52SAlek Pinchuk pid$target::smb_wcequiv_strlen:return 77*ed81dd52SAlek Pinchuk { 78*ed81dd52SAlek Pinchuk self->mask--; 79*ed81dd52SAlek Pinchuk } 80*ed81dd52SAlek Pinchuk 81*ed81dd52SAlek Pinchuk pid$target:*smbd::return, 82*ed81dd52SAlek Pinchuk pid$target:libmlsvc.so.1::return, 83*ed81dd52SAlek Pinchuk pid$target:libmlrpc.so.1::return, 84*ed81dd52SAlek Pinchuk pid$target:libsmbns.so.1::return, 85*ed81dd52SAlek Pinchuk pid$target:libsmb.so.1::return, 86*ed81dd52SAlek Pinchuk pid$target:libsmbfs.so.1::return 87*ed81dd52SAlek Pinchuk /self->trace > 0 && self->mask == 0/ 88*ed81dd52SAlek Pinchuk { 89*ed81dd52SAlek Pinchuk printf("\t0x%x", arg1); 90*ed81dd52SAlek Pinchuk } 91*ed81dd52SAlek Pinchuk 92*ed81dd52SAlek Pinchuk pid$target:*smbd:smbd_door_dispatch_op:return 93*ed81dd52SAlek Pinchuk { 94*ed81dd52SAlek Pinchuk self->trace--; 95*ed81dd52SAlek Pinchuk } 96