Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 19 Dec 2016 21:30:36 +0100
From:      Domagoj Stolfa <domagoj.stolfa@gmail.com>
To:        freebsd-arch@FreeBSD.org
Cc:        freebsd-current@FreeBSD.org
Subject:   RFC: DTrace probes for debugging or testing in userland programs
Message-ID:  <20161219203036.GD65993@freebsd-laptop>
In-Reply-To: <20161220.043646.1181938468712455328.hrs@allbsd.org>
References:  <20161220.043646.1181938468712455328.hrs@allbsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--/QKKmeG/X/bPShih
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Hello,


>  You can try to compile a new syslogd, run it, and then attach
>  dtrace(1) to the syslogd process by "dtrace -q -CI./
>  -s ./syslogd_trace.d -p `pgrep syslogd`" in the same directory.

one thing that comes to mind is the lack of a way to actually fire these
probes without running plenty of DTrace scripts. The SDT provider
dynamically links onto the binary using the linker set, so that probes
can be called. This is accomplished using the DTrace command that you've
issued, would we need to issue one for each daemon that operates in such
a way?

>  Questions from me are the following:
>=20
>   1. Where should foo_probes.d and foo_trace.d be installed?  And if
>      they depend on foo.h, where should foo.h be?
>=20
>   2. Is documenting probes into foo.8 reasonable?

This would again depend on the way that they're implemented. If USDTs
are used, documenting them might be beneficial, as the user might at one
point want to turn them off dynamically or write their own script.

>   foo_probes.d and foo_trace.d are added.  The former is the
>   definition of USDT probes, and the latter is a D script example to
>   reproduce the original debug log by dprintf() or something like
>   that.  A section to describe what probes are available is added into
>   foo.8.  One can trace the foo daemon using "dtrace -Cs foo_trace.d -p
>   `pgrep foo`" on runtime, and also can create own script.
>=20
>   foo.h may be added because foo_probes.d and foo_trace.d often require
>   information of data structure used in foo.c.
>=20
>  * Possible incompatible change
>=20
>   A debug flag to activate additional logging is no longer necessary
>   after this rewrite, so we can remove it (-d flag in the case of
>   syslogd).  And dump of the internal state can be implemented as a
>   SIGINFO handler.  In the syslogd example, SIGINFO dumps syslogd
>   configuration and access control list.

One thing that could be done as well is instead of using the SDT
provider, a new provider could be written, which could in turn be
controlled by the additional flags, or pehaps even a sysctl integer that
would specify the level of logging that one would want. This provider
could also be entirely disabled, causing it to disable all the existing
probes and, similarly to SDT, use the linker set to patch a couple of
nops back in.

The user could also attach to this provider with their own scripts,
should they wish to perform some other form of monitoring as well.

This might be redundant with the SDT provider though, so perhaps a more
generic, backwards-compatible way can be thought of that would allow
this sort of behaviour?

--=20
Best regards,
Domagoj Stolfa.

--/QKKmeG/X/bPShih
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQEzBAEBCAAdFiEEHQB+y96lmmv+IXofwxT+ikb0YU4FAlhYQ2wACgkQwxT+ikb0
YU5tEAf/XK4zQ0LKyP5OsCoEX6Q2zmAoej+Dbgpc9Fu6dTZs32Y9B+0tel4x/LVE
ew5MO7wMGLoLPpHAQbjRADtRoFeoiyw6AdueXXnNIHVO+9fFfeSAI0RoDakdg27D
1l3yox+v+DlODfX/30vtG4Nl99eSgopn9HB71GgOwoPEBzC86cfsjhgvuKyPevma
tgPHs4FQQiu86MGyN2PKcdy0BqAN6a/1Fhqt64Sa4r9SY7DwDevzvRjRO3PemAq6
9YXaP6JM7yg6Bd4V5AKLt7ROBZb0bNv68LFpcvkwbi4nVPZHyhILf1b5l/1RErwb
3OyerJc+XAyccp5FBgslxL5S4ThZkA==
=UV+u
-----END PGP SIGNATURE-----

--/QKKmeG/X/bPShih--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20161219203036.GD65993>