From 399f89a3ce97d7f6e1132b3be50338558b1614f8 Mon Sep 17 00:00:00 2001 From: vangyzen Date: Thu, 15 Dec 2016 16:52:17 +0000 Subject: MFC r309676 Export the whole thread name in kinfo_proc kinfo_proc::ki_tdname is three characters shorter than thread::td_name. Add a ki_moretdname field for these three extra characters. Add the new field to kinfo_proc32, as well. Update all in-tree consumers to read the new field and assemble the full name, except for lldb's HostThreadFreeBSD.cpp, which I will handle separately. Bump __FreeBSD_version. Sponsored by: Dell EMC --- usr.bin/procstat/procstat.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'usr.bin/procstat/procstat.c') diff --git a/usr.bin/procstat/procstat.c b/usr.bin/procstat/procstat.c index 48a2135..a6774e5 100644 --- a/usr.bin/procstat/procstat.c +++ b/usr.bin/procstat/procstat.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -115,6 +116,21 @@ kinfo_proc_sort(struct kinfo_proc *kipp, int count) qsort(kipp, count, sizeof(*kipp), kinfo_proc_compare); } +const char * +kinfo_proc_thread_name(const struct kinfo_proc *kipp) +{ + static char name[MAXCOMLEN+1]; + + strlcpy(name, kipp->ki_tdname, sizeof(name)); + strlcat(name, kipp->ki_moretdname, sizeof(name)); + if (name[0] == '\0' || strcmp(kipp->ki_comm, name) == 0) { + name[0] = '-'; + name[1] = '\0'; + } + + return (name); +} + int main(int argc, char *argv[]) { -- cgit v1.1