Lines Matching +full:dsp +full:- +full:based
44 * during the parsing phase are performed by dt_node_free(), which frees node-
61 * in the case of a comma-separated list of probe descriptions). As such, the
82 * - associative arrays that do not yet have a value type defined
83 * - translated data (i.e. the result of the xlate operator)
84 * - aggregations
123 char yyintprefix; /* int token macro prefix (+/-) */
135 case DT_TOK_SUB_EQ: return ("-=");
161 case DT_TOK_SUB: return ("-");
170 case DT_TOK_SUBSUB: return ("--");
171 case DT_TOK_PREDEC: return ("--");
172 case DT_TOK_POSTDEC: return ("--");
174 case DT_TOK_INEG: return ("-");
185 case DT_TOK_PTR: return ("->");
199 dtrace_hdl_t *dtp = yypcb->pcb_hdl;
210 char *object = alloca((size_t)(q - p) + 1);
211 char *type = alloca((size_t)(end - s) + 1);
215 * backquote (q) to extract the nul-terminated object.
217 bcopy(p, object, (size_t)(q - p));
218 object[(size_t)(q - p)] = '\0';
225 bcopy(s, type, (size_t)(p - s));
226 bcopy(q + 1, type + (size_t)(p - s), strlen(q + 1) + 1);
234 * if it rouglhly meets the from LM[0-9]
250 if (yypcb->pcb_idepth != 0)
261 * Unfortunately CTF is limited to a per-container view, so ctf_type_pointer()
265 * to potentially construct the required type on-the-fly.
270 dtrace_hdl_t *dtp = yypcb->pcb_hdl;
271 ctf_file_t *ctfp = tip->dtt_ctfp;
272 ctf_id_t type = tip->dtt_type;
274 uint_t bflags = tip->dtt_flags;
281 tip->dtt_type = ptr;
285 if (yypcb->pcb_idepth != 0)
286 dmp = dtp->dt_cdefs;
288 dmp = dtp->dt_ddefs;
290 if (ctfp != dmp->dm_ctfp && ctfp != ctf_parent_file(dmp->dm_ctfp) &&
291 (type = ctf_add_type(dmp->dm_ctfp, ctfp, type)) == CTF_ERR) {
292 dtp->dt_ctferr = ctf_errno(dmp->dm_ctfp);
296 ptr = ctf_add_pointer(dmp->dm_ctfp, CTF_ADD_ROOT, type);
298 if (ptr == CTF_ERR || ctf_update(dmp->dm_ctfp) == CTF_ERR) {
299 dtp->dt_ctferr = ctf_errno(dmp->dm_ctfp);
303 tip->dtt_object = dmp->dm_name;
304 tip->dtt_ctfp = dmp->dm_ctfp;
305 tip->dtt_type = ptr;
306 tip->dtt_flags = bflags;
314 dtrace_hdl_t *dtp = yypcb->pcb_hdl;
338 ctf_file_t *lfp = lp->dn_ctfp;
339 ctf_id_t ltype = lp->dn_type;
341 ctf_file_t *rfp = rp->dn_ctfp;
342 ctf_id_t rtype = rp->dn_type;
350 dtrace_hdl_t *dtp = yypcb->pcb_hdl;
368 yypcb->pcb_hdl->dt_ctferr = ctf_errno(lfp);
369 longjmp(yypcb->pcb_jmpbuf, EDT_CTF);
373 yypcb->pcb_hdl->dt_ctferr = ctf_errno(rfp);
374 longjmp(yypcb->pcb_jmpbuf, EDT_CTF);
378 * Compute an integer rank based on the size and unsigned status.
387 if (lbase - rbase < 0)
409 dt_type_promote(lp, rp, &dnp->dn_ctfp, &dnp->dn_type);
410 dt_node_type_assign(dnp, dnp->dn_ctfp, dnp->dn_type, B_FALSE);
411 dt_node_attr_assign(dnp, dt_attr_min(lp->dn_attr, rp->dn_attr));
424 switch (dnp->dn_kind) {
427 (u_longlong_t)dnp->dn_value);
430 s = strchr2esc(dnp->dn_string, strlen(dnp->dn_string));
432 s != NULL ? s : dnp->dn_string);
436 (void) snprintf(buf, len, "identifier %s", dnp->dn_string);
442 switch (dnp->dn_ident->di_kind) {
453 dt_idkind_name(dnp->dn_ident->di_kind),
454 prefix, dnp->dn_ident->di_name, suffix);
457 dts = dnp->dn_ident->di_data;
459 dts->dts_object, dts->dts_name);
468 (void) snprintf(buf, len, "operator %s", opstr(dnp->dn_op));
472 if (dnp->dn_expr)
473 return (dt_node_name(dnp->dn_expr, buf, len));
477 if (dnp->dn_desc->dtpd_id == 0) {
480 dnp->dn_desc->dtpd_provider, dnp->dn_desc->dtpd_mod,
481 dnp->dn_desc->dtpd_func, dnp->dn_desc->dtpd_name);
484 dnp->dn_desc->dtpd_id);
491 (void) snprintf(buf, len, "member %s", dnp->dn_membname);
495 dt_type_name(dnp->dn_xlator->dx_dst_ctfp,
496 dnp->dn_xlator->dx_dst_type, n1, sizeof (n1)),
497 dt_type_name(dnp->dn_xlator->dx_src_ctfp,
498 dnp->dn_xlator->dx_src_type, n2, sizeof (n2)));
504 (void) snprintf(buf, len, "node <%u>", dnp->dn_kind);
523 dnp->dn_ctfp = NULL;
524 dnp->dn_type = CTF_ERR;
525 dnp->dn_kind = (uchar_t)kind;
526 dnp->dn_flags = 0;
527 dnp->dn_op = 0;
528 dnp->dn_line = -1;
529 dnp->dn_reg = -1;
530 dnp->dn_attr = _dtrace_defattr;
531 dnp->dn_list = NULL;
532 dnp->dn_link = NULL;
533 bzero(&dnp->dn_u, sizeof (dnp->dn_u));
540 * assigns the node location based on the current lexer line number and places
547 dt_node_t *dnp = dt_node_xalloc(yypcb->pcb_hdl, kind);
550 longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
552 dnp->dn_line = yylineno;
553 dnp->dn_link = yypcb->pcb_list;
554 yypcb->pcb_list = dnp;
562 uchar_t kind = dnp->dn_kind;
564 dnp->dn_kind = DT_NODE_FREE;
570 free(dnp->dn_string);
571 dnp->dn_string = NULL;
577 if (dnp->dn_ident != NULL) {
578 if (dnp->dn_ident->di_flags & DT_IDFLG_ORPHAN)
579 dt_ident_destroy(dnp->dn_ident);
580 dnp->dn_ident = NULL;
582 dt_node_list_free(&dnp->dn_args);
586 if (dnp->dn_child != NULL) {
587 dt_node_free(dnp->dn_child);
588 dnp->dn_child = NULL;
593 if (dnp->dn_expr != NULL) {
594 dt_node_free(dnp->dn_expr);
595 dnp->dn_expr = NULL;
599 if (dnp->dn_left != NULL) {
600 dt_node_free(dnp->dn_left);
601 dnp->dn_left = NULL;
603 if (dnp->dn_right != NULL) {
604 dt_node_free(dnp->dn_right);
605 dnp->dn_right = NULL;
611 if (dnp->dn_expr != NULL) {
612 dt_node_free(dnp->dn_expr);
613 dnp->dn_expr = NULL;
618 if (dnp->dn_aggfun != NULL) {
619 dt_node_free(dnp->dn_aggfun);
620 dnp->dn_aggfun = NULL;
622 dt_node_list_free(&dnp->dn_aggtup);
626 free(dnp->dn_spec);
627 dnp->dn_spec = NULL;
628 free(dnp->dn_desc);
629 dnp->dn_desc = NULL;
633 if (dnp->dn_pred != NULL)
634 dt_node_free(dnp->dn_pred);
635 if (dnp->dn_locals != NULL)
636 dt_idhash_destroy(dnp->dn_locals);
637 dt_node_list_free(&dnp->dn_pdescs);
638 dt_node_list_free(&dnp->dn_acts);
642 free(dnp->dn_membname);
643 dnp->dn_membname = NULL;
644 if (dnp->dn_membexpr != NULL) {
645 dt_node_free(dnp->dn_membexpr);
646 dnp->dn_membexpr = NULL;
651 dt_node_list_free(&dnp->dn_probes);
652 free(dnp->dn_provname);
653 dnp->dn_provname = NULL;
657 dt_node_list_free(&dnp->dn_list);
665 if ((yypcb->pcb_cflags & DTRACE_C_EATTR) &&
666 (dt_attr_cmp(attr, yypcb->pcb_amin) < 0)) {
675 dnp->dn_attr = attr;
686 dnp->dn_flags &=
692 if (size > 8 || (e.cte_bits % NBBY) != 0 || (size & (size - 1)))
693 dnp->dn_flags |= DT_NF_BITFIELD;
696 dnp->dn_flags |= DT_NF_SIGNED;
701 dnp->dn_flags |= DT_NF_REF;
707 dnp->dn_flags |= DT_NF_REF;
708 else if (yypcb != NULL && fp == DT_DYN_CTFP(yypcb->pcb_hdl) &&
709 type == DT_DYN_TYPE(yypcb->pcb_hdl))
710 dnp->dn_flags |= DT_NF_REF;
713 dnp->dn_flags |= DT_NF_USERLAND;
715 dnp->dn_flags |= DT_NF_COOKED;
716 dnp->dn_ctfp = fp;
717 dnp->dn_type = type;
723 assert(src->dn_flags & DT_NF_COOKED);
724 dst->dn_flags = src->dn_flags & ~DT_NF_LVALUE;
725 dst->dn_ctfp = src->dn_ctfp;
726 dst->dn_type = src->dn_type;
732 if (dt_node_is_dynamic(dnp) && dnp->dn_ident != NULL) {
734 dt_idkind_name(dt_ident_resolve(dnp->dn_ident)->di_kind));
738 if (dnp->dn_flags & DT_NF_USERLAND) {
740 len = len > n ? len - n : 0;
741 (void) dt_type_name(dnp->dn_ctfp, dnp->dn_type, buf + n, len);
745 return (dt_type_name(dnp->dn_ctfp, dnp->dn_type, buf, len));
752 dtrace_hdl_t *dtp = yypcb->pcb_hdl;
754 if (dnp->dn_kind == DT_NODE_STRING)
755 return (strlen(dnp->dn_string) + 1);
757 if (dt_node_is_dynamic(dnp) && dnp->dn_ident != NULL)
758 return (dt_ident_size(dnp->dn_ident));
760 base = ctf_type_resolve(dnp->dn_ctfp, dnp->dn_type);
762 if (ctf_type_kind(dnp->dn_ctfp, base) == CTF_K_FORWARD)
766 * Here we have a 32-bit user pointer that is being used with a 64-bit
767 * kernel. When we're using it and its tagged as a userland reference --
768 * then we need to keep it as a 32-bit pointer. However, if we are
773 if (ctf_type_kind(dnp->dn_ctfp, base) == CTF_K_POINTER &&
774 ctf_getmodel(dnp->dn_ctfp) == CTF_MODEL_ILP32 &&
775 !(dnp->dn_flags & DT_NF_USERLAND) &&
776 dtp->dt_conf.dtc_ctfmodel == CTF_MODEL_LP64)
779 return (ctf_type_size(dnp->dn_ctfp, dnp->dn_type));
792 switch (dnp->dn_kind) {
799 idp = dt_ident_resolve(dnp->dn_ident);
800 return (idp->di_kind == idkind ? idp : NULL);
804 idp = dt_ident_resolve(dnp->dn_ident);
805 return (idp->di_kind == idkind ? idp : NULL);
816 dtrace_hdl_t *dtp = yypcb->pcb_hdl;
827 if (dnp->dn_kind != DT_NODE_SYM)
830 sip = dnp->dn_ident->di_data;
832 if (dtrace_lookup_by_name(dtp, sip->dts_object,
833 sip->dts_name, &sym, NULL) == -1)
842 ctf_file_t *fp = dnp->dn_ctfp;
847 assert(dnp->dn_flags & DT_NF_COOKED);
849 type = ctf_type_resolve(fp, dnp->dn_type);
862 ctf_file_t *fp = dnp->dn_ctfp;
867 assert(dnp->dn_flags & DT_NF_COOKED);
869 type = ctf_type_resolve(fp, dnp->dn_type);
873 ctf_type_encoding(dnp->dn_ctfp, type, &e) == 0 && (
881 ctf_file_t *fp = dnp->dn_ctfp;
886 assert(dnp->dn_flags & DT_NF_COOKED);
888 type = ctf_type_resolve(fp, dnp->dn_type);
902 ctf_file_t *fp = dnp->dn_ctfp;
907 assert(dnp->dn_flags & DT_NF_COOKED);
909 type = ctf_type_resolve(fp, dnp->dn_type);
921 ctf_file_t *fp = dnp->dn_ctfp;
926 assert(dnp->dn_flags & DT_NF_COOKED);
928 type = ctf_type_resolve(fp, dnp->dn_type);
942 if (dnp->dn_kind == DT_NODE_VAR &&
943 (dnp->dn_ident->di_flags & DT_IDFLG_INLINE)) {
944 const dt_idnode_t *inp = dnp->dn_ident->di_iarg;
945 return (inp->din_root ? dt_node_is_dynamic(inp->din_root) : 0);
948 return (dnp->dn_ctfp == DT_DYN_CTFP(yypcb->pcb_hdl) &&
949 dnp->dn_type == DT_DYN_TYPE(yypcb->pcb_hdl));
955 return (dnp->dn_ctfp == DT_STR_CTFP(yypcb->pcb_hdl) &&
956 dnp->dn_type == DT_STR_TYPE(yypcb->pcb_hdl));
962 return (dnp->dn_ctfp == DT_STACK_CTFP(yypcb->pcb_hdl) &&
963 dnp->dn_type == DT_STACK_TYPE(yypcb->pcb_hdl));
969 return (dnp->dn_ctfp == DT_SYMADDR_CTFP(yypcb->pcb_hdl) &&
970 dnp->dn_type == DT_SYMADDR_TYPE(yypcb->pcb_hdl));
976 return (dnp->dn_ctfp == DT_USYMADDR_CTFP(yypcb->pcb_hdl) &&
977 dnp->dn_type == DT_USYMADDR_TYPE(yypcb->pcb_hdl));
983 ctf_file_t *fp = dnp->dn_ctfp;
989 assert(dnp->dn_flags & DT_NF_COOKED);
991 base = ctf_type_resolve(fp, dnp->dn_type);
1011 ctf_file_t *fp = dnp->dn_ctfp;
1014 assert(dnp->dn_flags & DT_NF_COOKED);
1017 return (0); /* string are pass-by-ref but act like structs */
1019 kind = ctf_type_kind(fp, ctf_type_resolve(fp, dnp->dn_type));
1026 ctf_file_t *fp = dnp->dn_ctfp;
1039 type = ctf_type_resolve(fp, dnp->dn_type);
1049 ctf_file_t *lfp = lp->dn_ctfp;
1050 ctf_file_t *rfp = rp->dn_ctfp;
1060 assert(lp->dn_flags & DT_NF_COOKED);
1061 assert(rp->dn_flags & DT_NF_COOKED);
1072 if (lp_is_int && (lp->dn_kind != DT_NODE_INT || lp->dn_value != 0))
1075 if (rp_is_int && (rp->dn_kind != DT_NODE_INT || rp->dn_value != 0))
1079 (lp->dn_flags & DT_NF_USERLAND) ^ (rp->dn_flags & DT_NF_USERLAND)))
1083 * Resolve the left-hand and right-hand types to their base type, and
1088 lbase = ctf_type_resolve(lfp, lp->dn_type);
1101 rbase = ctf_type_resolve(rfp, rp->dn_type);
1114 * We know that one or the other type may still be a zero-valued
1116 * type variables equal to the non-integer types and proceed.
1177 * in the ANSI-C spec (see K&R[A7.3.2] and K&R[A7.17]). We use the same rule
1183 ctf_file_t *lfp = lp->dn_ctfp;
1184 ctf_file_t *rfp = rp->dn_ctfp;
1186 assert(lp->dn_flags & DT_NF_COOKED);
1187 assert(rp->dn_flags & DT_NF_COOKED);
1204 switch (ctf_type_kind(lfp, ctf_type_resolve(lfp, lp->dn_type))) {
1208 return (ctf_type_compat(lfp, lp->dn_type, rfp, rp->dn_type));
1216 * wish to verify that an argument is a positive non-zero integer constant.
1221 return (dnp->dn_kind == DT_NODE_INT && dnp->dn_value != 0 && (
1222 (dnp->dn_flags & DT_NF_SIGNED) == 0 || (int64_t)dnp->dn_value > 0));
1228 return (dnp->dn_kind == DT_NODE_FUNC &&
1229 dnp->dn_ident->di_kind == DT_IDENT_ACTFUNC);
1255 * unsigned long long. Compute an integer array starting index based on the
1256 * suffix (e.g. none = 0, u = 1, ull = 5), and compute an increment based on
1266 dtrace_hdl_t *dtp = yypcb->pcb_hdl;
1274 dnp->dn_op = DT_TOK_INT;
1275 dnp->dn_value = value;
1284 for (; i < sizeof (dtp->dt_ints) / sizeof (dtp->dt_ints[0]); i += n) {
1285 if (value <= dtp->dt_ints[i].did_limit) {
1287 dtp->dt_ints[i].did_ctfp,
1288 dtp->dt_ints[i].did_type, B_FALSE);
1297 case '-':
1306 "in any built-in integral type\n", (u_longlong_t)value);
1314 dtrace_hdl_t *dtp = yypcb->pcb_hdl;
1318 longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
1321 dnp->dn_op = DT_TOK_STRING;
1322 dnp->dn_string = string;
1335 longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
1343 if ((idp = dt_idstack_lookup(&yypcb->pcb_globals, name)) != NULL &&
1344 (idp->di_flags & DT_IDFLG_INLINE)) {
1345 dt_idnode_t *inp = idp->di_iarg;
1347 if (inp->din_root != NULL &&
1348 inp->din_root->dn_kind == DT_NODE_INT) {
1352 dnp->dn_op = DT_TOK_INT;
1353 dnp->dn_value = inp->din_root->dn_value;
1354 dt_node_type_propagate(inp->din_root, dnp);
1361 dnp->dn_op = name[0] == '@' ? DT_TOK_AGG : DT_TOK_IDENT;
1362 dnp->dn_string = name;
1375 dtrace_hdl_t *dtp = yypcb->pcb_hdl;
1393 longjmp(yypcb->pcb_jmpbuf, EDT_COMPILER);
1397 dnp->dn_op = DT_TOK_IDENT;
1398 dnp->dn_string = name;
1402 if (dtt.dtt_ctfp == dtp->dt_cdefs->dm_ctfp ||
1403 dtt.dtt_ctfp == dtp->dt_ddefs->dm_ctfp)
1420 dnp->dn_op = DT_TOK_IDENT;
1421 dnp->dn_ctfp = yypcb->pcb_hdl->dt_cdefs->dm_ctfp;
1422 dnp->dn_type = CTF_ERR;
1423 dnp->dn_attr = _dtrace_defattr;
1438 dtrace_hdl_t *dtp = yypcb->pcb_hdl;
1439 dt_scope_t *dsp = &yypcb->pcb_dstack;
1440 dt_dclass_t class = dsp->ds_class;
1451 longjmp(yypcb->pcb_jmpbuf, EDT_COMPILER);
1458 if (dsp->ds_ident == NULL) {
1459 if (ddp->dd_kind != CTF_K_STRUCT &&
1460 ddp->dd_kind != CTF_K_UNION && ddp->dd_kind != CTF_K_ENUM)
1464 ddp->dd_ctfp, ddp->dd_type, n1, sizeof (n1)), ddp->dd_type);
1469 if (strchr(dsp->ds_ident, '`') != NULL) {
1471 "a declaration name (%s)\n", dsp->ds_ident);
1478 if (yypcb->pcb_idepth != 0)
1479 dmp = dtp->dt_cdefs;
1481 dmp = dtp->dt_ddefs;
1505 dmp->dm_name, dsp->ds_ident, &sym, &dts) == 0;
1512 dmp->dm_name, dsp->ds_ident,
1518 dsp->ds_ident, &dtt) == NULL) {
1520 "failed to extern %s: %s\n", dsp->ds_ident,
1524 dmp->dm_name, dsp->ds_ident,
1532 if (dt_idstack_lookup(&yypcb->pcb_globals, dsp->ds_ident)) {
1534 "redeclared: %s\n", dsp->ds_ident);
1537 if (ctf_lookup_by_name(dmp->dm_ctfp,
1538 dsp->ds_ident) != CTF_ERR) {
1540 "typedef redeclared: %s\n", dsp->ds_ident);
1548 if (dtt.dtt_ctfp != dmp->dm_ctfp &&
1549 dtt.dtt_ctfp != ctf_parent_file(dmp->dm_ctfp)) {
1551 dtt.dtt_type = ctf_add_type(dmp->dm_ctfp,
1553 dtt.dtt_ctfp = dmp->dm_ctfp;
1558 "source type: %s\n", dsp->ds_ident,
1563 type = ctf_add_typedef(dmp->dm_ctfp,
1564 CTF_ADD_ROOT, dsp->ds_ident, dtt.dtt_type);
1566 if (type == CTF_ERR || ctf_update(dmp->dm_ctfp) == CTF_ERR) {
1568 dsp->ds_ident, ctf_errmsg(ctf_errno(dmp->dm_ctfp)));
1571 dt_dprintf("typedef %s added as id %ld\n", dsp->ds_ident, type);
1585 dhp = yypcb->pcb_locals;
1587 idp = dt_idhash_lookup(dhp, dsp->ds_ident);
1590 dhp = dtp->dt_tls;
1592 idp = dt_idhash_lookup(dhp, dsp->ds_ident);
1595 dhp = dtp->dt_globals;
1598 &yypcb->pcb_globals, dsp->ds_ident);
1602 if (ddp->dd_kind == CTF_K_ARRAY && ddp->dd_node == NULL) {
1605 "tuple signature: %s\n", dsp->ds_ident);
1608 if (idp != NULL && idp->di_gen == 0) {
1609 xyerror(D_DECL_IDRED, "built-in identifier "
1610 "redeclared: %s\n", idp->di_name);
1614 dsp->ds_ident, NULL) == 0 ||
1616 dsp->ds_ident, NULL) == 0) {
1618 "redeclared: %s\n", dsp->ds_ident);
1628 assc = ddp->dd_kind == CTF_K_ARRAY &&
1629 ddp->dd_node->dn_kind == DT_NODE_TYPE;
1636 * If the pre-existing ident has its di_type set, propagate
1643 if (idp != NULL && idp->di_type != CTF_ERR)
1644 dt_node_type_assign(&idn, idp->di_ctfp, idp->di_type,
1653 " %s\n", dsp->ds_ident);
1656 if (dt_decl_type(ddp->dd_next, &dtt) != 0)
1657 longjmp(yypcb->pcb_jmpbuf, EDT_COMPILER);
1660 if (idp != NULL && (idp->di_kind != idkind ||
1665 dsp->ds_ident, dt_idkind_name(idkind),
1668 dt_idkind_name(idp->di_kind),
1672 const dt_idsig_t *isp = idp->di_data;
1673 dt_node_t *dnp = ddp->dd_node;
1676 for (; dnp != NULL; dnp = dnp->dn_list, argc++) {
1677 const dt_node_t *pnp = &isp->dis_args[argc];
1679 if (argc >= isp->dis_argc)
1682 if (ctf_type_cmp(dnp->dn_ctfp, dnp->dn_type,
1683 pnp->dn_ctfp, pnp->dn_type) == 0)
1690 dsp->ds_ident,
1693 dt_idkind_name(idp->di_kind), argc + 1,
1697 if (isp->dis_argc != argc) {
1702 dsp->ds_ident, dt_idkind_name(idkind),
1705 dt_idkind_name(idp->di_kind),
1707 isp->dis_argc);
1719 "void object: %s\n", dsp->ds_ident);
1731 n1, sizeof (n1)), dsp->ds_ident);
1735 if (dt_idhash_nextid(dhp, &id) == -1) {
1738 dsp->ds_ident, dt_idhash_name(dhp));
1743 dsp->ds_ident, id);
1745 idp = dt_idhash_insert(dhp, dsp->ds_ident, idkind,
1748 &dt_idops_thaw, NULL, dtp->dt_gen);
1751 longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
1760 * types pointed to by ddp->dd_node. We also reset
1761 * the identifier's attributes based upon the result.
1764 idp->di_attr =
1765 dt_ident_cook(&idn, idp, &ddp->dd_node);
1772 free(dsp->ds_ident);
1773 dsp->ds_ident = NULL;
1783 if (dnp->dn_kind != DT_NODE_IDENT) {
1788 idp = dt_idstack_lookup(&yypcb->pcb_globals, dnp->dn_string);
1792 "undefined function name: %s\n", dnp->dn_string);
1795 if (idp->di_kind != DT_IDENT_FUNC &&
1796 idp->di_kind != DT_IDENT_AGGFUNC &&
1797 idp->di_kind != DT_IDENT_ACTFUNC) {
1799 "function\n", dt_idkind_name(idp->di_kind), idp->di_name);
1802 free(dnp->dn_string);
1803 dnp->dn_string = NULL;
1805 dnp->dn_kind = DT_NODE_FUNC;
1806 dnp->dn_flags &= ~DT_NF_COOKED;
1807 dnp->dn_ident = idp;
1808 dnp->dn_args = args;
1809 dnp->dn_list = NULL;
1839 longjmp(yypcb->pcb_jmpbuf, EDT_COMPILER);
1859 "cannot take offset of a bit-field: %s\n", name);
1870 if (cp->dn_kind == DT_NODE_INT) {
1878 cp->dn_value = -cp->dn_value;
1879 if (!(cp->dn_flags & DT_NF_SIGNED)) {
1880 cp->dn_value &= ~0ULL >>
1881 (64 - dt_node_type_size(cp) * NBBY);
1887 cp->dn_value = ~cp->dn_value;
1890 cp->dn_value = !cp->dn_value;
1901 (cp->dn_kind == DT_NODE_STRING || cp->dn_kind == DT_NODE_TYPE)) {
1902 dtrace_hdl_t *dtp = yypcb->pcb_hdl;
1910 dt_node_type_assign(cp, dtp->dt_ddefs->dm_ctfp,
1911 ctf_lookup_by_name(dtp->dt_ddefs->dm_ctfp, "size_t"),
1914 cp->dn_kind = DT_NODE_INT;
1915 cp->dn_op = DT_TOK_INT;
1916 cp->dn_value = size;
1923 dnp->dn_op = (ushort_t)op;
1924 dnp->dn_child = cp;
1933 * changing signed-ness. If so, we first shift rp's bits bits high (losing
1944 int n = (sizeof (uint64_t) - dstsize) * NBBY;
1945 rp->dn_value <<= n;
1946 rp->dn_value >>= n;
1948 int n = (sizeof (uint64_t) - srcsize) * NBBY;
1949 int s = (dstsize - srcsize) * NBBY;
1951 rp->dn_value <<= n;
1952 if (rp->dn_flags & DT_NF_SIGNED) {
1953 rp->dn_value = (intmax_t)rp->dn_value >> s;
1954 rp->dn_value >>= n - s;
1956 rp->dn_value >>= n;
1964 dtrace_hdl_t *dtp = yypcb->pcb_hdl;
1968 * First we check for operations that are illegal -- namely those that
1971 if (rp->dn_kind == DT_NODE_INT && rp->dn_value == 0 &&
1980 if (lp->dn_kind == DT_NODE_INT && rp->dn_kind == DT_NODE_INT) {
1981 uintmax_t l = lp->dn_value;
1982 uintmax_t r = rp->dn_value;
1988 dnp->dn_value = l || r;
1993 dnp->dn_value = (l != 0) ^ (r != 0);
1998 dnp->dn_value = l && r;
2003 dnp->dn_value = l | r;
2007 dnp->dn_value = l ^ r;
2011 dnp->dn_value = l & r;
2015 dnp->dn_value = l == r;
2020 dnp->dn_value = l != r;
2026 if (dnp->dn_flags & DT_NF_SIGNED)
2027 dnp->dn_value = (intmax_t)l < (intmax_t)r;
2029 dnp->dn_value = l < r;
2035 if (dnp->dn_flags & DT_NF_SIGNED)
2036 dnp->dn_value = (intmax_t)l <= (intmax_t)r;
2038 dnp->dn_value = l <= r;
2044 if (dnp->dn_flags & DT_NF_SIGNED)
2045 dnp->dn_value = (intmax_t)l > (intmax_t)r;
2047 dnp->dn_value = l > r;
2053 if (dnp->dn_flags & DT_NF_SIGNED)
2054 dnp->dn_value = (intmax_t)l >= (intmax_t)r;
2056 dnp->dn_value = l >= r;
2061 dnp->dn_value = l << r;
2064 dt_attr_min(lp->dn_attr, rp->dn_attr));
2067 dnp->dn_value = l >> r;
2070 dt_attr_min(lp->dn_attr, rp->dn_attr));
2073 dnp->dn_value = l + r;
2077 dnp->dn_value = l - r;
2081 dnp->dn_value = l * r;
2086 if (dnp->dn_flags & DT_NF_SIGNED)
2087 dnp->dn_value = (intmax_t)l / (intmax_t)r;
2089 dnp->dn_value = l / r;
2093 if (dnp->dn_flags & DT_NF_SIGNED)
2094 dnp->dn_value = (intmax_t)l % (intmax_t)r;
2096 dnp->dn_value = l % r;
2110 if (op == DT_TOK_LPAR && rp->dn_kind == DT_NODE_INT &&
2114 dt_node_attr_assign(rp, dt_attr_min(lp->dn_attr, rp->dn_attr));
2126 dnp->dn_op = (ushort_t)op;
2127 dnp->dn_left = lp;
2128 dnp->dn_right = rp;
2138 if (expr->dn_kind == DT_NODE_INT)
2139 return (expr->dn_value != 0 ? lp : rp);
2142 dnp->dn_op = DT_TOK_QUESTION;
2143 dnp->dn_expr = expr;
2144 dnp->dn_left = lp;
2145 dnp->dn_right = rp;
2155 if (expr->dn_kind == DT_NODE_AGG)
2158 if (expr->dn_kind == DT_NODE_FUNC &&
2159 expr->dn_ident->di_kind == DT_IDENT_ACTFUNC)
2164 dnp->dn_expr = expr;
2172 dnp->dn_conditional = pred;
2173 dnp->dn_body = acts;
2174 dnp->dn_alternate_body = else_acts;
2182 dtrace_hdl_t *dtp = yypcb->pcb_hdl;
2186 longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
2189 dnp->dn_spec = spec;
2190 dnp->dn_desc = malloc(sizeof (dtrace_probedesc_t));
2192 if (dnp->dn_desc == NULL)
2193 longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
2195 if (dtrace_xstr2desc(dtp, yypcb->pcb_pspec, dnp->dn_spec,
2196 yypcb->pcb_sargc, yypcb->pcb_sargv, dnp->dn_desc) != 0) {
2198 dnp->dn_spec, dtrace_errmsg(dtp, dtrace_errno(dtp)));
2201 free(dnp->dn_spec);
2202 dnp->dn_spec = NULL;
2214 dtrace_hdl_t *dtp = yypcb->pcb_hdl;
2217 if ((dnp->dn_desc = malloc(sizeof (dtrace_probedesc_t))) == NULL)
2218 longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
2225 if (yypcb->pcb_pspec != DTRACE_PROBESPEC_NAME) {
2228 names[yypcb->pcb_pspec]);
2231 if (dtrace_id2desc(dtp, (dtrace_id_t)id, dnp->dn_desc) != 0) {
2244 dnp->dn_pdescs = pdescs;
2245 dnp->dn_pred = pred;
2246 dnp->dn_acts = acts;
2254 dtrace_hdl_t *dtp = yypcb->pcb_hdl;
2255 dt_scope_t *dsp = &yypcb->pcb_dstack;
2266 longjmp(yypcb->pcb_jmpbuf, EDT_COMPILER);
2268 if (dsp->ds_class != DT_DC_DEFAULT) {
2273 if (dsp->ds_ident == NULL)
2277 &yypcb->pcb_globals, dsp->ds_ident)) != NULL) {
2280 idp->di_name, dt_idkind_name(idp->di_kind),
2281 (idp->di_flags & DT_IDFLG_INLINE) ? "inline" : "");
2288 if (ddp->dd_kind == CTF_K_ARRAY) {
2289 if (ddp->dd_node == NULL) {
2291 "array tuple signature: %s\n", dsp->ds_ident);
2294 if (ddp->dd_node->dn_kind != DT_NODE_TYPE) {
2296 "of scalar array type: %s\n", dsp->ds_ident);
2299 if (dt_decl_type(ddp->dd_next, &dtt) != 0)
2300 longjmp(yypcb->pcb_jmpbuf, EDT_COMPILER);
2306 * until we have successfully cooked the right-hand expression, below.
2314 "cannot declare void inline: %s\n", dsp->ds_ident);
2317 if (ctf_type_kind(dnp->dn_ctfp, ctf_type_resolve(
2318 dnp->dn_ctfp, dnp->dn_type)) == CTF_K_FORWARD) {
2321 dt_node_type_name(dnp, n, sizeof (n)), dsp->ds_ident);
2325 longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
2329 idp = dnp->dn_ident = dt_ident_create(dsp->ds_ident,
2330 ddp->dd_kind == CTF_K_ARRAY ? DT_IDENT_ARRAY : DT_IDENT_SCALAR,
2332 _dtrace_defattr, 0, &dt_idops_inline, inp, dtp->dt_gen);
2336 longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
2341 * hash containing the named parameters and store it in inp->din_hash.
2344 if (ddp->dd_kind == CTF_K_ARRAY) {
2350 for (pnp = ddp->dd_node; pnp != NULL; pnp = pnp->dn_list)
2353 inp->din_hash = dt_idhash_create("inline args", NULL, 0, 0);
2354 inp->din_argv = calloc(i, sizeof (dt_ident_t *));
2356 if (inp->din_hash == NULL || inp->din_argv == NULL)
2357 longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
2366 for (i = 0, pnp = ddp->dd_node;
2367 pnp != NULL; pnp = pnp->dn_list, i++) {
2369 if (pnp->dn_string == NULL)
2373 longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
2375 pidp = dt_idhash_insert(inp->din_hash, pnp->dn_string,
2378 pinp, dtp->dt_gen);
2382 longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
2385 inp->din_argv[i] = pidp;
2387 dt_ident_type_assign(pidp, pnp->dn_ctfp, pnp->dn_type);
2390 dt_idstack_push(&yypcb->pcb_globals, inp->din_hash);
2394 * Unlike most constructors, we need to explicitly cook the right-hand
2396 * the right-hand side uses the inline itself, the cook will fail.
2400 if (ddp->dd_kind == CTF_K_ARRAY)
2401 dt_idstack_pop(&yypcb->pcb_globals, inp->din_hash);
2404 * Set the type, attributes, and flags for the inline. If the right-
2410 rdp = dt_ident_resolve(expr->dn_ident);
2411 else if (expr->dn_kind == DT_NODE_VAR || expr->dn_kind == DT_NODE_SYM)
2412 rdp = expr->dn_ident;
2417 idp->di_flags |= (rdp->di_flags &
2421 idp->di_attr = dt_attr_min(_dtrace_defattr, expr->dn_attr);
2423 (void) dt_ident_cook(dnp, idp, &ddp->dd_node);
2426 * Store the parse tree nodes for 'expr' inside of idp->di_data ('inp')
2430 inp->din_list = yypcb->pcb_list;
2431 inp->din_root = expr;
2440 dt_idhash_xinsert(dtp->dt_globals, idp);
2456 longjmp(yypcb->pcb_jmpbuf, EDT_COMPILER);
2460 dnp->dn_membname = name;
2461 dnp->dn_membexpr = expr;
2473 dtrace_hdl_t *dtp = yypcb->pcb_hdl;
2492 longjmp(yypcb->pcb_jmpbuf, EDT_COMPILER);
2521 dxp = dt_xlator_create(dtp, &src, &dst, name, members, yypcb->pcb_list);
2526 longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
2529 dnp->dn_xlator = dxp;
2530 dnp->dn_members = members;
2538 dtrace_hdl_t *dtp = yypcb->pcb_hdl;
2554 if (strlen(name) - 2 >= DTRACE_NAMELEN) {
2556 "characters: %s\n", DTRACE_NAMELEN - 1, name);
2561 dnp->dn_ident = dt_ident_create(name, DT_IDENT_PROBE,
2563 &dt_idops_probe, NULL, dtp->dt_gen);
2581 if (dnp->dn_ident == NULL || dt_probe_create(dtp,
2582 dnp->dn_ident, protoc, nargs, nargc, xargs, xargc) == NULL)
2583 longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
2591 dtrace_hdl_t *dtp = yypcb->pcb_hdl;
2596 dnp->dn_provname = name;
2597 dnp->dn_probes = probes;
2606 "characters: %s\n", DTRACE_PROVNAMELEN - 1, name);
2609 if (isdigit(name[len - 1])) {
2616 * dtrace(7D). If so, set dn_provred to treat it as a re-declaration.
2617 * If not, create a new provider and set its interface-only flag. This
2620 if ((dnp->dn_provider = dt_provider_lookup(dtp, name)) != NULL)
2621 dnp->dn_provred = B_TRUE;
2622 else if ((dnp->dn_provider = dt_provider_create(dtp, name)) == NULL)
2623 longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
2625 dnp->dn_provider->pv_flags |= DT_PROVIDER_INTF;
2630 * Note that if dnp->dn_provred is true, we may end up storing dups of
2635 for (lnp = yypcb->pcb_list; lnp->dn_link != NULL; lnp = lnp->dn_link)
2638 lnp->dn_link = dnp->dn_provider->pv_nodes;
2639 dnp->dn_provider->pv_nodes = yypcb->pcb_list;
2649 dnp->dn_list = lnp;
2664 dtrace_hdl_t *dtp = yypcb->pcb_hdl;
2685 if ((name = strrchr(dnp->dn_string, '`')) != NULL) {
2686 if (name > dnp->dn_string && name[-1] == '`') {
2688 name[-1] = '\0';
2691 if (name == dnp->dn_string + uref)
2694 scope = dnp->dn_string;
2701 name = dnp->dn_string + 1;
2705 name = dnp->dn_string;
2719 (dhp != dtp->dt_globals &&
2721 (dhp == dtp->dt_globals &&
2722 (idp = dt_idstack_lookup(&yypcb->pcb_globals, name)) != NULL))) {
2727 * the time operator -> is seen; more parsing is needed.
2729 if (idp->di_kind != idkind && dhp == dtp->dt_globals) {
2731 "as %s\n", dt_idkind_name(idp->di_kind),
2732 idp->di_name, dt_idkind_name(idkind));
2740 if (idp->di_kind != DT_IDENT_ARRAY &&
2741 idp->di_kind != DT_IDENT_AGG)
2746 attr = idp->di_attr;
2749 free(dnp->dn_string);
2750 dnp->dn_string = NULL;
2751 dnp->dn_kind = dnkind;
2752 dnp->dn_ident = idp;
2753 dnp->dn_flags |= DT_NF_LVALUE;
2755 if (idp->di_flags & DT_IDFLG_WRITE)
2756 dnp->dn_flags |= DT_NF_WRITABLE;
2760 } else if (dhp == dtp->dt_globals && scope != DTRACE_OBJ_EXEC &&
2764 int umod = (mp->dm_flags & DT_DM_KERNEL) == 0;
2778 * For now, we special-case EDT_DATAMODEL to clarify
2781 if (dtp->dt_errno == EDT_DATAMODEL) {
2786 dt_module_modelname(dtp->dt_ddefs));
2796 _dtrace_symattr, 0, &dt_idops_thaw, NULL, dtp->dt_gen);
2799 longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
2801 if (mp->dm_flags & DT_DM_PRIMARY)
2802 idp->di_flags |= DT_IDFLG_PRIM;
2804 idp->di_next = dtp->dt_externs;
2805 dtp->dt_externs = idp;
2808 longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
2811 idp->di_data = sip;
2812 idp->di_ctfp = dtt.dtt_ctfp;
2813 idp->di_type = dtt.dtt_type;
2815 free(dnp->dn_string);
2816 dnp->dn_string = NULL;
2817 dnp->dn_kind = DT_NODE_SYM;
2818 dnp->dn_ident = idp;
2819 dnp->dn_flags |= DT_NF_LVALUE;
2826 idp->di_flags |= DT_IDFLG_USER;
2827 dnp->dn_flags |= DT_NF_USERLAND;
2834 if (dt_idhash_nextid(dhp, &id) == -1) {
2839 if (dhp == yypcb->pcb_locals)
2841 else if (dhp == dtp->dt_tls)
2850 &dt_idops_assc, NULL, dtp->dt_gen);
2854 &dt_idops_thaw, NULL, dtp->dt_gen);
2858 longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
2865 if (idp->di_kind != DT_IDENT_ARRAY &&
2866 idp->di_kind != DT_IDENT_AGG)
2871 attr = idp->di_attr;
2874 free(dnp->dn_string);
2875 dnp->dn_string = NULL;
2876 dnp->dn_kind = dnkind;
2877 dnp->dn_ident = idp;
2878 dnp->dn_flags |= DT_NF_LVALUE | DT_NF_WRITABLE;
2884 dnp->dn_string, mark, name,
2888 dnp->dn_string, dtrace_errmsg(dtp, dtrace_errno(dtp)));
2895 dtrace_hdl_t *dtp = yypcb->pcb_hdl;
2897 if (dnp->dn_op == DT_TOK_AGG)
2898 dt_xcook_ident(dnp, dtp->dt_aggs, DT_IDENT_AGG, B_FALSE);
2900 dt_xcook_ident(dnp, dtp->dt_globals, DT_IDENT_SCALAR, B_FALSE);
2906 * Since operators [ and -> can instantiate new variables before we know
2914 dt_ident_t *idp = dnp->dn_ident;
2919 (idp->di_flags & DT_IDFLG_LOCAL) ? "this->" :
2920 (idp->di_flags & DT_IDFLG_TLS) ? "self->" : "",
2921 idp->di_name);
2924 dt_node_attr_assign(dnp, dt_ident_cook(dnp, idp, &dnp->dn_args));
2933 dt_ident_cook(dnp, dnp->dn_ident, &dnp->dn_args));
2941 dtrace_hdl_t *dtp = yypcb->pcb_hdl;
2942 dt_node_t *cp = dnp->dn_child;
2953 if (dnp->dn_op == DT_TOK_PREINC || dnp->dn_op == DT_TOK_POSTINC ||
2954 dnp->dn_op == DT_TOK_PREDEC || dnp->dn_op == DT_TOK_POSTDEC)
2960 * We allow the unary ++ and -- operators to instantiate new scalar
2963 if (cp->dn_kind == DT_NODE_IDENT && (idflags & DT_IDFLG_MOD))
2964 dt_xcook_ident(cp, dtp->dt_globals, DT_IDENT_SCALAR, B_TRUE);
2966 cp = dnp->dn_child = dt_node_cook(cp, 0); /* don't set idflags yet */
2968 if (cp->dn_kind == DT_NODE_VAR && dt_ident_unref(cp->dn_ident)) {
2972 dt_ident_type_assign(cp->dn_ident, dtt.dtt_ctfp, dtt.dtt_type);
2977 if (cp->dn_kind == DT_NODE_VAR)
2978 cp->dn_ident->di_flags |= idflags;
2980 switch (dnp->dn_op) {
2987 dt_xlator_t *dxp = idp->di_data;
2989 dnp->dn_ident = &dxp->dx_souid;
2991 dnp->dn_ident->di_ctfp, dnp->dn_ident->di_type,
2992 cp->dn_flags & DT_NF_USERLAND);
2996 type = ctf_type_resolve(cp->dn_ctfp, cp->dn_type);
2997 kind = ctf_type_kind(cp->dn_ctfp, type);
3000 if (ctf_array_info(cp->dn_ctfp, type, &r) != 0) {
3001 dtp->dt_ctferr = ctf_errno(cp->dn_ctfp);
3002 longjmp(yypcb->pcb_jmpbuf, EDT_CTF);
3006 type = ctf_type_reference(cp->dn_ctfp, type);
3009 "cannot dereference non-pointer type\n");
3012 dt_node_type_assign(dnp, cp->dn_ctfp, type,
3013 cp->dn_flags & DT_NF_USERLAND);
3014 base = ctf_type_resolve(cp->dn_ctfp, type);
3015 kind = ctf_type_kind(cp->dn_ctfp, base);
3017 if (kind == CTF_K_INTEGER && ctf_type_encoding(cp->dn_ctfp,
3029 dnp->dn_flags |= DT_NF_LVALUE; /* see K&R[A7.4.3] */
3032 * If we propagated the l-value bit and the child operand was
3038 if ((cp->dn_flags & DT_NF_WRITABLE) ||
3039 (cp->dn_kind == DT_NODE_OP2 && cp->dn_op == DT_TOK_ADD &&
3040 (cp->dn_left->dn_flags & DT_NF_WRITABLE)))
3041 dnp->dn_flags |= DT_NF_WRITABLE;
3043 if ((cp->dn_flags & DT_NF_USERLAND) &&
3044 (kind == CTF_K_POINTER || (dnp->dn_flags & DT_NF_REF)))
3045 dnp->dn_flags |= DT_NF_USERLAND;
3052 "of arithmetic type\n", opstr(dnp->dn_op));
3054 dt_node_type_propagate(cp, dnp); /* see K&R[A7.4.4-6] */
3060 "integral type\n", opstr(dnp->dn_op));
3062 dt_node_type_propagate(cp, dnp); /* see K&R[A7.4.4-6] */
3068 "of scalar type\n", opstr(dnp->dn_op));
3075 if (cp->dn_kind == DT_NODE_VAR || cp->dn_kind == DT_NODE_AGG) {
3085 if (!(cp->dn_flags & DT_NF_LVALUE)) {
3090 if (cp->dn_flags & DT_NF_BITFIELD) {
3092 "cannot take address of bit-field\n");
3096 .dtt_ctfp = cp->dn_ctfp,
3097 .dtt_type = cp->dn_type,
3100 if (dt_type_pointer(&dtt) == -1) {
3106 cp->dn_flags & DT_NF_USERLAND);
3110 if (cp->dn_flags & DT_NF_BITFIELD) {
3112 "cannot apply sizeof to a bit-field\n");
3120 dt_node_type_assign(dnp, dtp->dt_ddefs->dm_ctfp,
3121 ctf_lookup_by_name(dtp->dt_ddefs->dm_ctfp, "size_t"),
3133 cp->dn_flags & DT_NF_USERLAND);
3142 "scalar type\n", opstr(dnp->dn_op));
3147 "of known size\n", opstr(dnp->dn_op));
3150 if (!(cp->dn_flags & DT_NF_LVALUE)) {
3152 "lvalue as an operand\n", opstr(dnp->dn_op));
3155 if (!(cp->dn_flags & DT_NF_WRITABLE)) {
3157 "to a writable variable\n", opstr(dnp->dn_op));
3164 xyerror(D_UNKNOWN, "invalid unary op %s\n", opstr(dnp->dn_op));
3167 dt_node_attr_assign(dnp, cp->dn_attr);
3174 dt_node_t *lp = dnp->dn_left;
3175 dt_node_t *rp = dnp->dn_right;
3176 int op = dnp->dn_op;
3178 if (rp->dn_kind == DT_NODE_INT)
3181 if (!(lp->dn_flags & DT_NF_LVALUE)) {
3187 if (!(lp->dn_flags & DT_NF_WRITABLE)) {
3193 dt_node_attr_assign(dnp, dt_attr_min(lp->dn_attr, rp->dn_attr));
3199 dtrace_hdl_t *dtp = yypcb->pcb_hdl;
3200 dt_node_t *lp = dnp->dn_left;
3201 dt_node_t *rp = dnp->dn_right;
3202 int op = dnp->dn_op;
3216 * unless the left-hand side is an untyped D scalar, associative array,
3221 if (lp->dn_kind == DT_NODE_IDENT) {
3225 if (lp->dn_op == DT_TOK_AGG) {
3226 dhp = dtp->dt_aggs;
3227 idp = dt_idhash_lookup(dhp, lp->dn_string + 1);
3230 dhp = dtp->dt_globals;
3232 &yypcb->pcb_globals, lp->dn_string);
3239 dt_xcook_ident(lp, dhp, idp->di_kind, B_FALSE);
3241 lp = dnp->dn_left = dt_node_cook(lp, 0);
3248 * (b) lp is a non-ARRAY variable that has already been given
3252 if (lp->dn_kind == DT_NODE_VAR) {
3253 if (lp->dn_ident->di_kind == DT_IDENT_ARRAY) {
3254 if (lp->dn_args != NULL)
3256 } else if (!dt_ident_unref(lp->dn_ident)) {
3259 } else if (lp->dn_kind != DT_NODE_AGG) {
3268 lp = dnp->dn_left = dt_node_cook(lp, DT_IDFLG_REF);
3269 rp = dnp->dn_right = dt_node_cook(rp, DT_IDFLG_REF);
3276 dt_node_promote(lp, rp, dnp); /* see K&R[A7.11-13] */
3281 lp = dnp->dn_left = dt_node_cook(lp, DT_IDFLG_REF);
3282 rp = dnp->dn_right = dt_node_cook(rp, DT_IDFLG_REF);
3290 dt_node_attr_assign(dnp, dt_attr_min(lp->dn_attr, rp->dn_attr));
3294 lp = dnp->dn_left = dt_node_cook(lp, DT_IDFLG_REF);
3295 rp = dnp->dn_right = dt_node_cook(rp, DT_IDFLG_REF);
3307 lp = dnp->dn_left = dt_node_cook(lp, DT_IDFLG_REF);
3308 rp = dnp->dn_right = dt_node_cook(rp, DT_IDFLG_REF);
3321 lp = dnp->dn_left = dt_node_cook(lp, DT_IDFLG_REF);
3322 rp = dnp->dn_right = dt_node_cook(rp, DT_IDFLG_REF);
3331 dt_node_attr_assign(dnp, dt_attr_min(lp->dn_attr, rp->dn_attr));
3342 * a right-hand identifier into a corresponding enum tag value
3343 * if the left-hand side is an enum type. To do this, we cook
3344 * the left-hand side, and then see if the right-hand side is
3348 lp = dnp->dn_left = dt_node_cook(lp, DT_IDFLG_REF);
3350 kind = ctf_type_kind(lp->dn_ctfp,
3351 ctf_type_resolve(lp->dn_ctfp, lp->dn_type));
3353 if (kind == CTF_K_ENUM && rp->dn_kind == DT_NODE_IDENT &&
3354 strchr(rp->dn_string, '`') == NULL && ctf_enum_value(
3355 lp->dn_ctfp, lp->dn_type, rp->dn_string, &val) == 0) {
3357 if ((idp = dt_idstack_lookup(&yypcb->pcb_globals,
3358 rp->dn_string)) != NULL) {
3362 opstr(op), rp->dn_string,
3364 dt_idkind_name(idp->di_kind));
3367 free(rp->dn_string);
3368 rp->dn_string = NULL;
3369 rp->dn_kind = DT_NODE_INT;
3370 rp->dn_flags |= DT_NF_COOKED;
3371 rp->dn_op = DT_TOK_INT;
3372 rp->dn_value = (intmax_t)val;
3374 dt_node_type_assign(rp, lp->dn_ctfp, lp->dn_type,
3379 rp = dnp->dn_right = dt_node_cook(rp, DT_IDFLG_REF);
3383 * described in the ANSI-C spec (see K&R[A7.9-10]). We perform
3385 * also allow derived strings to be compared as a first-class
3386 * type (resulting in a strcmp(3C)-style comparison), and we
3392 if (ctf_type_compat(lp->dn_ctfp, lp->dn_type,
3393 rp->dn_ctfp, rp->dn_type))
3409 dt_node_attr_assign(dnp, dt_attr_min(lp->dn_attr, rp->dn_attr));
3416 * described in the ANSI-C spec (see K&R[A7.7]). Pointers and
3422 lp = dnp->dn_left = dt_node_cook(lp, DT_IDFLG_REF);
3423 rp = dnp->dn_right = dt_node_cook(rp, DT_IDFLG_REF);
3437 ctfp = lp->dn_ctfp;
3438 type = lp->dn_type;
3439 uref = lp->dn_flags & DT_NF_USERLAND;
3441 ctfp = rp->dn_ctfp;
3442 type = rp->dn_type;
3443 uref = rp->dn_flags & DT_NF_USERLAND;
3446 ctfp = dtp->dt_ddefs->dm_ctfp;
3457 dt_node_attr_assign(dnp, dt_attr_min(lp->dn_attr, rp->dn_attr));
3460 dnp->dn_flags |= DT_NF_USERLAND;
3470 if (lp->dn_kind == DT_NODE_IDENT) {
3471 dt_xcook_ident(lp, dtp->dt_globals,
3475 lp = dnp->dn_left =
3478 rp = dnp->dn_right =
3489 if (lp->dn_kind == DT_NODE_IDENT) {
3490 dt_xcook_ident(lp, dtp->dt_globals,
3494 lp = dnp->dn_left =
3497 rp = dnp->dn_right =
3508 * If the left-hand side is an identifier, attempt to resolve
3513 if (lp->dn_kind == DT_NODE_IDENT) {
3514 if (lp->dn_op == DT_TOK_AGG) {
3515 dt_xcook_ident(lp, dtp->dt_aggs,
3518 dt_xcook_ident(lp, dtp->dt_globals,
3523 lp = dnp->dn_left = dt_node_cook(lp, 0); /* don't set mod yet */
3524 rp = dnp->dn_right = dt_node_cook(rp, DT_IDFLG_REF);
3527 * If the left-hand side is an aggregation, verify that we are
3535 if (lp->dn_kind == DT_NODE_AGG) {
3536 const char *aname = lp->dn_ident->di_name;
3537 dt_ident_t *oid = lp->dn_ident->di_iarg;
3539 if (rp->dn_kind != DT_NODE_FUNC ||
3540 rp->dn_ident->di_kind != DT_IDENT_AGGFUNC) {
3546 if (oid != NULL && oid != rp->dn_ident) {
3551 rp->dn_ident->di_name, aname, oid->di_name,
3552 lp->dn_ident->di_lineno);
3554 lp->dn_ident->di_iarg = rp->dn_ident;
3562 if (lp->dn_aggfun != NULL) {
3567 lp->dn_aggfun = rp;
3570 dnp->dn_left = dnp->dn_right = NULL;
3577 * If the right-hand side is a dynamic variable that is the
3581 ctfp = idp->di_ctfp;
3582 type = idp->di_type;
3583 uref = idp->di_flags & DT_IDFLG_USER;
3585 ctfp = rp->dn_ctfp;
3586 type = rp->dn_type;
3587 uref = rp->dn_flags & DT_NF_USERLAND;
3591 * If the left-hand side of an assignment statement is a virgin
3593 * this variable to the type of the right-hand side.
3595 if (lp->dn_kind == DT_NODE_VAR &&
3596 dt_ident_unref(lp->dn_ident)) {
3598 dt_ident_type_assign(lp->dn_ident, ctfp, type);
3601 lp->dn_flags |= DT_NF_USERLAND;
3602 lp->dn_ident->di_flags |= DT_IDFLG_USER;
3606 if (lp->dn_kind == DT_NODE_VAR)
3607 lp->dn_ident->di_flags |= DT_IDFLG_MOD;
3611 * described in the ANSI-C spec (see K&R[A7.17]). We share
3615 kind = ctf_type_kind(lp->dn_ctfp,
3616 ctf_type_resolve(lp->dn_ctfp, lp->dn_type));
3626 if (idp != NULL && idp->di_kind == DT_IDENT_XLSOU &&
3627 ctf_type_compat(lp->dn_ctfp, lp->dn_type, ctfp, type))
3641 if (lp->dn_kind == DT_NODE_IDENT) {
3642 dt_xcook_ident(lp, dtp->dt_globals,
3646 lp = dnp->dn_left =
3649 rp = dnp->dn_right =
3661 * described in the ANSI-C spec (see K&R[A7.17]). To these
3668 "operator %s requires left-hand scalar "
3685 * If the left-hand side of operator -> is one of the scoping
3689 if (lp->dn_kind == DT_NODE_IDENT) {
3692 if (strcmp(lp->dn_string, "self") == 0) {
3693 dhp = dtp->dt_tls;
3694 } else if (strcmp(lp->dn_string, "this") == 0) {
3695 dhp = yypcb->pcb_locals;
3698 if (rp->dn_kind != DT_NODE_VAR) {
3707 dnp->dn_right = dnp->dn_left;
3714 lp = dnp->dn_left = dt_node_cook(lp, DT_IDFLG_REF);
3716 if (rp->dn_kind != DT_NODE_IDENT) {
3724 * If the left-hand side is a translated struct or ptr,
3727 dt_xlator_t *dxp = idp->di_data;
3729 if (dt_xlator_member(dxp, rp->dn_string) == NULL) {
3732 "for member: %s\n", rp->dn_string);
3735 ctfp = idp->di_ctfp;
3736 type = ctf_type_resolve(ctfp, idp->di_type);
3737 uref = idp->di_flags & DT_IDFLG_USER;
3739 ctfp = lp->dn_ctfp;
3740 type = ctf_type_resolve(ctfp, lp->dn_type);
3741 uref = lp->dn_flags & DT_NF_USERLAND;
3779 xyerror(D_OP_SOU, "operator -> cannot be "
3791 if (ctf_member_info(ctfp, type, rp->dn_string, &m) == CTF_ERR) {
3793 "%s is not a member of %s\n", rp->dn_string,
3801 dt_node_attr_assign(dnp, lp->dn_attr);
3805 dnp->dn_flags |= DT_NF_LVALUE; /* see K&R[A7.3.3] */
3807 if (op == DT_TOK_DOT && (lp->dn_flags & DT_NF_LVALUE) &&
3809 dnp->dn_flags |= DT_NF_LVALUE; /* see K&R[A7.3.3] */
3811 if (lp->dn_flags & DT_NF_WRITABLE)
3812 dnp->dn_flags |= DT_NF_WRITABLE;
3815 (dnp->dn_flags & DT_NF_REF)))
3816 dnp->dn_flags |= DT_NF_USERLAND;
3821 * If op is DT_TOK_LBRAC, we know from the special-case code at
3827 * If the left-hand side is an aggregation, just set dn_aggtup
3828 * to the right-hand side and return the cooked aggregation.
3833 if (lp->dn_kind == DT_NODE_AGG) {
3834 if (lp->dn_aggtup != NULL) {
3836 "reference @%s as a multi-dimensional "
3837 "array\n", lp->dn_ident->di_name);
3840 lp->dn_aggtup = rp;
3843 dnp->dn_left = dnp->dn_right = NULL;
3849 assert(lp->dn_kind == DT_NODE_VAR);
3850 idp = lp->dn_ident;
3853 * If the left-hand side is a non-global scalar that hasn't yet
3854 * been referenced or modified, it was just created by self->
3855 * or this-> and we can convert it from scalar to assoc array.
3857 if (idp->di_kind == DT_IDENT_SCALAR && dt_ident_unref(idp) &&
3858 (idp->di_flags & (DT_IDFLG_LOCAL | DT_IDFLG_TLS)) != 0) {
3860 if (idp->di_flags & DT_IDFLG_LOCAL) {
3863 "associative arrays: %s\n", idp->di_name);
3867 "array\n", idp->di_name, idp->di_id);
3873 if (idp->di_kind != DT_IDENT_ARRAY) {
3875 "as %s\n", dt_idkind_name(idp->di_kind),
3876 idp->di_name, dt_idkind_name(DT_IDENT_ARRAY));
3880 * Now that we've confirmed our left-hand side is a DT_NODE_VAR
3883 * where dn_args for the VAR node is the right-hand 'rp' tree,
3889 * / \ +- dn_args -> [ ??? ]=rp
3893 * must perform the transformations as a group first by over-
3897 assert(lp->dn_kind == DT_NODE_VAR);
3898 assert(lp->dn_args == NULL);
3900 lnp = dnp->dn_link;
3902 dnp->dn_link = lnp;
3904 dnp->dn_args = rp;
3905 dnp->dn_list = NULL;
3914 assert(lp->dn_kind == DT_NODE_TYPE);
3915 rp = dnp->dn_right = dt_node_cook(rp, DT_IDFLG_REF);
3925 dnp->dn_ident = dt_xlator_ident(dxp, lp->dn_ctfp, lp->dn_type);
3929 dt_attr_min(rp->dn_attr, dnp->dn_ident->di_attr));
3937 assert(lp->dn_kind == DT_NODE_TYPE);
3938 rp = dnp->dn_right = dt_node_cook(rp, DT_IDFLG_REF);
3940 ltype = ctf_type_resolve(lp->dn_ctfp, lp->dn_type);
3941 lkind = ctf_type_kind(lp->dn_ctfp, ltype);
3943 rtype = ctf_type_resolve(rp->dn_ctfp, rp->dn_type);
3944 rkind = ctf_type_kind(rp->dn_ctfp, rtype);
3953 if (ctf_type_compat(lp->dn_ctfp, lp->dn_type,
3954 rp->dn_ctfp, rp->dn_type))
3974 dt_node_attr_assign(dnp, dt_attr_min(lp->dn_attr, rp->dn_attr));
3981 dnp->dn_flags |= DT_NF_WRITABLE;
3987 lp = dnp->dn_left = dt_node_cook(lp, DT_IDFLG_REF);
3988 rp = dnp->dn_right = dt_node_cook(rp, DT_IDFLG_REF);
4001 dt_node_attr_assign(dnp, dt_attr_min(lp->dn_attr, rp->dn_attr));
4012 * end up with a comma-separated list inside of a non-associative
4015 if (dnp->dn_op == DT_TOK_LBRAC && op == DT_TOK_ADD) {
4018 if (rp->dn_list != NULL) {
4024 dnp->dn_op = DT_TOK_ADD;
4031 * list because the sub-expression may be part of a definition.
4033 assert(yypcb->pcb_list == pnp);
4034 yypcb->pcb_list = pnp->dn_link;
4036 pnp->dn_link = dnp->dn_link;
4037 dnp->dn_link = pnp;
4053 dnp->dn_expr = dt_node_cook(dnp->dn_expr, DT_IDFLG_REF);
4054 lp = dnp->dn_left = dt_node_cook(dnp->dn_left, DT_IDFLG_REF);
4055 rp = dnp->dn_right = dt_node_cook(dnp->dn_right, DT_IDFLG_REF);
4057 if (!dt_node_is_scalar(dnp->dn_expr)) {
4069 * are described in the ANSI-C spec (see K&R[A7.16]). We implement
4072 if (ctf_type_compat(lp->dn_ctfp, lp->dn_type,
4073 rp->dn_ctfp, rp->dn_type)) {
4074 ctfp = lp->dn_ctfp;
4075 type = lp->dn_type;
4080 ctfp = DT_STR_CTFP(yypcb->pcb_hdl);
4081 type = DT_STR_TYPE(yypcb->pcb_hdl);
4093 dt_node_attr_assign(dnp, dt_attr_min(dnp->dn_expr->dn_attr,
4094 dt_attr_min(lp->dn_attr, rp->dn_attr)));
4102 dnp->dn_expr = dt_node_cook(dnp->dn_expr, idflags);
4103 dt_node_attr_assign(dnp, dnp->dn_expr->dn_attr);
4118 dtrace_hdl_t *dtp = yypcb->pcb_hdl;
4120 if (dnp->dn_aggfun != NULL) {
4121 dnp->dn_aggfun = dt_node_cook(dnp->dn_aggfun, DT_IDFLG_REF);
4123 dnp->dn_ident, &dnp->dn_aggtup));
4127 dt_node_attr_assign(dnp, dnp->dn_ident->di_attr);
4138 * probe-description-list probe-description-list
4144 * In the left-hand example, the predicate uses operator ++ to instantiate 'x'
4147 * right-hand example, the action list uses ++ to instantiate 'x'; the action
4158 * cook actions = OK, cook predicate = OK -> OK
4159 * cook actions = OK, cook predicate = ERR -> ERR
4160 * cook actions = ERR, cook predicate = ERR -> ERR
4161 * cook actions = ERR, cook predicate = OK, cook actions = OK -> OK
4162 * cook actions = ERR, cook predicate = OK, cook actions = ERR -> ERR
4167 * probe-description-list
4186 dt_node_attr_assign(dnp, yypcb->pcb_pinfo.dtp_attr);
4187 dnp->dn_ctxattr = yypcb->pcb_pinfo.dtp_attr;
4189 bcopy(yypcb->pcb_jmpbuf, ojb, sizeof (jmp_buf));
4192 if (dnp->dn_pred != NULL && (err = setjmp(yypcb->pcb_jmpbuf)) != 0) {
4193 bcopy(ojb, yypcb->pcb_jmpbuf, sizeof (jmp_buf));
4195 yypcb->pcb_hdl->dt_errtag != dt_errtag(D_IDENT_UNDEF) &&
4196 yypcb->pcb_hdl->dt_errtag != dt_errtag(D_VAR_UNDEF)))
4197 longjmp(yypcb->pcb_jmpbuf, err);
4204 dt_node_list_cook(&dnp->dn_acts, idflags));
4206 bcopy(ojb, yypcb->pcb_jmpbuf, sizeof (jmp_buf));
4210 if (dnp->dn_pred != NULL) {
4213 dnp->dn_pred = dt_node_cook(dnp->dn_pred, idflags);
4215 dt_attr_min(dnp->dn_attr, dnp->dn_pred->dn_attr));
4217 if (!dt_node_is_scalar(dnp->dn_pred)) {
4229 dt_node_list_cook(&dnp->dn_acts, idflags));
4241 dt_idnode_t *inp = dnp->dn_ident->di_iarg;
4247 assert(dnp->dn_ident->di_flags & DT_IDFLG_INLINE);
4248 assert(inp->din_root->dn_flags & DT_NF_COOKED);
4255 if ((rdp = dt_node_resolve(inp->din_root, DT_IDENT_XLSOU)) != NULL ||
4256 (rdp = dt_node_resolve(inp->din_root, DT_IDENT_XLPTR)) != NULL) {
4258 ctf_file_t *lctfp = dnp->dn_ctfp;
4259 ctf_id_t ltype = ctf_type_resolve(lctfp, dnp->dn_type);
4261 dt_xlator_t *dxp = rdp->di_data;
4262 ctf_file_t *rctfp = dxp->dx_dst_ctfp;
4263 ctf_id_t rtype = dxp->dx_dst_base;
4273 "\"%s\" = \"%s\"\n", dnp->dn_ident->di_name,
4278 } else if (dt_node_is_argcompat(dnp, inp->din_root) == 0) {
4281 "\"%s\" = \"%s\"\n", dnp->dn_ident->di_name,
4283 dt_node_type_name(inp->din_root, n2, sizeof (n2)));
4292 dnp->dn_membexpr = dt_node_cook(dnp->dn_membexpr, idflags);
4293 dt_node_attr_assign(dnp, dnp->dn_membexpr->dn_attr);
4301 dtrace_hdl_t *dtp = yypcb->pcb_hdl;
4302 dt_xlator_t *dxp = dnp->dn_xlator;
4313 * hash containing translator-local identifiers on to pcb_globals to
4316 dt_idstack_push(&yypcb->pcb_globals, dxp->dx_locals);
4318 for (mnp = dnp->dn_members; mnp != NULL; mnp = mnp->dn_list) {
4319 if (ctf_member_info(dxp->dx_dst_ctfp, dxp->dx_dst_type,
4320 mnp->dn_membname, &ctm) == CTF_ERR) {
4323 mnp->dn_membname, ctf_type_name(dxp->dx_dst_ctfp,
4324 dxp->dx_dst_type, n1, sizeof (n1)));
4328 dt_node_type_assign(mnp, dxp->dx_dst_ctfp, ctm.ctm_type,
4330 attr = dt_attr_min(attr, mnp->dn_attr);
4332 if (dt_node_is_argcompat(mnp, mnp->dn_membexpr) == 0) {
4336 mnp->dn_membname,
4338 dt_node_type_name(mnp->dn_membexpr,
4343 dt_idstack_pop(&yypcb->pcb_globals, dxp->dx_locals);
4345 dxp->dx_souid.di_attr = attr;
4346 dxp->dx_ptrid.di_attr = attr;
4358 dt_probe_t *prp = pnp->dn_ident->di_data;
4368 pvp->pv_desc.dtvd_name, prp->pr_ident->di_name, kind,
4374 old_argv = old_argv->dn_list, new_argv = new_argv->dn_list) {
4375 if (ctf_type_cmp(old_argv->dn_ctfp, old_argv->dn_type,
4376 new_argv->dn_ctfp, new_argv->dn_type) == 0)
4382 pvp->pv_desc.dtvd_name, prp->pr_ident->di_name, kind, i + 1,
4399 old->pr_xargc, old->pr_xargs, new->pr_xargc, new->pr_xargs);
4401 if (old->pr_nargs != old->pr_xargs && new->pr_nargs != new->pr_xargs) {
4403 old->pr_nargc, old->pr_nargs, new->pr_nargc, new->pr_nargs);
4406 if (old->pr_nargs == old->pr_xargs && new->pr_nargs != new->pr_xargs) {
4407 if (pvp->pv_flags & DT_PROVIDER_IMPL) {
4412 pvp->pv_desc.dtvd_name, pvp->pv_desc.dtvd_name,
4413 new->pr_ident->di_name, pvp->pv_desc.dtvd_name,
4414 old->pr_ident->di_name);
4417 if (old->pr_ident->di_gen == yypcb->pcb_hdl->dt_gen)
4418 old->pr_ident->di_flags |= DT_IDFLG_ORPHAN;
4420 dt_idhash_delete(pvp->pv_probes, old->pr_ident);
4428 dtrace_hdl_t *dtp = yypcb->pcb_hdl;
4429 dt_probe_t *prp = dnp->dn_ident->di_data;
4437 if (prp->pr_nargs == prp->pr_xargs)
4440 for (i = 0; i < prp->pr_xargc; i++) {
4441 dt_node_t *xnp = prp->pr_xargv[i];
4442 dt_node_t *nnp = prp->pr_nargv[prp->pr_mapping[i]];
4446 if (dt_provider_xref(dtp, pvp, dxp->dx_id) != 0)
4447 longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
4456 pvp->pv_desc.dtvd_name, dnp->dn_ident->di_name, i + 1,
4466 dt_provider_t *pvp = dnp->dn_provider;
4474 for (pnp = dnp->dn_probes; pnp != NULL; pnp = pnp->dn_list) {
4475 const char *probename = pnp->dn_ident->di_name;
4478 assert(pnp->dn_kind == DT_NODE_PROBE);
4480 if (prp != NULL && dnp->dn_provred) {
4482 prp, pnp->dn_ident->di_data);
4483 } else if (prp == NULL && dnp->dn_provred) {
4488 dnp->dn_provname, dnp->dn_provname,
4489 probename, dnp->dn_provname, probename);
4492 dnp->dn_provname, probename);
4494 dt_probe_declare(pvp, pnp->dn_ident->di_data);
4545 yylineno = dnp->dn_line;
4547 assert(dnp->dn_kind <
4549 dnp = dt_cook_funcs[dnp->dn_kind](dnp, idflags);
4550 dnp->dn_flags |= DT_NF_COOKED;
4552 if (dnp->dn_kind == DT_NODE_VAR || dnp->dn_kind == DT_NODE_AGG)
4553 dnp->dn_ident->di_flags |= idflags;
4566 nnp = dnp->dn_list;
4568 attr = dt_attr_min(attr, dnp->dn_attr);
4569 dnp->dn_list = nnp;
4570 pnp = &dnp->dn_list;
4582 nnp = dnp->dn_list;
4596 nnp = dnp->dn_link;
4601 nnp = dnp->dn_link;
4619 for (dnp = lp; dnp->dn_list != NULL; dnp = dnp->dn_list)
4622 dnp->dn_list = rp;
4629 * is valid: any references to handle-specific data must be made through 'dtp'.
4634 if (dnp->dn_ctfp == DT_STR_CTFP(dtp) &&
4635 dnp->dn_type == DT_STR_TYPE(dtp)) {
4636 tp->dtdt_kind = DIF_TYPE_STRING;
4637 tp->dtdt_ckind = CTF_K_UNKNOWN;
4639 tp->dtdt_kind = DIF_TYPE_CTF;
4640 tp->dtdt_ckind = ctf_type_kind(dnp->dn_ctfp,
4641 ctf_type_resolve(dnp->dn_ctfp, dnp->dn_type));
4644 tp->dtdt_flags = (dnp->dn_flags & DT_NF_REF) ?
4645 (dnp->dn_flags & DT_NF_USERLAND) ? DIF_TF_BYUREF :
4647 tp->dtdt_pad = 0;
4648 tp->dtdt_size = ctf_type_size(dnp->dn_ctfp, dnp->dn_type);
4652 * Output the parse tree as D. The "-xtree=8" argument will call this
4661 * - Only the clauses are output. #pragma options, variable
4663 * - Command argument substitution has already been done, so the output
4671 switch (dnp->dn_kind) {
4673 (void) fprintf(fp, "0x%llx", (u_longlong_t)dnp->dn_value);
4674 if (!(dnp->dn_flags & DT_NF_SIGNED))
4679 char *escd = strchr2esc(dnp->dn_string, strlen(dnp->dn_string));
4686 (void) fprintf(fp, "%s", dnp->dn_string);
4691 (dnp->dn_ident->di_flags & DT_IDFLG_LOCAL) ? "this->" :
4692 (dnp->dn_ident->di_flags & DT_IDFLG_TLS) ? "self->" : "",
4693 dnp->dn_ident->di_name);
4695 if (dnp->dn_args != NULL) {
4698 for (arg = dnp->dn_args; arg != NULL;
4699 arg = arg->dn_list) {
4701 if (arg->dn_list != NULL)
4710 const dtrace_syminfo_t *dts = dnp->dn_ident->di_data;
4711 (void) fprintf(fp, "%s`%s", dts->dts_object, dts->dts_name);
4715 (void) fprintf(fp, "%s(", dnp->dn_ident->di_name);
4717 for (arg = dnp->dn_args; arg != NULL; arg = arg->dn_list) {
4719 if (arg->dn_list != NULL)
4726 (void) fprintf(fp, "%s(", opstr(dnp->dn_op));
4727 dt_printd(dnp->dn_child, fp, 0);
4733 dt_printd(dnp->dn_left, fp, 0);
4734 if (dnp->dn_op == DT_TOK_LPAR) {
4736 dt_printd(dnp->dn_right, fp, 0);
4739 if (dnp->dn_op == DT_TOK_PTR || dnp->dn_op == DT_TOK_DOT ||
4740 dnp->dn_op == DT_TOK_LBRAC)
4741 (void) fprintf(fp, "%s", opstr(dnp->dn_op));
4743 (void) fprintf(fp, " %s ", opstr(dnp->dn_op));
4744 dt_printd(dnp->dn_right, fp, 0);
4745 if (dnp->dn_op == DT_TOK_LBRAC) {
4746 dt_node_t *ln = dnp->dn_right;
4747 while (ln->dn_list != NULL) {
4749 dt_printd(ln->dn_list, fp, depth);
4750 ln = ln->dn_list;
4759 dt_printd(dnp->dn_expr, fp, 0);
4761 dt_printd(dnp->dn_left, fp, 0);
4763 dt_printd(dnp->dn_right, fp, 0);
4770 dt_printd(dnp->dn_expr, fp, depth + 1);
4776 dnp->dn_desc->dtpd_provider, dnp->dn_desc->dtpd_mod,
4777 dnp->dn_desc->dtpd_func, dnp->dn_desc->dtpd_name);
4781 for (arg = dnp->dn_pdescs; arg != NULL; arg = arg->dn_list) {
4783 if (arg->dn_list != NULL)
4788 if (dnp->dn_pred != NULL) {
4790 dt_printd(dnp->dn_pred, fp, 0);
4795 for (arg = dnp->dn_acts; arg != NULL; arg = arg->dn_list)
4803 dt_printd(dnp->dn_conditional, fp, 0);
4806 for (arg = dnp->dn_body; arg != NULL; arg = arg->dn_list)
4808 if (dnp->dn_alternate_body == NULL) {
4812 for (arg = dnp->dn_alternate_body; arg != NULL;
4813 arg = arg->dn_list)
4822 (void *)dnp, dnp->dn_kind);
4835 (void) dt_attr_str(dnp->dn_attr, a, sizeof (a));
4837 if (dnp->dn_ctfp != NULL && dnp->dn_type != CTF_ERR &&
4838 ctf_type_name(dnp->dn_ctfp, dnp->dn_type, n, sizeof (n)) != NULL) {
4842 dnp->dn_type, a);
4845 if (dnp->dn_flags != 0) {
4847 if (dnp->dn_flags & DT_NF_SIGNED)
4849 if (dnp->dn_flags & DT_NF_COOKED)
4851 if (dnp->dn_flags & DT_NF_REF)
4853 if (dnp->dn_flags & DT_NF_LVALUE)
4855 if (dnp->dn_flags & DT_NF_WRITABLE)
4857 if (dnp->dn_flags & DT_NF_BITFIELD)
4859 if (dnp->dn_flags & DT_NF_USERLAND)
4865 switch (dnp->dn_kind) {
4872 (u_longlong_t)dnp->dn_value, buf);
4876 (void) fprintf(fp, "STRING \"%s\" (%s)\n", dnp->dn_string, buf);
4880 (void) fprintf(fp, "IDENT %s (%s)\n", dnp->dn_string, buf);
4885 (dnp->dn_ident->di_flags & DT_IDFLG_LOCAL) ? "this->" :
4886 (dnp->dn_ident->di_flags & DT_IDFLG_TLS) ? "self->" : "",
4887 dnp->dn_ident->di_name, buf);
4889 if (dnp->dn_args != NULL)
4892 for (arg = dnp->dn_args; arg != NULL; arg = arg->dn_list) {
4894 if (arg->dn_list != NULL)
4898 if (dnp->dn_args != NULL)
4903 dts = dnp->dn_ident->di_data;
4905 dts->dts_object, dts->dts_name, buf);
4909 if (dnp->dn_string != NULL) {
4911 buf, dnp->dn_string);
4918 dnp->dn_ident->di_name, buf);
4920 for (arg = dnp->dn_args; arg != NULL; arg = arg->dn_list) {
4922 if (arg->dn_list != NULL)
4928 (void) fprintf(fp, "OP1 %s (%s)\n", opstr(dnp->dn_op), buf);
4929 dt_node_printr(dnp->dn_child, fp, depth + 1);
4933 (void) fprintf(fp, "OP2 %s (%s)\n", opstr(dnp->dn_op), buf);
4934 dt_node_printr(dnp->dn_left, fp, depth + 1);
4935 dt_node_printr(dnp->dn_right, fp, depth + 1);
4936 if (dnp->dn_op == DT_TOK_LBRAC) {
4937 dt_node_t *ln = dnp->dn_right;
4938 while (ln->dn_list != NULL) {
4939 dt_node_printr(ln->dn_list, fp, depth + 1);
4940 ln = ln->dn_list;
4947 dt_node_printr(dnp->dn_expr, fp, depth + 1);
4949 dt_node_printr(dnp->dn_left, fp, depth + 1);
4951 dt_node_printr(dnp->dn_right, fp, depth + 1);
4957 dt_node_printr(dnp->dn_expr, fp, depth + 1);
4962 dnp->dn_ident->di_name, a);
4964 for (arg = dnp->dn_aggtup; arg != NULL; arg = arg->dn_list) {
4966 if (arg->dn_list != NULL)
4970 if (dnp->dn_aggfun) {
4972 dt_node_printr(dnp->dn_aggfun, fp, depth + 1);
4976 if (dnp->dn_aggfun)
4982 dnp->dn_desc->dtpd_provider, dnp->dn_desc->dtpd_mod,
4983 dnp->dn_desc->dtpd_func, dnp->dn_desc->dtpd_name,
4984 dnp->dn_desc->dtpd_id);
4990 for (arg = dnp->dn_pdescs; arg != NULL; arg = arg->dn_list)
4994 dt_attr_str(dnp->dn_ctxattr, a, sizeof (a)));
4996 if (dnp->dn_pred != NULL) {
4998 dt_node_printr(dnp->dn_pred, fp, depth + 1);
5002 for (arg = dnp->dn_acts; arg != NULL; arg = arg->dn_list)
5008 inp = dnp->dn_ident->di_iarg;
5011 dnp->dn_ident->di_name, buf);
5012 dt_node_printr(inp->din_root, fp, depth + 1);
5016 (void) fprintf(fp, "MEMBER %s (%s)\n", dnp->dn_membname, buf);
5017 if (dnp->dn_membexpr)
5018 dt_node_printr(dnp->dn_membexpr, fp, depth + 1);
5024 if (ctf_type_name(dnp->dn_xlator->dx_src_ctfp,
5025 dnp->dn_xlator->dx_src_type, n, sizeof (n)) != NULL)
5028 if (ctf_type_name(dnp->dn_xlator->dx_dst_ctfp,
5029 dnp->dn_xlator->dx_dst_type, n, sizeof (n)) != NULL)
5034 for (arg = dnp->dn_members; arg != NULL; arg = arg->dn_list)
5039 (void) fprintf(fp, "PROBE %s\n", dnp->dn_ident->di_name);
5044 dnp->dn_provname, dnp->dn_provred ? "redecl" : "decl");
5045 for (arg = dnp->dn_probes; arg != NULL; arg = arg->dn_list)
5051 for (arg = dnp->dn_list; arg != NULL; arg = arg->dn_list)
5058 dt_node_printr(dnp->dn_conditional, fp, depth + 1);
5061 for (arg = dnp->dn_body; arg != NULL; arg = arg->dn_list)
5064 if (dnp->dn_alternate_body != NULL) {
5066 for (arg = dnp->dn_alternate_body; arg != NULL;
5067 arg = arg->dn_list)
5075 (void *)dnp, dnp->dn_kind);
5082 yypcb->pcb_root = dnp;
5093 yylineno = dnp->dn_line;
5100 longjmp(yypcb->pcb_jmpbuf, EDT_COMPILER);
5110 yylineno = dnp->dn_line;
5129 longjmp(yypcb->pcb_jmpbuf, EDT_COMPILER);
5147 return; /* compiler is not currently active: act as a no-op */
5149 dt_set_errmsg(yypcb->pcb_hdl, dt_errtag(tag), yypcb->pcb_region,
5150 yypcb->pcb_filetag, yypcb->pcb_fileptr ? yylineno : 0, format, ap);
5163 longjmp(yypcb->pcb_jmpbuf, EDT_COMPILER);
5181 return; /* compiler is not currently active: act as a no-op */
5183 dt_set_errmsg(yypcb->pcb_hdl, dt_errtag(D_SYNTAX), yypcb->pcb_region,
5184 yypcb->pcb_filetag, yypcb->pcb_fileptr ? yylineno : 0, format, ap);
5187 dtrace_hdl_t *dtp = yypcb->pcb_hdl;
5188 size_t len = strlen(dtp->dt_errmsg);
5189 char *p, *s = dtp->dt_errmsg + len;
5190 size_t n = sizeof (dtp->dt_errmsg) - len;
5208 yypcb->pcb_region = label;