From owner-freebsd-arch@freebsd.org Mon Dec 19 20:30:42 2016 Return-Path: Delivered-To: freebsd-arch@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 80B7DC88BB7; Mon, 19 Dec 2016 20:30:42 +0000 (UTC) (envelope-from domagoj.stolfa@gmail.com) Received: from mail-wj0-x244.google.com (mail-wj0-x244.google.com [IPv6:2a00:1450:400c:c01::244]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 141341F56; Mon, 19 Dec 2016 20:30:42 +0000 (UTC) (envelope-from domagoj.stolfa@gmail.com) Received: by mail-wj0-x244.google.com with SMTP id j10so25119260wjb.3; Mon, 19 Dec 2016 12:30:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=DlgS4UstoJniGSuFeA1MOkMtJUMJJHo0Q+oSE8v5j/E=; b=Oc9lK4thwvzKvYQREZ1TfvdrC876d/TQCFwDoc2n01h9WxbZMnG+AXU25Pr29ggoPS UuE8zuNTi/ZtgQrjLIPI9tJ/sYaOwPnPADmiEGYNsG62f6wzNmoiC7n/qJ8MAgNCMGNC 1duH94scQupT5w+4C6kTHMGZJGj6OJM+hbS/Wm9dL5y0z7I8USmfANhRv5goG49PdQnK yiL++4uFLPGeUDsgSuKL9q+03EcPPCWz8uiM7ZEwz0SkLHE8iQse7S1Xqcx8KU6gyn+2 XexkpR+XFZ9oS1ZAh9aTHGSXsV9URlbjnHd2h03rmrvBF2UuL0KatxAJm22/4ck9wzNc V8gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=DlgS4UstoJniGSuFeA1MOkMtJUMJJHo0Q+oSE8v5j/E=; b=HDkZ2J7QRwgBa74aiMi0M6iKQq2AaTIkvELFV4xrHV3Y0Y6FOw5smi84HdX+ADZxfc wGuqhBWMr8zHhppq6jBOl4P6e748jp+JEoDVrjZwtUqdi360b86pHRv6nBCR85hPcba9 hQ+43rKLX8uz340NPVmhmlJojTYCsmjKI7mzgSz5D7qJN3s24qW4Il8lTevsKqke0OpV +g2qaIkb2Ubo1ElOSD3qeKRrEsSCclPWRHQk1N1ZWcUs3ZvaH92fZCo1wdf0WBCBme0P GgTi8sZ+mwjSoe5NnVCRvuMO943bWbYXZJkvcRinfRapgIrEmLgEaW725sHjV1Y5cvJD d0Lg== X-Gm-Message-State: AKaTC03x/p5aenMrj2duk1AIf33lsBMQkOQHhV0fv104OEym0grPi4cW04hxQvKFd9HgHQ== X-Received: by 10.194.7.233 with SMTP id m9mr15095233wja.108.1482179440282; Mon, 19 Dec 2016 12:30:40 -0800 (PST) Received: from freebsd-laptop (213-202-67-199.dsl.iskon.hr. [213.202.67.199]) by smtp.gmail.com with ESMTPSA id l67sm18701625wmf.20.2016.12.19.12.30.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Dec 2016 12:30:39 -0800 (PST) Date: Mon, 19 Dec 2016 21:30:36 +0100 From: Domagoj Stolfa 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> References: <20161220.043646.1181938468712455328.hrs@allbsd.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="/QKKmeG/X/bPShih" Content-Disposition: inline In-Reply-To: <20161220.043646.1181938468712455328.hrs@allbsd.org> User-Agent: Mutt/1.7.2 (2016-11-26) X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Dec 2016 20:30:42 -0000 --/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--