summaryrefslogtreecommitdiffstats
path: root/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c
diff options
context:
space:
mode:
authormarkj <markj@FreeBSD.org>2015-06-06 16:47:45 +0000
committermarkj <markj@FreeBSD.org>2015-06-06 16:47:45 +0000
commit07f201748f5d0ecfda7b6ede2f3812cb700ba119 (patch)
treebd58f4c20b241be6bb262fadb944f66dfe0bb160 /cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c
parentc9b0e303298fafc6398d009d1cfd3f1e9827fc88 (diff)
downloadFreeBSD-src-07f201748f5d0ecfda7b6ede2f3812cb700ba119.zip
FreeBSD-src-07f201748f5d0ecfda7b6ede2f3812cb700ba119.tar.gz
libdtrace: allow D libraries to declare dependencies on kernel modules
The "depends_on module" pragma can be used to declare a dependency on a DTrace module, which for kernel probes corresponds to a KLD. Such dependencies cannot be checked if the KLD is compiled into the kernel. Therefore, allow a module dependency to be satisfied if either a kernel module or a KLD with the specified name is loaded. Differential Revision: https://reviews.freebsd.org/D2653 Reviewed by: gnn, rpaulo Reported by: gnn
Diffstat (limited to 'cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c')
-rw-r--r--cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c
index 80e4be9..ac0524b 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c
@@ -1178,6 +1178,9 @@ alloc:
#endif
dtp->dt_modbuckets = _dtrace_strbuckets;
dtp->dt_mods = calloc(dtp->dt_modbuckets, sizeof (dt_module_t *));
+#ifdef __FreeBSD__
+ dtp->dt_kmods = calloc(dtp->dt_modbuckets, sizeof (dt_module_t *));
+#endif
dtp->dt_provbuckets = _dtrace_strbuckets;
dtp->dt_provs = calloc(dtp->dt_provbuckets, sizeof (dt_provider_t *));
dt_proc_hash_create(dtp);
@@ -1199,6 +1202,7 @@ alloc:
if (dtp->dt_mods == NULL || dtp->dt_provs == NULL ||
dtp->dt_procs == NULL || dtp->dt_ld_path == NULL ||
#ifdef __FreeBSD__
+ dtp->dt_kmods == NULL ||
dtp->dt_objcopy_path == NULL ||
#endif
dtp->dt_cpp_path == NULL || dtp->dt_cpp_argv == NULL)
@@ -1621,6 +1625,10 @@ dtrace_close(dtrace_hdl_t *dtp)
dtrace_prog_t *pgp;
dt_xlator_t *dxp;
dt_dirpath_t *dirp;
+#ifdef __FreeBSD__
+ dt_kmodule_t *dkm;
+ uint_t h;
+#endif
int i;
if (dtp->dt_procs != NULL)
@@ -1648,6 +1656,15 @@ dtrace_close(dtrace_hdl_t *dtp)
if (dtp->dt_tls != NULL)
dt_idhash_destroy(dtp->dt_tls);
+#ifdef __FreeBSD__
+ for (h = 0; h < dtp->dt_modbuckets; h++)
+ while ((dkm = dtp->dt_kmods[h]) != NULL) {
+ dtp->dt_kmods[h] = dkm->dkm_next;
+ free(dkm->dkm_name);
+ free(dkm);
+ }
+#endif
+
while ((dmp = dt_list_next(&dtp->dt_modlist)) != NULL)
dt_module_destroy(dtp, dmp);
@@ -1697,6 +1714,9 @@ dtrace_close(dtrace_hdl_t *dtp)
#endif
free(dtp->dt_mods);
+#ifdef __FreeBSD__
+ free(dtp->dt_kmods);
+#endif
free(dtp->dt_provs);
free(dtp);
}
OpenPOWER on IntegriCloud