Print this page
libdtrace: attempt to resolve FORWARD types to concrete types
libdtrace: treat DTT_FL_USER properly in the parser

*** 1367,1377 **** dnp = dt_node_alloc(DT_NODE_TYPE); dnp->dn_op = DT_TOK_IDENT; dnp->dn_string = name; ! dt_node_type_assign(dnp, dtt.dtt_ctfp, dtt.dtt_type, dtt.dtt_flags); if (dtt.dtt_ctfp == dtp->dt_cdefs->dm_ctfp || dtt.dtt_ctfp == dtp->dt_ddefs->dm_ctfp) dt_node_attr_assign(dnp, _dtrace_defattr); else --- 1367,1378 ---- dnp = dt_node_alloc(DT_NODE_TYPE); dnp->dn_op = DT_TOK_IDENT; dnp->dn_string = name; ! dt_node_type_assign(dnp, dtt.dtt_ctfp, dtt.dtt_type, ! dtt.dtt_flags & DTT_FL_USER ? B_TRUE : B_FALSE); if (dtt.dtt_ctfp == dtp->dt_cdefs->dm_ctfp || dtt.dtt_ctfp == dtp->dt_ddefs->dm_ctfp) dt_node_attr_assign(dnp, _dtrace_defattr); else
*** 1796,1805 **** --- 1797,1807 ---- char *name; int err; ctf_membinfo_t ctm; ctf_id_t type; + ctf_file_t *ctfp; uint_t kind; name = strdupa(s); free(s);
*** 1821,1831 **** xyerror(D_UNKNOWN, "failed to determine offset of %s: %s\n", name, ctf_errmsg(ctf_errno(dtt.dtt_ctfp))); } bzero(&dn, sizeof (dn)); ! dt_node_type_assign(&dn, dtt.dtt_ctfp, ctm.ctm_type, B_FALSE); if (dn.dn_flags & DT_NF_BITFIELD) { xyerror(D_OFFSETOF_BITFIELD, "cannot take offset of a bit-field: %s\n", name); } --- 1823,1841 ---- xyerror(D_UNKNOWN, "failed to determine offset of %s: %s\n", name, ctf_errmsg(ctf_errno(dtt.dtt_ctfp))); } bzero(&dn, sizeof (dn)); ! /* ! * Resolution of CTF_K_FORWARD is unnecessary here, since it can't be ! * both forward _and_ a bitfield, but is done for completeness. ! */ ! type = ctm.ctm_type; ! ctfp = dtt.dtt_ctfp; ! ! dt_resolve_forward_decl(&ctfp, &type); ! dt_node_type_assign(&dn, ctfp, type, B_FALSE); if (dn.dn_flags & DT_NF_BITFIELD) { xyerror(D_OFFSETOF_BITFIELD, "cannot take offset of a bit-field: %s\n", name); }
*** 2421,2431 **** dnp->dn_membname = name; dnp->dn_membexpr = expr; if (ddp != NULL) dt_node_type_assign(dnp, dtt.dtt_ctfp, dtt.dtt_type, ! dtt.dtt_flags); return (dnp); } dt_node_t * --- 2431,2441 ---- dnp->dn_membname = name; dnp->dn_membexpr = expr; if (ddp != NULL) dt_node_type_assign(dnp, dtt.dtt_ctfp, dtt.dtt_type, ! dtt.dtt_flags & DTT_FL_USER ? B_TRUE : B_FALSE); return (dnp); } dt_node_t *
*** 2778,2788 **** dnp->dn_kind = DT_NODE_SYM; dnp->dn_ident = idp; dnp->dn_flags |= DT_NF_LVALUE; dt_node_type_assign(dnp, dtt.dtt_ctfp, dtt.dtt_type, ! dtt.dtt_flags); dt_node_attr_assign(dnp, _dtrace_symattr); if (uref) { idp->di_flags |= DT_IDFLG_USER; dnp->dn_flags |= DT_NF_USERLAND; --- 2788,2798 ---- dnp->dn_kind = DT_NODE_SYM; dnp->dn_ident = idp; dnp->dn_flags |= DT_NF_LVALUE; dt_node_type_assign(dnp, dtt.dtt_ctfp, dtt.dtt_type, ! dtt.dtt_flags & DTT_FL_USER ? B_TRUE : B_FALSE); dt_node_attr_assign(dnp, _dtrace_symattr); if (uref) { idp->di_flags |= DT_IDFLG_USER; dnp->dn_flags |= DT_NF_USERLAND;
*** 2930,2940 **** if (dt_type_lookup("int64_t", &dtt) != 0) xyerror(D_TYPE_ERR, "failed to lookup int64_t\n"); dt_ident_type_assign(cp->dn_ident, dtt.dtt_ctfp, dtt.dtt_type); dt_node_type_assign(cp, dtt.dtt_ctfp, dtt.dtt_type, ! dtt.dtt_flags); } if (cp->dn_kind == DT_NODE_VAR) cp->dn_ident->di_flags |= idflags; --- 2940,2950 ---- if (dt_type_lookup("int64_t", &dtt) != 0) xyerror(D_TYPE_ERR, "failed to lookup int64_t\n"); dt_ident_type_assign(cp->dn_ident, dtt.dtt_ctfp, dtt.dtt_type); dt_node_type_assign(cp, dtt.dtt_ctfp, dtt.dtt_type, ! dtt.dtt_flags & DTT_FL_USER ? B_TRUE : B_FALSE); } if (cp->dn_kind == DT_NODE_VAR) cp->dn_ident->di_flags |= idflags;
*** 3723,3750 **** /* * If we follow a reference to a forward declaration tag, * search the entire type space for the actual definition. */ ! while (kind == CTF_K_FORWARD) { ! char *tag = ctf_type_name(ctfp, type, n1, sizeof (n1)); ! dtrace_typeinfo_t dtt; ! ! if (tag != NULL && dt_type_lookup(tag, &dtt) == 0 && ! (dtt.dtt_ctfp != ctfp || dtt.dtt_type != type)) { ! ctfp = dtt.dtt_ctfp; ! type = ctf_type_resolve(ctfp, dtt.dtt_type); kind = ctf_type_kind(ctfp, type); ! } else { xyerror(D_OP_INCOMPLETE, "operator %s cannot be applied to a " "forward declaration: no %s definition " ! "is available\n", opstr(op), tag); ! } ! } ! ! if (kind != CTF_K_STRUCT && kind != CTF_K_UNION) { if (op == DT_TOK_PTR) { xyerror(D_OP_SOU, "operator -> cannot be " "applied to pointer to type \"%s\"; must " "be applied to a struct or union pointer\n", ctf_type_name(ctfp, type, n1, sizeof (n1))); --- 3733,3752 ---- /* * If we follow a reference to a forward declaration tag, * search the entire type space for the actual definition. */ ! dt_resolve_forward_decl(&ctfp, &type); kind = ctf_type_kind(ctfp, type); ! ! if (kind == CTF_K_FORWARD) { xyerror(D_OP_INCOMPLETE, "operator %s cannot be applied to a " "forward declaration: no %s definition " ! "is available\n", opstr(op), ! ctf_type_name(ctfp, type, n1, sizeof (n1))); ! } else if (kind != CTF_K_STRUCT && kind != CTF_K_UNION) { if (op == DT_TOK_PTR) { xyerror(D_OP_SOU, "operator -> cannot be " "applied to pointer to type \"%s\"; must " "be applied to a struct or union pointer\n", ctf_type_name(ctfp, type, n1, sizeof (n1)));
*** 3760,3775 **** xyerror(D_TYPE_MEMBER, "%s is not a member of %s\n", rp->dn_string, ctf_type_name(ctfp, type, n1, sizeof (n1))); } ! type = ctf_type_resolve(ctfp, m.ctm_type); ! kind = ctf_type_kind(ctfp, type); ! dt_node_type_assign(dnp, ctfp, m.ctm_type, B_FALSE); dt_node_attr_assign(dnp, lp->dn_attr); if (op == DT_TOK_PTR && (kind != CTF_K_ARRAY || dt_node_is_string(dnp))) dnp->dn_flags |= DT_NF_LVALUE; /* see K&R[A7.3.3] */ if (op == DT_TOK_DOT && (lp->dn_flags & DT_NF_LVALUE) && --- 3762,3780 ---- xyerror(D_TYPE_MEMBER, "%s is not a member of %s\n", rp->dn_string, ctf_type_name(ctfp, type, n1, sizeof (n1))); } ! type = m.ctm_type; ! dt_resolve_forward_decl(&ctfp, &type); ! dt_node_type_assign(dnp, ctfp, type, B_FALSE); dt_node_attr_assign(dnp, lp->dn_attr); + type = ctf_type_resolve(ctfp, type); + kind = ctf_type_kind(ctfp, type); + if (op == DT_TOK_PTR && (kind != CTF_K_ARRAY || dt_node_is_string(dnp))) dnp->dn_flags |= DT_NF_LVALUE; /* see K&R[A7.3.3] */ if (op == DT_TOK_DOT && (lp->dn_flags & DT_NF_LVALUE) &&
*** 4273,4282 **** --- 4278,4289 ---- char n1[DT_TYPE_NAMELEN]; char n2[DT_TYPE_NAMELEN]; dtrace_attribute_t attr = _dtrace_maxattr; ctf_membinfo_t ctm; + ctf_id_t type; + ctf_file_t *ctfp; /* * Before cooking each translator member, we push a reference to the * hash containing translator-local identifiers on to pcb_globals to * temporarily interpose these identifiers in front of other globals.
*** 4291,4301 **** mnp->dn_membname, ctf_type_name(dxp->dx_dst_ctfp, dxp->dx_dst_type, n1, sizeof (n1))); } (void) dt_node_cook(mnp, DT_IDFLG_REF); ! dt_node_type_assign(mnp, dxp->dx_dst_ctfp, ctm.ctm_type, B_FALSE); attr = dt_attr_min(attr, mnp->dn_attr); if (dt_node_is_argcompat(mnp, mnp->dn_membexpr) == 0) { xyerror(D_XLATE_INCOMPAT, --- 4298,4317 ---- mnp->dn_membname, ctf_type_name(dxp->dx_dst_ctfp, dxp->dx_dst_type, n1, sizeof (n1))); } (void) dt_node_cook(mnp, DT_IDFLG_REF); ! ctfp = dxp->dx_dst_ctfp; ! type = ctm.ctm_type; ! ! /* ! * ! * This probably doesn't need to be resolved, because it's of ! * the translator, but is done for completeness right now. ! */ ! dt_resolve_forward_decl(&ctfp, &type); ! dt_node_type_assign(mnp, ctfp, type, B_FALSE); attr = dt_attr_min(attr, mnp->dn_attr); if (dt_node_is_argcompat(mnp, mnp->dn_membexpr) == 0) { xyerror(D_XLATE_INCOMPAT,