Print this page
8158 Want named threads API
9857 proc manpages should have LIBRARY section

@@ -19,11 +19,11 @@
  * CDDL HEADER END
  */
 
 /*
  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2017, Joyent, Inc.
+ * Copyright (c) 2018, Joyent, Inc.
  * Copyright (c) 2012, 2014 by Delphix. All rights reserved.
  */
 
 /*
  * DTrace - Dynamic Tracing for Solaris

@@ -3537,10 +3537,29 @@
                 if ((lwp = curthread->t_lwp) == NULL)
                         return (0);
 
                 return ((uint64_t)lwp->lwp_errno);
         }
+
+        case DIF_VAR_THREADNAME:
+                /*
+                 * See comment in DIF_VAR_PID.
+                 */
+                if (DTRACE_ANCHORED(mstate->dtms_probe) && CPU_ON_INTR(CPU))
+                        return (0);
+
+                if (curthread->t_name == NULL)
+                        return (0);
+
+                /*
+                 * Once set, ->t_name itself is never changed: any updates are
+                 * made to the same buffer that we are pointing out.  So we are
+                 * safe to dereference it here.
+                 */
+                return (dtrace_dif_varstr((uintptr_t)curthread->t_name,
+                    state, mstate));
+
         default:
                 DTRACE_CPUFLAG_SET(CPU_DTRACE_ILLOP);
                 return (0);
         }
 }