diff options
author | Tycho Nightingale <tychon@FreeBSD.org> | 2017-03-30 18:21:36 +0000 |
---|---|---|
committer | Tycho Nightingale <tychon@FreeBSD.org> | 2017-03-30 18:21:36 +0000 |
commit | 86be94fca32cba783d836da0200837f914d56cac (patch) | |
tree | 1a2ed8405fd580e6f366465bdd678a59a2155940 /lib/libprocstat/libprocstat.c | |
parent | 1fb4382cb22e201435107888c19bb7fd1daa13e3 (diff) |
Notes
Diffstat (limited to 'lib/libprocstat/libprocstat.c')
-rw-r--r-- | lib/libprocstat/libprocstat.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/lib/libprocstat/libprocstat.c b/lib/libprocstat/libprocstat.c index 85dcec07015d..b81811408799 100644 --- a/lib/libprocstat/libprocstat.c +++ b/lib/libprocstat/libprocstat.c @@ -1,4 +1,5 @@ /*- + * Copyright (c) 2017 Dell EMC * Copyright (c) 2009 Stanislav Sedov <stas@FreeBSD.org> * Copyright (c) 1988, 1993 * The Regents of the University of California. All rights reserved. @@ -65,6 +66,7 @@ __FBSDID("$FreeBSD$"); #define _KERNEL #include <sys/mount.h> #include <sys/pipe.h> +#include <sys/ptrace.h> #include <ufs/ufs/quota.h> #include <ufs/ufs/inode.h> #include <fs/devfs/devfs.h> @@ -2470,6 +2472,48 @@ procstat_freeauxv(struct procstat *procstat __unused, Elf_Auxinfo *auxv) free(auxv); } +static struct ptrace_lwpinfo * +procstat_getptlwpinfo_core(struct procstat_core *core, unsigned int *cntp) +{ + void *buf; + struct ptrace_lwpinfo *pl; + unsigned int cnt; + size_t len; + + cnt = procstat_core_note_count(core, PSC_TYPE_PTLWPINFO); + if (cnt == 0) + return (NULL); + + len = cnt * sizeof(*pl); + buf = calloc(1, len); + pl = procstat_core_get(core, PSC_TYPE_PTLWPINFO, buf, &len); + if (pl == NULL) { + free(buf); + return (NULL); + } + *cntp = len / sizeof(*pl); + return (pl); +} + +struct ptrace_lwpinfo * +procstat_getptlwpinfo(struct procstat *procstat, unsigned int *cntp) +{ + switch (procstat->type) { + case PROCSTAT_CORE: + return (procstat_getptlwpinfo_core(procstat->core, cntp)); + default: + warnx("unknown access method: %d", procstat->type); + return (NULL); + } +} + +void +procstat_freeptlwpinfo(struct procstat *procstat __unused, + struct ptrace_lwpinfo *pl) +{ + free(pl); +} + static struct kinfo_kstack * procstat_getkstack_sysctl(pid_t pid, int *cntp) { |