[DTrace-devel] [PATCH 1/2] cc: remove dead code
Eugene Loh
eugene.loh at oracle.com
Thu Aug 24 16:28:07 UTC 2023
Reviewed-by: Eugene Loh <eugene.loh at oracle.com>
On 8/24/23 11:13, Kris Van Hees via DTrace-devel wrote:
> The legacy implementation of actions was retained in dt_cc.c for
> reference, but now that almost all are implemented in the new code base
> there is no reason to retain them.
>
> Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
> ---
> libdtrace/dt_cc.c | 1304 ---------------------------------------------
> 1 file changed, 1304 deletions(-)
>
> diff --git a/libdtrace/dt_cc.c b/libdtrace/dt_cc.c
> index 90cb788f..86807caa 100644
> --- a/libdtrace/dt_cc.c
> +++ b/libdtrace/dt_cc.c
> @@ -133,1310 +133,6 @@ dt_stmt_create(dtrace_hdl_t *dtp, dtrace_ecbdesc_t *edp,
> return sdp;
> }
>
> -#ifdef FIXME
> -/*
> - * For the first element of an aggregation tuple or for printa(), we create a
> - * simple DIF program that simply returns the immediate value that is the ID
> - * of the aggregation itself. This could be optimized in the future by
> - * creating a new in-kernel dtad_kind that just returns an integer.
> - */
> -static void
> -dt_action_difconst(dtrace_actdesc_t *ap, uint_t id, dtrace_actkind_t kind)
> -{
> - dtrace_hdl_t *dtp = yypcb->pcb_hdl;
> - dtrace_difo_t *dp = dt_zalloc(dtp, sizeof(dtrace_difo_t));
> -
> - if (dp == NULL)
> - longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
> -
> - dp->dtdo_buf = dt_calloc(dtp, 2, sizeof(dif_instr_t));
> - if (dp->dtdo_buf == NULL) {
> - dt_difo_free(dtp, dp);
> - longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
> - }
> -
> - dp->dtdo_buf[0] = BPF_MOV_IMM(BPF_REG_0, 0); /* mov %r0, 0 */
> - dp->dtdo_buf[1] = BPF_RETURN(); /* exit */
> - dp->dtdo_len = 2;
> - dp->dtdo_rtype = dt_int_rtype;
> -
> - ap->dtad_difo = dp;
> - ap->dtad_kind = kind;
> -}
> -
> -static void
> -dt_action_clear(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
> -{
> - dt_ident_t *aid;
> - dtrace_actdesc_t *ap;
> - dt_node_t *anp;
> -
> - char n[DT_TYPE_NAMELEN];
> -
> - anp = dnp->dn_args;
> - assert(anp != NULL);
> -
> - if (anp->dn_kind != DT_NODE_AGG)
> - dnerror(dnp, D_CLEAR_AGGARG,
> - "%s( ) argument #1 is incompatible with prototype:\n"
> - "\tprototype: aggregation\n\t argument: %s\n",
> - dnp->dn_ident->di_name,
> - dt_node_type_name(anp, n, sizeof(n)));
> -
> - aid = anp->dn_ident;
> -
> - if (aid->di_gen == dtp->dt_gen && !(aid->di_flags & DT_IDFLG_MOD))
> - dnerror(dnp, D_CLEAR_AGGBAD,
> - "undefined aggregation: @%s\n", aid->di_name);
> -
> - ap = dt_stmt_action(dtp, sdp);
> - dt_action_difconst(ap, anp->dn_ident->di_id, DTRACEACT_LIBACT);
> - ap->dtad_arg = DT_ACT_CLEAR;
> -}
> -
> -static void
> -dt_action_normalize(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
> -{
> - dt_ident_t *aid;
> - dtrace_actdesc_t *ap;
> - dt_node_t *anp, *normal;
> - int denormal = (strcmp(dnp->dn_ident->di_name, "denormalize") == 0);
> -
> - char n[DT_TYPE_NAMELEN];
> - int argc = 0;
> -
> - for (anp = dnp->dn_args; anp != NULL; anp = anp->dn_list)
> - argc++; /* count up arguments for error messages below */
> -
> - if ((denormal && argc != 1) || (!denormal && argc != 2)) {
> - dnerror(dnp, D_NORMALIZE_PROTO,
> - "%s( ) prototype mismatch: %d args passed, %d expected\n",
> - dnp->dn_ident->di_name, argc, denormal ? 1 : 2);
> - }
> -
> - anp = dnp->dn_args;
> - assert(anp != NULL);
> -
> - if (anp->dn_kind != DT_NODE_AGG) {
> - dnerror(dnp, D_NORMALIZE_AGGARG,
> - "%s( ) argument #1 is incompatible with prototype:\n"
> - "\tprototype: aggregation\n\t argument: %s\n",
> - dnp->dn_ident->di_name,
> - dt_node_type_name(anp, n, sizeof(n)));
> - }
> -
> - if ((normal = anp->dn_list) != NULL && !dt_node_is_scalar(normal)) {
> - dnerror(dnp, D_NORMALIZE_SCALAR,
> - "%s( ) argument #2 must be of scalar type\n",
> - dnp->dn_ident->di_name);
> - }
> -
> - aid = anp->dn_ident;
> -
> - if (aid->di_gen == dtp->dt_gen && !(aid->di_flags & DT_IDFLG_MOD)) {
> - dnerror(dnp, D_NORMALIZE_AGGBAD,
> - "undefined aggregation: @%s\n", aid->di_name);
> - }
> -
> - ap = dt_stmt_action(dtp, sdp);
> - dt_action_difconst(ap, anp->dn_ident->di_id, DTRACEACT_LIBACT);
> -
> - if (denormal) {
> - ap->dtad_arg = DT_ACT_DENORMALIZE;
> - return;
> - }
> -
> - ap->dtad_arg = DT_ACT_NORMALIZE;
> -
> - assert(normal != NULL);
> - ap = dt_stmt_action(dtp, sdp);
> - dt_cg(yypcb, normal);
> -
> - ap->dtad_difo = dt_as(yypcb);
> - ap->dtad_kind = DTRACEACT_LIBACT;
> - ap->dtad_arg = DT_ACT_NORMALIZE;
> -}
> -
> -static void
> -dt_action_trunc(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
> -{
> - dt_ident_t *aid;
> - dtrace_actdesc_t *ap;
> - dt_node_t *anp, *trunc;
> -
> - char n[DT_TYPE_NAMELEN];
> - int argc = 0;
> -
> - for (anp = dnp->dn_args; anp != NULL; anp = anp->dn_list)
> - argc++; /* count up arguments for error messages below */
> -
> - if (argc > 2 || argc < 1) {
> - dnerror(dnp, D_TRUNC_PROTO,
> - "%s( ) prototype mismatch: %d args passed, %s expected\n",
> - dnp->dn_ident->di_name, argc,
> - argc < 1 ? "at least 1" : "no more than 2");
> - }
> -
> - anp = dnp->dn_args;
> - assert(anp != NULL);
> - trunc = anp->dn_list;
> -
> - if (anp->dn_kind != DT_NODE_AGG) {
> - dnerror(dnp, D_TRUNC_AGGARG,
> - "%s( ) argument #1 is incompatible with prototype:\n"
> - "\tprototype: aggregation\n\t argument: %s\n",
> - dnp->dn_ident->di_name,
> - dt_node_type_name(anp, n, sizeof(n)));
> - }
> -
> - if (argc == 2) {
> - assert(trunc != NULL);
> - if (!dt_node_is_scalar(trunc)) {
> - dnerror(dnp, D_TRUNC_SCALAR,
> - "%s( ) argument #2 must be of scalar type\n",
> - dnp->dn_ident->di_name);
> - }
> - }
> -
> - aid = anp->dn_ident;
> -
> - if (aid->di_gen == dtp->dt_gen && !(aid->di_flags & DT_IDFLG_MOD)) {
> - dnerror(dnp, D_TRUNC_AGGBAD,
> - "undefined aggregation: @%s\n", aid->di_name);
> - }
> -
> - ap = dt_stmt_action(dtp, sdp);
> - dt_action_difconst(ap, anp->dn_ident->di_id, DTRACEACT_LIBACT);
> - ap->dtad_arg = DT_ACT_TRUNC;
> -
> - ap = dt_stmt_action(dtp, sdp);
> -
> - if (argc == 1) {
> - dt_action_difconst(ap, 0, DTRACEACT_LIBACT);
> - } else {
> - assert(trunc != NULL);
> - dt_cg(yypcb, trunc);
> - ap->dtad_difo = dt_as(yypcb);
> - ap->dtad_kind = DTRACEACT_LIBACT;
> - }
> -
> - ap->dtad_arg = DT_ACT_TRUNC;
> -}
> -
> -static void
> -dt_action_printa(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
> -{
> - dt_ident_t *aid, *fid;
> - dtrace_actdesc_t *ap;
> - const char *format;
> - dt_node_t *anp, *proto = NULL;
> -
> - char n[DT_TYPE_NAMELEN];
> - int argc = 0, argr = 0;
> -
> - for (anp = dnp->dn_args; anp != NULL; anp = anp->dn_list)
> - argc++; /* count up arguments for error messages below */
> -
> - switch (dnp->dn_args->dn_kind) {
> - case DT_NODE_STRING:
> - format = dnp->dn_args->dn_string;
> - anp = dnp->dn_args->dn_list;
> - argr = 2;
> - break;
> - case DT_NODE_AGG:
> - format = NULL;
> - anp = dnp->dn_args;
> - argr = 1;
> - break;
> - default:
> - format = NULL;
> - anp = dnp->dn_args;
> - argr = 1;
> - }
> -
> - if (argc < argr) {
> - dnerror(dnp, D_PRINTA_PROTO,
> - "%s( ) prototype mismatch: %d args passed, %d expected\n",
> - dnp->dn_ident->di_name, argc, argr);
> - }
> -
> - assert(anp != NULL);
> -
> - while (anp != NULL) {
> - if (anp->dn_kind != DT_NODE_AGG) {
> - dnerror(dnp, D_PRINTA_AGGARG,
> - "%s( ) argument #%d is incompatible with "
> - "prototype:\n\tprototype: aggregation\n"
> - "\t argument: %s\n", dnp->dn_ident->di_name, argr,
> - dt_node_type_name(anp, n, sizeof(n)));
> - }
> -
> - aid = anp->dn_ident;
> - fid = aid->di_iarg;
> -
> - if (aid->di_gen == dtp->dt_gen &&
> - !(aid->di_flags & DT_IDFLG_MOD)) {
> - dnerror(dnp, D_PRINTA_AGGBAD,
> - "undefined aggregation: @%s\n", aid->di_name);
> - }
> -
> - /*
> - * If we have multiple aggregations, we must be sure that
> - * their key signatures match.
> - */
> - if (proto != NULL) {
> - dt_printa_validate(proto, anp);
> - } else {
> - proto = anp;
> - }
> -
> - if (format != NULL) {
> - yylineno = dnp->dn_line;
> -
> - sdp->dtsd_fmtdata =
> - dt_printf_create(yypcb->pcb_hdl, format);
> - dt_printf_validate(sdp->dtsd_fmtdata,
> - DT_PRINTF_AGGREGATION, dnp->dn_ident, 1,
> - fid->di_id, ((dt_idsig_t *)aid->di_data)->dis_args);
> - format = NULL;
> - }
> -
> - ap = dt_stmt_action(dtp, sdp);
> - dt_action_difconst(ap, anp->dn_ident->di_id, DTRACEACT_PRINTA);
> -
> - anp = anp->dn_list;
> - argr++;
> - }
> -}
> -
> -static void
> -dt_action_printflike(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp,
> - dtrace_actkind_t kind)
> -{
> - dt_node_t *anp, *arg1;
> - dtrace_actdesc_t *ap = NULL;
> - char n[DT_TYPE_NAMELEN], *str;
> -
> - assert(DTRACEACT_ISPRINTFLIKE(kind));
> -
> - if (dnp->dn_args->dn_kind != DT_NODE_STRING) {
> - dnerror(dnp, D_PRINTF_ARG_FMT,
> - "%s( ) argument #1 is incompatible with prototype:\n"
> - "\tprototype: string constant\n\t argument: %s\n",
> - dnp->dn_ident->di_name,
> - dt_node_type_name(dnp->dn_args, n, sizeof(n)));
> - }
> -
> - arg1 = dnp->dn_args->dn_list;
> - yylineno = dnp->dn_line;
> - str = dnp->dn_args->dn_string;
> -
> -
> - /*
> - * If this is an freopen(), we use an empty string to denote that
> - * stdout should be restored. For other printf()-like actions, an
> - * empty format string is illegal: an empty format string would
> - * result in malformed DOF, and the compiler thus flags an empty
> - * format string as a compile-time error. To avoid propagating the
> - * freopen() special case throughout the system, we simply transpose
> - * an empty string into a sentinel string (DT_FREOPEN_RESTORE) that
> - * denotes that stdout should be restored.
> - */
> - if (kind == DTRACEACT_FREOPEN) {
> - if (strcmp(str, DT_FREOPEN_RESTORE) == 0) {
> - /*
> - * Our sentinel is always an invalid argument to
> - * freopen(), but if it's been manually specified, we
> - * must fail now instead of when the freopen() is
> - * actually evaluated.
> - */
> - dnerror(dnp, D_FREOPEN_INVALID,
> - "%s( ) argument #1 cannot be \"%s\"\n",
> - dnp->dn_ident->di_name, DT_FREOPEN_RESTORE);
> - }
> -
> - if (str[0] == '\0')
> - str = DT_FREOPEN_RESTORE;
> - }
> -
> - sdp->dtsd_fmtdata = dt_printf_create(dtp, str);
> -
> - dt_printf_validate(sdp->dtsd_fmtdata, DT_PRINTF_EXACTLEN,
> - dnp->dn_ident, 1, DTRACEACT_AGGREGATION, arg1);
> -
> - if (arg1 == NULL) {
> - struct bpf_insn *dbuf;
> - dtrace_difo_t *dp;
> -
> - if ((dbuf = dt_alloc(dtp, sizeof(struct bpf_insn))) == NULL ||
> - (dp = dt_zalloc(dtp, sizeof(dtrace_difo_t))) == NULL) {
> - dt_free(dtp, dbuf);
> - longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
> - }
> -
> - dbuf[0] = BPF_RETURN(); /* ret %r0 */
> -
> - dp->dtdo_buf = dbuf;
> - dp->dtdo_len = 1;
> - dp->dtdo_rtype = dt_int_rtype;
> -
> - ap = dt_stmt_action(dtp, sdp);
> - ap->dtad_difo = dp;
> - ap->dtad_kind = kind;
> - return;
> - }
> -
> - for (anp = arg1; anp != NULL; anp = anp->dn_list) {
> - ap = dt_stmt_action(dtp, sdp);
> - dt_cg(yypcb, anp);
> - ap->dtad_difo = dt_as(yypcb);
> - ap->dtad_kind = kind;
> - }
> -}
> -
> -static void
> -dt_action_trace(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
> -{
> - dtrace_actdesc_t *ap = dt_stmt_action(dtp, sdp);
> -
> - if (dt_node_is_void(dnp->dn_args)) {
> - dnerror(dnp->dn_args, D_TRACE_VOID,
> - "trace( ) may not be applied to a void expression\n");
> - }
> -
> - if (dt_node_is_dynamic(dnp->dn_args)) {
> - dnerror(dnp->dn_args, D_TRACE_DYN,
> - "trace( ) may not be applied to a dynamic expression\n");
> - }
> -
> - dt_cg(yypcb, dnp->dn_args);
> - ap->dtad_difo = dt_as(yypcb);
> - ap->dtad_kind = DTRACEACT_DIFEXPR;
> -}
> -
> -static void
> -dt_action_tracemem(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
> -{
> - dtrace_actdesc_t *ap;
> -
> - dt_node_t *addr = dnp->dn_args;
> - dt_node_t *size = dnp->dn_args->dn_list;
> - dt_node_t *dsize;
> -
> - char n[DT_TYPE_NAMELEN];
> -
> - if (dt_node_is_integer(addr) == 0 && dt_node_is_pointer(addr) == 0) {
> - dnerror(addr, D_TRACEMEM_ADDR,
> - "tracemem( ) argument #1 is incompatible with "
> - "prototype:\n\tprototype: pointer or integer\n"
> - "\t argument: %s\n",
> - dt_node_type_name(addr, n, sizeof(n)));
> - }
> -
> - if (dt_node_is_posconst(size) == 0) {
> - dnerror(size, D_TRACEMEM_SIZE, "tracemem( ) argument #2 must "
> - "be a non-zero positive integral constant expression\n");
> - }
> -
> - ap = dt_stmt_action(dtp, sdp);
> - dt_cg(yypcb, addr);
> - ap->dtad_difo = dt_as(yypcb);
> - ap->dtad_kind = DTRACEACT_TRACEMEM;
> - ap->dtad_difo->dtdo_rtype.dtdt_flags |= DIF_TF_BYREF;
> - ap->dtad_difo->dtdo_rtype.dtdt_size = size->dn_value;
> -
> - if ((dsize = size->dn_list) != NULL) {
> - ctf_file_t *fp = dsize->dn_ctfp;
> - ctf_id_t type = dsize->dn_type;
> - ctf_encoding_t e;
> -
> - ap->dtad_arg = DTRACE_TRACEMEM_DYNAMIC;
> -
> - ap = dt_stmt_action(dtp, sdp);
> - dt_cg(yypcb, dsize);
> - ap->dtad_difo = dt_as(yypcb);
> - ap->dtad_kind = DTRACEACT_TRACEMEM;
> -
> - if (ctf_type_encoding(fp, ctf_type_resolve(fp, type), &e) == CTF_ERR)
> - longjmp(yypcb->pcb_jmpbuf, EDT_CTF);
> -
> - if (e.cte_format & CTF_INT_SIGNED)
> - ap->dtad_arg = DTRACE_TRACEMEM_SSIZE;
> - else
> - ap->dtad_arg = DTRACE_TRACEMEM_SIZE;
> - } else {
> - ap->dtad_arg = DTRACE_TRACEMEM_STATIC;
> - }
> -}
> -
> -static void
> -dt_action_stack_args(dtrace_hdl_t *dtp, dtrace_actdesc_t *ap, dt_node_t *arg0)
> -{
> - ap->dtad_kind = DTRACEACT_STACK;
> -
> - if (dtp->dt_options[DTRACEOPT_STACKFRAMES] != DTRACEOPT_UNSET) {
> - ap->dtad_arg = dtp->dt_options[DTRACEOPT_STACKFRAMES];
> - } else {
> - ap->dtad_arg = 0;
> - }
> -
> - if (arg0 != NULL) {
> - if (arg0->dn_list != NULL) {
> - dnerror(arg0, D_STACK_PROTO, "stack( ) prototype "
> - "mismatch: too many arguments\n");
> - }
> -
> - if (dt_node_is_posconst(arg0) == 0) {
> - dnerror(arg0, D_STACK_SIZE, "stack( ) size must be a "
> - "non-zero positive integral constant expression\n");
> - }
> -
> - ap->dtad_arg = arg0->dn_value;
> - }
> -}
> -
> -static void
> -dt_action_stack(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
> -{
> - dtrace_actdesc_t *ap = dt_stmt_action(dtp, sdp);
> - dt_action_stack_args(dtp, ap, dnp->dn_args);
> -}
> -
> -static void
> -dt_action_ustack_args(dtrace_hdl_t *dtp, dtrace_actdesc_t *ap, dt_node_t *dnp)
> -{
> - uint32_t nframes = 0;
> - uint32_t strsize = 0; /* default string table size */
> - dt_node_t *arg0 = dnp->dn_args;
> - dt_node_t *arg1 = arg0 != NULL ? arg0->dn_list : NULL;
> -
> - assert(dnp->dn_ident->di_id == DT_ACT_JSTACK ||
> - dnp->dn_ident->di_id == DT_ACT_USTACK);
> -
> - if (dnp->dn_ident->di_id == DT_ACT_JSTACK) {
> - if (dtp->dt_options[DTRACEOPT_JSTACKFRAMES] != DTRACEOPT_UNSET)
> - nframes = dtp->dt_options[DTRACEOPT_JSTACKFRAMES];
> -
> - if (dtp->dt_options[DTRACEOPT_JSTACKSTRSIZE] != DTRACEOPT_UNSET)
> - strsize = dtp->dt_options[DTRACEOPT_JSTACKSTRSIZE];
> -
> - ap->dtad_kind = DTRACEACT_JSTACK;
> - } else {
> - assert(dnp->dn_ident->di_id == DT_ACT_USTACK);
> -
> - if (dtp->dt_options[DTRACEOPT_USTACKFRAMES] != DTRACEOPT_UNSET)
> - nframes = dtp->dt_options[DTRACEOPT_USTACKFRAMES];
> -
> - ap->dtad_kind = DTRACEACT_USTACK;
> - }
> -
> - if (arg0 != NULL) {
> - if (!dt_node_is_posconst(arg0)) {
> - dnerror(arg0, D_USTACK_FRAMES, "ustack( ) argument #1 "
> - "must be a non-zero positive integer constant\n");
> - }
> - nframes = (uint32_t)arg0->dn_value;
> - }
> -
> - if (arg1 != NULL) {
> - if (arg1->dn_kind != DT_NODE_INT ||
> - ((arg1->dn_flags & DT_NF_SIGNED) &&
> - (int64_t)arg1->dn_value < 0)) {
> - dnerror(arg1, D_USTACK_STRSIZE, "ustack( ) argument #2 "
> - "must be a positive integer constant\n");
> - }
> -
> - if (arg1->dn_list != NULL) {
> - dnerror(arg1, D_USTACK_PROTO, "ustack( ) prototype "
> - "mismatch: too many arguments\n");
> - }
> -
> - strsize = (uint32_t)arg1->dn_value;
> - }
> -
> - ap->dtad_arg = DTRACE_USTACK_ARG(nframes, strsize);
> -}
> -
> -static void
> -dt_action_ustack(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
> -{
> - dtrace_actdesc_t *ap = dt_stmt_action(dtp, sdp);
> - dt_action_ustack_args(dtp, ap, dnp);
> -}
> -
> -static void
> -dt_action_setopt(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
> -{
> - dtrace_actdesc_t *ap;
> - dt_node_t *arg0, *arg1;
> -
> - /*
> - * The prototype guarantees that we are called with either one or
> - * two arguments, and that any arguments that are present are strings.
> - */
> - arg0 = dnp->dn_args;
> - arg1 = arg0->dn_list;
> -
> - ap = dt_stmt_action(dtp, sdp);
> - dt_cg(yypcb, arg0);
> - ap->dtad_difo = dt_as(yypcb);
> - ap->dtad_kind = DTRACEACT_LIBACT;
> - ap->dtad_arg = DT_ACT_SETOPT;
> -
> - ap = dt_stmt_action(dtp, sdp);
> -
> - if (arg1 == NULL) {
> - dt_action_difconst(ap, 0, DTRACEACT_LIBACT);
> - } else {
> - dt_cg(yypcb, arg1);
> - ap->dtad_difo = dt_as(yypcb);
> - ap->dtad_kind = DTRACEACT_LIBACT;
> - }
> -
> - ap->dtad_arg = DT_ACT_SETOPT;
> -}
> -
> -/*ARGSUSED*/
> -static void
> -dt_action_symmod_args(dtrace_hdl_t *dtp, dtrace_actdesc_t *ap,
> - dt_node_t *dnp, dtrace_actkind_t kind)
> -{
> - assert(kind == DTRACEACT_SYM || kind == DTRACEACT_MOD ||
> - kind == DTRACEACT_USYM || kind == DTRACEACT_UMOD ||
> - kind == DTRACEACT_UADDR);
> -
> - dt_cg(yypcb, dnp);
> - ap->dtad_difo = dt_as(yypcb);
> - ap->dtad_kind = kind;
> - ap->dtad_difo->dtdo_rtype.dtdt_size = sizeof(uint64_t);
> -}
> -
> -static void
> -dt_action_symmod(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp,
> - dtrace_actkind_t kind)
> -{
> - dtrace_actdesc_t *ap = dt_stmt_action(dtp, sdp);
> - dt_action_symmod_args(dtp, ap, dnp->dn_args, kind);
> -}
> -
> -/*ARGSUSED*/
> -static void
> -dt_action_ftruncate(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
> -{
> - dtrace_actdesc_t *ap = dt_stmt_action(dtp, sdp);
> -
> - /*
> - * Library actions need a DIFO that serves as an argument. As
> - * ftruncate() doesn't take an argument, we generate the constant 0
> - * in a DIFO; this constant will be ignored when the ftruncate() is
> - * processed.
> - */
> - dt_action_difconst(ap, 0, DTRACEACT_LIBACT);
> - ap->dtad_arg = DT_ACT_FTRUNCATE;
> -}
> -
> -/*ARGSUSED*/
> -static void
> -dt_action_stop(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
> -{
> - dtrace_actdesc_t *ap = dt_stmt_action(dtp, sdp);
> -
> - ap->dtad_kind = DTRACEACT_STOP;
> - ap->dtad_arg = 0;
> -}
> -
> -/*ARGSUSED*/
> -static void
> -dt_action_breakpoint(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
> -{
> - dtrace_actdesc_t *ap = dt_stmt_action(dtp, sdp);
> -
> - ap->dtad_kind = DTRACEACT_BREAKPOINT;
> - ap->dtad_arg = 0;
> -}
> -
> -/*ARGSUSED*/
> -static void
> -dt_action_panic(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
> -{
> - dtrace_actdesc_t *ap = dt_stmt_action(dtp, sdp);
> -
> - ap->dtad_kind = DTRACEACT_PANIC;
> - ap->dtad_arg = 0;
> -}
> -
> -static void
> -dt_action_pcap(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
> -{
> - dtrace_actdesc_t *ap;
> - dt_node_t *addr = dnp->dn_args;
> - dt_node_t *anp, *proto;
> - char n[DT_TYPE_NAMELEN];
> - int argc = 0;
> -
> - for (anp = dnp->dn_args; anp != NULL; anp = anp->dn_list)
> - argc++;
> -
> - if (argc != 2) {
> - dnerror(dnp, D_PCAP_PROTO,
> - "%s( ) prototype mismatch: %d args passed, 2 expected\n",
> - dnp->dn_ident->di_name, argc);
> - }
> -
> - if (dt_node_is_integer(addr) == 0 && dt_node_is_pointer(addr) == 0) {
> - dnerror(addr, D_PCAP_ADDR,
> - "pcap( ) argument #1 is incompatible with "
> - "prototype:\n\tprototype: pointer or integer\n"
> - "\t argument: %s\n",
> - dt_node_type_name(addr, n, sizeof(n)));
> - }
> -
> - proto = addr->dn_list;
> -
> - ap = dt_stmt_action(dtp, sdp);
> - dt_cg(yypcb, addr);
> - ap->dtad_difo = dt_as(yypcb);
> - ap->dtad_kind = DTRACEACT_PCAP;
> - ap->dtad_difo->dtdo_rtype.dtdt_flags |= DIF_TF_BYREF;
> -
> - /*
> - * Enough space for 64-bit timestamp, len and pkt data.
> - */
> -
> - ap->dtad_difo->dtdo_rtype.dtdt_size = (2 * sizeof(uint64_t)) +
> - DT_PCAPSIZE(dtp->dt_options[DTRACEOPT_PCAPSIZE]);
> - ap->dtad_arg = 0;
> -
> - ap = dt_stmt_action(dtp, sdp);
> - dt_cg(yypcb, proto);
> - ap->dtad_difo = dt_as(yypcb);
> - ap->dtad_kind = DTRACEACT_PCAP;
> -}
> -
> -static void
> -dt_action_chill(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
> -{
> - dtrace_actdesc_t *ap = dt_stmt_action(dtp, sdp);
> -
> - dt_cg(yypcb, dnp->dn_args);
> - ap->dtad_difo = dt_as(yypcb);
> - ap->dtad_kind = DTRACEACT_CHILL;
> -}
> -
> -static void
> -dt_action_raise(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
> -{
> - dtrace_actdesc_t *ap = dt_stmt_action(dtp, sdp);
> -
> - dt_cg(yypcb, dnp->dn_args);
> - ap->dtad_difo = dt_as(yypcb);
> - ap->dtad_kind = DTRACEACT_RAISE;
> -}
> -
> -static void
> -dt_action_exit(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
> -{
> - dtrace_actdesc_t *ap = dt_stmt_action(dtp, sdp);
> -
> - dt_cg(yypcb, dnp->dn_args);
> - ap->dtad_difo = dt_as(yypcb);
> - ap->dtad_kind = DTRACEACT_EXIT;
> - ap->dtad_difo->dtdo_rtype.dtdt_size = sizeof(int);
> -}
> -
> -static void
> -dt_action_speculate(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
> -{
> - dtrace_actdesc_t *ap = dt_stmt_action(dtp, sdp);
> -
> - dt_cg(yypcb, dnp->dn_args);
> - ap->dtad_difo = dt_as(yypcb);
> - ap->dtad_kind = DTRACEACT_SPECULATE;
> -}
> -
> -static void
> -dt_action_commit(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
> -{
> - dtrace_actdesc_t *ap = dt_stmt_action(dtp, sdp);
> -
> - dt_cg(yypcb, dnp->dn_args);
> - ap->dtad_difo = dt_as(yypcb);
> - ap->dtad_kind = DTRACEACT_COMMIT;
> -}
> -
> -static void
> -dt_action_discard(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
> -{
> - dtrace_actdesc_t *ap = dt_stmt_action(dtp, sdp);
> -
> - dt_cg(yypcb, dnp->dn_args);
> - ap->dtad_difo = dt_as(yypcb);
> - ap->dtad_kind = DTRACEACT_DISCARD;
> -}
> -
> -static void
> -dt_compile_fun(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
> -{
> - switch (dnp->dn_expr->dn_ident->di_id) {
> - case DT_ACT_BREAKPOINT:
> - dt_action_breakpoint(dtp, dnp->dn_expr, sdp);
> - break;
> - case DT_ACT_CHILL:
> - dt_action_chill(dtp, dnp->dn_expr, sdp);
> - break;
> - case DT_ACT_CLEAR:
> - dt_action_clear(dtp, dnp->dn_expr, sdp);
> - break;
> - case DT_ACT_COMMIT:
> - dt_action_commit(dtp, dnp->dn_expr, sdp);
> - break;
> - case DT_ACT_DENORMALIZE:
> - dt_action_normalize(dtp, dnp->dn_expr, sdp);
> - break;
> - case DT_ACT_DISCARD:
> - dt_action_discard(dtp, dnp->dn_expr, sdp);
> - break;
> - case DT_ACT_EXIT:
> - dt_action_exit(dtp, dnp->dn_expr, sdp);
> - break;
> - case DT_ACT_FREOPEN:
> - dt_action_printflike(dtp, dnp->dn_expr, sdp, DTRACEACT_FREOPEN);
> - break;
> - case DT_ACT_FTRUNCATE:
> - dt_action_ftruncate(dtp, dnp->dn_expr, sdp);
> - break;
> - case DT_ACT_MOD:
> - dt_action_symmod(dtp, dnp->dn_expr, sdp, DTRACEACT_MOD);
> - break;
> - case DT_ACT_NORMALIZE:
> - dt_action_normalize(dtp, dnp->dn_expr, sdp);
> - break;
> - case DT_ACT_PANIC:
> - dt_action_panic(dtp, dnp->dn_expr, sdp);
> - break;
> - case DT_ACT_PCAP:
> - dt_action_pcap(dtp, dnp->dn_expr, sdp);
> - break;
> - case DT_ACT_PRINTA:
> - dt_action_printa(dtp, dnp->dn_expr, sdp);
> - break;
> - case DT_ACT_PRINTF:
> - dt_action_printflike(dtp, dnp->dn_expr, sdp, DTRACEACT_PRINTF);
> - break;
> - case DT_ACT_RAISE:
> - dt_action_raise(dtp, dnp->dn_expr, sdp);
> - break;
> - case DT_ACT_SETOPT:
> - dt_action_setopt(dtp, dnp->dn_expr, sdp);
> - break;
> - case DT_ACT_SPECULATE:
> - dt_action_speculate(dtp, dnp->dn_expr, sdp);
> - break;
> - case DT_ACT_STACK:
> - dt_action_stack(dtp, dnp->dn_expr, sdp);
> - break;
> - case DT_ACT_STOP:
> - dt_action_stop(dtp, dnp->dn_expr, sdp);
> - break;
> - case DT_ACT_SYM:
> - dt_action_symmod(dtp, dnp->dn_expr, sdp, DTRACEACT_SYM);
> - break;
> - case DT_ACT_SYSTEM:
> - dt_action_printflike(dtp, dnp->dn_expr, sdp, DTRACEACT_SYSTEM);
> - break;
> - case DT_ACT_TRACE:
> - dt_action_trace(dtp, dnp->dn_expr, sdp);
> - break;
> - case DT_ACT_TRACEMEM:
> - dt_action_tracemem(dtp, dnp->dn_expr, sdp);
> - break;
> - case DT_ACT_TRUNC:
> - dt_action_trunc(dtp, dnp->dn_expr, sdp);
> - break;
> - case DT_ACT_UADDR:
> - dt_action_symmod(dtp, dnp->dn_expr, sdp, DTRACEACT_UADDR);
> - break;
> - case DT_ACT_UMOD:
> - dt_action_symmod(dtp, dnp->dn_expr, sdp, DTRACEACT_UMOD);
> - break;
> - case DT_ACT_USYM:
> - dt_action_symmod(dtp, dnp->dn_expr, sdp, DTRACEACT_USYM);
> - break;
> - case DT_ACT_USTACK:
> - case DT_ACT_JSTACK:
> - dt_action_ustack(dtp, dnp->dn_expr, sdp);
> - break;
> - default:
> - dnerror(dnp->dn_expr, D_UNKNOWN, "tracing function %s( ) is "
> - "not yet supported\n", dnp->dn_expr->dn_ident->di_name);
> - }
> -}
> -#endif
> -
> -#ifdef FIXME
> -static void
> -dt_compile_exp(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
> -{
> - dtrace_actdesc_t *ap = dt_stmt_action(dtp, sdp);
> -
> - dt_cg(yypcb, dnp->dn_expr);
> - ap->dtad_difo = dt_as(yypcb);
> - ap->dtad_difo->dtdo_rtype = dt_void_rtype;
> - ap->dtad_kind = DTRACEACT_DIFEXPR;
> -}
> -
> -static void
> -dt_compile_agg(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
> -{
> - dt_ident_t *aid, *fid;
> - dt_node_t *anp, *incr = NULL;
> - dtrace_actdesc_t *ap;
> - uint_t n = 1, argmax;
> - uint64_t arg = 0;
> -
> - /*
> - * If the aggregation has no aggregating function applied to it, then
> - * this statement has no effect. Flag this as a programming error.
> - */
> - if (dnp->dn_aggfun == NULL) {
> - dnerror(dnp, D_AGG_NULL, "expression has null effect: @%s\n",
> - dnp->dn_ident->di_name);
> - }
> -
> - aid = dnp->dn_ident;
> - fid = dnp->dn_aggfun->dn_ident;
> -
> - if (dnp->dn_aggfun->dn_args != NULL &&
> - dt_node_is_scalar(dnp->dn_aggfun->dn_args) == 0) {
> - dnerror(dnp->dn_aggfun, D_AGG_SCALAR, "%s( ) argument #1 must "
> - "be of scalar type\n", fid->di_name);
> - }
> -
> - /*
> - * The ID of the aggregation itself is implicitly recorded as the first
> - * member of each aggregation tuple so we can distinguish them later.
> - */
> - ap = dt_stmt_action(dtp, sdp);
> - dt_action_difconst(ap, aid->di_id, DTRACEACT_DIFEXPR);
> -
> - for (anp = dnp->dn_aggtup; anp != NULL; anp = anp->dn_list) {
> - ap = dt_stmt_action(dtp, sdp);
> - n++;
> -
> - if (anp->dn_kind == DT_NODE_FUNC) {
> - if (anp->dn_ident->di_id == DT_ACT_STACK) {
> - dt_action_stack_args(dtp, ap, anp->dn_args);
> - continue;
> - }
> -
> - if (anp->dn_ident->di_id == DT_ACT_USTACK ||
> - anp->dn_ident->di_id == DT_ACT_JSTACK) {
> - dt_action_ustack_args(dtp, ap, anp);
> - continue;
> - }
> -
> - switch (anp->dn_ident->di_id) {
> - case DT_ACT_UADDR:
> - dt_action_symmod_args(dtp, ap,
> - anp->dn_args, DTRACEACT_UADDR);
> - continue;
> -
> - case DT_ACT_USYM:
> - dt_action_symmod_args(dtp, ap,
> - anp->dn_args, DTRACEACT_USYM);
> - continue;
> -
> - case DT_ACT_UMOD:
> - dt_action_symmod_args(dtp, ap,
> - anp->dn_args, DTRACEACT_UMOD);
> - continue;
> -
> - case DT_ACT_SYM:
> - dt_action_symmod_args(dtp, ap,
> - anp->dn_args, DTRACEACT_SYM);
> - continue;
> -
> - case DT_ACT_MOD:
> - dt_action_symmod_args(dtp, ap,
> - anp->dn_args, DTRACEACT_MOD);
> - continue;
> -
> - default:
> - break;
> - }
> - }
> -
> - dt_cg(yypcb, anp);
> - ap->dtad_difo = dt_as(yypcb);
> - ap->dtad_kind = DTRACEACT_DIFEXPR;
> - }
> -
> - if (fid->di_id == DT_AGG_LQUANTIZE) {
> - /*
> - * For linear quantization, we have between two and four
> - * arguments in addition to the expression:
> - *
> - * arg1 => Base value
> - * arg2 => Limit value
> - * arg3 => Quantization level step size (defaults to 1)
> - * arg4 => Quantization increment value (defaults to 1)
> - */
> - dt_node_t *arg1 = dnp->dn_aggfun->dn_args->dn_list;
> - dt_node_t *arg2 = arg1->dn_list;
> - dt_node_t *arg3 = arg2->dn_list;
> - dt_idsig_t *isp;
> - uint64_t nlevels, step = 1, oarg;
> - int64_t baseval, limitval;
> -
> - if (arg1->dn_kind != DT_NODE_INT) {
> - dnerror(arg1, D_LQUANT_BASETYPE, "lquantize( ) "
> - "argument #1 must be an integer constant\n");
> - }
> -
> - baseval = (int64_t)arg1->dn_value;
> -
> - if (baseval < INT32_MIN || baseval > INT32_MAX) {
> - dnerror(arg1, D_LQUANT_BASEVAL, "lquantize( ) "
> - "argument #1 must be a 32-bit quantity\n");
> - }
> -
> - if (arg2->dn_kind != DT_NODE_INT) {
> - dnerror(arg2, D_LQUANT_LIMTYPE, "lquantize( ) "
> - "argument #2 must be an integer constant\n");
> - }
> -
> - limitval = (int64_t)arg2->dn_value;
> -
> - if (limitval < INT32_MIN || limitval > INT32_MAX) {
> - dnerror(arg2, D_LQUANT_LIMVAL, "lquantize( ) "
> - "argument #2 must be a 32-bit quantity\n");
> - }
> -
> - if (limitval < baseval) {
> - dnerror(dnp, D_LQUANT_MISMATCH,
> - "lquantize( ) base (argument #1) must be less "
> - "than limit (argument #2)\n");
> - }
> -
> - if (arg3 != NULL) {
> - if (!dt_node_is_posconst(arg3)) {
> - dnerror(arg3, D_LQUANT_STEPTYPE, "lquantize( ) "
> - "argument #3 must be a non-zero positive "
> - "integer constant\n");
> - }
> -
> - if ((step = arg3->dn_value) > UINT16_MAX) {
> - dnerror(arg3, D_LQUANT_STEPVAL, "lquantize( ) "
> - "argument #3 must be a 16-bit quantity\n");
> - }
> - }
> -
> - nlevels = (limitval - baseval) / step;
> -
> - if (nlevels == 0) {
> - dnerror(dnp, D_LQUANT_STEPLARGE,
> - "lquantize( ) step (argument #3) too large: must "
> - "have at least one quantization level\n");
> - }
> -
> - if (nlevels > UINT16_MAX) {
> - dnerror(dnp, D_LQUANT_STEPSMALL, "lquantize( ) step "
> - "(argument #3) too small: number of quantization "
> - "levels must be a 16-bit quantity\n");
> - }
> -
> - arg = (step << DTRACE_LQUANTIZE_STEPSHIFT) |
> - (nlevels << DTRACE_LQUANTIZE_LEVELSHIFT) |
> - ((baseval << DTRACE_LQUANTIZE_BASESHIFT) &
> - DTRACE_LQUANTIZE_BASEMASK);
> -
> - assert(arg != 0);
> -
> - isp = (dt_idsig_t *)aid->di_data;
> -
> - if (isp->dis_auxinfo == 0) {
> - /*
> - * This is the first time we've seen an lquantize()
> - * for this aggregation; we'll store our argument
> - * as the auxiliary signature information.
> - */
> - isp->dis_auxinfo = arg;
> - } else if ((oarg = isp->dis_auxinfo) != arg) {
> - /*
> - * If we have seen this lquantize() before and the
> - * argument doesn't match the original argument, pick
> - * the original argument apart to concisely report the
> - * mismatch.
> - */
> - int obaseval = DTRACE_LQUANTIZE_BASE(oarg);
> - int onlevels = DTRACE_LQUANTIZE_LEVELS(oarg);
> - int ostep = DTRACE_LQUANTIZE_STEP(oarg);
> -
> - if (obaseval != baseval) {
> - dnerror(dnp, D_LQUANT_MATCHBASE, "lquantize( ) "
> - "base (argument #1) doesn't match previous "
> - "declaration: expected %d, found %d\n",
> - obaseval, (int)baseval);
> - }
> -
> - if (onlevels * ostep != nlevels * step) {
> - dnerror(dnp, D_LQUANT_MATCHLIM, "lquantize( ) "
> - "limit (argument #2) doesn't match previous"
> - " declaration: expected %d, found %d\n",
> - obaseval + onlevels * ostep,
> - (int)baseval + (int)nlevels * (int)step);
> - }
> -
> - if (ostep != step) {
> - dnerror(dnp, D_LQUANT_MATCHSTEP, "lquantize( ) "
> - "step (argument #3) doesn't match previous "
> - "declaration: expected %d, found %d\n",
> - ostep, (int)step);
> - }
> -
> - /*
> - * We shouldn't be able to get here -- one of the
> - * parameters must be mismatched if the arguments
> - * didn't match.
> - */
> - assert(0);
> - }
> -
> - incr = arg3 != NULL ? arg3->dn_list : NULL;
> - argmax = 5;
> - }
> -
> - if (fid->di_id == DT_AGG_LLQUANTIZE) {
> - /*
> - * For log linear quantization, we have four
> - * arguments in addition to the expression:
> - *
> - * arg1 => Factor
> - * arg2 => Lower magnitude
> - * arg3 => Upper magnitude
> - * arg4 => Steps per magnitude
> - */
> - dt_node_t *arg1 = dnp->dn_aggfun->dn_args->dn_list;
> - dt_node_t *arg2 = arg1->dn_list;
> - dt_node_t *arg3 = arg2->dn_list;
> - dt_node_t *arg4 = arg3->dn_list;
> - dt_idsig_t *isp;
> - uint64_t factor, lmag, hmag, steps, oarg;
> -
> - if (arg1->dn_kind != DT_NODE_INT) {
> - dnerror(arg1, D_LLQUANT_FACTORTYPE, "llquantize( ) "
> - "argument #1 must be an integer constant\n");
> - }
> -
> - factor = (uint64_t)arg1->dn_value;
> -
> - if (factor > UINT16_MAX || factor < 2) {
> - dnerror(arg1, D_LLQUANT_FACTORVAL, "llquantize( ) "
> - "argument #1 must be an unsigned 16-bit "
> - "quantity greater than or equal to 2\n");
> - }
> -
> - if (arg2->dn_kind != DT_NODE_INT) {
> - dnerror(arg2, D_LLQUANT_LMAGTYPE, "llquantize( ) "
> - "argument #2 must be an integer constant\n");
> - }
> -
> - lmag = (uint64_t)arg2->dn_value;
> -
> - if (lmag > UINT16_MAX) {
> - dnerror(arg2, D_LLQUANT_LMAGVAL, "llquantize( ) "
> - "argument #2 must be an unsigned 16-bit "
> - "quantity\n");
> - }
> -
> - if (arg3->dn_kind != DT_NODE_INT) {
> - dnerror(arg3, D_LLQUANT_HMAGTYPE, "llquantize( ) "
> - "argument #3 must be an integer constant\n");
> - }
> -
> - hmag = (uint64_t)arg3->dn_value;
> -
> - if (hmag > UINT16_MAX) {
> - dnerror(arg3, D_LLQUANT_HMAGVAL, "llquantize( ) "
> - "argument #3 must be an unsigned 16-bit "
> - "quantity\n");
> - }
> -
> - if (hmag < lmag) {
> - dnerror(arg3, D_LLQUANT_HMAGVAL, "llquantize( ) "
> - "argument #3 (high magnitude) must be at least "
> - "argument #2 (low magnitude)\n");
> - }
> -
> - if (powl(factor, hmag + 1) > (long double)UINT64_MAX) {
> - dnerror(arg3, D_LLQUANT_HMAGVAL, "llquantize( ) "
> - "argument #3 (high magnitude) will cause overflow "
> - "of 64 bits\n");
> - }
> -
> - if (arg4->dn_kind != DT_NODE_INT) {
> - dnerror(arg4, D_LLQUANT_STEPTYPE, "llquantize( ) "
> - "argument #4 must be an integer constant\n");
> - }
> -
> - steps = (uint64_t)arg4->dn_value;
> -
> - if (steps > UINT16_MAX) {
> - dnerror(arg4, D_LLQUANT_STEPVAL, "llquantize( ) "
> - "argument #4 must be an unsigned 16-bit "
> - "quantity\n");
> - }
> -
> - if (steps < factor) {
> - if (factor % steps != 0) {
> - dnerror(arg1, D_LLQUANT_STEPVAL, "llquantize() "
> - "argument #4 (steps) must evenly divide "
> - "argument #1 (factor) when steps<factor\n");
> - }
> - }
> - if (steps > factor) {
> - if (steps % factor != 0) {
> - dnerror(arg1, D_LLQUANT_STEPVAL, "llquantize() "
> - "argument #4 (steps) must be a multiple of "
> - "argument #1 (factor) when steps>factor\n");
> - }
> - if (lmag == 0) {
> - if ((factor * factor) % steps != 0) {
> - dnerror(arg1, D_LLQUANT_STEPVAL, "llquantize() "
> - "argument #4 (steps) must evenly divide the square of "
> - "argument #1 (factor) when steps>factor and "
> - "lmag==0\n");
> - }
> - } else {
> - unsigned long long ii = powl(factor, lmag + 1);
> - if (ii % steps != 0) {
> - dnerror(arg1, D_LLQUANT_STEPVAL, "llquantize() "
> - "argument #4 (steps) must evenly divide pow("
> - "argument #1 (factor), lmag "
> - "(argument #2) + 1) "
> - "when steps>factor and "
> - "lmag==0\n");
> - }
> - }
> - }
> -
> - arg = (steps << DTRACE_LLQUANTIZE_STEPSSHIFT |
> - hmag << DTRACE_LLQUANTIZE_HMAGSHIFT |
> - lmag << DTRACE_LLQUANTIZE_LMAGSHIFT |
> - factor << DTRACE_LLQUANTIZE_FACTORSHIFT);
> -
> - assert(arg != 0);
> -
> - isp = (dt_idsig_t *)aid->di_data;
> -
> - if (isp->dis_auxinfo == 0) {
> - /*
> - * This is the first time we've seen an llquantize()
> - * for this aggregation; we'll store our argument
> - * as the auxiliary signature information.
> - */
> - isp->dis_auxinfo = arg;
> - } else if ((oarg = isp->dis_auxinfo) != arg) {
> - /*
> - * If we have seen this llquantize() before and the
> - * argument doesn't match the original argument, pick
> - * the original argument apart to concisely report the
> - * mismatch.
> - */
> - int ofactor = DTRACE_LLQUANTIZE_FACTOR(oarg);
> - int olmag = DTRACE_LLQUANTIZE_LMAG(oarg);
> - int ohmag = DTRACE_LLQUANTIZE_HMAG(oarg);
> - int osteps = DTRACE_LLQUANTIZE_STEPS(oarg);
> -
> - if (ofactor != factor) {
> - dnerror(dnp, D_LLQUANT_MATCHFACTOR,
> - "llquantize() factor (argument #1) doesn't "
> - "match previous declaration: expected %d, "
> - "found %d\n", ofactor, (int)factor);
> - }
> -
> - if (olmag != lmag) {
> - dnerror(dnp, D_LLQUANT_MATCHLMAG,
> - "llquantize() lmag (argument #2) doesn't "
> - "match previous declaration: expected %d, "
> - "found %d\n", olmag, (int)lmag);
> - }
> -
> - if (ohmag != hmag) {
> - dnerror(dnp, D_LLQUANT_MATCHHMAG,
> - "llquantize() hmag (argument #3) doesn't "
> - "match previous declaration: expected %d, "
> - "found %d\n", ohmag, (int)hmag);
> - }
> -
> - if (osteps != steps) {
> - dnerror(dnp, D_LLQUANT_MATCHSTEPS,
> - "llquantize() steps (argument #4) doesn't "
> - "match previous declaration: expected %d, "
> - "found %d\n", osteps, (int)steps);
> - }
> -
> - /*
> - * We shouldn't be able to get here -- one of the
> - * parameters must be mismatched if the arguments
> - * didn't match.
> - */
> - assert(0);
> - }
> -
> - incr = arg4 != NULL ? arg4->dn_list : NULL;
> - argmax = 6;
> - }
> -
> - if (fid->di_id == DT_AGG_QUANTIZE) {
> - incr = dnp->dn_aggfun->dn_args->dn_list;
> - argmax = 2;
> - }
> -
> - if (incr != NULL) {
> - if (!dt_node_is_scalar(incr)) {
> - dnerror(dnp, D_PROTO_ARG, "%s( ) increment value "
> - "(argument #%d) must be of scalar type\n",
> - fid->di_name, argmax);
> - }
> -
> - if ((anp = incr->dn_list) != NULL) {
> - int argc = argmax;
> -
> - for (; anp != NULL; anp = anp->dn_list)
> - argc++;
> -
> - dnerror(incr, D_PROTO_LEN, "%s( ) prototype "
> - "mismatch: %d args passed, at most %d expected",
> - fid->di_name, argc, argmax);
> - }
> -
> - ap = dt_stmt_action(dtp, sdp);
> - n++;
> -
> - dt_cg(yypcb, incr);
> - ap->dtad_difo = dt_as(yypcb);
> - ap->dtad_difo->dtdo_rtype = dt_void_rtype;
> - ap->dtad_kind = DTRACEACT_DIFEXPR;
> - }
> -
> - assert(sdp->dtsd_aggdata == NULL);
> - sdp->dtsd_aggdata = aid;
> -
> - ap = dt_stmt_action(dtp, sdp);
> - assert(fid->di_kind == DT_IDENT_AGGFUNC);
> - assert(DTRACEACT_ISAGG(fid->di_id));
> - ap->dtad_kind = fid->di_id;
> - ap->dtad_ntuple = n;
> - ap->dtad_arg = arg;
> -
> - if (dnp->dn_aggfun->dn_args != NULL) {
> - dt_cg(yypcb, dnp->dn_aggfun->dn_args);
> - ap->dtad_difo = dt_as(yypcb);
> - }
> -}
> -#endif
> -
> static dt_ident_t *
> dt_clause_create(dtrace_hdl_t *dtp, dtrace_difo_t *dp)
> {
More information about the DTrace-devel
mailing list