From owner-freebsd-dtrace@freebsd.org Mon Dec 19 18:52:15 2016 Return-Path: Delivered-To: freebsd-dtrace@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 01D81C88741 for ; Mon, 19 Dec 2016 18:52:15 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from mail.allbsd.org (gatekeeper.allbsd.org [IPv6:2001:2f0:104:e001::32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.allbsd.org", Issuer "RapidSSL SHA256 CA - G3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 67B79186D; Mon, 19 Dec 2016 18:52:14 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from mail-d.allbsd.org (p2027-ipbf1605funabasi.chiba.ocn.ne.jp [123.225.191.27]) (authenticated bits=56) by mail.allbsd.org (8.15.2/8.15.2) with ESMTPSA id uBJIpoQv062947 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) (Client CN "/OU=GT07882699/OU=See+20www.rapidssl.com/resources/cps+20+28c+2915/OU=Domain+20Control+20Validated+20-+20RapidSSL+28R+29/CN=*.allbsd.org", Issuer "/C=US/O=GeoTrust+20Inc./CN=RapidSSL+20SHA256+20CA+20-+20G3"); Tue, 20 Dec 2016 03:52:09 +0900 (JST) (envelope-from hrs@FreeBSD.org) Received: from alph.allbsd.org (alph.allbsd.org [192.168.0.10]) by mail-d.allbsd.org (8.15.2/8.15.2) with ESMTPS id uBJIoYIl049141 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 20 Dec 2016 03:50:34 +0900 (JST) (envelope-from hrs@FreeBSD.org) Received: from localhost (localhost [IPv6:::1]) (authenticated bits=0) by alph.allbsd.org (8.15.2/8.15.2) with ESMTPA id uBJIoXIC049138; Tue, 20 Dec 2016 03:50:34 +0900 (JST) (envelope-from hrs@FreeBSD.org) Date: Tue, 20 Dec 2016 03:02:24 +0900 (JST) Message-Id: <20161220.030224.323335605995825210.hrs@allbsd.org> To: markj@FreeBSD.org Cc: freebsd-dtrace@freebsd.org Subject: Re: clause-local variable with copyin() From: Hiroki Sato In-Reply-To: <20161219030125.GB57753@wkstn-mjohnston.west.isilon.com> References: <20161217.151014.1579687141761225852.hrs@allbsd.org> <20161219030125.GB57753@wkstn-mjohnston.west.isilon.com> X-PGPkey-fingerprint: BDB3 443F A5DD B3D0 A530 FFD7 4F2C D3D8 2793 CF2D X-Mailer: Mew version 6.7 on Emacs 25.1 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Multipart/Signed; protocol="application/pgp-signature"; micalg=pgp-sha1; boundary="--Security_Multipart(Tue_Dec_20_03_02_24_2016_631)--" Content-Transfer-Encoding: 7bit X-Virus-Scanned: clamav-milter 0.99 at gatekeeper.allbsd.org X-Virus-Status: Clean X-Greylist: Sender DNS name whitelisted, not delayed by milter-greylist-4.4.3 (mail.allbsd.org [133.31.130.32]); Tue, 20 Dec 2016 03:52:11 +0900 (JST) X-Spam-Status: No, score=-99.9 required=13.0 tests=CONTENT_TYPE_PRESENT, QENCPTR1,USER_IN_WHITELIST autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on gatekeeper.allbsd.org X-BeenThere: freebsd-dtrace@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "A discussion list for developers working on DTrace in FreeBSD." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Dec 2016 18:52:15 -0000 ----Security_Multipart(Tue_Dec_20_03_02_24_2016_631)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Mark Johnston wrote in <20161219030125.GB57753@wkstn-mjohnston.west.isilon.com>: ma> On Sat, Dec 17, 2016 at 03:10:14PM +0900, Hiroki Sato wrote: ma> > Do I misunderstand clause-local variable? I noticed this when I use ma> > if-then clause which was recently implemented as a syntax sugar to ma> > split a probe automatically. The following ended up with the same ma> > result: ma> ma> I think this is more a quirk of copyin() than of clause-local variables. ma> In particular: ma> - your example works as expected if copyinstr() is used instead of ma> copyin(), and ma> - your example works if one assigns this->st = stringof(copyin(...)). ma> ma> copyin() and copyinstr() both copy data into a scratch buffer. However, ma> copyinstr() returns a pass-by-reference string, while copyin() returns a ma> pass-by-value pointer. The DIF instruction which saves to a clause-local ma> variable, STLS, performs a deep copy of pass-by-reference variables to ma> some dedicated storage. The scratch space containing the ma> copyin()/copyinstr() is not preserved between enablings of the same ma> probe, so the string copied during the first probe is not available in ma> the second probe when copyin() is used. The difference of the scratch space when using copyin() and copyinstr() were the following ("-" is copyin() and "+" is copyinstr()): NAME ID KND SCP FLAG TYPE arg0 106 scl glb r D type (integer) (size 8) -st 500 scl loc w D type (pointer) (size 8) +st 500 scl loc w string (unknown) by ref (size 256) As you explained copyinstr() had DIF_TF_BYREF and DIF_OP_STLS performed dtrace_vcopy(). However, I still do not understand the difference of the behavior across the boundary of two clauses for a single probe. Is it correct that the cause is that the contents of the scratch space which came from copyin() or copyinstr() are not preserved across multiple clauses of a single probe? If it is true, I am still wondering why copyinstr() works. I think DIF_OP_LDLS in the second probe to load this->st always fails if the scratch space is not preserved regardless of whether the data type involves dereference or not. -- Hiroki ----Security_Multipart(Tue_Dec_20_03_02_24_2016_631)-- Content-Type: application/pgp-signature Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEABECAAYFAlhYILAACgkQTyzT2CeTzy0iMACgmAZW0gBSq1iuzq/GYqtwMGMG qWEAoI/V4657LgnTc10a/bk1sF8jxF7C =T9NS -----END PGP SIGNATURE----- ----Security_Multipart(Tue_Dec_20_03_02_24_2016_631)----