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

@@ -1367,11 +1367,12 @@
 
         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);
+        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,10 +1797,11 @@
         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,11 +1823,19 @@
                 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);
+        /*
+         * 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,11 +2431,11 @@
         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.dtt_flags & DTT_FL_USER ? B_TRUE : B_FALSE);
 
         return (dnp);
 }
 
 dt_node_t *

@@ -2778,11 +2788,11 @@
                 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.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,11 +2940,11 @@
                 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.dtt_flags & DTT_FL_USER ? B_TRUE : B_FALSE);
         }
 
         if (cp->dn_kind == DT_NODE_VAR)
                 cp->dn_ident->di_flags |= idflags;
 

@@ -3723,28 +3733,20 @@
 
                 /*
                  * 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);
+                dt_resolve_forward_decl(&ctfp, &type);
                                 kind = ctf_type_kind(ctfp, type);
-                        } else {
+
+                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), tag);
-                        }
-                }
-
-                if (kind != CTF_K_STRUCT && kind != CTF_K_UNION) {
+                            "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,16 +3762,19 @@
                         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);
+                type = m.ctm_type;
 
-                dt_node_type_assign(dnp, ctfp, m.ctm_type, B_FALSE);
+                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,10 +4278,12 @@
         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,11 +4298,20 @@
                             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,
+                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,