summaryrefslogtreecommitdiff
path: root/usr/src/lib
diff options
context:
space:
mode:
authorJason King <jason.brian.king@gmail.com>2017-05-05 22:58:26 +0000
committerJohn Levon <john.levon@joyent.com>2018-09-26 08:38:04 +0000
commitc113f3b5211bf6ae3ff1ee916a9f9ad0c28b7125 (patch)
treeed3893fad0f78462adf85cf08feb76669ab9abab /usr/src/lib
parentdee777b5a3880de62b42997fe61524f95dcc16db (diff)
downloadillumos-joyent-OS-7200.tar.gz
OS-7200 would like thread name APIOS-7200
OS-7205 bhyve makefile uses wrong linker flags
Diffstat (limited to 'usr/src/lib')
-rw-r--r--usr/src/lib/brand/bhyve/zone/platform.xml1
-rw-r--r--usr/src/lib/libc/inc/thr_uberdata.h4
-rw-r--r--usr/src/lib/libc/port/mapfile-vers8
-rw-r--r--usr/src/lib/libc/port/threads/pthr_attr.c61
-rw-r--r--usr/src/lib/libc/port/threads/pthread.c4
-rw-r--r--usr/src/lib/libc/port/threads/thr.c88
-rw-r--r--usr/src/lib/libdtrace/common/dt_open.c10
-rw-r--r--usr/src/lib/libfakekernel/common/sys/thread.h2
-rw-r--r--usr/src/lib/libproc/common/Pcontrol.h6
-rw-r--r--usr/src/lib/libproc/common/Pcore.c29
-rw-r--r--usr/src/lib/libproc/common/Pgcore.c11
-rw-r--r--usr/src/lib/libproc/common/Plwpregs.c34
-rw-r--r--usr/src/lib/libproc/common/libproc.h3
-rw-r--r--usr/src/lib/libproc/common/mapfile-vers3
14 files changed, 242 insertions, 22 deletions
diff --git a/usr/src/lib/brand/bhyve/zone/platform.xml b/usr/src/lib/brand/bhyve/zone/platform.xml
index 0aa8d875c3..4f4446b345 100644
--- a/usr/src/lib/brand/bhyve/zone/platform.xml
+++ b/usr/src/lib/brand/bhyve/zone/platform.xml
@@ -29,6 +29,7 @@
opt="ro,nodevices,nosub" type="lofs" />
<!-- Local filesystems to mount when booting the zone -->
+ <mount special="/proc" directory="/proc" type="proc" />
<mount special="swap" directory="/var/run" type="tmpfs"
opt="size=50m"/>
diff --git a/usr/src/lib/libc/inc/thr_uberdata.h b/usr/src/lib/libc/inc/thr_uberdata.h
index 2c56e76f17..7f08a0b8c4 100644
--- a/usr/src/lib/libc/inc/thr_uberdata.h
+++ b/usr/src/lib/libc/inc/thr_uberdata.h
@@ -57,6 +57,7 @@
#include <sys/priocntl.h>
#include <thread_db.h>
#include <setjmp.h>
+#include <sys/thread.h>
#include "libc_int.h"
#include "tdb_agent.h"
#include "thr_debug.h"
@@ -1237,6 +1238,7 @@ typedef struct _thrattr {
int policy;
int inherit;
size_t guardsize;
+ char name[THREAD_NAME_MAX];
} thrattr_t;
typedef struct _rwlattr {
@@ -1497,7 +1499,7 @@ extern int rw_read_held(rwlock_t *);
extern int rw_write_held(rwlock_t *);
extern int _thrp_create(void *, size_t, void *(*)(void *), void *, long,
- thread_t *, size_t);
+ thread_t *, size_t, const char *);
extern int _thrp_suspend(thread_t, uchar_t);
extern int _thrp_continue(thread_t, uchar_t);
diff --git a/usr/src/lib/libc/port/mapfile-vers b/usr/src/lib/libc/port/mapfile-vers
index 9992247d90..f51996c646 100644
--- a/usr/src/lib/libc/port/mapfile-vers
+++ b/usr/src/lib/libc/port/mapfile-vers
@@ -23,7 +23,7 @@
# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
# Copyright 2018 Nexenta Systems, Inc.
# Copyright (c) 2012 by Delphix. All rights reserved.
-# Copyright 2016 Joyent, Inc.
+# Copyright 2018 Joyent, Inc.
# Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved.
# Copyright (c) 2013 Gary Mills
# Copyright 2014 Garrett D'Amore <garrett@damore.org>
@@ -3097,7 +3097,11 @@ $endif
pset_bind_lwp;
_psignal;
pthread_attr_getdaemonstate_np;
+ pthread_attr_getname_np;
pthread_attr_setdaemonstate_np;
+ pthread_attr_setname_np;
+ pthread_getname_np;
+ pthread_setname_np;
_pthread_setcleanupinit;
__putwchar_xpg5;
__putwc_xpg5;
@@ -3176,6 +3180,7 @@ $endif
_thr_continue_allmutators;
thr_continue_mutator;
_thr_continue_mutator;
+ thr_getname;
thr_getstate;
_thr_getstate;
thr_mutators_barrier;
@@ -3184,6 +3189,7 @@ $endif
_thr_schedctl;
thr_setmutator;
_thr_setmutator;
+ thr_setname;
thr_setstate;
_thr_setstate;
thr_sighndlrinfo;
diff --git a/usr/src/lib/libc/port/threads/pthr_attr.c b/usr/src/lib/libc/port/threads/pthr_attr.c
index b04bcdba7c..7cfc970120 100644
--- a/usr/src/lib/libc/port/threads/pthr_attr.c
+++ b/usr/src/lib/libc/port/threads/pthr_attr.c
@@ -25,11 +25,13 @@
*/
/*
- * Copyright 2015, Joyent, Inc.
+ * Copyright 2018, Joyent, Inc.
*/
#include "lint.h"
#include "thr_uberdata.h"
+#include <sys/ctype.h>
+#include <strings.h>
#include <sched.h>
/*
@@ -48,7 +50,8 @@ def_thrattr(void)
0, /* prio */
SCHED_OTHER, /* policy */
PTHREAD_INHERIT_SCHED, /* inherit */
- 0 /* guardsize */
+ 0, /* guardsize */
+ { 0 } /* name */
};
if (thrattr.guardsize == 0)
thrattr.guardsize = _sysconf(_SC_PAGESIZE);
@@ -95,7 +98,7 @@ pthread_attr_clone(pthread_attr_t *attr, const pthread_attr_t *old_attr)
{
thrattr_t *ap;
const thrattr_t *old_ap =
- old_attr? old_attr->__pthread_attrp : def_thrattr();
+ old_attr ? old_attr->__pthread_attrp : def_thrattr();
if (old_ap == NULL)
return (EINVAL);
@@ -114,8 +117,8 @@ pthread_attr_clone(pthread_attr_t *attr, const pthread_attr_t *old_attr)
int
pthread_attr_equal(const pthread_attr_t *attr1, const pthread_attr_t *attr2)
{
- const thrattr_t *ap1 = attr1? attr1->__pthread_attrp : def_thrattr();
- const thrattr_t *ap2 = attr2? attr2->__pthread_attrp : def_thrattr();
+ const thrattr_t *ap1 = attr1 ? attr1->__pthread_attrp : def_thrattr();
+ const thrattr_t *ap2 = attr2 ? attr2->__pthread_attrp : def_thrattr();
if (ap1 == NULL || ap2 == NULL)
return (0);
@@ -476,6 +479,53 @@ pthread_attr_getstack(const pthread_attr_t *attr,
return (EINVAL);
}
+int
+pthread_attr_setname_np(pthread_attr_t *attr, const char *name)
+{
+ thrattr_t *ap;
+
+ if (attr == NULL || (ap = attr->__pthread_attrp) == NULL)
+ return (EINVAL);
+
+ if (name == NULL) {
+ bzero(ap->name, sizeof (ap->name));
+ return (0);
+ }
+
+ if (strlen(name) >= sizeof (ap->name))
+ return (ERANGE);
+
+ /*
+ * We really want the ASCII version of isprint() here...
+ */
+ for (size_t i = 0; name[i] != '\0'; i++) {
+ if (!ISPRINT(name[i]))
+ return (EINVAL);
+ }
+
+ /*
+ * not having garbage after the end of the string simplifies attr
+ * comparison
+ */
+ bzero(ap->name, sizeof (ap->name));
+ (void) strlcpy(ap->name, name, sizeof (ap->name));
+ return (0);
+}
+
+int
+pthread_attr_getname_np(pthread_attr_t *attr, char *buf, size_t len)
+{
+ thrattr_t *ap;
+
+ if (buf == NULL || attr == NULL ||
+ (ap = attr->__pthread_attrp) == NULL)
+ return (EINVAL);
+
+ if (strlcpy(buf, ap->name, len) > len)
+ return (ERANGE);
+ return (0);
+}
+
/*
* This function is a common BSD extension to pthread which is used to obtain
* the attributes of a thread that might have changed after its creation, for
@@ -551,6 +601,7 @@ pthread_attr_get_np(pthread_t tid, pthread_attr_t *attr)
ap->policy = target->ul_policy;
ap->inherit = target->ul_ptinherit;
ap->guardsize = target->ul_guardsize;
+ (void) pthread_getname_np(tid, ap->name, sizeof (ap->name));
ret = 0;
out:
diff --git a/usr/src/lib/libc/port/threads/pthread.c b/usr/src/lib/libc/port/threads/pthread.c
index 6a22995639..34b4b4c73c 100644
--- a/usr/src/lib/libc/port/threads/pthread.c
+++ b/usr/src/lib/libc/port/threads/pthread.c
@@ -24,7 +24,7 @@
* Use is subject to license terms.
*/
/*
- * Copyright 2016 Joyent, Inc.
+ * Copyright 2018 Joyent, Inc.
*/
#include "lint.h"
@@ -128,7 +128,7 @@ pthread_create(pthread_t *thread, const pthread_attr_t *attr,
flag = ap->scope | ap->detachstate | ap->daemonstate | THR_SUSPENDED;
error = _thrp_create(ap->stkaddr, ap->stksize, start_routine, arg,
- flag, &tid, ap->guardsize);
+ flag, &tid, ap->guardsize, ap->name);
if (error == 0) {
/*
* Record the original inheritence value for
diff --git a/usr/src/lib/libc/port/threads/thr.c b/usr/src/lib/libc/port/threads/thr.c
index b6580b3e3a..69c5f24981 100644
--- a/usr/src/lib/libc/port/threads/thr.c
+++ b/usr/src/lib/libc/port/threads/thr.c
@@ -25,7 +25,7 @@
* Copyright (c) 2017 by The MathWorks, Inc. All rights reserved.
*/
/*
- * Copyright 2016 Joyent, Inc.
+ * Copyright 2018 Joyent, Inc.
*/
#include "lint.h"
@@ -562,7 +562,7 @@ find_lwp(thread_t tid)
int
_thrp_create(void *stk, size_t stksize, void *(*func)(void *), void *arg,
- long flags, thread_t *new_thread, size_t guardsize)
+ long flags, thread_t *new_thread, size_t guardsize, const char *name)
{
ulwp_t *self = curthread;
uberdata_t *udp = self->ul_uberdata;
@@ -717,6 +717,9 @@ _thrp_create(void *stk, size_t stksize, void *(*func)(void *), void *arg,
exit_critical(self);
+ if (name != NULL)
+ (void) pthread_setname_np(tid, name);
+
if (!(flags & THR_SUSPENDED))
(void) _thrp_continue(tid, TSTP_REGULAR);
@@ -727,7 +730,8 @@ int
thr_create(void *stk, size_t stksize, void *(*func)(void *), void *arg,
long flags, thread_t *new_thread)
{
- return (_thrp_create(stk, stksize, func, arg, flags, new_thread, 0));
+ return (_thrp_create(stk, stksize, func, arg, flags, new_thread, 0,
+ NULL));
}
/*
@@ -2407,6 +2411,84 @@ __nthreads(void)
return (curthread->ul_uberdata->nthreads);
}
+#pragma weak pthread_setname_np = thr_setname
+int
+thr_setname(pthread_t tid, const char *name)
+{
+ extern ssize_t __write(int, const void *, size_t);
+ char path[PATH_MAX];
+ int saved_errno;
+ size_t len;
+ ssize_t n;
+ int fd;
+
+ if (name == NULL)
+ name = "";
+
+ len = strlen(name) + 1;
+ if (len > THREAD_NAME_MAX)
+ return (ERANGE);
+
+ /* "/proc/self/lwp/%u/lwpname" w/o stdio */
+ (void) strlcpy(path, "/proc/self/lwp/", sizeof (path));
+ ultos((uint64_t)tid, 10, path + strlen(path));
+ (void) strlcat(path, "/lwpname", sizeof (path));
+
+ if ((fd = __open(path, O_WRONLY, 0)) < 0) {
+ if (errno == ENOENT)
+ errno = ESRCH;
+ return (errno);
+ }
+
+ n = __write(fd, name, len);
+ saved_errno = errno;
+ (void) __close(fd);
+
+ if (n < 0)
+ return (saved_errno);
+ if (n != len)
+ return (EFAULT);
+ return (0);
+}
+
+#pragma weak pthread_getname_np = thr_getname
+int
+thr_getname(pthread_t tid, char *buf, size_t bufsize)
+{
+ extern ssize_t __read(int, void *, size_t);
+ char name[THREAD_NAME_MAX];
+ char path[PATH_MAX];
+ int saved_errno;
+ ssize_t n;
+ int fd;
+
+ if (buf == NULL)
+ return (EINVAL);
+
+ /* "/proc/self/lwp/%u/name" w/o stdio */
+ (void) strlcpy(path, "/proc/self/lwp/", sizeof (path));
+ ultos((uint64_t)tid, 10, path + strlen(path));
+ (void) strlcat(path, "/lwpname", sizeof (path));
+
+ if ((fd = __open(path, O_RDONLY, 0)) < 0) {
+ if (errno == ENOENT)
+ errno = ESRCH;
+ return (errno);
+ }
+
+ n = __read(fd, name, sizeof (name));
+ saved_errno = errno;
+ (void) __close(fd);
+
+ if (n < 0)
+ return (saved_errno);
+ if (n != sizeof (name))
+ return (EFAULT);
+ if (strlcpy(buf, name, bufsize) >= bufsize)
+ return (ERANGE);
+ return (0);
+}
+
/*
* XXX
* The remainder of this file implements the private interfaces to java for
diff --git a/usr/src/lib/libdtrace/common/dt_open.c b/usr/src/lib/libdtrace/common/dt_open.c
index 3325f333ab..d515669e0c 100644
--- a/usr/src/lib/libdtrace/common/dt_open.c
+++ b/usr/src/lib/libdtrace/common/dt_open.c
@@ -21,7 +21,7 @@
/*
* 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, 2016 by Delphix. All rights reserved.
*/
@@ -117,8 +117,9 @@
#define DT_VERS_1_12 DT_VERSION_NUMBER(1, 12, 0)
#define DT_VERS_1_12_1 DT_VERSION_NUMBER(1, 12, 1)
#define DT_VERS_1_13 DT_VERSION_NUMBER(1, 13, 0)
-#define DT_VERS_LATEST DT_VERS_1_13
-#define DT_VERS_STRING "Sun D 1.13"
+#define DT_VERS_1_14 DT_VERSION_NUMBER(1, 14, 0)
+#define DT_VERS_LATEST DT_VERS_1_14
+#define DT_VERS_STRING "Sun D 1.14"
const dt_version_t _dtrace_versions[] = {
DT_VERS_1_0, /* D API 1.0.0 (PSARC 2001/466) Solaris 10 FCS */
@@ -145,6 +146,7 @@ const dt_version_t _dtrace_versions[] = {
DT_VERS_1_12, /* D API 1.12 */
DT_VERS_1_12_1, /* D API 1.12.1 */
DT_VERS_1_13, /* D API 1.13 */
+ DT_VERS_1_14, /* D API 1.14 */
0
};
@@ -402,6 +404,8 @@ static const dt_ident_t _dtrace_globals[] = {
&dt_idops_func, "void(@, ...)" },
{ "this", DT_IDENT_PTR, 0, 0, DT_ATTR_STABCMN, DT_VERS_1_0,
&dt_idops_type, "void" },
+{ "threadname", DT_IDENT_SCALAR, 0, DIF_VAR_THREADNAME,
+ DT_ATTR_STABCMN, DT_VERS_1_14, &dt_idops_type, "string" },
{ "tid", DT_IDENT_SCALAR, 0, DIF_VAR_TID, DT_ATTR_STABCMN, DT_VERS_1_0,
&dt_idops_type, "id_t" },
{ "timestamp", DT_IDENT_SCALAR, 0, DIF_VAR_TIMESTAMP,
diff --git a/usr/src/lib/libfakekernel/common/sys/thread.h b/usr/src/lib/libfakekernel/common/sys/thread.h
index 6213be2807..d6e05c691c 100644
--- a/usr/src/lib/libfakekernel/common/sys/thread.h
+++ b/usr/src/lib/libfakekernel/common/sys/thread.h
@@ -24,6 +24,7 @@
* Use is subject to license terms.
*
* Copyright 2013 Nexenta Systems, Inc. All rights reserved.
+ * Copyright 2018 Joyent, Inc.
*/
#ifndef _SYS_THREAD_H
@@ -82,6 +83,7 @@ extern kthread_t *_curthread(void); /* returns thread pointer */
#define _KTHREAD_INVALID ((void *)(uintptr_t)-1)
+#define THREAD_NAME_MAX (32)
struct proc;
extern struct proc *_curproc(void);
diff --git a/usr/src/lib/libproc/common/Pcontrol.h b/usr/src/lib/libproc/common/Pcontrol.h
index 7e19e8777c..3122207902 100644
--- a/usr/src/lib/libproc/common/Pcontrol.h
+++ b/usr/src/lib/libproc/common/Pcontrol.h
@@ -24,8 +24,8 @@
*/
/*
* Copyright 2012 DEY Storage Systems, Inc. All rights reserved.
- * Copyright (c) 2015, Joyent, Inc. All rights reserved.
* Copyright (c) 2013 by Delphix. All rights reserved.
+ * Copyright 2018 Joyent, Inc.
*/
#ifndef _PCONTROL_H
@@ -45,6 +45,7 @@
#include <libctf.h>
#include <limits.h>
#include <libproc.h>
+#include <thread.h>
#include <sys/secflags.h>
#ifdef __cplusplus
@@ -139,6 +140,7 @@ typedef struct lwp_info { /* per-lwp information from core file */
lwpid_t lwp_id; /* lwp identifier */
lwpsinfo_t lwp_psinfo; /* /proc/<pid>/lwp/<lwpid>/lwpsinfo data */
lwpstatus_t lwp_status; /* /proc/<pid>/lwp/<lwpid>/lwpstatus data */
+ char lwp_name[THREAD_NAME_MAX];
#if defined(sparc) || defined(__sparc)
gwindows_t *lwp_gwins; /* /proc/<pid>/lwp/<lwpid>/gwindows data */
prxregset_t *lwp_xregs; /* /proc/<pid>/lwp/<lwpid>/xregs data */
@@ -276,7 +278,7 @@ extern void optimize_symtab(sym_tbl_t *);
extern void Pbuild_file_symtab(struct ps_prochandle *, file_info_t *);
extern ctf_file_t *Pbuild_file_ctf(struct ps_prochandle *, file_info_t *);
extern map_info_t *Paddr2mptr(struct ps_prochandle *, uintptr_t);
-extern char *Pfindexec(struct ps_prochandle *, const char *,
+extern char *Pfindexec(struct ps_prochandle *, const char *,
int (*)(const char *, void *), void *);
extern int getlwpstatus(struct ps_prochandle *, lwpid_t, lwpstatus_t *);
int Pstopstatus(struct ps_prochandle *, long, uint32_t);
diff --git a/usr/src/lib/libproc/common/Pcore.c b/usr/src/lib/libproc/common/Pcore.c
index 89c5ce47fa..cfeb0ebb87 100644
--- a/usr/src/lib/libproc/common/Pcore.c
+++ b/usr/src/lib/libproc/common/Pcore.c
@@ -24,7 +24,7 @@
*/
/*
* Copyright 2012 DEY Storage Systems, Inc. All rights reserved.
- * Copyright (c) 2014, Joyent, Inc. All rights reserved.
+ * Copyright (c) 2018, Joyent, Inc. All rights reserved.
* Copyright (c) 2013 by Delphix. All rights reserved.
* Copyright 2015 Gary Mills
*/
@@ -726,6 +726,32 @@ err:
}
static int
+note_lwpname(struct ps_prochandle *P, size_t nbytes)
+{
+ prlwpname_t name;
+ lwp_info_t *lwp;
+
+ if (nbytes != sizeof (name) ||
+ read(P->asfd, &name, sizeof (name)) != sizeof (name))
+ goto err;
+
+ if ((lwp = lwpid2info(P, name.pr_lwpid)) == NULL)
+ goto err;
+
+ if (strlcpy(lwp->lwp_name, name.pr_lwpname,
+ sizeof (lwp->lwp_name)) >= sizeof (lwp->lwp_name)) {
+ errno = ENAMETOOLONG;
+ goto err;
+ }
+
+ return (0);
+
+err:
+ dprintf("Pgrab_core: failed to read NT_LWPNAME\n");
+ return (-1);
+}
+
+static int
note_fdinfo(struct ps_prochandle *P, size_t nbytes)
{
prfdinfo_t prfd;
@@ -1231,6 +1257,7 @@ static int (*nhdlrs[])(struct ps_prochandle *, size_t) = {
note_fdinfo, /* 22 NT_FDINFO */
note_spymaster, /* 23 NT_SPYMASTER */
note_secflags, /* 24 NT_SECFLAGS */
+ note_lwpname, /* 25 NT_LWPNAME */
};
static void
diff --git a/usr/src/lib/libproc/common/Pgcore.c b/usr/src/lib/libproc/common/Pgcore.c
index 6ddf92ad2f..64ef98065b 100644
--- a/usr/src/lib/libproc/common/Pgcore.c
+++ b/usr/src/lib/libproc/common/Pgcore.c
@@ -25,7 +25,7 @@
*/
/*
* Copyright 2012 DEY Storage Systems, Inc. All rights reserved.
- * Copyright 2015 Joyent, Inc.
+ * Copyright 2018 Joyent, Inc.
* Copyright (c) 2013 by Delphix. All rights reserved.
*/
@@ -509,6 +509,7 @@ new_per_lwp(void *data, const lwpstatus_t *lsp, const lwpsinfo_t *lip)
{
pgcore_t *pgc = data;
struct ps_prochandle *P = pgc->P;
+ prlwpname_t name = { 0, "" };
psinfo_t ps;
/*
@@ -577,6 +578,14 @@ new_per_lwp(void *data, const lwpstatus_t *lsp, const lwpsinfo_t *lip)
#endif /* __sparcv9 */
#endif /* sparc */
+ if (Plwp_getname(P, lsp->pr_lwpid, name.pr_lwpname,
+ sizeof (name.pr_lwpname)) == 0) {
+ name.pr_lwpid = lsp->pr_lwpid;
+ if (write_note(pgc->pgc_fd, NT_LWPNAME, &name,
+ sizeof (name), pgc->pgc_doff) != 0)
+ return (1);
+ }
+
if (!(lsp->pr_flags & PR_AGENT))
return (0);
diff --git a/usr/src/lib/libproc/common/Plwpregs.c b/usr/src/lib/libproc/common/Plwpregs.c
index c2b150000f..d400eb185c 100644
--- a/usr/src/lib/libproc/common/Plwpregs.c
+++ b/usr/src/lib/libproc/common/Plwpregs.c
@@ -24,8 +24,8 @@
*/
/*
- * Copyright (c) 2013, Joyent, Inc. All rights reserved.
* Copyright (c) 2013 by Delphix. All rights reserved.
+ * Copyright 2018 Joyent, Inc.
*/
#include <sys/types.h>
@@ -353,6 +353,38 @@ Plwp_getpsinfo(struct ps_prochandle *P, lwpid_t lwpid, lwpsinfo_t *lps)
}
int
+Plwp_getname(struct ps_prochandle *P, lwpid_t lwpid,
+ char *buf, size_t bufsize)
+{
+ char lwpname[THREAD_NAME_MAX];
+ char *from = NULL;
+ lwp_info_t *lwp;
+
+ if (P->state == PS_IDLE) {
+ errno = ENODATA;
+ return (-1);
+ }
+
+ if (P->state != PS_DEAD) {
+ if (getlwpfile(P, lwpid, "lwpname",
+ lwpname, sizeof (lwpname)) != 0)
+ return (-1);
+ from = lwpname;
+ } else {
+ if ((lwp = getlwpcore(P, lwpid)) == NULL)
+ return (-1);
+ from = lwp->lwp_name;
+ }
+
+ if (strlcpy(buf, from, bufsize) >= bufsize) {
+ errno = ENAMETOOLONG;
+ return (-1);
+ }
+
+ return (0);
+}
+
+int
Plwp_getspymaster(struct ps_prochandle *P, lwpid_t lwpid, psinfo_t *ps)
{
lwpstatus_t lps;
diff --git a/usr/src/lib/libproc/common/libproc.h b/usr/src/lib/libproc/common/libproc.h
index d74c08e828..eb73039a21 100644
--- a/usr/src/lib/libproc/common/libproc.h
+++ b/usr/src/lib/libproc/common/libproc.h
@@ -25,7 +25,7 @@
*
* Portions Copyright 2007 Chad Mynhier
* Copyright 2012 DEY Storage Systems, Inc. All rights reserved.
- * Copyright 2015, Joyent, Inc.
+ * Copyright 2018, Joyent, Inc.
* Copyright (c) 2013 by Delphix. All rights reserved.
*/
@@ -436,6 +436,7 @@ extern int Pldt(struct ps_prochandle *, struct ssd *, int);
extern int proc_get_ldt(pid_t, struct ssd *, int);
#endif /* __i386 || __amd64 */
+extern int Plwp_getname(struct ps_prochandle *, lwpid_t, char *, size_t);
extern int Plwp_getpsinfo(struct ps_prochandle *, lwpid_t, lwpsinfo_t *);
extern int Plwp_getspymaster(struct ps_prochandle *, lwpid_t, psinfo_t *);
diff --git a/usr/src/lib/libproc/common/mapfile-vers b/usr/src/lib/libproc/common/mapfile-vers
index b3f9df9d97..6b31f79e98 100644
--- a/usr/src/lib/libproc/common/mapfile-vers
+++ b/usr/src/lib/libproc/common/mapfile-vers
@@ -21,8 +21,8 @@
#
# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
# Copyright 2012 DEY Storage Systems, Inc. All rights reserved.
-# Copyright (c) 2013, Joyent, Inc. All rights reserved.
# Copyright (c) 2013 by Delphix. All rights reserved.
+# Copyright 2018 Joyent, Inc.
#
#
@@ -136,6 +136,7 @@ SYMBOL_VERSION SUNWprivate_1.1 {
Plookup_by_name;
Plwp_alt_stack;
Plwp_getfpregs;
+ Plwp_getname;
Plwp_getpsinfo;
Plwp_getregs;
Plwp_getspymaster;