Date: Sat, 15 Dec 2012 06:40:00 GMT From: Mark Johnston <markjdb@gmail.com> To: freebsd-bugs@FreeBSD.org Subject: Re: bin/171678: [dtrace] dtrace -h doesn't work when io.d is installed Message-ID: <201212150640.qBF6e0f8072842@freefall.freebsd.org>
index | next in thread | raw e-mail
The following reply was made to PR bin/171678; it has been noted by GNATS.
From: Mark Johnston <markjdb@gmail.com>
To: bug-followup@FreeBSD.org
Cc:
Subject: Re: bin/171678: [dtrace] dtrace -h doesn't work when io.d is
installed
Date: Sat, 15 Dec 2012 01:34:08 -0500
--jTMWTj4UTAEmbWeb
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
I've attached a patch with an actual fix. Specific, this changes
libdtrace to first look for providers from the debug.dtrace.providers
sysctl. This doesn't require the user to be root, so dtrace -h works as
expected.
Here's an easy test case (for CURRENT) to reproduce the original problem:
$ cat probe.d
provider test {
probe testprobe();
};
$ dtrace -h -s probe.d
dtrace: failed to compile script probe.d: "/usr/lib/dtrace/regs_x86.d", line 2: type redeclared: struct devinfo
$
As I mentioned, this is caused by the depends_on pragma in io.d. The
same problem comes up if a "depends_on provider" pragma is added to
probe.d.
Thanks,
-Mark
--jTMWTj4UTAEmbWeb
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment; filename="dtrace_depends_on_sysctl.patch"
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_pragma.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_pragma.c
index 00578f4..8d64d8d 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_pragma.c
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_pragma.c
@@ -241,6 +241,8 @@ dt_pragma_depends(const char *prname, dt_node_t *cnp)
int found;
dt_lib_depend_t *dld;
char lib[MAXPATHLEN];
+ size_t plen;
+ char *provs, *cpy, *tok;
if (cnp == NULL || nnp == NULL ||
cnp->dn_kind != DT_NODE_IDENT || nnp->dn_kind != DT_NODE_IDENT) {
@@ -248,9 +250,28 @@ dt_pragma_depends(const char *prname, dt_node_t *cnp)
"<class> <name>\n", prname);
}
- if (strcmp(cnp->dn_string, "provider") == 0)
- found = dt_provider_lookup(dtp, nnp->dn_string) != NULL;
- else if (strcmp(cnp->dn_string, "module") == 0) {
+ if (strcmp(cnp->dn_string, "provider") == 0) {
+ /*
+ * First try to get the provider list using the
+ * debug.dtrace.providers sysctl, since that'll work even if
+ * we're not running as root.
+ */
+ provs = NULL;
+ if (sysctlbyname("debug.dtrace.providers", NULL, &plen, NULL, 0) ||
+ ((provs = dt_alloc(dtp, plen)) == NULL) ||
+ sysctlbyname("debug.dtrace.providers", provs, &plen, NULL, 0))
+ found = dt_provider_lookup(dtp, nnp->dn_string) != NULL;
+ else {
+ found = B_FALSE;
+ for (cpy = provs; (tok = strsep(&cpy, " ")) != NULL; )
+ if (strcmp(tok, nnp->dn_string) == 0) {
+ found = B_TRUE;
+ break;
+ }
+ }
+ if (provs != NULL)
+ dt_free(dtp, provs);
+ } else if (strcmp(cnp->dn_string, "module") == 0) {
dt_module_t *mp = dt_module_lookup_by_name(dtp, nnp->dn_string);
found = mp != NULL && dt_module_getctf(dtp, mp) != NULL;
} else if (strcmp(cnp->dn_string, "library") == 0) {
--jTMWTj4UTAEmbWeb--
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201212150640.qBF6e0f8072842>
