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.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
29 #include <sys/types.h>
31 #include <sys/sysmacros.h>
44 #include <dt_provider.h>
45 #include <dt_module.h>
46 #include <dt_string.h>
49 static dt_provider_t *
50 dt_provider_insert(dtrace_hdl_t *dtp, dt_provider_t *pvp, uint_t h)
52 dt_list_append(&dtp->dt_provlist, pvp);
54 pvp->pv_next = dtp->dt_provs[h];
55 dtp->dt_provs[h] = pvp;
62 dt_provider_lookup(dtrace_hdl_t *dtp, const char *name)
64 uint_t h = dt_strtab_hash(name, NULL) % dtp->dt_provbuckets;
65 dtrace_providerdesc_t desc;
68 for (pvp = dtp->dt_provs[h]; pvp != NULL; pvp = pvp->pv_next) {
69 if (strcmp(pvp->pv_desc.dtvd_name, name) == 0)
73 if (strisglob(name) || name[0] == '\0') {
74 (void) dt_set_errno(dtp, EDT_NOPROV);
78 bzero(&desc, sizeof (desc));
79 (void) strlcpy(desc.dtvd_name, name, DTRACE_PROVNAMELEN);
81 if (dt_ioctl(dtp, DTRACEIOC_PROVIDER, &desc) == -1) {
82 (void) dt_set_errno(dtp, errno == ESRCH ? EDT_NOPROV : errno);
86 if ((pvp = dt_provider_create(dtp, name)) == NULL)
87 return (NULL); /* dt_errno is set for us */
89 bcopy(&desc, &pvp->pv_desc, sizeof (desc));
90 pvp->pv_flags |= DT_PROVIDER_IMPL;
95 dt_provider_create(dtrace_hdl_t *dtp, const char *name)
99 if ((pvp = dt_zalloc(dtp, sizeof (dt_provider_t))) == NULL)
102 (void) strlcpy(pvp->pv_desc.dtvd_name, name, DTRACE_PROVNAMELEN);
103 pvp->pv_probes = dt_idhash_create(pvp->pv_desc.dtvd_name, NULL, 0, 0);
104 pvp->pv_gen = dtp->dt_gen;
107 if (pvp->pv_probes == NULL) {
109 (void) dt_set_errno(dtp, EDT_NOMEM);
113 pvp->pv_desc.dtvd_attr.dtpa_provider = _dtrace_prvattr;
114 pvp->pv_desc.dtvd_attr.dtpa_mod = _dtrace_prvattr;
115 pvp->pv_desc.dtvd_attr.dtpa_func = _dtrace_prvattr;
116 pvp->pv_desc.dtvd_attr.dtpa_name = _dtrace_prvattr;
117 pvp->pv_desc.dtvd_attr.dtpa_args = _dtrace_prvattr;
119 return (dt_provider_insert(dtp, pvp,
120 dt_strtab_hash(name, NULL) % dtp->dt_provbuckets));
124 dt_provider_destroy(dtrace_hdl_t *dtp, dt_provider_t *pvp)
129 assert(pvp->pv_hdl == dtp);
131 h = dt_strtab_hash(pvp->pv_desc.dtvd_name, NULL) % dtp->dt_provbuckets;
132 pp = &dtp->dt_provs[h];
134 while (*pp != NULL && *pp != pvp)
135 pp = &(*pp)->pv_next;
137 assert(*pp != NULL && *pp == pvp);
140 dt_list_delete(&dtp->dt_provlist, pvp);
143 if (pvp->pv_probes != NULL)
144 dt_idhash_destroy(pvp->pv_probes);
146 dt_node_link_free(&pvp->pv_nodes);
147 dt_free(dtp, pvp->pv_xrefs);
152 dt_provider_xref(dtrace_hdl_t *dtp, dt_provider_t *pvp, id_t id)
154 size_t oldsize = BT_SIZEOFMAP(pvp->pv_xrmax);
155 size_t newsize = BT_SIZEOFMAP(dtp->dt_xlatorid);
157 assert(id >= 0 && id < dtp->dt_xlatorid);
159 if (newsize > oldsize) {
160 ulong_t *xrefs = dt_zalloc(dtp, newsize);
165 bcopy(pvp->pv_xrefs, xrefs, oldsize);
166 dt_free(dtp, pvp->pv_xrefs);
168 pvp->pv_xrefs = xrefs;
169 pvp->pv_xrmax = dtp->dt_xlatorid;
172 BT_SET(pvp->pv_xrefs, id);
177 dt_probe_argmap(dt_node_t *xnp, dt_node_t *nnp)
181 for (i = 0; nnp != NULL; i++) {
182 if (nnp->dn_string != NULL &&
183 strcmp(nnp->dn_string, xnp->dn_string) == 0)
193 dt_probe_alloc_args(dt_provider_t *pvp, int argc)
195 dt_node_t *args = NULL, *pnp = NULL, *dnp;
198 for (i = 0; i < argc; i++, pnp = dnp) {
199 if ((dnp = dt_node_xalloc(pvp->pv_hdl, DT_NODE_TYPE)) == NULL)
202 dnp->dn_link = pvp->pv_nodes;
215 dt_probe_keylen(const dtrace_probedesc_t *pdp)
217 return (strlen(pdp->dtpd_mod) + 1 +
218 strlen(pdp->dtpd_func) + 1 + strlen(pdp->dtpd_name) + 1);
222 dt_probe_key(const dtrace_probedesc_t *pdp, char *s)
224 (void) snprintf(s, INT_MAX, "%s:%s:%s",
225 pdp->dtpd_mod, pdp->dtpd_func, pdp->dtpd_name);
230 * If a probe was discovered from the kernel, ask dtrace(7D) for a description
231 * of each of its arguments, including native and translated types.
234 dt_probe_discover(dt_provider_t *pvp, const dtrace_probedesc_t *pdp)
236 dtrace_hdl_t *dtp = pvp->pv_hdl;
237 char *name = dt_probe_key(pdp, alloca(dt_probe_keylen(pdp)));
239 dt_node_t *xargs, *nargs;
243 dtrace_typeinfo_t dtt;
246 int adc = _dtrace_argmax;
247 dtrace_argdesc_t *adv = alloca(sizeof (dtrace_argdesc_t) * adc);
248 dtrace_argdesc_t *adp = adv;
250 assert(strcmp(pvp->pv_desc.dtvd_name, pdp->dtpd_provider) == 0);
251 assert(pdp->dtpd_id != DTRACE_IDNONE);
253 dt_dprintf("discovering probe %s:%s id=%d\n",
254 pvp->pv_desc.dtvd_name, name, pdp->dtpd_id);
256 for (nc = -1, i = 0; i < adc; i++, adp++) {
257 bzero(adp, sizeof (dtrace_argdesc_t));
259 adp->dtargd_id = pdp->dtpd_id;
261 if (dt_ioctl(dtp, DTRACEIOC_PROBEARG, adp) != 0) {
262 (void) dt_set_errno(dtp, errno);
266 if (adp->dtargd_ndx == DTRACE_ARGNONE)
267 break; /* all argument descs have been retrieved */
269 nc = MAX(nc, adp->dtargd_mapping);
276 * Now that we have discovered the number of native and translated
277 * arguments from the argument descriptions, allocate a new probe ident
278 * and corresponding dt_probe_t and hash it into the provider.
280 xargs = dt_probe_alloc_args(pvp, xc);
281 nargs = dt_probe_alloc_args(pvp, nc);
283 if ((xc != 0 && xargs == NULL) || (nc != 0 && nargs == NULL))
284 return (NULL); /* dt_errno is set for us */
286 idp = dt_ident_create(name, DT_IDENT_PROBE,
287 DT_IDFLG_ORPHAN, pdp->dtpd_id, _dtrace_defattr, 0,
288 &dt_idops_probe, NULL, dtp->dt_gen);
291 (void) dt_set_errno(dtp, EDT_NOMEM);
295 if ((prp = dt_probe_create(dtp, idp, 2,
296 nargs, nc, xargs, xc)) == NULL) {
297 dt_ident_destroy(idp);
301 dt_probe_declare(pvp, prp);
304 * Once our new dt_probe_t is fully constructed, iterate over the
305 * cached argument descriptions and assign types to prp->pr_nargv[]
306 * and prp->pr_xargv[] and assign mappings to prp->pr_mapping[].
308 for (adp = adv, i = 0; i < xc; i++, adp++) {
309 if (dtrace_type_strcompile(dtp,
310 adp->dtargd_native, &dtt) != 0) {
311 dt_dprintf("failed to resolve input type %s "
312 "for %s:%s arg #%d: %s\n", adp->dtargd_native,
313 pvp->pv_desc.dtvd_name, name, i + 1,
314 dtrace_errmsg(dtp, dtrace_errno(dtp)));
316 dtt.dtt_object = NULL;
318 dtt.dtt_type = CTF_ERR;
320 dt_node_type_assign(prp->pr_nargv[adp->dtargd_mapping],
321 dtt.dtt_ctfp, dtt.dtt_type);
324 if (dtt.dtt_type != CTF_ERR && (adp->dtargd_xlate[0] == '\0' ||
325 strcmp(adp->dtargd_native, adp->dtargd_xlate) == 0)) {
326 dt_node_type_propagate(prp->pr_nargv[
327 adp->dtargd_mapping], prp->pr_xargv[i]);
328 } else if (dtrace_type_strcompile(dtp,
329 adp->dtargd_xlate, &dtt) != 0) {
330 dt_dprintf("failed to resolve output type %s "
331 "for %s:%s arg #%d: %s\n", adp->dtargd_xlate,
332 pvp->pv_desc.dtvd_name, name, i + 1,
333 dtrace_errmsg(dtp, dtrace_errno(dtp)));
335 dtt.dtt_object = NULL;
337 dtt.dtt_type = CTF_ERR;
339 dt_node_type_assign(prp->pr_xargv[i],
340 dtt.dtt_ctfp, dtt.dtt_type);
343 prp->pr_mapping[i] = adp->dtargd_mapping;
344 prp->pr_argv[i] = dtt;
351 * Lookup a probe declaration based on a known provider and full or partially
352 * specified module, function, and name. If the probe is not known to us yet,
353 * ask dtrace(7D) to match the description and then cache any useful results.
356 dt_probe_lookup(dt_provider_t *pvp, const char *s)
358 dtrace_hdl_t *dtp = pvp->pv_hdl;
359 dtrace_probedesc_t pd;
364 if (dtrace_str2desc(dtp, DTRACE_PROBESPEC_NAME, s, &pd) != 0)
365 return (NULL); /* dt_errno is set for us */
367 keylen = dt_probe_keylen(&pd);
368 key = dt_probe_key(&pd, alloca(keylen));
371 * If the probe is already declared, then return the dt_probe_t from
372 * the existing identifier. This could come from a static declaration
373 * or it could have been cached from an earlier call to this function.
375 if ((idp = dt_idhash_lookup(pvp->pv_probes, key)) != NULL)
376 return (idp->di_data);
379 * If the probe isn't known, use the probe description computed above
380 * to ask dtrace(7D) to find the first matching probe.
382 if (dt_ioctl(dtp, DTRACEIOC_PROBEMATCH, &pd) == 0)
383 return (dt_probe_discover(pvp, &pd));
385 if (errno == ESRCH || errno == EBADF)
386 (void) dt_set_errno(dtp, EDT_NOPROBE);
388 (void) dt_set_errno(dtp, errno);
394 dt_probe_create(dtrace_hdl_t *dtp, dt_ident_t *idp, int protoc,
395 dt_node_t *nargs, uint_t nargc, dt_node_t *xargs, uint_t xargc)
402 assert(idp->di_kind == DT_IDENT_PROBE);
403 assert(idp->di_data == NULL);
406 * If only a single prototype is given, set xargc/s to nargc/s to
407 * simplify subsequent use. Note that we can have one or both of nargs
408 * and xargs be specified but set to NULL, indicating a void prototype.
411 assert(xargs == NULL);
417 if ((prp = dt_alloc(dtp, sizeof (dt_probe_t))) == NULL)
423 p = strrchr(idp->di_name, ':');
425 prp->pr_name = p + 1;
427 prp->pr_nargs = nargs;
428 prp->pr_nargv = dt_alloc(dtp, sizeof (dt_node_t *) * nargc);
429 prp->pr_nargc = nargc;
430 prp->pr_xargs = xargs;
431 prp->pr_xargv = dt_alloc(dtp, sizeof (dt_node_t *) * xargc);
432 prp->pr_xargc = xargc;
433 prp->pr_mapping = dt_alloc(dtp, sizeof (uint8_t) * xargc);
435 prp->pr_argv = dt_alloc(dtp, sizeof (dtrace_typeinfo_t) * xargc);
436 prp->pr_argc = xargc;
438 if ((prp->pr_nargc != 0 && prp->pr_nargv == NULL) ||
439 (prp->pr_xargc != 0 && prp->pr_xargv == NULL) ||
440 (prp->pr_xargc != 0 && prp->pr_mapping == NULL) ||
441 (prp->pr_argc != 0 && prp->pr_argv == NULL)) {
442 dt_probe_destroy(prp);
446 for (i = 0; i < xargc; i++, xargs = xargs->dn_list) {
447 if (xargs->dn_string != NULL)
448 prp->pr_mapping[i] = dt_probe_argmap(xargs, nargs);
450 prp->pr_mapping[i] = i;
452 prp->pr_xargv[i] = xargs;
454 if ((dmp = dt_module_lookup_by_ctf(dtp,
455 xargs->dn_ctfp)) != NULL)
456 prp->pr_argv[i].dtt_object = dmp->dm_name;
458 prp->pr_argv[i].dtt_object = NULL;
460 prp->pr_argv[i].dtt_ctfp = xargs->dn_ctfp;
461 prp->pr_argv[i].dtt_type = xargs->dn_type;
464 for (i = 0; i < nargc; i++, nargs = nargs->dn_list)
465 prp->pr_nargv[i] = nargs;
472 dt_probe_declare(dt_provider_t *pvp, dt_probe_t *prp)
474 assert(prp->pr_ident->di_kind == DT_IDENT_PROBE);
475 assert(prp->pr_ident->di_data == prp);
476 assert(prp->pr_pvp == NULL);
478 if (prp->pr_xargs != prp->pr_nargs)
479 pvp->pv_flags &= ~DT_PROVIDER_INTF;
482 dt_idhash_xinsert(pvp->pv_probes, prp->pr_ident);
486 dt_probe_destroy(dt_probe_t *prp)
488 dt_probe_instance_t *pip, *pip_next;
491 if (prp->pr_pvp != NULL)
492 dtp = prp->pr_pvp->pv_hdl;
494 dtp = yypcb->pcb_hdl;
496 dt_node_list_free(&prp->pr_nargs);
497 dt_node_list_free(&prp->pr_xargs);
499 dt_free(dtp, prp->pr_nargv);
500 dt_free(dtp, prp->pr_xargv);
502 for (pip = prp->pr_inst; pip != NULL; pip = pip_next) {
503 pip_next = pip->pi_next;
504 dt_free(dtp, pip->pi_offs);
505 dt_free(dtp, pip->pi_enoffs);
509 dt_free(dtp, prp->pr_mapping);
510 dt_free(dtp, prp->pr_argv);
515 dt_probe_define(dt_provider_t *pvp, dt_probe_t *prp,
516 const char *fname, const char *rname, uint32_t offset, int isenabled)
518 dtrace_hdl_t *dtp = pvp->pv_hdl;
519 dt_probe_instance_t *pip;
521 uint_t *noffs, *maxoffs;
523 assert(fname != NULL);
525 for (pip = prp->pr_inst; pip != NULL; pip = pip->pi_next) {
526 if (strcmp(pip->pi_fname, fname) == 0 &&
527 ((rname == NULL && pip->pi_rname[0] == '\0') ||
528 (rname != NULL && strcmp(pip->pi_rname, rname)) == 0))
533 if ((pip = dt_zalloc(dtp, sizeof (*pip))) == NULL)
536 if ((pip->pi_offs = dt_zalloc(dtp,
537 sizeof (uint32_t))) == NULL) {
542 if ((pip->pi_enoffs = dt_zalloc(dtp,
543 sizeof (uint32_t))) == NULL) {
544 dt_free(dtp, pip->pi_offs);
549 (void) strlcpy(pip->pi_fname, fname, sizeof (pip->pi_fname));
551 if (strlen(rname) + 1 > sizeof (pip->pi_rname)) {
552 dt_free(dtp, pip->pi_offs);
554 return (dt_set_errno(dtp, EDT_COMPILER));
556 (void) strcpy(pip->pi_rname, rname);
562 pip->pi_maxenoffs = 1;
564 pip->pi_next = prp->pr_inst;
570 offs = &pip->pi_enoffs;
571 noffs = &pip->pi_nenoffs;
572 maxoffs = &pip->pi_maxenoffs;
574 offs = &pip->pi_offs;
575 noffs = &pip->pi_noffs;
576 maxoffs = &pip->pi_maxoffs;
579 if (*noffs == *maxoffs) {
580 uint_t new_max = *maxoffs * 2;
581 uint32_t *new_offs = dt_alloc(dtp, sizeof (uint32_t) * new_max);
583 if (new_offs == NULL)
586 bcopy(*offs, new_offs, sizeof (uint32_t) * *maxoffs);
593 dt_dprintf("defined probe %s %s:%s %s() +0x%x (%s)\n",
594 isenabled ? "(is-enabled)" : "",
595 pvp->pv_desc.dtvd_name, prp->pr_ident->di_name, fname, offset,
596 rname != NULL ? rname : fname);
598 assert(*noffs < *maxoffs);
599 (*offs)[(*noffs)++] = offset;
605 * Lookup the dynamic translator type tag for the specified probe argument and
606 * assign the type to the specified node. If the type is not yet defined, add
607 * it to the "D" module's type container as a typedef for an unknown type.
610 dt_probe_tag(dt_probe_t *prp, uint_t argn, dt_node_t *dnp)
612 dtrace_hdl_t *dtp = prp->pr_pvp->pv_hdl;
613 dtrace_typeinfo_t dtt;
617 len = snprintf(NULL, 0, "__dtrace_%s___%s_arg%u",
618 prp->pr_pvp->pv_desc.dtvd_name, prp->pr_name, argn);
620 tag = alloca(len + 1);
622 (void) snprintf(tag, len + 1, "__dtrace_%s___%s_arg%u",
623 prp->pr_pvp->pv_desc.dtvd_name, prp->pr_name, argn);
625 if (dtrace_lookup_by_type(dtp, DTRACE_OBJ_DDEFS, tag, &dtt) != 0) {
626 dtt.dtt_object = DTRACE_OBJ_DDEFS;
627 dtt.dtt_ctfp = DT_DYN_CTFP(dtp);
628 dtt.dtt_type = ctf_add_typedef(DT_DYN_CTFP(dtp),
629 CTF_ADD_ROOT, tag, DT_DYN_TYPE(dtp));
631 if (dtt.dtt_type == CTF_ERR ||
632 ctf_update(dtt.dtt_ctfp) == CTF_ERR) {
633 xyerror(D_UNKNOWN, "cannot define type %s: %s\n",
634 tag, ctf_errmsg(ctf_errno(dtt.dtt_ctfp)));
638 bzero(dnp, sizeof (dt_node_t));
639 dnp->dn_kind = DT_NODE_TYPE;
641 dt_node_type_assign(dnp, dtt.dtt_ctfp, dtt.dtt_type);
642 dt_node_attr_assign(dnp, _dtrace_defattr);
649 dt_probe_desc(dtrace_hdl_t *dtp, const dtrace_probedesc_t *pdp, void *arg)
651 if (((dtrace_probedesc_t *)arg)->dtpd_id == DTRACE_IDNONE) {
652 bcopy(pdp, arg, sizeof (dtrace_probedesc_t));
660 dt_probe_info(dtrace_hdl_t *dtp,
661 const dtrace_probedesc_t *pdp, dtrace_probeinfo_t *pip)
663 int m_is_glob = pdp->dtpd_mod[0] == '\0' || strisglob(pdp->dtpd_mod);
664 int f_is_glob = pdp->dtpd_func[0] == '\0' || strisglob(pdp->dtpd_func);
665 int n_is_glob = pdp->dtpd_name[0] == '\0' || strisglob(pdp->dtpd_name);
667 dt_probe_t *prp = NULL;
668 const dtrace_pattr_t *pap;
673 * Attempt to lookup the probe in our existing cache for this provider.
674 * If none is found and an explicit probe ID was specified, discover
675 * that specific probe and cache its description and arguments.
677 if ((pvp = dt_provider_lookup(dtp, pdp->dtpd_provider)) != NULL) {
678 size_t keylen = dt_probe_keylen(pdp);
679 char *key = dt_probe_key(pdp, alloca(keylen));
681 if ((idp = dt_idhash_lookup(pvp->pv_probes, key)) != NULL)
683 else if (pdp->dtpd_id != DTRACE_IDNONE)
684 prp = dt_probe_discover(pvp, pdp);
688 * If no probe was found in our cache, convert the caller's partial
689 * probe description into a fully-formed matching probe description by
690 * iterating over up to at most two probes that match 'pdp'. We then
691 * call dt_probe_discover() on the resulting probe identifier.
694 dtrace_probedesc_t pd;
697 bzero(&pd, sizeof (pd));
698 pd.dtpd_id = DTRACE_IDNONE;
701 * Call dtrace_probe_iter() to find matching probes. Our
702 * dt_probe_desc() callback will produce the following results:
704 * m < 0 dtrace_probe_iter() found zero matches (or failed).
705 * m > 0 dtrace_probe_iter() found more than one match.
706 * m = 0 dtrace_probe_iter() found exactly one match.
708 if ((m = dtrace_probe_iter(dtp, pdp, dt_probe_desc, &pd)) < 0)
709 return (NULL); /* dt_errno is set for us */
711 if ((pvp = dt_provider_lookup(dtp, pd.dtpd_provider)) == NULL)
712 return (NULL); /* dt_errno is set for us */
715 * If more than one probe was matched, then do not report probe
716 * information if either of the following conditions is true:
718 * (a) The Arguments Data stability of the matched provider is
719 * less than Evolving.
721 * (b) Any description component that is at least Evolving is
722 * empty or is specified using a globbing expression.
724 * These conditions imply that providers that provide Evolving
725 * or better Arguments Data stability must guarantee that all
726 * probes with identical field names in a field of Evolving or
727 * better Name stability have identical argument signatures.
730 if (pvp->pv_desc.dtvd_attr.dtpa_args.dtat_data <
731 DTRACE_STABILITY_EVOLVING) {
732 (void) dt_set_errno(dtp, EDT_UNSTABLE);
737 if (pvp->pv_desc.dtvd_attr.dtpa_mod.dtat_name >=
738 DTRACE_STABILITY_EVOLVING && m_is_glob) {
739 (void) dt_set_errno(dtp, EDT_UNSTABLE);
743 if (pvp->pv_desc.dtvd_attr.dtpa_func.dtat_name >=
744 DTRACE_STABILITY_EVOLVING && f_is_glob) {
745 (void) dt_set_errno(dtp, EDT_UNSTABLE);
749 if (pvp->pv_desc.dtvd_attr.dtpa_name.dtat_name >=
750 DTRACE_STABILITY_EVOLVING && n_is_glob) {
751 (void) dt_set_errno(dtp, EDT_UNSTABLE);
757 * If we matched a probe exported by dtrace(7D), then discover
758 * the real attributes. Otherwise grab the static declaration.
760 if (pd.dtpd_id != DTRACE_IDNONE)
761 prp = dt_probe_discover(pvp, &pd);
763 prp = dt_probe_lookup(pvp, pd.dtpd_name);
766 return (NULL); /* dt_errno is set for us */
769 assert(pvp != NULL && prp != NULL);
772 * Compute the probe description attributes by taking the minimum of
773 * the attributes of the specified fields. If no provider is specified
774 * or a glob pattern is used for the provider, use Unstable attributes.
776 if (pdp->dtpd_provider[0] == '\0' || strisglob(pdp->dtpd_provider))
777 pap = &_dtrace_prvdesc;
779 pap = &pvp->pv_desc.dtvd_attr;
781 pip->dtp_attr = pap->dtpa_provider;
784 pip->dtp_attr = dt_attr_min(pip->dtp_attr, pap->dtpa_mod);
786 pip->dtp_attr = dt_attr_min(pip->dtp_attr, pap->dtpa_func);
788 pip->dtp_attr = dt_attr_min(pip->dtp_attr, pap->dtpa_name);
790 pip->dtp_arga = pap->dtpa_args;
791 pip->dtp_argv = prp->pr_argv;
792 pip->dtp_argc = prp->pr_argc;
798 dtrace_probe_info(dtrace_hdl_t *dtp,
799 const dtrace_probedesc_t *pdp, dtrace_probeinfo_t *pip)
801 return (dt_probe_info(dtp, pdp, pip) != NULL ? 0 : -1);
806 dt_probe_iter(dt_idhash_t *ihp, dt_ident_t *idp, dt_probe_iter_t *pit)
808 const dt_probe_t *prp = idp->di_data;
810 if (!dt_gmatch(prp->pr_name, pit->pit_pat))
811 return (0); /* continue on and examine next probe in hash */
813 (void) strlcpy(pit->pit_desc.dtpd_name, prp->pr_name, DTRACE_NAMELEN);
814 pit->pit_desc.dtpd_id = idp->di_id;
817 return (pit->pit_func(pit->pit_hdl, &pit->pit_desc, pit->pit_arg));
821 dtrace_probe_iter(dtrace_hdl_t *dtp,
822 const dtrace_probedesc_t *pdp, dtrace_probe_f *func, void *arg)
824 const char *provider = pdp ? pdp->dtpd_provider : NULL;
825 dtrace_id_t id = DTRACE_IDNONE;
827 dtrace_probedesc_t pd;
831 bzero(&pit, sizeof (pit));
835 pit.pit_pat = pdp ? pdp->dtpd_name : NULL;
837 for (pit.pit_pvp = dt_list_next(&dtp->dt_provlist);
838 pit.pit_pvp != NULL; pit.pit_pvp = dt_list_next(pit.pit_pvp)) {
840 if (pit.pit_pvp->pv_flags & DT_PROVIDER_IMPL)
841 continue; /* we'll get these later using dt_ioctl() */
843 if (!dt_gmatch(pit.pit_pvp->pv_desc.dtvd_name, provider))
846 (void) strlcpy(pit.pit_desc.dtpd_provider,
847 pit.pit_pvp->pv_desc.dtvd_name, DTRACE_PROVNAMELEN);
849 if ((rv = dt_idhash_iter(pit.pit_pvp->pv_probes,
850 (dt_idhash_f *)dt_probe_iter, &pit)) != 0)
855 cmd = DTRACEIOC_PROBEMATCH;
857 cmd = DTRACEIOC_PROBES;
861 bcopy(pdp, &pd, sizeof (pd));
865 if (dt_ioctl(dtp, cmd, &pd) != 0)
867 else if ((rv = func(dtp, &pd, arg)) != 0)
877 return (pit.pit_matches ? 0 : dt_set_errno(dtp, EDT_NOPROBE));
879 return (dt_set_errno(dtp, EDT_BADPGLOB));
881 return (dt_set_errno(dtp, errno));