Changeset View
Changeset View
Standalone View
Standalone View
head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_provider.c
Show First 20 Lines • Show All 539 Lines • ▼ Show 20 Lines | dt_probe_define(dt_provider_t *pvp, dt_probe_t *prp, | ||||
dt_probe_instance_t *pip; | dt_probe_instance_t *pip; | ||||
uint32_t **offs; | uint32_t **offs; | ||||
uint_t *noffs, *maxoffs; | uint_t *noffs, *maxoffs; | ||||
assert(fname != NULL); | assert(fname != NULL); | ||||
for (pip = prp->pr_inst; pip != NULL; pip = pip->pi_next) { | for (pip = prp->pr_inst; pip != NULL; pip = pip->pi_next) { | ||||
if (strcmp(pip->pi_fname, fname) == 0 && | if (strcmp(pip->pi_fname, fname) == 0 && | ||||
((rname == NULL && pip->pi_rname == NULL) || | strcmp(pip->pi_rname, rname) == 0) | ||||
(rname != NULL && pip->pi_rname != NULL && | |||||
strcmp(pip->pi_rname, rname) == 0))) | |||||
break; | break; | ||||
} | } | ||||
if (pip == NULL) { | if (pip == NULL) { | ||||
if ((pip = dt_zalloc(dtp, sizeof (*pip))) == NULL) | if ((pip = dt_zalloc(dtp, sizeof (*pip))) == NULL) | ||||
return (-1); | return (-1); | ||||
if ((pip->pi_offs = dt_zalloc(dtp, sizeof (uint32_t))) == NULL) | if ((pip->pi_offs = dt_zalloc(dtp, sizeof (uint32_t))) == NULL) | ||||
goto nomem; | goto nomem; | ||||
if ((pip->pi_enoffs = dt_zalloc(dtp, | if ((pip->pi_enoffs = dt_zalloc(dtp, | ||||
sizeof (uint32_t))) == NULL) | sizeof (uint32_t))) == NULL) | ||||
goto nomem; | goto nomem; | ||||
if ((pip->pi_fname = strdup(fname)) == NULL) | if ((pip->pi_fname = strdup(fname)) == NULL) | ||||
goto nomem; | goto nomem; | ||||
if (rname != NULL && (pip->pi_rname = strdup(rname)) == NULL) | if ((pip->pi_rname = strdup(rname)) == NULL) | ||||
goto nomem; | goto nomem; | ||||
pip->pi_noffs = 0; | pip->pi_noffs = 0; | ||||
pip->pi_maxoffs = 1; | pip->pi_maxoffs = 1; | ||||
pip->pi_nenoffs = 0; | pip->pi_nenoffs = 0; | ||||
pip->pi_maxenoffs = 1; | pip->pi_maxenoffs = 1; | ||||
pip->pi_next = prp->pr_inst; | pip->pi_next = prp->pr_inst; | ||||
Show All 23 Lines | if (*noffs == *maxoffs) { | ||||
dt_free(dtp, *offs); | dt_free(dtp, *offs); | ||||
*maxoffs = new_max; | *maxoffs = new_max; | ||||
*offs = new_offs; | *offs = new_offs; | ||||
} | } | ||||
dt_dprintf("defined probe %s %s:%s %s() +0x%x (%s)\n", | dt_dprintf("defined probe %s %s:%s %s() +0x%x (%s)\n", | ||||
isenabled ? "(is-enabled)" : "", | isenabled ? "(is-enabled)" : "", | ||||
pvp->pv_desc.dtvd_name, prp->pr_ident->di_name, fname, offset, | pvp->pv_desc.dtvd_name, prp->pr_ident->di_name, fname, offset, | ||||
rname != NULL ? rname : fname); | rname); | ||||
assert(*noffs < *maxoffs); | assert(*noffs < *maxoffs); | ||||
(*offs)[(*noffs)++] = offset; | (*offs)[(*noffs)++] = offset; | ||||
return (0); | return (0); | ||||
nomem: | nomem: | ||||
dt_free(dtp, pip->pi_fname); | dt_free(dtp, pip->pi_fname); | ||||
▲ Show 20 Lines • Show All 286 Lines • Show Last 20 Lines |