diff options
Diffstat (limited to 'usr/src/lib/libproc/common')
-rw-r--r-- | usr/src/lib/libproc/common/Pcontrol.h | 6 | ||||
-rw-r--r-- | usr/src/lib/libproc/common/Pcore.c | 29 | ||||
-rw-r--r-- | usr/src/lib/libproc/common/Pgcore.c | 11 | ||||
-rw-r--r-- | usr/src/lib/libproc/common/Plwpregs.c | 34 | ||||
-rw-r--r-- | usr/src/lib/libproc/common/libproc.h | 3 | ||||
-rw-r--r-- | usr/src/lib/libproc/common/mapfile-vers | 3 |
6 files changed, 79 insertions, 7 deletions
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; |