From owner-svn-src-head@freebsd.org Sat May 12 06:23:31 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B90EEFC6217; Sat, 12 May 2018 06:23:31 +0000 (UTC) (envelope-from dteske@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 64BCB8E6E3; Sat, 12 May 2018 06:23:31 +0000 (UTC) (envelope-from dteske@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4593F1AAED; Sat, 12 May 2018 06:23:31 +0000 (UTC) (envelope-from dteske@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w4C6NV5d051207; Sat, 12 May 2018 06:23:31 GMT (envelope-from dteske@FreeBSD.org) Received: (from dteske@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w4C6NVKO051206; Sat, 12 May 2018 06:23:31 GMT (envelope-from dteske@FreeBSD.org) Message-Id: <201805120623.w4C6NVKO051206@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dteske set sender to dteske@FreeBSD.org using -f From: Devin Teske Date: Sat, 12 May 2018 06:23:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r333519 - head/cddl/usr.sbin/dwatch/libexec X-SVN-Group: head X-SVN-Commit-Author: dteske X-SVN-Commit-Paths: head/cddl/usr.sbin/dwatch/libexec X-SVN-Commit-Revision: 333519 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 12 May 2018 06:23:32 -0000 Author: dteske Date: Sat May 12 06:23:30 2018 New Revision: 333519 URL: https://svnweb.freebsd.org/changeset/base/333519 Log: dwatch(1): Refactor sendrecv profile The profile for send(2)/recv(2) observation has been refactored to eliminate alloca() in favor of translations available in HEAD. Sponsored by: Smule, Inc. Modified: head/cddl/usr.sbin/dwatch/libexec/sendrecv Modified: head/cddl/usr.sbin/dwatch/libexec/sendrecv ============================================================================== --- head/cddl/usr.sbin/dwatch/libexec/sendrecv Sat May 12 06:18:15 2018 (r333518) +++ head/cddl/usr.sbin/dwatch/libexec/sendrecv Sat May 12 06:23:30 2018 (r333519) @@ -27,8 +27,10 @@ recv) : ${PROBE:=$( echo \ syscall::recvfrom:return, \ syscall::recvmsg:return )} ;; +recv*) + : ${PROBE:=syscall::$PROFILE:return} ;; *) - : ${PROBE:=syscall::$PROFILE} + : ${PROBE:=syscall::$PROFILE:entry} esac ############################################################ EVENT ACTION @@ -98,6 +100,8 @@ inline string address_family_string[sa_family_t af] = #pragma D binding "1.13" sa_data_size inline int sa_data_size = 14; +#pragma D binding "1.13" sa_dummy_data +inline char *sa_dummy_data = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; #pragma D binding "1.13" sa_data_addr inline string sa_data_addr[sa_family_t af, char data[sa_data_size]] = @@ -117,10 +121,14 @@ inline uint16_t sa_data_port[sa_family_t af, char data #pragma D binding "1.13" translator translator sainfo_t < struct sockaddr *SA > { - sa_family = SA->sa_family; - family = address_family_string[SA->sa_family]; - addr = sa_data_addr[SA->sa_family, SA->sa_data]; - port = sa_data_port[SA->sa_family, SA->sa_data]; + sa_family = SA == NULL ? 0 : SA->sa_family; + family = address_family_string[SA == NULL ? 0 : SA->sa_family]; + addr = SA == NULL ? + sa_data_addr[0, sa_dummy_data] : + sa_data_addr[SA->sa_family, SA->sa_data]; + port = SA == NULL ? + sa_data_port[0, sa_dummy_data] : + sa_data_port[SA->sa_family, SA->sa_data]; }; this sainfo_t sainfo; @@ -150,10 +158,8 @@ $PROBE /* probe ID $ID */ syscall::recvfrom:entry /* probe ID $(( $ID + 1 )) */ {${TRACE:+ printf("<$(( $ID + 1 ))>");} - this->sa = args[4] == NULL ? - (struct sockaddr *)alloca(sizeof(struct sockaddr)) : - (struct sockaddr *)copyin(arg4, sizeof(struct sockaddr)); - this->sainfo = xlate ((struct sockaddr *)this->sa); + this->sainfo = xlate ((struct sockaddr *)(args[4] == NULL ? + NULL : copyin(arg4, sizeof(struct sockaddr)))); } syscall::recvfrom:return /* probe ID $(( $ID + 2 )) */ @@ -166,10 +172,18 @@ syscall::recvfrom:return /* probe ID $(( $ID + 2 )) */ this->sainfo.addr, this->sainfo.port])); } -syscall::recvmsg:return /* probe ID $(( $ID + 3 )) */ +syscall::recvmsg:entry /* probe ID $(( $ID + 3 )) */ {${TRACE:+ printf("<$(( $ID + 3 ))>");} + this->sockaddr = (struct sockaddr *)arg1; +} + +syscall::recvmsg:return /this->sockaddr != NULL/ /* probe ID $(( $ID + 4 )) */ +{${TRACE:+ + printf("<$(( $ID + 4 ))>");} this->nbytes = arg0; + this->sainfo = xlate ((struct sockaddr *)this->sockaddr); + this->details = strjoin("sainfo=[", "]"); } syscall::sendmsg:entry /* probe ID $(( $ID + 5 )) */ @@ -178,14 +192,12 @@ syscall::sendmsg:entry /* probe ID $(( $ID + 5 )) */ this->nbytes = arg2; } -syscall::sendto:entry /* probe ID $(( $ID + 4 )) */ +syscall::sendto:entry /* probe ID $(( $ID + 6 )) */ {${TRACE:+ - printf("<$(( $ID + 4 ))>");} + printf("<$(( $ID + 6 ))>");} this->nbytes = arg2; - this->sa = arg4 == NULL ? - (struct sockaddr *)alloca(sizeof(struct sockaddr)) : - (struct sockaddr *)copyin(arg4, sizeof(struct sockaddr)); - this->sainfo = xlate ((struct sockaddr *)this->sa); + this->sainfo = xlate ((struct sockaddr *)(arg4 == NULL ? + NULL : copyin(arg4, sizeof(struct sockaddr)))); this->details = strjoin("to ", strjoin( strjoin(this->sainfo.family, " "), af_details[this->sainfo.sa_family, @@ -193,7 +205,7 @@ syscall::sendto:entry /* probe ID $(( $ID + 4 )) */ } EOF ACTIONS=$( cat <&9 ) -ID=$(( $ID + 5 )) +ID=$(( $ID + 7 )) ############################################################ EVENT DETAILS