summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/kdump/kdump.c55
-rw-r--r--usr.bin/procstat/procstat.c16
-rw-r--r--usr.bin/procstat/procstat.h1
-rw-r--r--usr.bin/procstat/procstat_cs.c8
-rw-r--r--usr.bin/procstat/procstat_kstack.c8
-rw-r--r--usr.bin/procstat/procstat_threads.c8
-rw-r--r--usr.bin/top/machine.c15
7 files changed, 79 insertions, 32 deletions
diff --git a/usr.bin/kdump/kdump.c b/usr.bin/kdump/kdump.c
index 9ac8b5b..389ded2 100644
--- a/usr.bin/kdump/kdump.c
+++ b/usr.bin/kdump/kdump.c
@@ -41,10 +41,7 @@ static char sccsid[] = "@(#)kdump.c 8.1 (Berkeley) 6/6/93";
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#define _KERNEL
-extern int errno;
-#include <sys/errno.h>
-#undef _KERNEL
+#define _WANT_KERNEL_ERRNO
#include <sys/param.h>
#include <sys/capsicum.h>
#include <sys/errno.h>
@@ -79,6 +76,7 @@ extern int errno;
#include <netdb.h>
#include <nl_types.h>
#include <pwd.h>
+#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -128,6 +126,27 @@ static struct ktr_header ktr_header;
#define TIME_FORMAT "%b %e %T %Y"
#define eqs(s1, s2) (strcmp((s1), (s2)) == 0)
+#define print_number64(first,i,n,c) do { \
+ uint64_t __v; \
+ \
+ if (quad_align && (((ptrdiff_t)((i) - (first))) & 1) == 1) { \
+ (i)++; \
+ (n)--; \
+ } \
+ if (quad_slots == 2) \
+ __v = (uint64_t)(uint32_t)(i)[0] | \
+ ((uint64_t)(uint32_t)(i)[1]) << 32; \
+ else \
+ __v = (uint64_t)*(i); \
+ if (decimal) \
+ printf("%c%jd", (c), (intmax_t)__v); \
+ else \
+ printf("%c%#jx", (c), (uintmax_t)__v); \
+ (i) += quad_slots; \
+ (n) -= quad_slots; \
+ (c) = ','; \
+} while (0)
+
#define print_number(i,n,c) do { \
if (decimal) \
printf("%c%jd", c, (intmax_t)*i); \
@@ -611,8 +630,9 @@ void
ktrsyscall(struct ktr_syscall *ktr, u_int flags)
{
int narg = ktr->ktr_narg;
- register_t *ip;
+ register_t *ip, *first;
intmax_t arg;
+ int quad_align, quad_slots;
if ((flags != 0 && ((flags & SV_ABI_MASK) != SV_ABI_FREEBSD)) ||
(ktr->ktr_code >= nsyscalls || ktr->ktr_code < 0))
@@ -622,11 +642,19 @@ ktrsyscall(struct ktr_syscall *ktr, u_int flags)
if (syscallno)
printf("[%d]", ktr->ktr_code);
}
- ip = &ktr->ktr_args[0];
+ ip = first = &ktr->ktr_args[0];
if (narg) {
char c = '(';
if (fancy &&
(flags == 0 || (flags & SV_ABI_MASK) == SV_ABI_FREEBSD)) {
+ quad_align = 0;
+ if (flags & SV_ILP32) {
+#ifdef __powerpc__
+ quad_align = 1;
+#endif
+ quad_slots = 2;
+ } else
+ quad_slots = 1;
switch (ktr->ktr_code) {
case SYS_bindat:
case SYS_connectat:
@@ -708,7 +736,7 @@ ktrsyscall(struct ktr_syscall *ktr, u_int flags)
c = ',';
ip++;
narg--;
- print_number(ip, narg, c);
+ print_number64(first, ip, narg, c);
print_number(ip, narg, c);
putchar(',');
wait6optname(*ip);
@@ -907,7 +935,7 @@ ktrsyscall(struct ktr_syscall *ktr, u_int flags)
print_number(ip, narg, c);
/* Hidden 'pad' argument, not in lseek(2) */
print_number(ip, narg, c);
- print_number(ip, narg, c);
+ print_number64(first, ip, narg, c);
putchar(',');
whencename(*ip);
ip++;
@@ -916,8 +944,7 @@ ktrsyscall(struct ktr_syscall *ktr, u_int flags)
#endif
case SYS_lseek:
print_number(ip, narg, c);
- /* Hidden 'pad' argument, not in lseek(2) */
- print_number(ip, narg, c);
+ print_number64(first, ip, narg, c);
putchar(',');
whencename(*ip);
ip++;
@@ -1196,7 +1223,7 @@ ktrsyscall(struct ktr_syscall *ktr, u_int flags)
c = ',';
ip++;
narg--;
- print_number(ip, narg, c);
+ print_number64(first, ip, narg, c);
putchar(',');
procctlcmdname(*ip);
ip++;
@@ -1222,6 +1249,12 @@ ktrsyscall(struct ktr_syscall *ktr, u_int flags)
}
ip++;
narg--;
+ break;
+ case SYS_ftruncate:
+ case SYS_truncate:
+ print_number(ip, narg, c);
+ print_number64(first, ip, narg, c);
+ break;
}
}
while (narg > 0) {
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 <libprocstat.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <sysexits.h>
#include <unistd.h>
@@ -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[])
{
diff --git a/usr.bin/procstat/procstat.h b/usr.bin/procstat/procstat.h
index 5079521..4c5242a 100644
--- a/usr.bin/procstat/procstat.h
+++ b/usr.bin/procstat/procstat.h
@@ -33,6 +33,7 @@ extern int hflag, nflag, Cflag, Hflag;
struct kinfo_proc;
void kinfo_proc_sort(struct kinfo_proc *kipp, int count);
+const char * kinfo_proc_thread_name(const struct kinfo_proc *kipp);
void procstat_args(struct procstat *prstat, struct kinfo_proc *kipp);
void procstat_auxv(struct procstat *prstat, struct kinfo_proc *kipp);
diff --git a/usr.bin/procstat/procstat_cs.c b/usr.bin/procstat/procstat_cs.c
index 8ccf1ea..4af29ca 100644
--- a/usr.bin/procstat/procstat_cs.c
+++ b/usr.bin/procstat/procstat_cs.c
@@ -50,7 +50,7 @@ procstat_cs(struct procstat *procstat, struct kinfo_proc *kipp)
int once, twice, lastcpu, cpu;
if (!hflag)
- printf("%5s %6s %-16s %-16s %2s %4s %-7s\n", "PID",
+ printf("%5s %6s %-19s %-19s %2s %4s %-7s\n", "PID",
"TID", "COMM", "TDNAME", "CPU", "CSID", "CPU MASK");
kip = procstat_getprocs(procstat, KERN_PROC_PID | KERN_PROC_INC_THREAD,
@@ -62,11 +62,9 @@ procstat_cs(struct procstat *procstat, struct kinfo_proc *kipp)
kipp = &kip[i];
printf("%5d ", kipp->ki_pid);
printf("%6d ", kipp->ki_tid);
- printf("%-16s ", strlen(kipp->ki_comm) ?
+ printf("%-19s ", strlen(kipp->ki_comm) ?
kipp->ki_comm : "-");
- printf("%-16s ", (strlen(kipp->ki_tdname) &&
- (strcmp(kipp->ki_comm, kipp->ki_tdname) != 0)) ?
- kipp->ki_tdname : "-");
+ printf("%-19s ", kinfo_proc_thread_name(kipp));
if (kipp->ki_oncpu != 255)
printf("%3d ", kipp->ki_oncpu);
else if (kipp->ki_lastcpu != 255)
diff --git a/usr.bin/procstat/procstat_kstack.c b/usr.bin/procstat/procstat_kstack.c
index 8ffa4f9..10cb5cf 100644
--- a/usr.bin/procstat/procstat_kstack.c
+++ b/usr.bin/procstat/procstat_kstack.c
@@ -134,7 +134,7 @@ procstat_kstack(struct procstat *procstat, struct kinfo_proc *kipp, int kflag)
unsigned int kip_count, kstk_count;
if (!hflag)
- printf("%5s %6s %-16s %-16s %-29s\n", "PID", "TID", "COMM",
+ printf("%5s %6s %-19s %-19s %-29s\n", "PID", "TID", "COMM",
"TDNAME", "KSTACK");
kkstp = kkstp_free = procstat_getkstack(procstat, kipp, &kstk_count);
@@ -171,10 +171,8 @@ procstat_kstack(struct procstat *procstat, struct kinfo_proc *kipp, int kflag)
printf("%5d ", kipp->ki_pid);
printf("%6d ", kkstp->kkst_tid);
- printf("%-16s ", kipp->ki_comm);
- printf("%-16s ", (strlen(kipp->ki_tdname) &&
- (strcmp(kipp->ki_comm, kipp->ki_tdname) != 0)) ?
- kipp->ki_tdname : "-");
+ printf("%-19s ", kipp->ki_comm);
+ printf("%-19s ", kinfo_proc_thread_name(kipp));
switch (kkstp->kkst_state) {
case KKST_STATE_RUNNING:
diff --git a/usr.bin/procstat/procstat_threads.c b/usr.bin/procstat/procstat_threads.c
index 6bd88da..f81ec74 100644
--- a/usr.bin/procstat/procstat_threads.c
+++ b/usr.bin/procstat/procstat_threads.c
@@ -47,7 +47,7 @@ procstat_threads(struct procstat *procstat, struct kinfo_proc *kipp)
const char *str;
if (!hflag)
- printf("%5s %6s %-16s %-16s %2s %4s %-7s %-9s\n", "PID",
+ printf("%5s %6s %-19s %-19s %2s %4s %-7s %-9s\n", "PID",
"TID", "COMM", "TDNAME", "CPU", "PRI", "STATE", "WCHAN");
kip = procstat_getprocs(procstat, KERN_PROC_PID | KERN_PROC_INC_THREAD,
@@ -59,11 +59,9 @@ procstat_threads(struct procstat *procstat, struct kinfo_proc *kipp)
kipp = &kip[i];
printf("%5d ", kipp->ki_pid);
printf("%6d ", kipp->ki_tid);
- printf("%-16s ", strlen(kipp->ki_comm) ?
+ printf("%-19s ", strlen(kipp->ki_comm) ?
kipp->ki_comm : "-");
- printf("%-16s ", (strlen(kipp->ki_tdname) &&
- (strcmp(kipp->ki_comm, kipp->ki_tdname) != 0)) ?
- kipp->ki_tdname : "-");
+ printf("%-19s ", kinfo_proc_thread_name(kipp));
if (kipp->ki_oncpu != 255)
printf("%3d ", kipp->ki_oncpu);
else if (kipp->ki_lastcpu != 255)
diff --git a/usr.bin/top/machine.c b/usr.bin/top/machine.c
index cf4714c..6978060 100644
--- a/usr.bin/top/machine.c
+++ b/usr.bin/top/machine.c
@@ -889,8 +889,8 @@ format_next_process(caddr_t handle, char *(*get_userid)(int), int flags)
if (!(flags & FMT_SHOWARGS)) {
if (ps.thread && pp->ki_flag & P_HADTHREADS &&
pp->ki_tdname[0]) {
- snprintf(cmdbuf, cmdlen, "%s{%s}", pp->ki_comm,
- pp->ki_tdname);
+ snprintf(cmdbuf, cmdlen, "%s{%s%s}", pp->ki_comm,
+ pp->ki_tdname, pp->ki_moretdname);
} else {
snprintf(cmdbuf, cmdlen, "%s", pp->ki_comm);
}
@@ -902,7 +902,8 @@ format_next_process(caddr_t handle, char *(*get_userid)(int), int flags)
if (ps.thread && pp->ki_flag & P_HADTHREADS &&
pp->ki_tdname[0]) {
snprintf(cmdbuf, cmdlen,
- "[%s{%s}]", pp->ki_comm, pp->ki_tdname);
+ "[%s{%s%s}]", pp->ki_comm, pp->ki_tdname,
+ pp->ki_moretdname);
} else {
snprintf(cmdbuf, cmdlen,
"[%s]", pp->ki_comm);
@@ -950,8 +951,9 @@ format_next_process(caddr_t handle, char *(*get_userid)(int), int flags)
if (ps.thread && pp->ki_flag & P_HADTHREADS &&
pp->ki_tdname[0])
snprintf(cmdbuf, cmdlen,
- "%s (%s){%s}", argbuf, pp->ki_comm,
- pp->ki_tdname);
+ "%s (%s){%s%s}", argbuf,
+ pp->ki_comm, pp->ki_tdname,
+ pp->ki_moretdname);
else
snprintf(cmdbuf, cmdlen,
"%s (%s)", argbuf, pp->ki_comm);
@@ -959,7 +961,8 @@ format_next_process(caddr_t handle, char *(*get_userid)(int), int flags)
if (ps.thread && pp->ki_flag & P_HADTHREADS &&
pp->ki_tdname[0])
snprintf(cmdbuf, cmdlen,
- "%s{%s}", argbuf, pp->ki_tdname);
+ "%s{%s%s}", argbuf, pp->ki_tdname,
+ pp->ki_moretdname);
else
strlcpy(cmdbuf, argbuf, cmdlen);
}
OpenPOWER on IntegriCloud