[PATCH 33/38] Eliminate dt_pdesc

eugene.loh
2024-06-27T05:39:45Z

From: Eugene Loh <eugene.loh@oracle.com>

Signed-off-by: Eugene Loh <eugene.loh@oracle.com>
---
libdtrace/dt_cc.c | 8 +-------
libdtrace/dt_consume.c | 3 +--
libdtrace/dt_handle.c | 2 +-
libdtrace/dt_impl.h | 7 ++-----
libdtrace/dt_map.c | 36 +++++++-----------------------------
5 files changed, 12 insertions(+), 44 deletions(-)

diff --git a/libdtrace/dt_cc.c b/libdtrace/dt_cc.c
index 3d9a9c79..d09a9775 100644
--- a/libdtrace/dt_cc.c
+++ b/libdtrace/dt_cc.c
@@ -958,7 +958,6 @@ dt_link_construct(dtrace_hdl_t *dtp, const dt_probe_t *prp, dtrace_difo_t *dp,
uint_t len = sdp->dtdo_brelen;
const dof_relodesc_t *rp = sdp->dtdo_breltab;
dof_relodesc_t *nrp = &dp->dtdo_breltab[rc];
- dtrace_id_t prid = prp->desc->id;
int no_deps = 0;

if (idp != NULL) {
@@ -1199,11 +1198,6 @@ dt_link_construct(dtrace_hdl_t *dtp, const dt_probe_t *prp, dtrace_difo_t *dp,
case DT_CONST_STACK_SKIP:
nrp->dofr_data = prp->prov->impl->stack_skip;
continue;
- default:
- /* probe name -> value is probe id */
- if (strchr(idp->di_name, ':') != NULL)
- prid = rp->dofr_data;
- continue;
}

continue;
@@ -1220,7 +1214,7 @@ dt_link_construct(dtrace_hdl_t *dtp, const dt_probe_t *prp, dtrace_difo_t *dp,
if (rdp == NULL)
return -1;
if (rdp->dtdo_ddesc != NULL) {
- nepid = dt_epid_add(dtp, rdp->dtdo_ddesc, prid);
+ nepid = dt_epid_add(dtp, rdp->dtdo_ddesc);
clid++;
} else
nepid = 0;
diff --git a/libdtrace/dt_consume.c b/libdtrace/dt_consume.c
index adbd2c7f..8d96789e 100644
--- a/libdtrace/dt_consume.c
+++ b/libdtrace/dt_consume.c
@@ -2229,8 +2229,7 @@ dt_consume_one_probe(dtrace_hdl_t *dtp, FILE *fp, char *data, uint32_t size,
pdat->dtpda_epid = epid;
pdat->dtpda_data = data;

- rval = dt_epid_lookup(dtp, epid, &pdat->dtpda_ddesc,
- &pdat->dtpda_pdesc);
+ rval = dt_epid_lookup(dtp, epid, &pdat->dtpda_ddesc);
if (rval != 0)
return dt_set_errno(dtp, EDT_BADEPID);
pdat->dtpda_pdesc = (dtrace_probedesc_t *)dtp->dt_probes[prid]->desc;
diff --git a/libdtrace/dt_handle.c b/libdtrace/dt_handle.c
index b1ba5f9f..79ecbac8 100644
--- a/libdtrace/dt_handle.c
+++ b/libdtrace/dt_handle.c
@@ -150,7 +150,7 @@ dt_handle_err(dtrace_hdl_t *dtp, dtrace_probedata_t *data)
*/
epid = DT_REC(uint64_t, 0);

- if (dt_epid_lookup(dtp, epid, &errdd, &errpd) != 0)
+ if (dt_epid_lookup(dtp, epid, &errdd) != 0)
return dt_set_errno(dtp, EDT_BADERROR);
errpd = (dtrace_probedesc_t *)dtp->dt_probes[epid>>32]->desc;
err.dteda_ddesc = errdd;
diff --git a/libdtrace/dt_impl.h b/libdtrace/dt_impl.h
index 445cd602..f8799b86 100644
--- a/libdtrace/dt_impl.h
+++ b/libdtrace/dt_impl.h
@@ -371,7 +371,6 @@ struct dtrace_hdl {
dtrace_epid_t dt_nextepid; /* next enabled probe ID to assign */
size_t dt_maxprobe; /* max enabled probe ID */
dtrace_datadesc_t **dt_ddesc; /* probe data descriptions */
- dtrace_probedesc_t **dt_pdesc; /* probe descriptions for enabled prbs */
size_t dt_maxagg; /* max aggregation ID */
dtrace_aggdesc_t **dt_adesc; /* aggregation descriptions */
dt_aggregate_t dt_aggregate; /* aggregate */
@@ -826,10 +825,8 @@ extern dtrace_datadesc_t *dt_datadesc_hold(dtrace_datadesc_t *ddp);
extern void dt_datadesc_release(dtrace_hdl_t *, dtrace_datadesc_t *);
extern dtrace_datadesc_t *dt_datadesc_create(dtrace_hdl_t *);
extern int dt_datadesc_finalize(dtrace_hdl_t *, dtrace_datadesc_t *);
-extern dtrace_epid_t dt_epid_add(dtrace_hdl_t *, dtrace_datadesc_t *,
- dtrace_id_t);
-extern int dt_epid_lookup(dtrace_hdl_t *, dtrace_epid_t, dtrace_datadesc_t **,
- dtrace_probedesc_t **);
+extern dtrace_epid_t dt_epid_add(dtrace_hdl_t *, dtrace_datadesc_t *);
+extern int dt_epid_lookup(dtrace_hdl_t *, dtrace_epid_t, dtrace_datadesc_t **);
extern void dt_epid_destroy(dtrace_hdl_t *);
typedef void (*dt_cg_gap_f)(dt_pcb_t *, int);
extern uint32_t dt_rec_add(dtrace_hdl_t *, dt_cg_gap_f, dtrace_actkind_t,
diff --git a/libdtrace/dt_map.c b/libdtrace/dt_map.c
index fe6194a7..513224ba 100644
--- a/libdtrace/dt_map.c
+++ b/libdtrace/dt_map.c
@@ -91,7 +91,7 @@ dt_datadesc_finalize(dtrace_hdl_t *dtp, dtrace_datadesc_t *ddp)
* description.
*/
dtrace_epid_t
-dt_epid_add(dtrace_hdl_t *dtp, dtrace_datadesc_t *ddp, dtrace_id_t prid)
+dt_epid_add(dtrace_hdl_t *dtp, dtrace_datadesc_t *ddp)
{
dtrace_id_t max = dtp->dt_maxprobe;
dtrace_epid_t epid;
@@ -100,27 +100,19 @@ dt_epid_add(dtrace_hdl_t *dtp, dtrace_datadesc_t *ddp, dtrace_id_t prid)
if (epid >= max || dtp->dt_ddesc == NULL) {
dtrace_id_t nmax = max ? (max << 1) : 2;
dtrace_datadesc_t **nddesc;
- dtrace_probedesc_t **npdesc;

nddesc = dt_calloc(dtp, nmax, sizeof(void *));
- npdesc = dt_calloc(dtp, nmax, sizeof(void *));
- if (nddesc == NULL || npdesc == NULL) {
- dt_free(dtp, nddesc);
- dt_free(dtp, npdesc);
+ if (nddesc == NULL)
return dt_set_errno(dtp, EDT_NOMEM);
- }

if (dtp->dt_ddesc != NULL) {
size_t osize = max * sizeof(void *);

memcpy(nddesc, dtp->dt_ddesc, osize);
dt_free(dtp, dtp->dt_ddesc);
- memcpy(npdesc, dtp->dt_pdesc, osize);
- dt_free(dtp, dtp->dt_pdesc);
}

dtp->dt_ddesc = nddesc;
- dtp->dt_pdesc = npdesc;
dtp->dt_maxprobe = nmax;
}

@@ -128,24 +120,20 @@ dt_epid_add(dtrace_hdl_t *dtp, dtrace_datadesc_t *ddp, dtrace_id_t prid)
return epid;

dtp->dt_ddesc[epid] = dt_datadesc_hold(ddp);
- dtp->dt_pdesc[epid] = (dtrace_probedesc_t *)dtp->dt_probes[prid]->desc;

return epid;
}

int
-dt_epid_lookup(dtrace_hdl_t *dtp, dtrace_epid_t epid, dtrace_datadesc_t **ddp,
- dtrace_probedesc_t **pdp)
+dt_epid_lookup(dtrace_hdl_t *dtp, dtrace_epid_t epid, dtrace_datadesc_t **ddp)
{
/* Remove the PRID portion of the EPID. */
epid &= 0xffffffff;

- if (epid >= dtp->dt_maxprobe ||
- dtp->dt_ddesc[epid] == NULL || dtp->dt_pdesc[epid] == NULL)
+ if (epid >= dtp->dt_maxprobe || dtp->dt_ddesc[epid] == NULL)
return -1;

*ddp = dtp->dt_ddesc[epid];
- *pdp = dtp->dt_pdesc[epid];

return 0;
}
@@ -155,26 +143,16 @@ dt_epid_destroy(dtrace_hdl_t *dtp)
{
size_t i;

- assert((dtp->dt_pdesc != NULL && dtp->dt_ddesc != NULL &&
- dtp->dt_maxprobe > 0) || (dtp->dt_pdesc == NULL &&
- dtp->dt_ddesc == NULL && dtp->dt_maxprobe == 0));
-
- if (dtp->dt_pdesc == NULL)
- return;
+ assert((dtp->dt_ddesc != NULL && dtp->dt_maxprobe > 0) ||
+ (dtp->dt_ddesc == NULL && dtp->dt_maxprobe == 0));

for (i = 0; i < dtp->dt_maxprobe; i++) {
- if (dtp->dt_ddesc[i] == NULL) {
- assert(dtp->dt_pdesc[i] == NULL);
+ if (dtp->dt_ddesc[i] == NULL)
continue;
- }

dt_datadesc_release(dtp, dtp->dt_ddesc[i]);
- assert(dtp->dt_pdesc[i] != NULL);
}

- free(dtp->dt_pdesc);
- dtp->dt_pdesc = NULL;
-
free(dtp->dt_ddesc);
dtp->dt_ddesc = NULL;
dtp->dt_nextepid = 0;
--
2.18.4