aboutsummaryrefslogtreecommitdiff
path: root/cddl
diff options
context:
space:
mode:
authorJohn Birrell <jb@FreeBSD.org>2008-04-26 04:53:24 +0000
committerJohn Birrell <jb@FreeBSD.org>2008-04-26 04:53:24 +0000
commitcccc7d47c01288e01058fda748e5a68bb352f2d5 (patch)
tree0530f85724e14e4131a89bd14eacc09dc4ac52c4 /cddl
parentbbda5851ce01e8040dc26b3ef8f3c451a924ceea (diff)
downloadsrc-cccc7d47c01288e01058fda748e5a68bb352f2d5.tar.gz
src-cccc7d47c01288e01058fda748e5a68bb352f2d5.zip
Merge FreeBSD include file changes with some code that should have come
in on the vendor branch.
Notes
Notes: svn path=/head/; revision=178566
Diffstat (limited to 'cddl')
-rw-r--r--cddl/contrib/opensolaris/lib/libdtrace/common/dt_pragma.c50
1 files changed, 39 insertions, 11 deletions
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_pragma.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_pragma.c
index 00b826978f37..a9328ab067b9 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_pragma.c
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_pragma.c
@@ -18,8 +18,9 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -27,7 +28,9 @@
#include <assert.h>
#include <strings.h>
+#if defined(sun)
#include <alloca.h>
+#endif
#include <stdlib.h>
#include <stdio.h>
@@ -210,6 +213,7 @@ dt_pragma_depends(const char *prname, dt_node_t *cnp)
dt_node_t *nnp = cnp ? cnp->dn_list : NULL;
int found;
dt_lib_depend_t *dld;
+ char lib[MAXPATHLEN];
if (cnp == NULL || nnp == NULL ||
cnp->dn_kind != DT_NODE_IDENT || nnp->dn_kind != DT_NODE_IDENT) {
@@ -223,29 +227,53 @@ dt_pragma_depends(const char *prname, dt_node_t *cnp)
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];
+ assert(dtp->dt_filetag != NULL);
+ /*
+ * We have the file we are working on in dtp->dt_filetag
+ * so find that node and add the dependency in.
+ */
dld = dt_lib_depend_lookup(&dtp->dt_lib_dep,
dtp->dt_filetag);
assert(dld != NULL);
- (void) snprintf(lib, MAXPATHLEN, "%s%s",
+ (void) snprintf(lib, sizeof (lib), "%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,
+ "failed to add dependency %s:%s\n", lib,
dtrace_errmsg(dtp, dtrace_errno(dtp)));
}
+ } else {
+ /*
+ * By this point we have already performed a topological
+ * sort of the dependencies; we process this directive
+ * as satisfied as long as the dependency was properly
+ * loaded.
+ */
+ if (dtp->dt_filetag == NULL)
+ xyerror(D_PRAGMA_DEPEND, "main program may "
+ "not explicitly depend on a library");
+
+ dld = dt_lib_depend_lookup(&dtp->dt_lib_dep,
+ dtp->dt_filetag);
+ assert(dld != NULL);
+
+ (void) snprintf(lib, sizeof (lib), "%s%s",
+ dld->dtld_libpath, nnp->dn_string);
+ dld = dt_lib_depend_lookup(&dtp->dt_lib_dep_sorted,
+ lib);
+ assert(dld != NULL);
+
+ if (!dld->dtld_loaded)
+ xyerror(D_PRAGMA_DEPEND, "program requires "
+ "library \"%s\" which failed to load",
+ lib);
}
- found = 1;
+
+ found = B_TRUE;
} else {
xyerror(D_PRAGMA_INVAL, "invalid class %s "
"specified by #pragma %s\n", cnp->dn_string, prname);