Lines Matching defs:probe
46 * - Non-probe context utility functions
166 static vmem_t *dtrace_arena; /* probe ID arena */
188 static dtrace_genid_t dtrace_probegen; /* current probe generation */
201 * etc. Importantly, dtrace_lock is _not_ required when in probe context;
202 * probe context is lock-free -- synchronization is handled via the
225 static kmutex_t dtrace_lock; /* probe state lock */
266 static dtrace_id_t dtrace_probeid_begin; /* special BEGIN probe */
267 static dtrace_id_t dtrace_probeid_end; /* special END probe */
268 dtrace_id_t dtrace_probeid_error; /* special ERROR probe */
313 #define DTRACE_HASHSTR(hash, probe) \
314 dtrace_hash_str(*((char **)((uintptr_t)(probe) + (hash)->dth_stroffs)))
316 #define DTRACE_HASHNEXT(hash, probe) \
317 (dtrace_probe_t **)((uintptr_t)(probe) + (hash)->dth_nextoffs)
319 #define DTRACE_HASHPREV(hash, probe) \
320 (dtrace_probe_t **)((uintptr_t)(probe) + (hash)->dth_prevoffs)
448 #define DTRACE_ANCHORED(probe) ((probe)->dtpr_func[0] != '\0')
491 * These functions are called from probe context. Because probe context is
494 * As a result, functions called from probe context may only call other DTrace
496 * (Note that the ASSERT macro is made probe-context safe by redefining it in
497 * terms of dtrace_assfail(), a probe-context safe function.) If arbitrary
498 * loads are to be performed from probe context, they _must_ be in terms of
501 * Some functions in this block are not actually called from probe context;
503 * "Note: not called from probe context."
528 * Atomically increment a specified error counter from probe context.
534 * Most counters stored to in probe context are per-CPU counters.
769 * structures cannot change over the duration of probe context,
1377 * the current probe to continue. Note that this routine may allow continued
1385 dtrace_probe_t *probe = ecb->dte_probe;
1386 dtrace_provider_t *prov = probe->dtpr_provider;
1394 probe->dtpr_id, probe->dtpr_arg);
1403 * see user-mode firings of this probe, check that the probe was fired
1405 * specified by the provider to determine if we drop the probe or
1486 * Note: not called from probe context. This function is called
1487 * asynchronously (and at a regular interval) from outside of probe context to
2812 * Note: not called from probe context. This function is called
2858 * Note: not called from probe context. This function is called
3002 * The easy case: this probe is allowed to read all of memory, so
3196 * If this is an unanchored probe, we are
3276 * Note that we are assuming that an unanchored probe is
3459 * amount of work done in probe context. As such, it is implemented as a
4456 * valid within multiple enablings of the same probe --
6352 dtrace_probe_t *probe = ecb->dte_probe;
6353 dtrace_provider_t *prov = probe->dtpr_provider;
6355 char *msg = "dtrace: breakpoint action at probe ";
6365 * It's impossible to be taking action on the NULL probe.
6367 ASSERT(probe != NULL);
6372 * the probe, along with the hex address of the ECB with the breakpoint
6383 for (str = probe->dtpr_mod; *str != '\0'; str++)
6387 for (str = probe->dtpr_func; *str != '\0'; str++)
6391 for (str = probe->dtpr_name; *str != '\0'; str++)
6414 dtrace_probe_t *probe = ecb->dte_probe;
6417 * It's impossible to be taking action on the NULL probe.
6419 ASSERT(probe != NULL);
6435 dtrace_panic("dtrace: panic action at probe %s:%s:%s:%s (ecb %p)",
6436 probe->dtpr_provider->dtpv_name, probe->dtpr_mod,
6437 probe->dtpr_func, probe->dtpr_name, (void *)ecb);
6692 * is the function called by the provider to fire a probe -- from which all
6693 * subsequent probe-context DTrace activity emanates.
6701 dtrace_probe_t *probe;
6720 probe = dtrace_probes[id - 1];
6726 if (!onintr && probe->dtpr_predcache != DTRACE_CACHEIDNONE &&
6727 probe->dtpr_predcache == curthread->t_predcache) {
6752 mstate.dtms_probe = probe;
6762 for (ecb = probe->dtpr_ecb; ecb != NULL; ecb = ecb->dte_next) {
6768 dtrace_provider_t *prov = probe->dtpr_provider;
6797 * If dtrace itself is the provider of this probe,
6817 * probe. If we are, we will only continue processing
6822 if (probe->dtpr_id == dtrace_probeid_begin &&
6890 dtrace_cacheid_t cid = probe->dtpr_predcache;
6961 size / sizeof (pc_t), probe->dtpr_aframes,
6962 DTRACE_ANCHORED(probe) ? NULL :
7239 if (probe->dtpr_id == dtrace_probeid_error) {
7242 * error on the error probe. We bump an
7297 * sections) are not _called_ from probe context. (Any exceptions to this are
7300 * the DTrace probe hashes. (Each probe is hashed by each element of the
7301 * probe tuple -- allowing for fast lookups, regardless of what was
7366 dtrace_probe_t *probe = bucket->dthb_chain;
7368 ASSERT(probe != NULL);
7369 ndx = DTRACE_HASHSTR(hash, probe) & new_mask;
7453 dtrace_hash_remove(dtrace_hash_t *hash, dtrace_probe_t *probe)
7455 int ndx = DTRACE_HASHSTR(hash, probe) & hash->dth_mask;
7458 dtrace_probe_t **prevp = DTRACE_HASHPREV(hash, probe);
7459 dtrace_probe_t **nextp = DTRACE_HASHNEXT(hash, probe);
7462 * Find the bucket that we're removing this probe from.
7465 if (DTRACE_HASHEQ(hash, bucket->dthb_chain, probe))
7474 * The removed probe was the only probe on this
7479 ASSERT(bucket->dthb_chain == probe);
7508 * These are random utility functions that are _not_ called from probe context.
7623 * a probe tuple, or some globbed expressions for elements of a probe tuple.
7843 dtrace_probe_t template, *probe;
7851 * If the probe ID is specified in the key, just lookup by ID and
7852 * invoke the match callback once if a matching probe is found.
7855 if ((probe = dtrace_probe_lookup_id(pkp->dtpk_id)) != NULL &&
7856 dtrace_match_probe(probe, pkp, priv, uid, zoneid) > 0) {
7857 if ((*matched)(probe, arg) == DTRACE_MATCH_FAIL)
7893 * If we did not select a hash table, iterate over every probe and
7894 * invoke our callback for each one that matches our input probe key.
7898 if ((probe = dtrace_probes[i]) == NULL ||
7899 dtrace_match_probe(probe, pkp, priv, uid,
7905 if ((rc = (*matched)(probe, arg)) !=
7917 * If we selected a hash table, iterate over each probe of the same key
7918 * name and invoke the callback for every probe that matches the other
7919 * attributes of our input probe key.
7921 for (probe = dtrace_hash_lookup(hash, &template); probe != NULL;
7922 probe = *(DTRACE_HASHNEXT(hash, probe))) {
7924 if (dtrace_match_probe(probe, pkp, priv, uid, zoneid) <= 0)
7929 if ((rc = (*matched)(probe, arg)) != DTRACE_MATCH_NEXT) {
7962 * Build a probe comparison key for use with dtrace_match_probe() from the
7963 * given probe description. By convention, a null key only matches anchored
7997 * the functions in the API for probe management (found below), and
8150 dtrace_probe_t *probe, *first = NULL;
8196 if ((probe = dtrace_probes[i]) == NULL)
8199 if (probe->dtpr_provider != old)
8202 if (probe->dtpr_ecb == NULL)
8235 * remove all of them from their hash chains and from the probe array.
8238 if ((probe = dtrace_probes[i]) == NULL)
8241 if (probe->dtpr_provider != old)
8246 dtrace_hash_remove(dtrace_bymod, probe);
8247 dtrace_hash_remove(dtrace_byfunc, probe);
8248 dtrace_hash_remove(dtrace_byname, probe);
8251 first = probe;
8252 probe->dtpr_nextmod = NULL;
8254 probe->dtpr_nextmod = first;
8255 first = probe;
8261 * from the probe array. Now issue a dtrace_sync() to be sure that
8262 * everyone has cleared out from any probe array processing.
8266 for (probe = first; probe != NULL; probe = first) {
8267 first = probe->dtpr_nextmod;
8269 old->dtpv_pops.dtps_destroy(old->dtpv_arg, probe->dtpr_id,
8270 probe->dtpr_arg);
8271 kmem_free(probe->dtpr_mod, strlen(probe->dtpr_mod) + 1);
8272 kmem_free(probe->dtpr_func, strlen(probe->dtpr_func) + 1);
8273 kmem_free(probe->dtpr_name, strlen(probe->dtpr_name) + 1);
8274 vmem_free(dtrace_arena, (void *)(uintptr_t)(probe->dtpr_id), 1);
8275 kmem_free(probe, sizeof (dtrace_probe_t));
8307 * Invalidate the specified provider. All subsequent probe lookups for the
8351 dtrace_probe_t *probe;
8366 if ((probe = dtrace_probes[i]) == NULL)
8369 if (probe->dtpr_provider != prov)
8372 if (probe->dtpr_ecb != NULL)
8377 dtrace_hash_remove(dtrace_bymod, probe);
8378 dtrace_hash_remove(dtrace_byfunc, probe);
8379 dtrace_hash_remove(dtrace_byname, probe);
8382 probe->dtpr_arg);
8383 kmem_free(probe->dtpr_mod, strlen(probe->dtpr_mod) + 1);
8384 kmem_free(probe->dtpr_func, strlen(probe->dtpr_func) + 1);
8385 kmem_free(probe->dtpr_name, strlen(probe->dtpr_name) + 1);
8386 kmem_free(probe, sizeof (dtrace_probe_t));
8399 * The functions in this section perform the DTrace probe management,
8407 * Create a probe with the specified module name, function name, and name.
8413 dtrace_probe_t *probe, **probes;
8425 probe = kmem_zalloc(sizeof (dtrace_probe_t), KM_SLEEP);
8427 probe->dtpr_id = id;
8428 probe->dtpr_gen = dtrace_probegen++;
8429 probe->dtpr_mod = dtrace_strdup(mod);
8430 probe->dtpr_func = dtrace_strdup(func);
8431 probe->dtpr_name = dtrace_strdup(name);
8432 probe->dtpr_arg = arg;
8433 probe->dtpr_aframes = aframes;
8434 probe->dtpr_provider = provider;
8436 dtrace_hash_add(dtrace_bymod, probe);
8437 dtrace_hash_add(dtrace_byfunc, probe);
8438 dtrace_hash_add(dtrace_byname, probe);
8477 dtrace_probes[id - 1] = probe;
8497 dtrace_probe_lookup_match(dtrace_probe_t *probe, void *arg)
8499 *((dtrace_id_t *)arg) = probe->dtpr_id;
8505 * Look up a probe based on provider and one or more of module name, function
8506 * name and probe name.
8536 * Returns the probe argument associated with the specified probe.
8541 dtrace_probe_t *probe;
8546 if ((probe = dtrace_probe_lookup_id(pid)) != NULL &&
8547 probe->dtpr_provider == (dtrace_provider_t *)id)
8548 rval = probe->dtpr_arg;
8556 * Copy a probe into a probe description.
8573 * Called to indicate that a probe -- or probes -- should be provided by a
8578 * opportunity to dynamically provide the specified probe, allowing providers
8628 * Iterate over each probe, and call the Framework-to-Provider API function
8636 dtrace_probe_t *probe;
8641 * We disable interrupts to walk through the probe array. This is
8648 if ((probe = dtrace_probes[i]) == NULL)
8651 if (probe->dtpr_ecb == NULL) {
8653 * This probe isn't enabled -- don't call the function.
8658 prov = probe->dtpr_provider;
8662 func(prov->dtpv_arg, i + 1, probe->dtpr_arg);
8682 * create an ECB with a NULL probe.
8731 dof_probe_t *probe;
8783 probe = (dof_probe_t *)(uintptr_t)(daddr +
8787 dhpb.dthpb_func = strtab + probe->dofpr_func;
8788 dhpb.dthpb_name = strtab + probe->dofpr_name;
8789 dhpb.dthpb_base = probe->dofpr_addr;
8790 dhpb.dthpb_offs = off + probe->dofpr_offidx;
8791 dhpb.dthpb_noffs = probe->dofpr_noffs;
8793 dhpb.dthpb_enoffs = enoff + probe->dofpr_enoffidx;
8794 dhpb.dthpb_nenoffs = probe->dofpr_nenoffs;
8799 dhpb.dthpb_args = arg + probe->dofpr_argidx;
8800 dhpb.dthpb_nargc = probe->dofpr_nargc;
8801 dhpb.dthpb_xargc = probe->dofpr_xargc;
8802 dhpb.dthpb_ntypes = strtab + probe->dofpr_nargv;
8803 dhpb.dthpb_xtypes = strtab + probe->dofpr_xargv;
10319 dtrace_ecb_add(dtrace_state_t *state, dtrace_probe_t *probe)
10328 ecb->dte_probe = probe;
10388 dtrace_probe_t *probe = ecb->dte_probe;
10394 if (probe == NULL) {
10396 * This is the NULL probe -- there's nothing to do.
10401 if (probe->dtpr_ecb == NULL) {
10402 dtrace_provider_t *prov = probe->dtpr_provider;
10405 * We're the first ECB on this probe.
10407 probe->dtpr_ecb = probe->dtpr_ecb_last = ecb;
10410 probe->dtpr_predcache = ecb->dte_predicate->dtp_cacheid;
10413 probe->dtpr_id, probe->dtpr_arg));
10416 * This probe is already active. Swing the last pointer to
10420 ASSERT(probe->dtpr_ecb_last != NULL);
10421 probe->dtpr_ecb_last->dte_next = ecb;
10422 probe->dtpr_ecb_last = ecb;
10423 probe->dtpr_predcache = 0;
11005 * We disable the ECB by removing it from its probe.
11008 dtrace_probe_t *probe = ecb->dte_probe;
11012 if (probe == NULL) {
11014 * This is the NULL probe; there is nothing to disable.
11019 for (pecb = probe->dtpr_ecb; pecb != NULL; pecb = pecb->dte_next) {
11028 probe->dtpr_ecb = ecb->dte_next;
11033 if (ecb == probe->dtpr_ecb_last) {
11035 probe->dtpr_ecb_last = prev;
11039 * The ECB has been disconnected from the probe; now sync to assure
11044 if (probe->dtpr_ecb == NULL) {
11046 * That was the last ECB on the probe; clear the predicate
11047 * cache ID for the probe, disable it and sync one more time
11050 dtrace_provider_t *prov = probe->dtpr_provider;
11053 ASSERT(probe->dtpr_ecb_last == NULL);
11054 probe->dtpr_predcache = DTRACE_CACHEIDNONE;
11056 probe->dtpr_id, probe->dtpr_arg);
11060 * There is at least one ECB remaining on the probe. If there
11061 * is _exactly_ one, set the probe's predicate cache ID to be
11064 ASSERT(probe->dtpr_ecb_last != NULL);
11065 ASSERT(probe->dtpr_predcache == DTRACE_CACHEIDNONE);
11067 if (probe->dtpr_ecb == probe->dtpr_ecb_last) {
11068 dtrace_predicate_t *p = probe->dtpr_ecb->dte_predicate;
11070 ASSERT(probe->dtpr_ecb->dte_next == NULL);
11073 probe->dtpr_predcache = p->dtp_cacheid;
11104 dtrace_ecb_create(dtrace_state_t *state, dtrace_probe_t *probe,
11116 ecb = dtrace_ecb_add(state, probe);
11124 if (probe != NULL) {
11134 * and DTRACE_COND_ZONEOWNER will then do at probe time.
11136 prov = probe->dtpr_provider;
11189 dtrace_ecb_create_enable(dtrace_probe_t *probe, void *arg)
11197 if (probe != NULL && probe->dtpr_gen < enab->dten_probegen) {
11199 * This probe was created in a generation for which this
11206 if ((ecb = dtrace_ecb_create(state, probe, enab)) == NULL)
11308 * that processes the BEGIN probe has its buffer activated
11408 * Note: called from probe context. This function just increments the drop
11421 * Note: called from probe context. This function is called to reserve space
11555 * the previous failed probe attempt. But at
11708 * if an ECB on a defunct probe (but for an active enabling) can be safely
11822 * specified ECB in every way, but has the specified probe description.
11848 cmn_err(CE_NOTE, "enabling probe %d (%s:%s:%s:%s)", i,
11981 * Now iterate over each probe description; we're looking for
11982 * an exact match to the specified probe description.
12001 * We have a winning probe! Add it to our growing
12062 * If a provider failed to enable a probe then get out and
12141 * NULL probe -- which is exactly what this function does.
12231 dtrace_probe_t *probe;
12240 if ((probe = dtrace_probes[i]) == NULL)
12243 if (probe->dtpr_ecb == NULL)
12246 prov = probe->dtpr_provider;
12275 * associated with the probe, we quit trying -- reaping is only
12279 while ((ecb = probe->dtpr_ecb) != NULL) {
12294 ASSERT(probe->dtpr_ecb != ecb);
12509 dof_probedesc_t *probe;
12516 dtrace_dof_error(dof, "invalid probe section");
12521 dtrace_dof_error(dof, "bad alignment in probe description");
12526 dtrace_dof_error(dof, "truncated probe description");
12530 probe = (dof_probedesc_t *)(uintptr_t)(daddr + sec->dofs_offset);
12531 strtab = dtrace_dof_sect(dof, DOF_SECT_STRTAB, probe->dofp_strtab);
12539 if (probe->dofp_provider >= strtab->dofs_size) {
12540 dtrace_dof_error(dof, "corrupt probe provider");
12545 (char *)(str + probe->dofp_provider),
12546 MIN(DTRACE_PROVNAMELEN - 1, size - probe->dofp_provider));
12548 if (probe->dofp_mod >= strtab->dofs_size) {
12549 dtrace_dof_error(dof, "corrupt probe module");
12553 (void) strncpy(desc->dtpd_mod, (char *)(str + probe->dofp_mod),
12554 MIN(DTRACE_MODNAMELEN - 1, size - probe->dofp_mod));
12556 if (probe->dofp_func >= strtab->dofs_size) {
12557 dtrace_dof_error(dof, "corrupt probe function");
12561 (void) strncpy(desc->dtpd_func, (char *)(str + probe->dofp_func),
12562 MIN(DTRACE_FUNCNAMELEN - 1, size - probe->dofp_func));
12564 if (probe->dofp_name >= strtab->dofs_size) {
12565 dtrace_dof_error(dof, "corrupt probe name");
12569 (void) strncpy(desc->dtpd_name, (char *)(str + probe->dofp_name),
12570 MIN(DTRACE_NAMELEN - 1, size - probe->dofp_name));
13509 * other hand, it saves an additional memory reference in the probe
13543 * Depending on the user credentials, we set flag bits which alter probe
13557 * examine the credential and the zone from probe context.
13768 dtrace_probe_t *probe;
13779 probe = dtrace_probes[dtrace_probeid_end - 1];
13780 ASSERT(probe != NULL);
13782 for (ecb = probe->dtpr_ecb; ecb != NULL; ecb = ecb->dte_next) {
14015 * Now it's time to actually fire the BEGIN probe. We need to disable
14017 * probe (the data from this CPU will be processed first at user
14029 * We may have had an exit action from a BEGIN probe; only change our
14042 * processing an ECB halfway down a probe's ECB chain; all CPUs will
14106 * iff we're in the END probe.
14113 * Finally, we can release the reserve and call the END probe. We
14114 * disable interrupts across calling the END probe to allow us to
14115 * return the CPU on which we actually called the END probe. This
14234 * issue a sync to be sure that everyone is out of probe
14260 dtrace_probe_t *probe = ecb->dte_probe;
14261 dtrace_provider_t *prov = probe->dtpr_provider;
14277 * every CPU is out of probe context.
14950 dof_probe_t *probe;
15036 probe = (dof_probe_t *)(uintptr_t)(daddr +
15039 if (probe->dofpr_func >= str_sec->dofs_size) {
15044 if (strlen(strtab + probe->dofpr_func) >= DTRACE_FUNCNAMELEN) {
15049 if (probe->dofpr_name >= str_sec->dofs_size ||
15050 strlen(strtab + probe->dofpr_name) >= DTRACE_NAMELEN) {
15051 dtrace_dof_error(dof, "invalid probe name");
15059 if (probe->dofpr_offidx + probe->dofpr_noffs <
15060 probe->dofpr_offidx ||
15061 (probe->dofpr_offidx + probe->dofpr_noffs) *
15063 dtrace_dof_error(dof, "invalid probe offset");
15071 * perform the same checks as for probe offsets
15075 if (probe->dofpr_enoffidx != 0 ||
15076 probe->dofpr_nenoffs != 0) {
15081 } else if (probe->dofpr_enoffidx +
15082 probe->dofpr_nenoffs < probe->dofpr_enoffidx ||
15083 (probe->dofpr_enoffidx + probe->dofpr_nenoffs) *
15090 if (probe->dofpr_noffs + probe->dofpr_nenoffs == 0) {
15091 dtrace_dof_error(dof, "zero probe and "
15095 } else if (probe->dofpr_noffs == 0) {
15096 dtrace_dof_error(dof, "zero probe offsets");
15100 if (probe->dofpr_argidx + probe->dofpr_xargc <
15101 probe->dofpr_argidx ||
15102 (probe->dofpr_argidx + probe->dofpr_xargc) *
15108 typeidx = probe->dofpr_nargv;
15109 typestr = strtab + probe->dofpr_nargv;
15110 for (k = 0; k < probe->dofpr_nargc; k++) {
15127 typeidx = probe->dofpr_xargv;
15128 typestr = strtab + probe->dofpr_xargv;
15129 for (k = 0; k < probe->dofpr_xargc; k++) {
15130 if (arg[probe->dofpr_argidx + k] > probe->dofpr_nargc) {
15512 dtrace_probe_t template, *probe, *first, *next;
15532 for (probe = first = dtrace_hash_lookup(dtrace_bymod, &template);
15533 probe != NULL; probe = probe->dtpr_nextmod) {
15534 if (probe->dtpr_ecb != NULL) {
15541 * unloading a module that has an enabled probe in it.
15547 * probe, either.
15558 probe = first;
15560 for (first = NULL; probe != NULL; probe = next) {
15561 ASSERT(dtrace_probes[probe->dtpr_id - 1] == probe);
15563 dtrace_probes[probe->dtpr_id - 1] = NULL;
15565 next = probe->dtpr_nextmod;
15566 dtrace_hash_remove(dtrace_bymod, probe);
15567 dtrace_hash_remove(dtrace_byfunc, probe);
15568 dtrace_hash_remove(dtrace_byname, probe);
15571 first = probe;
15572 probe->dtpr_nextmod = NULL;
15574 probe->dtpr_nextmod = first;
15575 first = probe;
15581 * from the probe array. Now issue a dtrace_sync() to be sure that
15582 * everyone has cleared out from any probe array processing.
15586 for (probe = first; probe != NULL; probe = first) {
15587 first = probe->dtpr_nextmod;
15588 prov = probe->dtpr_provider;
15589 prov->dtpv_pops.dtps_destroy(prov->dtpv_arg, probe->dtpr_id,
15590 probe->dtpr_arg);
15591 kmem_free(probe->dtpr_mod, strlen(probe->dtpr_mod) + 1);
15592 kmem_free(probe->dtpr_func, strlen(probe->dtpr_func) + 1);
15593 kmem_free(probe->dtpr_name, strlen(probe->dtpr_name) + 1);
15594 vmem_free(dtrace_arena, (void *)(uintptr_t)probe->dtpr_id, 1);
15595 kmem_free(probe, sizeof (dtrace_probe_t));
15726 * in probe context -- that assures that a dtrace_sync() can be used
15999 * CPU is in probe context with enabled helper tracing
16395 dtrace_probe_t *probe = NULL;
16413 * Before we attempt to match this probe, we want to give
16434 if ((probe = dtrace_probes[i - 1]) != NULL &&
16435 (m = dtrace_match_probe(probe, &pkey,
16447 if ((probe = dtrace_probes[i - 1]) != NULL &&
16448 dtrace_match_priv(probe, priv, uid, zoneid))
16453 if (probe == NULL) {
16458 dtrace_probe_description(probe, &desc);
16469 dtrace_probe_t *probe;
16492 if ((probe = dtrace_probes[desc.dtargd_id - 1]) == NULL) {
16501 prov = probe->dtpr_provider;
16505 * There isn't any typed information for this probe.
16515 probe->dtpr_id, probe->dtpr_arg, &desc);
17007 nulldev, /* probe */