clause-local variable with copyin()

Hiroki Sato hrs at FreeBSD.org
Mon Dec 19 18:52:15 UTC 2016


Mark Johnston <markj at FreeBSD.org> wrote
  in <20161219030125.GB57753 at 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-dtrace/attachments/20161220/1a810673/attachment.sig>


More information about the freebsd-dtrace mailing list