summaryrefslogtreecommitdiff
path: root/usr/src/lib/libdtrace/common/dt_pragma.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/lib/libdtrace/common/dt_pragma.c')
-rw-r--r--usr/src/lib/libdtrace/common/dt_pragma.c36
1 files changed, 31 insertions, 5 deletions
diff --git a/usr/src/lib/libdtrace/common/dt_pragma.c b/usr/src/lib/libdtrace/common/dt_pragma.c
index 6c26b6deff..00b826978f 100644
--- a/usr/src/lib/libdtrace/common/dt_pragma.c
+++ b/usr/src/lib/libdtrace/common/dt_pragma.c
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,12 +19,13 @@
* CDDL HEADER END
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
+#include <assert.h>
#include <strings.h>
#include <alloca.h>
#include <stdlib.h>
@@ -200,7 +200,8 @@ dt_pragma_binding(const char *prname, dt_node_t *dnp)
/*
* The #pragma depends_on directive can be used to express a dependency on a
- * module or provider, which if not present will cause processing to abort.
+ * module, provider or library which if not present will cause processing to
+ * abort.
*/
static void
dt_pragma_depends(const char *prname, dt_node_t *cnp)
@@ -208,6 +209,7 @@ dt_pragma_depends(const char *prname, dt_node_t *cnp)
dtrace_hdl_t *dtp = yypcb->pcb_hdl;
dt_node_t *nnp = cnp ? cnp->dn_list : NULL;
int found;
+ dt_lib_depend_t *dld;
if (cnp == NULL || nnp == NULL ||
cnp->dn_kind != DT_NODE_IDENT || nnp->dn_kind != DT_NODE_IDENT) {
@@ -220,6 +222,30 @@ dt_pragma_depends(const char *prname, dt_node_t *cnp)
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) {
+
+ /*
+ * We have the file we are working on in dtp->dt_filetag
+ * so find that node and add the dependency in.
+ */
+ if (yypcb->pcb_cflags & DTRACE_C_CTL) {
+ char lib[MAXPATHLEN];
+
+ dld = dt_lib_depend_lookup(&dtp->dt_lib_dep,
+ dtp->dt_filetag);
+ assert(dld != NULL);
+
+ (void) snprintf(lib, MAXPATHLEN, "%s%s",
+ dld->dtld_libpath, nnp->dn_string);
+ if ((dt_lib_depend_add(dtp, &dld->dtld_dependencies,
+ lib)) != 0) {
+ xyerror(D_PRAGMA_DEPEND,
+ "failed to add dependency %s:%s\n",
+ lib,
+ dtrace_errmsg(dtp, dtrace_errno(dtp)));
+ }
+ }
+ found = 1;
} else {
xyerror(D_PRAGMA_INVAL, "invalid class %s "
"specified by #pragma %s\n", cnp->dn_string, prname);