Skip to content

Commit

Permalink
Include aggregates in the DIFO vartab
Browse files Browse the repository at this point in the history
Aggregates used to be handled as special identifiers.  Under the new
design they will be handled more like variables and it is therefore
warranted to include them in the variable table.

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
Reviewed-by: Eugene Loh <eugene.loh@oracle.com>
  • Loading branch information
kvanhees committed Nov 30, 2020
1 parent 287e4bf commit cbba0c7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
1 change: 1 addition & 0 deletions include/dtrace/dif_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ typedef uint32_t dif_instr_t;

#define DIFV_KIND_ARRAY 0
#define DIFV_KIND_SCALAR 1
#define DIFV_KIND_AGGREGATE 2

#define DIFV_SCOPE_GLOBAL 0
#define DIFV_SCOPE_THREAD 1
Expand Down
24 changes: 19 additions & 5 deletions libdtrace/dt_as.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ dt_countvar(dt_idhash_t *dhp, dt_ident_t *idp, void *data)
size_t *np = data;

if (idp->di_flags & (DT_IDFLG_DIFR | DT_IDFLG_DIFW))
(*np)++; /* include variable in vartab */
(*np)++; /* include variable in vartab */
else if (idp->di_kind == DT_IDENT_AGG)
(*np)++; /* include variable in vartab */

return (0);
}
Expand All @@ -76,8 +78,9 @@ dt_copyvar(dt_idhash_t *dhp, dt_ident_t *idp, dtrace_hdl_t *dtp)
ssize_t stroff;
dt_node_t dn;

if (!(idp->di_flags & (DT_IDFLG_DIFR | DT_IDFLG_DIFW)))
return (0); /* omit variable from vartab */
if (!(idp->di_flags & (DT_IDFLG_DIFR | DT_IDFLG_DIFW)) &&
idp->di_kind != DT_IDENT_AGG)
return 0; /* omit variable from vartab */

dvp = &pcb->pcb_difo->dtdo_vartab[pcb->pcb_asvidx++];
stroff = dt_strtab_insert(dtp->dt_ccstab, idp->di_name);
Expand All @@ -91,8 +94,17 @@ dt_copyvar(dt_idhash_t *dhp, dt_ident_t *idp, dtrace_hdl_t *dtp)
dvp->dtdv_id = idp->di_id;
dvp->dtdv_flags = 0;

dvp->dtdv_kind = (idp->di_kind == DT_IDENT_ARRAY) ?
DIFV_KIND_ARRAY : DIFV_KIND_SCALAR;
switch (idp->di_kind) {
case DT_IDENT_AGG:
dvp->dtdv_kind = DIFV_KIND_AGGREGATE;
break;
case DT_IDENT_ARRAY:
dvp->dtdv_kind = DIFV_KIND_ARRAY;
break;
default:
dvp->dtdv_kind = DIFV_KIND_SCALAR;
}


if (idp->di_flags & DT_IDFLG_LOCAL)
dvp->dtdv_scope = DIFV_SCOPE_LOCAL;
Expand Down Expand Up @@ -358,6 +370,7 @@ dt_as(dt_pcb_t *pcb)
* table we insert the corresponding variable names into the strtab.
*/
dt_idhash_iter(dtp->dt_tls, dt_countvar, &n);
dt_idhash_iter(dtp->dt_aggs, dt_countvar, &n);
dt_idhash_iter(dtp->dt_globals, dt_countvar, &n);
dt_idhash_iter(pcb->pcb_locals, dt_countvar, &n);

Expand All @@ -369,6 +382,7 @@ dt_as(dt_pcb_t *pcb)
longjmp(pcb->pcb_jmpbuf, EDT_NOMEM);

dt_idhash_iter(dtp->dt_tls, (dt_idhash_f *)dt_copyvar, dtp);
dt_idhash_iter(dtp->dt_aggs, (dt_idhash_f *)dt_copyvar, dtp);
dt_idhash_iter(dtp->dt_globals, (dt_idhash_f *)dt_copyvar, dtp);
dt_idhash_iter(pcb->pcb_locals, (dt_idhash_f *)dt_copyvar, dtp);
}
Expand Down
3 changes: 3 additions & 0 deletions libdtrace/dt_dis.c
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,9 @@ dt_dis_difo(const dtrace_difo_t *dp, FILE *fp)
char kind[4], scope[4], range[12], flags[16] = { 0 };

switch (v->dtdv_kind) {
case DIFV_KIND_AGGREGATE:
strcpy(kind, "agg");
break;
case DIFV_KIND_ARRAY:
strcpy(kind, "arr");
break;
Expand Down

0 comments on commit cbba0c7

Please sign in to comment.