Print this page
4474 DTrace Userland CTF Support
4475 DTrace userland Keyword
4476 DTrace tests should be better citizens
4479 pid provider types
4480 dof emulation missing checks
Reviewed by: Bryan Cantrill <bryan@joyent.com>

@@ -23,12 +23,10 @@
 /*
  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
-#pragma ident   "%Z%%M% %I%     %E% SMI"
-
 #include <ctf_impl.h>
 
 ssize_t
 ctf_get_ctt_size(const ctf_file_t *fp, const ctf_type_t *tp, ssize_t *sizep,
     ssize_t *incrementp)

@@ -197,12 +195,13 @@
 
 /*
  * Lookup the given type ID and print a string name for it into buf.  Return
  * the actual number of bytes (not including \0) needed to format the name.
  */
-ssize_t
-ctf_type_lname(ctf_file_t *fp, ctf_id_t type, char *buf, size_t len)
+static ssize_t
+ctf_type_qlname(ctf_file_t *fp, ctf_id_t type, char *buf, size_t len,
+    const char *qname)
 {
         ctf_decl_t cd;
         ctf_decl_node_t *cdp;
         ctf_decl_prec_t prec, lp, rp;
         int ptr, arr;

@@ -253,10 +252,12 @@
 
                         switch (cdp->cd_kind) {
                         case CTF_K_INTEGER:
                         case CTF_K_FLOAT:
                         case CTF_K_TYPEDEF:
+                                if (qname != NULL)
+                                        ctf_decl_sprintf(&cd, "%s`", qname);
                                 ctf_decl_sprintf(&cd, "%s", name);
                                 break;
                         case CTF_K_POINTER:
                                 ctf_decl_sprintf(&cd, "*");
                                 break;

@@ -266,17 +267,26 @@
                         case CTF_K_FUNCTION:
                                 ctf_decl_sprintf(&cd, "()");
                                 break;
                         case CTF_K_STRUCT:
                         case CTF_K_FORWARD:
-                                ctf_decl_sprintf(&cd, "struct %s", name);
+                                ctf_decl_sprintf(&cd, "struct ");
+                                if (qname != NULL)
+                                        ctf_decl_sprintf(&cd, "%s`", qname);
+                                ctf_decl_sprintf(&cd, "%s", name);
                                 break;
                         case CTF_K_UNION:
-                                ctf_decl_sprintf(&cd, "union %s", name);
+                                ctf_decl_sprintf(&cd, "union ");
+                                if (qname != NULL)
+                                        ctf_decl_sprintf(&cd, "%s`", qname);
+                                ctf_decl_sprintf(&cd, "%s", name);
                                 break;
                         case CTF_K_ENUM:
-                                ctf_decl_sprintf(&cd, "enum %s", name);
+                                ctf_decl_sprintf(&cd, "enum ");
+                                if (qname != NULL)
+                                        ctf_decl_sprintf(&cd, "%s`", qname);
+                                ctf_decl_sprintf(&cd, "%s", name);
                                 break;
                         case CTF_K_VOLATILE:
                                 ctf_decl_sprintf(&cd, "volatile");
                                 break;
                         case CTF_K_CONST:

@@ -299,21 +309,36 @@
 
         ctf_decl_fini(&cd);
         return (cd.cd_len);
 }
 
+ssize_t
+ctf_type_lname(ctf_file_t *fp, ctf_id_t type, char *buf, size_t len)
+{
+        return (ctf_type_qlname(fp, type, buf, len, NULL));
+}
+
 /*
  * Lookup the given type ID and print a string name for it into buf.  If buf
  * is too small, return NULL: the ECTF_NAMELEN error is set on 'fp' for us.
  */
 char *
 ctf_type_name(ctf_file_t *fp, ctf_id_t type, char *buf, size_t len)
 {
-        ssize_t rv = ctf_type_lname(fp, type, buf, len);
+        ssize_t rv = ctf_type_qlname(fp, type, buf, len, NULL);
+        return (rv >= 0 && rv < len ? buf : NULL);
+}
+
+char *
+ctf_type_qname(ctf_file_t *fp, ctf_id_t type, char *buf, size_t len,
+    const char *qname)
+{
+        ssize_t rv = ctf_type_qlname(fp, type, buf, len, qname);
         return (rv >= 0 && rv < len ? buf : NULL);
 }
 
+
 /*
  * Resolve the type down to a base type node, and then return the size
  * of the type storage in bytes.
  */
 ssize_t