dt_pragma.c (178566) | dt_pragma.c (238558) |
---|---|
1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE --- 7 unchanged lines hidden (view full) --- 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22/* 23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. | 1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE --- 7 unchanged lines hidden (view full) --- 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22/* 23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. |
24 * Use is subject to license terms. | 24 * Copyright (c) 2011, Joyent Inc. All rights reserved. |
25 */ 26 27#pragma ident "%Z%%M% %I% %E% SMI" 28 29#include <assert.h> 30#include <strings.h> 31#if defined(sun) 32#include <alloca.h> 33#endif | 25 */ 26 27#pragma ident "%Z%%M% %I% %E% SMI" 28 29#include <assert.h> 30#include <strings.h> 31#if defined(sun) 32#include <alloca.h> 33#endif |
34#include <fcntl.h> |
|
34#include <stdlib.h> 35#include <stdio.h> 36 | 35#include <stdlib.h> 36#include <stdio.h> 37 |
38#include <sys/types.h> 39#include <sys/stat.h> 40 |
|
37#include <dt_parser.h> 38#include <dt_impl.h> 39#include <dt_provider.h> 40#include <dt_module.h> 41 42/* 43 * This callback function is installed in a given identifier hash to search for 44 * and apply deferred pragmas that are pending for a given new identifier name. --- 151 unchanged lines hidden (view full) --- 196 197 if (idp == NULL) 198 longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM); 199 200 if (dtp->dt_globals->dh_defer == NULL) 201 dtp->dt_globals->dh_defer = &dt_pragma_apply; 202} 203 | 41#include <dt_parser.h> 42#include <dt_impl.h> 43#include <dt_provider.h> 44#include <dt_module.h> 45 46/* 47 * This callback function is installed in a given identifier hash to search for 48 * and apply deferred pragmas that are pending for a given new identifier name. --- 151 unchanged lines hidden (view full) --- 200 201 if (idp == NULL) 202 longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM); 203 204 if (dtp->dt_globals->dh_defer == NULL) 205 dtp->dt_globals->dh_defer = &dt_pragma_apply; 206} 207 |
208static void 209dt_pragma_depends_finddep(dtrace_hdl_t *dtp, const char *lname, char *lib, 210 size_t len) 211{ 212 dt_dirpath_t *dirp; 213 struct stat sbuf; 214 int found = 0; 215 216 for (dirp = dt_list_next(&dtp->dt_lib_path); dirp != NULL; 217 dirp = dt_list_next(dirp)) { 218 (void) snprintf(lib, len, "%s/%s", dirp->dir_path, lname); 219 220 if (stat(lib, &sbuf) == 0) { 221 found = 1; 222 break; 223 } 224 } 225 226 if (!found) 227 xyerror(D_PRAGMA_DEPEND, 228 "failed to find dependency in libpath: %s", lname); 229} 230 |
|
204/* 205 * The #pragma depends_on directive can be used to express a dependency on a 206 * module, provider or library which if not present will cause processing to 207 * abort. 208 */ 209static void 210dt_pragma_depends(const char *prname, dt_node_t *cnp) 211{ --- 13 unchanged lines hidden (view full) --- 225 found = dt_provider_lookup(dtp, nnp->dn_string) != NULL; 226 else if (strcmp(cnp->dn_string, "module") == 0) { 227 dt_module_t *mp = dt_module_lookup_by_name(dtp, nnp->dn_string); 228 found = mp != NULL && dt_module_getctf(dtp, mp) != NULL; 229 } else if (strcmp(cnp->dn_string, "library") == 0) { 230 if (yypcb->pcb_cflags & DTRACE_C_CTL) { 231 assert(dtp->dt_filetag != NULL); 232 | 231/* 232 * The #pragma depends_on directive can be used to express a dependency on a 233 * module, provider or library which if not present will cause processing to 234 * abort. 235 */ 236static void 237dt_pragma_depends(const char *prname, dt_node_t *cnp) 238{ --- 13 unchanged lines hidden (view full) --- 252 found = dt_provider_lookup(dtp, nnp->dn_string) != NULL; 253 else if (strcmp(cnp->dn_string, "module") == 0) { 254 dt_module_t *mp = dt_module_lookup_by_name(dtp, nnp->dn_string); 255 found = mp != NULL && dt_module_getctf(dtp, mp) != NULL; 256 } else if (strcmp(cnp->dn_string, "library") == 0) { 257 if (yypcb->pcb_cflags & DTRACE_C_CTL) { 258 assert(dtp->dt_filetag != NULL); 259 |
233 /* 234 * We have the file we are working on in dtp->dt_filetag 235 * so find that node and add the dependency in. 236 */ | 260 dt_pragma_depends_finddep(dtp, nnp->dn_string, lib, 261 sizeof (lib)); 262 |
237 dld = dt_lib_depend_lookup(&dtp->dt_lib_dep, 238 dtp->dt_filetag); 239 assert(dld != NULL); 240 | 263 dld = dt_lib_depend_lookup(&dtp->dt_lib_dep, 264 dtp->dt_filetag); 265 assert(dld != NULL); 266 |
241 (void) snprintf(lib, sizeof (lib), "%s%s", 242 dld->dtld_libpath, nnp->dn_string); | |
243 if ((dt_lib_depend_add(dtp, &dld->dtld_dependencies, 244 lib)) != 0) { 245 xyerror(D_PRAGMA_DEPEND, 246 "failed to add dependency %s:%s\n", lib, 247 dtrace_errmsg(dtp, dtrace_errno(dtp))); 248 } 249 } else { 250 /* --- 5 unchanged lines hidden (view full) --- 256 if (dtp->dt_filetag == NULL) 257 xyerror(D_PRAGMA_DEPEND, "main program may " 258 "not explicitly depend on a library"); 259 260 dld = dt_lib_depend_lookup(&dtp->dt_lib_dep, 261 dtp->dt_filetag); 262 assert(dld != NULL); 263 | 267 if ((dt_lib_depend_add(dtp, &dld->dtld_dependencies, 268 lib)) != 0) { 269 xyerror(D_PRAGMA_DEPEND, 270 "failed to add dependency %s:%s\n", lib, 271 dtrace_errmsg(dtp, dtrace_errno(dtp))); 272 } 273 } else { 274 /* --- 5 unchanged lines hidden (view full) --- 280 if (dtp->dt_filetag == NULL) 281 xyerror(D_PRAGMA_DEPEND, "main program may " 282 "not explicitly depend on a library"); 283 284 dld = dt_lib_depend_lookup(&dtp->dt_lib_dep, 285 dtp->dt_filetag); 286 assert(dld != NULL); 287 |
264 (void) snprintf(lib, sizeof (lib), "%s%s", 265 dld->dtld_libpath, nnp->dn_string); | 288 dt_pragma_depends_finddep(dtp, nnp->dn_string, lib, 289 sizeof (lib)); |
266 dld = dt_lib_depend_lookup(&dtp->dt_lib_dep_sorted, 267 lib); 268 assert(dld != NULL); 269 270 if (!dld->dtld_loaded) 271 xyerror(D_PRAGMA_DEPEND, "program requires " 272 "library \"%s\" which failed to load", 273 lib); --- 234 unchanged lines hidden --- | 290 dld = dt_lib_depend_lookup(&dtp->dt_lib_dep_sorted, 291 lib); 292 assert(dld != NULL); 293 294 if (!dld->dtld_loaded) 295 xyerror(D_PRAGMA_DEPEND, "program requires " 296 "library \"%s\" which failed to load", 297 lib); --- 234 unchanged lines hidden --- |