[Midnightbsd-cvs] src [11314] U trunk/usr.bin/kdump: update kdump
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Wed Jul 4 10:45:14 EDT 2018
Revision: 11314
http://svnweb.midnightbsd.org/src/?rev=11314
Author: laffer1
Date: 2018-07-04 10:45:14 -0400 (Wed, 04 Jul 2018)
Log Message:
-----------
update kdump
Modified Paths:
--------------
trunk/usr.bin/kdump/Makefile
trunk/usr.bin/kdump/kdump.1
trunk/usr.bin/kdump/kdump.c
trunk/usr.bin/kdump/mkioctls
trunk/usr.bin/kdump/mksubr
Added Paths:
-----------
trunk/usr.bin/kdump/linux32_syscalls.conf
Removed Paths:
-------------
trunk/usr.bin/kdump/kdump_subr.h
Property Changed:
----------------
trunk/usr.bin/kdump/kdump.1
trunk/usr.bin/kdump/linux_syscalls.conf
trunk/usr.bin/kdump/mkioctls
trunk/usr.bin/kdump/mksubr
Modified: trunk/usr.bin/kdump/Makefile
===================================================================
--- trunk/usr.bin/kdump/Makefile 2018-07-04 14:15:46 UTC (rev 11313)
+++ trunk/usr.bin/kdump/Makefile 2018-07-04 14:45:14 UTC (rev 11314)
@@ -1,35 +1,47 @@
+# $MidnightBSD$
# @(#)Makefile 8.1 (Berkeley) 6/6/93
-# $MidnightBSD: src/usr.bin/kdump/Makefile,v 1.2 2012/11/15 12:57:12 laffer1 Exp $
+# $FreeBSD: stable/10/usr.bin/kdump/Makefile 294135 2016-01-16 07:46:25Z dchagin $
-.if (${MACHINE_ARCH} == "amd64")
-SFX= 32
-.endif
+.include <bsd.own.mk>
.PATH: ${.CURDIR}/../ktrace
PROG= kdump
-SRCS= kdump.c ioctl.c kdump_subr.c subr.c
-CFLAGS+= -I${.CURDIR}/../ktrace -I${.CURDIR} -I${.CURDIR}/../.. -I${.CURDIR}/../../sys
+SRCS= kdump_subr.c kdump_subr.h kdump.c ioctl.c subr.c
+CFLAGS+= -I${.CURDIR}/../ktrace -I${.CURDIR} -I${.CURDIR}/../.. -I.
-.if ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "i386"
-SRCS+= linux_syscalls.c
+.if ${MK_PF} != "no"
+CFLAGS+=-DPF
.endif
-WARNS?= 0
+NO_WERROR?= YES
-CLEANFILES= ioctl.c kdump_subr.c linux_syscalls.c
+CLEANFILES= ioctl.c kdump_subr.c kdump_subr.h
+.if (${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "i386")
+CLEANFILES+= linux_syscalls.c
+.endif
+.if (${MACHINE_ARCH} == "amd64")
+CLEANFILES+= linux32_syscalls.c
+.endif
+
ioctl.c: mkioctls
- env CPP="${CPP}" \
- sh ${.CURDIR}/mkioctls ${DESTDIR}/usr/include > ${.TARGET}
+ env MACHINE=${MACHINE} CPP="${CPP}" \
+ sh ${.CURDIR}/mkioctls print ${DESTDIR}/usr/include > ${.TARGET}
-kdump_subr.c: mksubr
- sh ${.CURDIR}/mksubr ${DESTDIR}/usr/include > ${.TARGET}
+kdump_subr.h: mksubr
+ sh ${.CURDIR}/mksubr ${DESTDIR}/usr/include | \
+ sed -n 's/^\([a-z].*)\)$$/void \1;/p' >${.TARGET}
-linux_syscalls.c:
- /bin/sh ${.CURDIR}/../../sys/kern/makesyscalls.sh \
- ${.CURDIR}/../../sys/${MACHINE_ARCH}/linux${SFX}/syscalls.master ${.CURDIR}/linux_syscalls.conf
- echo "int nlinux_syscalls = sizeof(linux_syscallnames) / sizeof(linux_syscallnames[0]);" \
- >> linux_syscalls.c
+kdump_subr.c: mksubr kdump_subr.h
+ sh ${.CURDIR}/mksubr ${DESTDIR}/usr/include >${.TARGET}
+.if (${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "i386")
+ sh ${.CURDIR}/../../sys/kern/makesyscalls.sh \
+ ${.CURDIR}/../../sys/${MACHINE_ARCH}/linux/syscalls.master ${.CURDIR}/linux_syscalls.conf
+.endif
+.if (${MACHINE_ARCH} == "amd64")
+ sh ${.CURDIR}/../../sys/kern/makesyscalls.sh \
+ ${.CURDIR}/../../sys/${MACHINE_ARCH}/linux32/syscalls.master ${.CURDIR}/linux32_syscalls.conf
+.endif
.include <bsd.prog.mk>
Modified: trunk/usr.bin/kdump/kdump.1
===================================================================
--- trunk/usr.bin/kdump/kdump.1 2018-07-04 14:15:46 UTC (rev 11313)
+++ trunk/usr.bin/kdump/kdump.1 2018-07-04 14:45:14 UTC (rev 11314)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1990, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,9 +27,9 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)kdump.1 8.1 (Berkeley) 6/6/93
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/usr.bin/kdump/kdump.1 264332 2014-04-11 01:00:51Z bdrewery $
.\"
-.Dd June 4, 2012
+.Dd March 28, 2014
.Dt KDUMP 1
.Os
.Sh NAME
@@ -36,7 +37,7 @@
.Nd display kernel trace data
.Sh SYNOPSIS
.Nm
-.Op Fl dEnlHRsTA
+.Op Fl dEnlHRSsTA
.Op Fl f Ar trfile
.Op Fl m Ar maxdata
.Op Fl p Ar pid
@@ -95,6 +96,8 @@
.It Fl r
When decoding STRU records, display structure members such as UIDs,
GIDs, dates etc. symbolically instead of numerically.
+.It Fl S
+Display system call numbers.
.It Fl s
Suppress display of I/O data.
.It Fl T
Property changes on: trunk/usr.bin/kdump/kdump.1
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/usr.bin/kdump/kdump.c
===================================================================
--- trunk/usr.bin/kdump/kdump.c 2018-07-04 14:15:46 UTC (rev 11313)
+++ trunk/usr.bin/kdump/kdump.c 2018-07-04 14:45:14 UTC (rev 11314)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved.
@@ -39,13 +40,11 @@
#endif
#endif /* not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/usr.bin/kdump/kdump.c 311708 2017-01-09 00:09:19Z jhb $");
-#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>
#define _KERNEL
#include <sys/time.h>
@@ -56,8 +55,10 @@
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/sysent.h>
+#include <sys/umtx.h>
#include <sys/un.h>
#include <sys/queue.h>
+#include <sys/wait.h>
#ifdef IPX
#include <sys/types.h>
#include <netipx/ipx.h>
@@ -73,10 +74,14 @@
#include <grp.h>
#include <inttypes.h>
#include <locale.h>
+#include <netdb.h>
+#include <nl_types.h>
#include <pwd.h>
+#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <termios.h>
#include <time.h>
#include <unistd.h>
#include <vis.h>
@@ -96,41 +101,71 @@
void ktrpsig(struct ktr_psig *);
void ktrcsw(struct ktr_csw *);
void ktrcsw_old(struct ktr_csw_old *);
-void ktruser(int, unsigned char *);
+void ktruser_malloc(void *);
+void ktruser_rtld(int, void *);
+void ktruser(int, void *);
+void ktrcaprights(cap_rights_t *);
+void ktritimerval(struct itimerval *it);
void ktrsockaddr(struct sockaddr *);
void ktrstat(struct stat *);
void ktrstruct(char *, size_t);
+void ktrcapfail(struct ktr_cap_fail *);
void ktrfault(struct ktr_fault *);
void ktrfaultend(struct ktr_faultend *);
+void limitfd(int fd);
void usage(void);
-void sockfamilyname(int);
-const char *ioctlname(u_long);
+void ioctlname(unsigned long, int);
-int timestamp, decimal, fancy = 1, suppressdata, tail, threads, maxdata,
- resolv = 0, abiflag = 0;
-const char *tracefile = DEF_TRACEFILE;
-struct ktr_header ktr_header;
+extern const char *signames[], *syscallnames[];
+extern int nsyscalls;
+static int timestamp, decimal, fancy = 1, suppressdata, tail, threads, maxdata,
+ resolv = 0, abiflag = 0, syscallno = 0;
+static const char *tracefile = DEF_TRACEFILE;
+static struct ktr_header ktr_header;
+
#define TIME_FORMAT "%b %e %T %Y"
#define eqs(s1, s2) (strcmp((s1), (s2)) == 0)
-#define print_number(i,n,c) do { \
- if (decimal) \
- printf("%c%ld", c, (long)*i); \
- else \
- printf("%c%#lx", c, (long)*i); \
- i++; \
- n--; \
- c = ','; \
- } while (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); \
+ else \
+ printf("%c%#jx", c, (uintmax_t)(u_register_t)*i); \
+ i++; \
+ n--; \
+ c = ','; \
+} while (0)
+
#if defined(__amd64__) || defined(__i386__)
-void linux_ktrsyscall(struct ktr_syscall *);
-void linux_ktrsysret(struct ktr_sysret *);
-extern char *linux_syscallnames[];
-extern int nlinux_syscalls;
+void linux_ktrsyscall(struct ktr_syscall *, u_int);
+void linux_ktrsysret(struct ktr_sysret *, u_int);
+extern const char *linux_syscallnames[];
+#include <linux_syscalls.c>
+
/*
* from linux.h
* Linux syscalls return negative errno's, we do positive and map them
@@ -149,6 +184,12 @@
};
#endif
+#if defined(__amd64__)
+extern const char *linux32_syscallnames[];
+
+#include <linux32_syscalls.c>
+#endif
+
struct proc_info
{
TAILQ_ENTRY(proc_info) info;
@@ -156,8 +197,33 @@
pid_t pid;
};
-TAILQ_HEAD(trace_procs, proc_info) trace_procs;
+static TAILQ_HEAD(trace_procs, proc_info) trace_procs;
+static void
+strerror_init(void)
+{
+
+ /*
+ * Cache NLS data before entering capability mode.
+ * XXXPJD: There should be strerror_init() and strsignal_init() in libc.
+ */
+ (void)catopen("libc", NL_CAT_LOCALE);
+}
+
+static void
+localtime_init(void)
+{
+ time_t ltime;
+
+ /*
+ * Allow localtime(3) to cache /etc/localtime content before entering
+ * capability mode.
+ * XXXPJD: There should be localtime_init() in libc.
+ */
+ (void)time(<ime);
+ (void)localtime(<ime);
+}
+
int
main(int argc, char *argv[])
{
@@ -168,10 +234,10 @@
pid_t pid = 0;
u_int sv_flags;
- (void) setlocale(LC_CTYPE, "");
+ setlocale(LC_CTYPE, "");
- while ((ch = getopt(argc,argv,"f:dElm:np:AHRrsTt:")) != -1)
- switch((char)ch) {
+ while ((ch = getopt(argc,argv,"f:dElm:np:AHRrSsTt:")) != -1)
+ switch (ch) {
case 'A':
abiflag = 1;
break;
@@ -196,6 +262,9 @@
case 'r':
resolv = 1;
break;
+ case 'S':
+ syscallno = 1;
+ break;
case 's':
suppressdata = 1;
break;
@@ -223,11 +292,23 @@
if (argc > optind)
usage();
- m = (void *)malloc(size = 1025);
+ m = malloc(size = 1025);
if (m == NULL)
errx(1, "%s", strerror(ENOMEM));
if (!freopen(tracefile, "r", stdin))
err(1, "%s", tracefile);
+
+ strerror_init();
+ localtime_init();
+
+ if (resolv == 0) {
+ if (cap_enter() < 0 && errno != ENOSYS)
+ err(1, "unable to enter capability mode");
+ }
+ limitfd(STDIN_FILENO);
+ limitfd(STDOUT_FILENO);
+ limitfd(STDERR_FILENO);
+
TAILQ_INIT(&trace_procs);
drop_logged = 0;
while (fread_tail(&ktr_header, sizeof(struct ktr_header), 1)) {
@@ -234,7 +315,7 @@
if (ktr_header.ktr_type & KTR_DROP) {
ktr_header.ktr_type &= ~KTR_DROP;
if (!drop_logged && threads) {
- (void)printf(
+ printf(
"%6jd %6jd %-8.*s Events dropped.\n",
(intmax_t)ktr_header.ktr_pid,
ktr_header.ktr_tid > 0 ?
@@ -242,7 +323,7 @@
MAXCOMLEN, ktr_header.ktr_comm);
drop_logged = 1;
} else if (!drop_logged) {
- (void)printf("%6jd %-8.*s Events dropped.\n",
+ printf("%6jd %-8.*s Events dropped.\n",
(intmax_t)ktr_header.ktr_pid, MAXCOMLEN,
ktr_header.ktr_comm);
drop_logged = 1;
@@ -255,7 +336,7 @@
if ((ktrlen = ktr_header.ktr_len) < 0)
errx(1, "bogus length 0x%x", ktrlen);
if (ktrlen > size) {
- m = (void *)realloc(m, ktrlen+1);
+ m = realloc(m, ktrlen+1);
if (m == NULL)
errx(1, "%s", strerror(ENOMEM));
size = ktrlen;
@@ -275,7 +356,8 @@
case KTR_SYSCALL:
#if defined(__amd64__) || defined(__i386__)
if ((sv_flags & SV_ABI_MASK) == SV_ABI_LINUX)
- linux_ktrsyscall((struct ktr_syscall *)m);
+ linux_ktrsyscall((struct ktr_syscall *)m,
+ sv_flags);
else
#endif
ktrsyscall((struct ktr_syscall *)m, sv_flags);
@@ -283,7 +365,8 @@
case KTR_SYSRET:
#if defined(__amd64__) || defined(__i386__)
if ((sv_flags & SV_ABI_MASK) == SV_ABI_LINUX)
- linux_ktrsysret((struct ktr_sysret *)m);
+ linux_ktrsysret((struct ktr_sysret *)m,
+ sv_flags);
else
#endif
ktrsysret((struct ktr_sysret *)m, sv_flags);
@@ -310,6 +393,9 @@
case KTR_STRUCT:
ktrstruct(m, ktrlen);
break;
+ case KTR_CAPFAIL:
+ ktrcapfail((struct ktr_cap_fail *)m);
+ break;
case KTR_FAULT:
ktrfault((struct ktr_fault *)m);
break;
@@ -321,11 +407,45 @@
break;
}
if (tail)
- (void)fflush(stdout);
+ fflush(stdout);
}
return 0;
}
+void
+limitfd(int fd)
+{
+ cap_rights_t rights;
+ unsigned long cmd;
+
+ cap_rights_init(&rights, CAP_FSTAT);
+ cmd = 0;
+
+ switch (fd) {
+ case STDIN_FILENO:
+ cap_rights_set(&rights, CAP_READ);
+ break;
+ case STDOUT_FILENO:
+ cap_rights_set(&rights, CAP_IOCTL, CAP_WRITE);
+ cmd = TIOCGETA; /* required by isatty(3) in printf(3) */
+ break;
+ case STDERR_FILENO:
+ cap_rights_set(&rights, CAP_WRITE);
+ if (!suppressdata) {
+ cap_rights_set(&rights, CAP_IOCTL);
+ cmd = TIOCGWINSZ;
+ }
+ break;
+ default:
+ abort();
+ }
+
+ if (cap_rights_limit(fd, &rights) < 0 && errno != ENOSYS)
+ err(1, "unable to limit rights for descriptor %d", fd);
+ if (cmd != 0 && cap_ioctls_limit(fd, &cmd, 1) < 0 && errno != ENOSYS)
+ err(1, "unable to limit ioctls for descriptor %d", fd);
+}
+
int
fread_tail(void *buf, int size, int num)
{
@@ -332,7 +452,7 @@
int i;
while ((i = fread(buf, size, num, stdin)) == 0 && tail) {
- (void)sleep(1);
+ sleep(1);
clearerr(stdin);
}
return (i);
@@ -455,6 +575,9 @@
/* FALLTHROUGH */
case KTR_PROCDTOR:
return;
+ case KTR_CAPFAIL:
+ type = "CAP ";
+ break;
case KTR_FAULT:
type = "PFLT";
break;
@@ -462,7 +585,7 @@
type = "PRET";
break;
default:
- (void)sprintf(unknown, "UNKNOWN(%d)", kth->ktr_type);
+ sprintf(unknown, "UNKNOWN(%d)", kth->ktr_type);
type = unknown;
}
@@ -475,11 +598,11 @@
* negative tid's as 0.
*/
if (threads)
- (void)printf("%6jd %6jd %-8.*s ", (intmax_t)kth->ktr_pid,
+ printf("%6jd %6jd %-8.*s ", (intmax_t)kth->ktr_pid,
kth->ktr_tid > 0 ? (intmax_t)kth->ktr_tid : 0,
MAXCOMLEN, kth->ktr_comm);
else
- (void)printf("%6jd %-8.*s ", (intmax_t)kth->ktr_pid, MAXCOMLEN,
+ printf("%6jd %-8.*s ", (intmax_t)kth->ktr_pid, MAXCOMLEN,
kth->ktr_comm);
if (timestamp) {
if (timestamp == 3) {
@@ -492,10 +615,10 @@
timevalsub(&kth->ktr_time, &prevtime);
prevtime = temp;
}
- (void)printf("%jd.%06ld ", (intmax_t)kth->ktr_time.tv_sec,
+ printf("%jd.%06ld ", (intmax_t)kth->ktr_time.tv_sec,
kth->ktr_time.tv_usec);
}
- (void)printf("%s ", type);
+ printf("%s ", type);
}
#include <sys/syscall.h>
@@ -508,469 +631,639 @@
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))
- (void)printf("[%d]", ktr->ktr_code);
- else
- (void)printf("%s", syscallnames[ktr->ktr_code]);
- ip = &ktr->ktr_args[0];
+ printf("[%d]", ktr->ktr_code);
+ else {
+ printf("%s", syscallnames[ktr->ktr_code]);
+ if (syscallno)
+ printf("[%d]", ktr->ktr_code);
+ }
+ ip = first = &ktr->ktr_args[0];
if (narg) {
char c = '(';
if (fancy &&
(flags == 0 || (flags & SV_ABI_MASK) == SV_ABI_FREEBSD)) {
- if (ktr->ktr_code == SYS_ioctl) {
- const char *cp;
- print_number(ip,narg,c);
- if ((cp = ioctlname(*ip)) != NULL)
- (void)printf(",%s", cp);
- else {
- if (decimal)
- (void)printf(",%ld", (long)*ip);
- else
- (void)printf(",%#lx ", (long)*ip);
- }
+ 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:
+ case SYS_faccessat:
+ case SYS_fchmodat:
+ case SYS_fchownat:
+ case SYS_fstatat:
+ case SYS_futimesat:
+ case SYS_linkat:
+ case SYS_mkdirat:
+ case SYS_mkfifoat:
+ case SYS_mknodat:
+ case SYS_openat:
+ case SYS_readlinkat:
+ case SYS_renameat:
+ case SYS_unlinkat:
+ case SYS_utimensat:
+ putchar('(');
+ atfdname(*ip, decimal);
c = ',';
ip++;
narg--;
- } else if (ktr->ktr_code == SYS_ptrace) {
- (void)putchar('(');
- ptraceopname ((int)*ip);
+ break;
+ }
+ switch (ktr->ktr_code) {
+ case SYS_ioctl: {
+ print_number(ip, narg, c);
+ putchar(c);
+ ioctlname(*ip, decimal);
c = ',';
ip++;
narg--;
- } else if (ktr->ktr_code == SYS_access ||
- ktr->ktr_code == SYS_eaccess) {
- print_number(ip,narg,c);
- (void)putchar(',');
- accessmodename ((int)*ip);
+ break;
+ }
+ case SYS_ptrace:
+ putchar('(');
+ ptraceopname(*ip);
+ c = ',';
ip++;
narg--;
- } else if (ktr->ktr_code == SYS_open) {
- int flags;
- int mode;
- print_number(ip,narg,c);
- flags = *ip;
- mode = *++ip;
- (void)putchar(',');
- flagsandmodename (flags, mode, decimal);
+ break;
+ case SYS_access:
+ case SYS_eaccess:
+ case SYS_faccessat:
+ print_number(ip, narg, c);
+ putchar(',');
+ accessmodename(*ip);
ip++;
- narg-=2;
- } else if (ktr->ktr_code == SYS_wait4) {
- print_number(ip,narg,c);
- print_number(ip,narg,c);
- (void)putchar(',');
- wait4optname ((int)*ip);
+ narg--;
+ break;
+ case SYS_open:
+ case SYS_openat:
+ print_number(ip, narg, c);
+ putchar(',');
+ flagsandmodename(ip[0], ip[1], decimal);
+ ip += 2;
+ narg -= 2;
+ break;
+ case SYS_wait4:
+ print_number(ip, narg, c);
+ print_number(ip, narg, c);
+ /*
+ * A flags value of zero is valid for
+ * wait4() but not for wait6(), so
+ * handle zero special here.
+ */
+ if (*ip == 0) {
+ print_number(ip, narg, c);
+ } else {
+ putchar(',');
+ wait6optname(*ip);
+ ip++;
+ narg--;
+ }
+ break;
+ case SYS_wait6:
+ putchar('(');
+ idtypename(*ip, decimal);
+ c = ',';
ip++;
narg--;
- } else if (ktr->ktr_code == SYS_chmod ||
- ktr->ktr_code == SYS_fchmod ||
- ktr->ktr_code == SYS_lchmod) {
- print_number(ip,narg,c);
- (void)putchar(',');
- modename ((int)*ip);
+ print_number64(first, ip, narg, c);
+ print_number(ip, narg, c);
+ putchar(',');
+ wait6optname(*ip);
ip++;
narg--;
- } else if (ktr->ktr_code == SYS_mknod) {
- print_number(ip,narg,c);
- (void)putchar(',');
- modename ((int)*ip);
+ break;
+ case SYS_chmod:
+ case SYS_fchmod:
+ case SYS_lchmod:
+ print_number(ip, narg, c);
+ putchar(',');
+ modename(*ip);
ip++;
narg--;
- } else if (ktr->ktr_code == SYS_getfsstat) {
- print_number(ip,narg,c);
- print_number(ip,narg,c);
- (void)putchar(',');
- getfsstatflagsname ((int)*ip);
+ break;
+ case SYS_mknod:
+ case SYS_mknodat:
+ print_number(ip, narg, c);
+ putchar(',');
+ modename(*ip);
ip++;
narg--;
- } else if (ktr->ktr_code == SYS_mount) {
- print_number(ip,narg,c);
- print_number(ip,narg,c);
- (void)putchar(',');
- mountflagsname ((int)*ip);
+ break;
+ case SYS_getfsstat:
+ print_number(ip, narg, c);
+ print_number(ip, narg, c);
+ putchar(',');
+ getfsstatflagsname(*ip);
ip++;
narg--;
- } else if (ktr->ktr_code == SYS_unmount) {
- print_number(ip,narg,c);
- (void)putchar(',');
- mountflagsname ((int)*ip);
+ break;
+ case SYS_mount:
+ print_number(ip, narg, c);
+ print_number(ip, narg, c);
+ putchar(',');
+ mountflagsname(*ip);
ip++;
narg--;
- } else if (ktr->ktr_code == SYS_recvmsg ||
- ktr->ktr_code == SYS_sendmsg) {
- print_number(ip,narg,c);
- print_number(ip,narg,c);
- (void)putchar(',');
- sendrecvflagsname ((int)*ip);
+ break;
+ case SYS_unmount:
+ print_number(ip, narg, c);
+ putchar(',');
+ mountflagsname(*ip);
ip++;
narg--;
- } else if (ktr->ktr_code == SYS_recvfrom ||
- ktr->ktr_code == SYS_sendto) {
- print_number(ip,narg,c);
- print_number(ip,narg,c);
- print_number(ip,narg,c);
- (void)putchar(',');
- sendrecvflagsname ((int)*ip);
+ break;
+ case SYS_recvmsg:
+ case SYS_sendmsg:
+ print_number(ip, narg, c);
+ print_number(ip, narg, c);
+ putchar(',');
+ sendrecvflagsname(*ip);
ip++;
narg--;
- } else if (ktr->ktr_code == SYS_chflags ||
- ktr->ktr_code == SYS_fchflags ||
- ktr->ktr_code == SYS_lchflags) {
- print_number(ip,narg,c);
- (void)putchar(',');
- modename((int)*ip);
+ break;
+ case SYS_recvfrom:
+ case SYS_sendto:
+ print_number(ip, narg, c);
+ print_number(ip, narg, c);
+ print_number(ip, narg, c);
+ putchar(',');
+ sendrecvflagsname(*ip);
ip++;
narg--;
- } else if (ktr->ktr_code == SYS_kill) {
- print_number(ip,narg,c);
- (void)putchar(',');
- signame((int)*ip);
+ break;
+ case SYS_chflags:
+ case SYS_fchflags:
+ case SYS_lchflags:
+ print_number(ip, narg, c);
+ putchar(',');
+ modename(*ip);
ip++;
narg--;
- } else if (ktr->ktr_code == SYS_reboot) {
- (void)putchar('(');
- rebootoptname((int)*ip);
+ break;
+ case SYS_kill:
+ print_number(ip, narg, c);
+ putchar(',');
+ signame(*ip);
ip++;
narg--;
- } else if (ktr->ktr_code == SYS_umask) {
- (void)putchar('(');
- modename((int)*ip);
+ break;
+ case SYS_reboot:
+ putchar('(');
+ rebootoptname(*ip);
ip++;
narg--;
- } else if (ktr->ktr_code == SYS_msync) {
- print_number(ip,narg,c);
- print_number(ip,narg,c);
- (void)putchar(',');
- msyncflagsname((int)*ip);
+ break;
+ case SYS_umask:
+ putchar('(');
+ modename(*ip);
ip++;
narg--;
+ break;
+ case SYS_msync:
+ print_number(ip, narg, c);
+ print_number(ip, narg, c);
+ putchar(',');
+ msyncflagsname(*ip);
+ ip++;
+ narg--;
+ break;
#ifdef SYS_freebsd6_mmap
- } else if (ktr->ktr_code == SYS_freebsd6_mmap) {
- print_number(ip,narg,c);
- print_number(ip,narg,c);
- (void)putchar(',');
- mmapprotname ((int)*ip);
- (void)putchar(',');
+ case SYS_freebsd6_mmap:
+ print_number(ip, narg, c);
+ print_number(ip, narg, c);
+ putchar(',');
+ mmapprotname(*ip);
+ putchar(',');
ip++;
narg--;
- mmapflagsname ((int)*ip);
+ mmapflagsname(*ip);
ip++;
narg--;
+ break;
#endif
- } else if (ktr->ktr_code == SYS_mmap) {
- print_number(ip,narg,c);
- print_number(ip,narg,c);
- (void)putchar(',');
- mmapprotname ((int)*ip);
- (void)putchar(',');
+ case SYS_mmap:
+ print_number(ip, narg, c);
+ print_number(ip, narg, c);
+ putchar(',');
+ mmapprotname(*ip);
+ putchar(',');
ip++;
narg--;
- mmapflagsname ((int)*ip);
+ mmapflagsname(*ip);
ip++;
narg--;
- } else if (ktr->ktr_code == SYS_mprotect) {
- print_number(ip,narg,c);
- print_number(ip,narg,c);
- (void)putchar(',');
- mmapprotname ((int)*ip);
+ break;
+ case SYS_mprotect:
+ print_number(ip, narg, c);
+ print_number(ip, narg, c);
+ putchar(',');
+ mmapprotname(*ip);
ip++;
narg--;
- } else if (ktr->ktr_code == SYS_madvise) {
- print_number(ip,narg,c);
- print_number(ip,narg,c);
- (void)putchar(',');
- madvisebehavname((int)*ip);
+ break;
+ case SYS_madvise:
+ print_number(ip, narg, c);
+ print_number(ip, narg, c);
+ putchar(',');
+ madvisebehavname(*ip);
ip++;
narg--;
- } else if (ktr->ktr_code == SYS_setpriority) {
- print_number(ip,narg,c);
- print_number(ip,narg,c);
- (void)putchar(',');
- prioname((int)*ip);
+ break;
+ case SYS_setpriority:
+ print_number(ip, narg, c);
+ print_number(ip, narg, c);
+ putchar(',');
+ prioname(*ip);
ip++;
narg--;
- } else if (ktr->ktr_code == SYS_fcntl) {
- int cmd;
- int arg;
- print_number(ip,narg,c);
- cmd = *ip;
- arg = *++ip;
- (void)putchar(',');
- fcntlcmdname(cmd, arg, decimal);
- ip++;
- narg-=2;
- } else if (ktr->ktr_code == SYS_socket) {
+ break;
+ case SYS_fcntl:
+ print_number(ip, narg, c);
+ putchar(',');
+ fcntlcmdname(ip[0], ip[1], decimal);
+ ip += 2;
+ narg -= 2;
+ break;
+ case SYS_socket: {
int sockdomain;
- (void)putchar('(');
- sockdomain=(int)*ip;
+ putchar('(');
+ sockdomain = *ip;
sockdomainname(sockdomain);
ip++;
narg--;
- (void)putchar(',');
- socktypename((int)*ip);
+ putchar(',');
+ socktypenamewithflags(*ip);
ip++;
narg--;
if (sockdomain == PF_INET ||
sockdomain == PF_INET6) {
- (void)putchar(',');
- sockipprotoname((int)*ip);
+ putchar(',');
+ sockipprotoname(*ip);
ip++;
narg--;
}
c = ',';
- } else if (ktr->ktr_code == SYS_setsockopt ||
- ktr->ktr_code == SYS_getsockopt) {
- print_number(ip,narg,c);
- (void)putchar(',');
- sockoptlevelname((int)*ip, decimal);
- if ((int)*ip == SOL_SOCKET) {
+ break;
+ }
+ case SYS_setsockopt:
+ case SYS_getsockopt:
+ print_number(ip, narg, c);
+ putchar(',');
+ sockoptlevelname(*ip, decimal);
+ if (*ip == SOL_SOCKET) {
ip++;
narg--;
- (void)putchar(',');
- sockoptname((int)*ip);
+ putchar(',');
+ sockoptname(*ip);
}
ip++;
narg--;
+ break;
#ifdef SYS_freebsd6_lseek
- } else if (ktr->ktr_code == SYS_freebsd6_lseek) {
- print_number(ip,narg,c);
+ case SYS_freebsd6_lseek:
+ print_number(ip, narg, c);
/* Hidden 'pad' argument, not in lseek(2) */
- print_number(ip,narg,c);
- print_number(ip,narg,c);
- (void)putchar(',');
- whencename ((int)*ip);
+ print_number(ip, narg, c);
+ print_number64(first, ip, narg, c);
+ putchar(',');
+ whencename(*ip);
ip++;
narg--;
+ break;
#endif
- } else if (ktr->ktr_code == SYS_lseek) {
- print_number(ip,narg,c);
- /* Hidden 'pad' argument, not in lseek(2) */
- print_number(ip,narg,c);
- (void)putchar(',');
- whencename ((int)*ip);
+ case SYS_lseek:
+ print_number(ip, narg, c);
+ print_number64(first, ip, narg, c);
+ putchar(',');
+ whencename(*ip);
ip++;
narg--;
-
- } else if (ktr->ktr_code == SYS_flock) {
- print_number(ip,narg,c);
- (void)putchar(',');
- flockname((int)*ip);
+ break;
+ case SYS_flock:
+ print_number(ip, narg, c);
+ putchar(',');
+ flockname(*ip);
ip++;
narg--;
- } else if (ktr->ktr_code == SYS_mkfifo ||
- ktr->ktr_code == SYS_mkdir) {
- print_number(ip,narg,c);
- (void)putchar(',');
- modename((int)*ip);
+ break;
+ case SYS_mkfifo:
+ case SYS_mkfifoat:
+ case SYS_mkdir:
+ case SYS_mkdirat:
+ print_number(ip, narg, c);
+ putchar(',');
+ modename(*ip);
ip++;
narg--;
- } else if (ktr->ktr_code == SYS_shutdown) {
- print_number(ip,narg,c);
- (void)putchar(',');
- shutdownhowname((int)*ip);
+ break;
+ case SYS_shutdown:
+ print_number(ip, narg, c);
+ putchar(',');
+ shutdownhowname(*ip);
ip++;
narg--;
- } else if (ktr->ktr_code == SYS_socketpair) {
- (void)putchar('(');
- sockdomainname((int)*ip);
+ break;
+ case SYS_socketpair:
+ putchar('(');
+ sockdomainname(*ip);
ip++;
narg--;
- (void)putchar(',');
- socktypename((int)*ip);
+ putchar(',');
+ socktypenamewithflags(*ip);
ip++;
narg--;
c = ',';
- } else if (ktr->ktr_code == SYS_getrlimit ||
- ktr->ktr_code == SYS_setrlimit) {
- (void)putchar('(');
- rlimitname((int)*ip);
+ break;
+ case SYS_getrlimit:
+ case SYS_setrlimit:
+ putchar('(');
+ rlimitname(*ip);
ip++;
narg--;
c = ',';
- } else if (ktr->ktr_code == SYS_quotactl) {
- print_number(ip,narg,c);
- (void)putchar(',');
- quotactlname((int)*ip);
+ break;
+ case SYS_quotactl:
+ print_number(ip, narg, c);
+ putchar(',');
+ quotactlname(*ip);
ip++;
narg--;
c = ',';
- } else if (ktr->ktr_code == SYS_nfssvc) {
- (void)putchar('(');
- nfssvcname((int)*ip);
+ break;
+ case SYS_nfssvc:
+ putchar('(');
+ nfssvcname(*ip);
ip++;
narg--;
c = ',';
- } else if (ktr->ktr_code == SYS_rtprio) {
- (void)putchar('(');
- rtprioname((int)*ip);
+ break;
+ case SYS_rtprio:
+ putchar('(');
+ rtprioname(*ip);
ip++;
narg--;
c = ',';
- } else if (ktr->ktr_code == SYS___semctl) {
- print_number(ip,narg,c);
- print_number(ip,narg,c);
- (void)putchar(',');
- semctlname((int)*ip);
+ break;
+ case SYS___semctl:
+ print_number(ip, narg, c);
+ print_number(ip, narg, c);
+ putchar(',');
+ semctlname(*ip);
ip++;
narg--;
- } else if (ktr->ktr_code == SYS_semget) {
- print_number(ip,narg,c);
- print_number(ip,narg,c);
- (void)putchar(',');
- semgetname((int)*ip);
+ break;
+ case SYS_semget:
+ print_number(ip, narg, c);
+ print_number(ip, narg, c);
+ putchar(',');
+ semgetname(*ip);
ip++;
narg--;
- } else if (ktr->ktr_code == SYS_msgctl) {
- print_number(ip,narg,c);
- (void)putchar(',');
- shmctlname((int)*ip);
+ break;
+ case SYS_msgctl:
+ print_number(ip, narg, c);
+ putchar(',');
+ shmctlname(*ip);
ip++;
narg--;
- } else if (ktr->ktr_code == SYS_shmat) {
- print_number(ip,narg,c);
- print_number(ip,narg,c);
- (void)putchar(',');
- shmatname((int)*ip);
+ break;
+ case SYS_shmat:
+ print_number(ip, narg, c);
+ print_number(ip, narg, c);
+ putchar(',');
+ shmatname(*ip);
ip++;
narg--;
- } else if (ktr->ktr_code == SYS_shmctl) {
- print_number(ip,narg,c);
- (void)putchar(',');
- shmctlname((int)*ip);
+ break;
+ case SYS_shmctl:
+ print_number(ip, narg, c);
+ putchar(',');
+ shmctlname(*ip);
ip++;
narg--;
- } else if (ktr->ktr_code == SYS_minherit) {
- print_number(ip,narg,c);
- print_number(ip,narg,c);
- (void)putchar(',');
- minheritname((int)*ip);
+ break;
+ case SYS_shm_open:
+ print_number(ip, narg, c);
+ putchar(',');
+ flagsname(ip[0]);
+ printf(",0%o", (unsigned int)ip[1]);
+ ip += 3;
+ narg -= 3;
+ break;
+ case SYS_minherit:
+ print_number(ip, narg, c);
+ print_number(ip, narg, c);
+ putchar(',');
+ minheritname(*ip);
ip++;
narg--;
- } else if (ktr->ktr_code == SYS_rfork) {
- (void)putchar('(');
- rforkname((int)*ip);
+ break;
+ case SYS_rfork:
+ putchar('(');
+ rforkname(*ip);
ip++;
narg--;
c = ',';
- } else if (ktr->ktr_code == SYS_lio_listio) {
- (void)putchar('(');
- lio_listioname((int)*ip);
+ break;
+ case SYS_lio_listio:
+ putchar('(');
+ lio_listioname(*ip);
ip++;
narg--;
c = ',';
- } else if (ktr->ktr_code == SYS_mlockall) {
- (void)putchar('(');
- mlockallname((int)*ip);
+ break;
+ case SYS_mlockall:
+ putchar('(');
+ mlockallname(*ip);
ip++;
narg--;
- } else if (ktr->ktr_code == SYS_sched_setscheduler) {
- print_number(ip,narg,c);
- (void)putchar(',');
- schedpolicyname((int)*ip);
+ break;
+ case SYS_sched_setscheduler:
+ print_number(ip, narg, c);
+ putchar(',');
+ schedpolicyname(*ip);
ip++;
narg--;
- } else if (ktr->ktr_code == SYS_sched_get_priority_max ||
- ktr->ktr_code == SYS_sched_get_priority_min) {
- (void)putchar('(');
- schedpolicyname((int)*ip);
+ break;
+ case SYS_sched_get_priority_max:
+ case SYS_sched_get_priority_min:
+ putchar('(');
+ schedpolicyname(*ip);
ip++;
narg--;
- } else if (ktr->ktr_code == SYS_sendfile) {
- print_number(ip,narg,c);
- print_number(ip,narg,c);
- print_number(ip,narg,c);
- print_number(ip,narg,c);
- print_number(ip,narg,c);
- print_number(ip,narg,c);
- (void)putchar(',');
- sendfileflagsname((int)*ip);
+ break;
+ case SYS_sendfile:
+ print_number(ip, narg, c);
+ print_number(ip, narg, c);
+ print_number(ip, narg, c);
+ print_number(ip, narg, c);
+ print_number(ip, narg, c);
+ print_number(ip, narg, c);
+ putchar(',');
+ sendfileflagsname(*(int *)ip);
ip++;
narg--;
- } else if (ktr->ktr_code == SYS_kldsym) {
- print_number(ip,narg,c);
- (void)putchar(',');
- kldsymcmdname((int)*ip);
+ break;
+ case SYS_kldsym:
+ print_number(ip, narg, c);
+ putchar(',');
+ kldsymcmdname(*ip);
ip++;
narg--;
- } else if (ktr->ktr_code == SYS_sigprocmask) {
- (void)putchar('(');
- sigprocmaskhowname((int)*ip);
+ break;
+ case SYS_sigprocmask:
+ putchar('(');
+ sigprocmaskhowname(*ip);
ip++;
narg--;
c = ',';
- } else if (ktr->ktr_code == SYS___acl_get_file ||
- ktr->ktr_code == SYS___acl_set_file ||
- ktr->ktr_code == SYS___acl_get_fd ||
- ktr->ktr_code == SYS___acl_set_fd ||
- ktr->ktr_code == SYS___acl_delete_file ||
- ktr->ktr_code == SYS___acl_delete_fd ||
- ktr->ktr_code == SYS___acl_aclcheck_file ||
- ktr->ktr_code == SYS___acl_aclcheck_fd ||
- ktr->ktr_code == SYS___acl_get_link ||
- ktr->ktr_code == SYS___acl_set_link ||
- ktr->ktr_code == SYS___acl_delete_link ||
- ktr->ktr_code == SYS___acl_aclcheck_link) {
- print_number(ip,narg,c);
- (void)putchar(',');
- acltypename((int)*ip);
+ break;
+ case SYS___acl_get_file:
+ case SYS___acl_set_file:
+ case SYS___acl_get_fd:
+ case SYS___acl_set_fd:
+ case SYS___acl_delete_file:
+ case SYS___acl_delete_fd:
+ case SYS___acl_aclcheck_file:
+ case SYS___acl_aclcheck_fd:
+ case SYS___acl_get_link:
+ case SYS___acl_set_link:
+ case SYS___acl_delete_link:
+ case SYS___acl_aclcheck_link:
+ print_number(ip, narg, c);
+ putchar(',');
+ acltypename(*ip);
ip++;
narg--;
- } else if (ktr->ktr_code == SYS_sigaction) {
- (void)putchar('(');
- signame((int)*ip);
+ break;
+ case SYS_sigaction:
+ putchar('(');
+ signame(*ip);
ip++;
narg--;
c = ',';
- } else if (ktr->ktr_code == SYS_extattrctl) {
- print_number(ip,narg,c);
- (void)putchar(',');
- extattrctlname((int)*ip);
+ break;
+ case SYS_extattrctl:
+ print_number(ip, narg, c);
+ putchar(',');
+ extattrctlname(*ip);
ip++;
narg--;
- } else if (ktr->ktr_code == SYS_nmount) {
- print_number(ip,narg,c);
- print_number(ip,narg,c);
- (void)putchar(',');
- mountflagsname ((int)*ip);
+ break;
+ case SYS_nmount:
+ print_number(ip, narg, c);
+ print_number(ip, narg, c);
+ putchar(',');
+ mountflagsname(*ip);
ip++;
narg--;
- } else if (ktr->ktr_code == SYS_thr_create) {
- print_number(ip,narg,c);
- print_number(ip,narg,c);
- (void)putchar(',');
- thrcreateflagsname ((int)*ip);
+ break;
+ case SYS_thr_create:
+ print_number(ip, narg, c);
+ print_number(ip, narg, c);
+ putchar(',');
+ thrcreateflagsname(*ip);
ip++;
narg--;
- } else if (ktr->ktr_code == SYS_thr_kill) {
- print_number(ip,narg,c);
- (void)putchar(',');
- signame ((int)*ip);
+ break;
+ case SYS_thr_kill:
+ print_number(ip, narg, c);
+ putchar(',');
+ signame(*ip);
ip++;
narg--;
- } else if (ktr->ktr_code == SYS_kldunloadf) {
- print_number(ip,narg,c);
- (void)putchar(',');
- kldunloadfflagsname ((int)*ip);
+ break;
+ case SYS_kldunloadf:
+ print_number(ip, narg, c);
+ putchar(',');
+ kldunloadfflagsname(*ip);
ip++;
narg--;
- } else if (ktr->ktr_code == SYS_posix_fadvise) {
- print_number(ip,narg,c);
- print_number(ip,narg,c);
- print_number(ip,narg,c);
+ break;
+ case SYS_linkat:
+ case SYS_renameat:
+ case SYS_symlinkat:
+ print_number(ip, narg, c);
+ putchar(',');
+ atfdname(*ip, decimal);
+ ip++;
+ narg--;
+ break;
+ case SYS_cap_fcntls_limit:
+ print_number(ip, narg, c);
+ putchar(',');
+ arg = *ip;
+ ip++;
+ narg--;
+ capfcntlname(arg);
+ break;
+ case SYS_posix_fadvise:
+ print_number(ip, narg, c);
+ print_number(ip, narg, c);
+ print_number(ip, narg, c);
(void)putchar(',');
fadvisebehavname((int)*ip);
ip++;
narg--;
+ break;
+ case SYS_procctl:
+ putchar('(');
+ idtypename(*ip, decimal);
+ c = ',';
+ ip++;
+ narg--;
+ print_number64(first, ip, narg, c);
+ putchar(',');
+ procctlcmdname(*ip);
+ ip++;
+ narg--;
+ break;
+ case SYS__umtx_op:
+ print_number(ip, narg, c);
+ putchar(',');
+ umtxopname(*ip);
+ switch (*ip) {
+ case UMTX_OP_CV_WAIT:
+ ip++;
+ narg--;
+ putchar(',');
+ umtxcvwaitflags(*ip);
+ break;
+ case UMTX_OP_RW_RDLOCK:
+ ip++;
+ narg--;
+ putchar(',');
+ umtxrwlockflags(*ip);
+ break;
+ }
+ ip++;
+ narg--;
+ break;
+ case SYS_ftruncate:
+ case SYS_truncate:
+ print_number(ip, narg, c);
+ print_number64(first, ip, narg, c);
+ break;
}
}
while (narg > 0) {
- print_number(ip,narg,c);
+ print_number(ip, narg, c);
}
- (void)putchar(')');
+ putchar(')');
}
- (void)putchar('\n');
+ putchar('\n');
}
void
@@ -982,37 +1275,41 @@
if ((flags != 0 && ((flags & SV_ABI_MASK) != SV_ABI_FREEBSD)) ||
(code >= nsyscalls || code < 0))
- (void)printf("[%d] ", code);
- else
- (void)printf("%s ", syscallnames[code]);
+ printf("[%d] ", code);
+ else {
+ printf("%s", syscallnames[code]);
+ if (syscallno)
+ printf("[%d]", code);
+ printf(" ");
+ }
if (error == 0) {
if (fancy) {
- (void)printf("%ld", (long)ret);
+ printf("%ld", (long)ret);
if (ret < 0 || ret > 9)
- (void)printf("/%#lx", (long)ret);
+ printf("/%#lx", (unsigned long)ret);
} else {
if (decimal)
- (void)printf("%ld", (long)ret);
+ printf("%ld", (long)ret);
else
- (void)printf("%#lx", (long)ret);
+ printf("%#lx", (unsigned long)ret);
}
} else if (error == ERESTART)
- (void)printf("RESTART");
+ printf("RESTART");
else if (error == EJUSTRETURN)
- (void)printf("JUSTRETURN");
+ printf("JUSTRETURN");
else {
- (void)printf("-1 errno %d", ktr->ktr_error);
+ printf("-1 errno %d", ktr->ktr_error);
if (fancy)
- (void)printf(" %s", strerror(ktr->ktr_error));
+ printf(" %s", strerror(ktr->ktr_error));
}
- (void)putchar('\n');
+ putchar('\n');
}
void
ktrnamei(char *cp, int len)
{
- (void)printf("\"%.*s\"\n", len, cp);
+ printf("\"%.*s\"\n", len, cp);
}
void
@@ -1069,10 +1366,10 @@
int width;
char visbuf[5];
- (void)printf(" \"");
+ printf(" \"");
col = 8;
for (;datalen > 0; datalen--, dp++) {
- (void) vis(visbuf, *dp, VIS_CSTYLE, *(dp+1));
+ vis(visbuf, *dp, VIS_CSTYLE, *(dp+1));
cp = visbuf;
/*
* Keep track of printables and
@@ -1079,13 +1376,13 @@
* space chars (like fold(1)).
*/
if (col == 0) {
- (void)putchar('\t');
+ putchar('\t');
col = 8;
}
switch(*cp) {
case '\n':
col = 0;
- (void)putchar('\n');
+ putchar('\n');
continue;
case '\t':
width = 8 - (col&07);
@@ -1094,17 +1391,17 @@
width = strlen(cp);
}
if (col + width > (screenwidth-2)) {
- (void)printf("\\\n\t");
+ printf("\\\n\t");
col = 8;
}
col += width;
do {
- (void)putchar(*cp++);
+ putchar(*cp++);
} while (*cp);
}
if (col == 0)
- (void)printf(" ");
- (void)printf("\"\n");
+ printf(" ");
+ printf("\"\n");
}
void
@@ -1115,6 +1412,11 @@
static int screenwidth = 0;
int i, binary;
+ printf("fd %d %s %d byte%s\n", ktr->ktr_fd,
+ ktr->ktr_rw == UIO_READ ? "read" : "wrote", datalen,
+ datalen == 1 ? "" : "s");
+ if (suppressdata)
+ return;
if (screenwidth == 0) {
struct winsize ws;
@@ -1124,11 +1426,6 @@
else
screenwidth = 80;
}
- printf("fd %d %s %d byte%s\n", ktr->ktr_fd,
- ktr->ktr_rw == UIO_READ ? "read" : "wrote", datalen,
- datalen == 1 ? "" : "s");
- if (suppressdata)
- return;
if (maxdata && datalen > maxdata)
datalen = maxdata;
@@ -1158,14 +1455,18 @@
ktrpsig(struct ktr_psig *psig)
{
if (psig->signo > 0 && psig->signo < NSIG)
- (void)printf("SIG%s ", signames[psig->signo]);
+ printf("SIG%s ", signames[psig->signo]);
else
- (void)printf("SIG %d ", psig->signo);
- if (psig->action == SIG_DFL)
- (void)printf("SIG_DFL code=0x%x\n", psig->code);
- else {
- (void)printf("caught handler=0x%lx mask=0x%x code=0x%x\n",
- (u_long)psig->action, psig->mask.__bits[0], psig->code);
+ printf("SIG %d ", psig->signo);
+ if (psig->action == SIG_DFL) {
+ printf("SIG_DFL code=");
+ sigcodename(psig->signo, psig->code);
+ putchar('\n');
+ } else {
+ printf("caught handler=0x%lx mask=0x%x code=",
+ (u_long)psig->action, psig->mask.__bits[0]);
+ sigcodename(psig->signo, psig->code);
+ putchar('\n');
}
}
@@ -1172,7 +1473,7 @@
void
ktrcsw_old(struct ktr_csw_old *cs)
{
- (void)printf("%s %s\n", cs->out ? "stop" : "resume",
+ printf("%s %s\n", cs->out ? "stop" : "resume",
cs->user ? "user" : "kernel");
}
@@ -1193,6 +1494,8 @@
#define UTRACE_PRELOAD_FINISHED 8
#define UTRACE_INIT_CALL 9
#define UTRACE_FINI_CALL 10
+#define UTRACE_DLSYM_START 11
+#define UTRACE_DLSYM_STOP 12
struct utrace_rtld {
char sig[4]; /* 'RTLD' */
@@ -1205,9 +1508,10 @@
};
void
-ktruser_rtld(int len, unsigned char *p)
+ktruser_rtld(int len, void *p)
{
- struct utrace_rtld *ut = (struct utrace_rtld *)p;
+ struct utrace_rtld *ut = p;
+ unsigned char *cp;
void *parent;
int mode;
@@ -1271,15 +1575,23 @@
printf("RTLD: fini %p for %p (%s)\n", ut->mapbase, ut->handle,
ut->name);
break;
+ case UTRACE_DLSYM_START:
+ printf("RTLD: dlsym(%p, %s)\n", ut->handle, ut->name);
+ break;
+ case UTRACE_DLSYM_STOP:
+ printf("RTLD: %p = dlsym(%p, %s)\n", ut->mapbase, ut->handle,
+ ut->name);
+ break;
default:
- p += 4;
+ cp = p;
+ cp += 4;
len -= 4;
printf("RTLD: %d ", len);
while (len--)
if (decimal)
- printf(" %d", *p++);
+ printf(" %d", *cp++);
else
- printf(" %02x", *p++);
+ printf(" %02x", *cp++);
printf("\n");
}
}
@@ -1291,9 +1603,9 @@
};
void
-ktruser_malloc(int len, unsigned char *p)
+ktruser_malloc(void *p)
{
- struct utrace_malloc *ut = (struct utrace_malloc *)p;
+ struct utrace_malloc *ut = p;
if (ut->p == (void *)(intptr_t)(-1))
printf("malloc_init()\n");
@@ -1306,8 +1618,9 @@
}
void
-ktruser(int len, unsigned char *p)
+ktruser(int len, void *p)
{
+ unsigned char *cp;
if (len >= 8 && bcmp(p, "RTLD", 4) == 0) {
ktruser_rtld(len, p);
@@ -1315,20 +1628,48 @@
}
if (len == sizeof(struct utrace_malloc)) {
- ktruser_malloc(len, p);
+ ktruser_malloc(p);
return;
}
- (void)printf("%d ", len);
+ printf("%d ", len);
+ cp = p;
while (len--)
if (decimal)
- (void)printf(" %d", *p++);
+ printf(" %d", *cp++);
else
- (void)printf(" %02x", *p++);
- (void)printf("\n");
+ printf(" %02x", *cp++);
+ printf("\n");
}
void
+ktrcaprights(cap_rights_t *rightsp)
+{
+
+ printf("cap_rights_t ");
+ capname(rightsp);
+ printf("\n");
+}
+
+static void
+ktrtimeval(struct timeval *tv)
+{
+
+ printf("{%ld, %ld}", (long)tv->tv_sec, tv->tv_usec);
+}
+
+void
+ktritimerval(struct itimerval *it)
+{
+
+ printf("itimerval { .interval = ");
+ ktrtimeval(&it->it_interval);
+ printf(", .value = ");
+ ktrtimeval(&it->it_value);
+ printf(" }\n");
+}
+
+void
ktrsockaddr(struct sockaddr *sa)
{
/*
@@ -1350,7 +1691,7 @@
printf(", ");
#define check_sockaddr_len(n) \
- if (sa_##n->s##n##_len < sizeof(struct sockaddr_##n)) { \
+ if (sa_##n.s##n##_len < sizeof(struct sockaddr_##n)) { \
printf("invalid"); \
break; \
}
@@ -1357,54 +1698,60 @@
switch(sa->sa_family) {
case AF_INET: {
- struct sockaddr_in *sa_in;
+ struct sockaddr_in sa_in;
- sa_in = (struct sockaddr_in *)sa;
+ memset(&sa_in, 0, sizeof(sa_in));
+ memcpy(&sa_in, sa, sa->sa_len);
check_sockaddr_len(in);
- inet_ntop(AF_INET, &sa_in->sin_addr, addr, sizeof addr);
- printf("%s:%u", addr, ntohs(sa_in->sin_port));
+ inet_ntop(AF_INET, &sa_in.sin_addr, addr, sizeof addr);
+ printf("%s:%u", addr, ntohs(sa_in.sin_port));
break;
}
#ifdef NETATALK
case AF_APPLETALK: {
- struct sockaddr_at *sa_at;
+ struct sockaddr_at sa_at;
struct netrange *nr;
- sa_at = (struct sockaddr_at *)sa;
+ memset(&sa_at, 0, sizeof(sa_at));
+ memcpy(&sa_at, sa, sa->sa_len);
check_sockaddr_len(at);
- nr = &sa_at->sat_range.r_netrange;
- printf("%d.%d, %d-%d, %d", ntohs(sa_at->sat_addr.s_net),
- sa_at->sat_addr.s_node, ntohs(nr->nr_firstnet),
+ nr = &sa_at.sat_range.r_netrange;
+ printf("%d.%d, %d-%d, %d", ntohs(sa_at.sat_addr.s_net),
+ sa_at.sat_addr.s_node, ntohs(nr->nr_firstnet),
ntohs(nr->nr_lastnet), nr->nr_phase);
break;
}
#endif
case AF_INET6: {
- struct sockaddr_in6 *sa_in6;
+ struct sockaddr_in6 sa_in6;
- sa_in6 = (struct sockaddr_in6 *)sa;
+ memset(&sa_in6, 0, sizeof(sa_in6));
+ memcpy(&sa_in6, sa, sa->sa_len);
check_sockaddr_len(in6);
- inet_ntop(AF_INET6, &sa_in6->sin6_addr, addr, sizeof addr);
- printf("[%s]:%u", addr, htons(sa_in6->sin6_port));
+ getnameinfo((struct sockaddr *)&sa_in6, sizeof(sa_in6),
+ addr, sizeof(addr), NULL, 0, NI_NUMERICHOST);
+ printf("[%s]:%u", addr, htons(sa_in6.sin6_port));
break;
}
#ifdef IPX
case AF_IPX: {
- struct sockaddr_ipx *sa_ipx;
+ struct sockaddr_ipx sa_ipx;
- sa_ipx = (struct sockaddr_ipx *)sa;
+ memset(&sa_ipx, 0, sizeof(sa_ipx));
+ memcpy(&sa_ipx, sa, sa->sa_len);
check_sockaddr_len(ipx);
/* XXX wish we had ipx_ntop */
- printf("%s", ipx_ntoa(sa_ipx->sipx_addr));
+ printf("%s", ipx_ntoa(sa_ipx.sipx_addr));
+ free(sa_ipx);
break;
}
#endif
case AF_UNIX: {
- struct sockaddr_un *sa_un;
+ struct sockaddr_un sa_un;
- sa_un = (struct sockaddr_un *)sa;
- check_sockaddr_len(un);
- printf("%.*s", (int)sizeof(sa_un->sun_path), sa_un->sun_path);
+ memset(&sa_un, 0, sizeof(sa_un));
+ memcpy(&sa_un, sa, sa->sa_len);
+ printf("%.*s", (int)sizeof(sa_un.sun_path), sa_un.sun_path);
break;
}
default:
@@ -1426,10 +1773,15 @@
* buffer exactly sizeof(struct stat) bytes long.
*/
printf("struct stat {");
- strmode(statp->st_mode, mode);
- printf("dev=%ju, ino=%ju, mode=%s, nlink=%ju, ",
- (uintmax_t)statp->st_dev, (uintmax_t)statp->st_ino, mode,
- (uintmax_t)statp->st_nlink);
+ printf("dev=%ju, ino=%ju, ",
+ (uintmax_t)statp->st_dev, (uintmax_t)statp->st_ino);
+ if (resolv == 0)
+ printf("mode=0%jo, ", (uintmax_t)statp->st_mode);
+ else {
+ strmode(statp->st_mode, mode);
+ printf("mode=%s, ", mode);
+ }
+ printf("nlink=%ju, ", (uintmax_t)statp->st_nlink);
if (resolv == 0 || (pwd = getpwuid(statp->st_uid)) == NULL)
printf("uid=%ju, ", (uintmax_t)statp->st_uid);
else
@@ -1444,7 +1796,7 @@
printf("%jd", (intmax_t)statp->st_atim.tv_sec);
else {
tm = localtime(&statp->st_atim.tv_sec);
- (void)strftime(timestr, sizeof(timestr), TIME_FORMAT, tm);
+ strftime(timestr, sizeof(timestr), TIME_FORMAT, tm);
printf("\"%s\"", timestr);
}
if (statp->st_atim.tv_nsec != 0)
@@ -1451,12 +1803,12 @@
printf(".%09ld, ", statp->st_atim.tv_nsec);
else
printf(", ");
- printf("stime=");
+ printf("mtime=");
if (resolv == 0)
printf("%jd", (intmax_t)statp->st_mtim.tv_sec);
else {
tm = localtime(&statp->st_mtim.tv_sec);
- (void)strftime(timestr, sizeof(timestr), TIME_FORMAT, tm);
+ strftime(timestr, sizeof(timestr), TIME_FORMAT, tm);
printf("\"%s\"", timestr);
}
if (statp->st_mtim.tv_nsec != 0)
@@ -1468,7 +1820,7 @@
printf("%jd", (intmax_t)statp->st_ctim.tv_sec);
else {
tm = localtime(&statp->st_ctim.tv_sec);
- (void)strftime(timestr, sizeof(timestr), TIME_FORMAT, tm);
+ strftime(timestr, sizeof(timestr), TIME_FORMAT, tm);
printf("\"%s\"", timestr);
}
if (statp->st_ctim.tv_nsec != 0)
@@ -1480,7 +1832,7 @@
printf("%jd", (intmax_t)statp->st_birthtim.tv_sec);
else {
tm = localtime(&statp->st_birthtim.tv_sec);
- (void)strftime(timestr, sizeof(timestr), TIME_FORMAT, tm);
+ strftime(timestr, sizeof(timestr), TIME_FORMAT, tm);
printf("\"%s\"", timestr);
}
if (statp->st_birthtim.tv_nsec != 0)
@@ -1499,6 +1851,8 @@
char *name, *data;
size_t namelen, datalen;
int i;
+ cap_rights_t rights;
+ struct itimerval it;
struct stat sb;
struct sockaddr_storage ss;
@@ -1515,10 +1869,20 @@
if (datalen == 0)
goto invalid;
/* sanity check */
- for (i = 0; i < namelen; ++i)
- if (!isalpha((unsigned char)name[i]))
+ for (i = 0; i < (int)namelen; ++i)
+ if (!isalpha(name[i]))
goto invalid;
- if (strcmp(name, "stat") == 0) {
+ if (strcmp(name, "caprights") == 0) {
+ if (datalen != sizeof(cap_rights_t))
+ goto invalid;
+ memcpy(&rights, data, datalen);
+ ktrcaprights(&rights);
+ } else if (strcmp(name, "itimerval") == 0) {
+ if (datalen != sizeof(struct itimerval))
+ goto invalid;
+ memcpy(&it, data, datalen);
+ ktritimerval(&it);
+ } else if (strcmp(name, "stat") == 0) {
if (datalen != sizeof(struct stat))
goto invalid;
memcpy(&sb, data, datalen);
@@ -1527,8 +1891,7 @@
if (datalen > sizeof(ss))
goto invalid;
memcpy(&ss, data, datalen);
- if (datalen < sizeof(struct sockaddr) ||
- datalen != ss.ss_len)
+ if (datalen != ss.ss_len)
goto invalid;
ktrsockaddr((struct sockaddr *)&ss);
} else {
@@ -1540,10 +1903,46 @@
}
void
+ktrcapfail(struct ktr_cap_fail *ktr)
+{
+ switch (ktr->cap_type) {
+ case CAPFAIL_NOTCAPABLE:
+ /* operation on fd with insufficient capabilities */
+ printf("operation requires ");
+ capname(&ktr->cap_needed);
+ printf(", process holds ");
+ capname(&ktr->cap_held);
+ break;
+ case CAPFAIL_INCREASE:
+ /* requested more capabilities than fd already has */
+ printf("attempt to increase capabilities from ");
+ capname(&ktr->cap_held);
+ printf(" to ");
+ capname(&ktr->cap_needed);
+ break;
+ case CAPFAIL_SYSCALL:
+ /* called restricted syscall */
+ printf("disallowed system call");
+ break;
+ case CAPFAIL_LOOKUP:
+ /* used ".." in strict-relative mode */
+ printf("restricted VFS lookup");
+ break;
+ default:
+ printf("unknown capability failure: ");
+ capname(&ktr->cap_needed);
+ printf(" ");
+ capname(&ktr->cap_held);
+ break;
+ }
+ printf("\n");
+}
+
+void
ktrfault(struct ktr_fault *ktr)
{
- printf("0x%jx ", ktr->vaddr);
+ printf("0x%jx ", (uintmax_t)ktr->vaddr);
vmprotname(ktr->type);
printf("\n");
}
@@ -1557,16 +1956,31 @@
}
#if defined(__amd64__) || defined(__i386__)
+
+#if defined(__amd64__)
+#define NLINUX_SYSCALLS(v) ((v) & SV_ILP32 ? \
+ nitems(linux32_syscallnames) : nitems(linux_syscallnames))
+#define LINUX_SYSCALLNAMES(v, i) ((v) & SV_ILP32 ? \
+ linux32_syscallnames[i] : linux_syscallnames[i])
+#else
+#define NLINUX_SYSCALLS(v) (nitems(linux_syscallnames))
+#define LINUX_SYSCALLNAMES(v, i) (linux_syscallnames[i])
+#endif
+
void
-linux_ktrsyscall(struct ktr_syscall *ktr)
+linux_ktrsyscall(struct ktr_syscall *ktr, u_int sv_flags)
{
int narg = ktr->ktr_narg;
+ unsigned code = ktr->ktr_code;
register_t *ip;
- if (ktr->ktr_code >= nlinux_syscalls || ktr->ktr_code < 0)
+ if (ktr->ktr_code < 0 || code >= NLINUX_SYSCALLS(sv_flags))
printf("[%d]", ktr->ktr_code);
- else
- printf("%s", linux_syscallnames[ktr->ktr_code]);
+ else {
+ printf("%s", LINUX_SYSCALLNAMES(sv_flags, ktr->ktr_code));
+ if (syscallno)
+ printf("[%d]", ktr->ktr_code);
+ }
ip = &ktr->ktr_args[0];
if (narg) {
char c = '(';
@@ -1578,27 +1992,31 @@
}
void
-linux_ktrsysret(struct ktr_sysret *ktr)
+linux_ktrsysret(struct ktr_sysret *ktr, u_int sv_flags)
{
register_t ret = ktr->ktr_retval;
+ unsigned code = ktr->ktr_code;
int error = ktr->ktr_error;
- int code = ktr->ktr_code;
- if (code >= nlinux_syscalls || code < 0)
- printf("[%d] ", code);
- else
- printf("%s ", linux_syscallnames[code]);
+ if (ktr->ktr_code < 0 || code >= NLINUX_SYSCALLS(sv_flags))
+ printf("[%d] ", ktr->ktr_code);
+ else {
+ printf("%s ", LINUX_SYSCALLNAMES(sv_flags, code));
+ if (syscallno)
+ printf("[%d]", code);
+ printf(" ");
+ }
if (error == 0) {
if (fancy) {
printf("%ld", (long)ret);
if (ret < 0 || ret > 9)
- printf("/%#lx", (long)ret);
+ printf("/%#lx", (unsigned long)ret);
} else {
if (decimal)
printf("%ld", (long)ret);
else
- printf("%#lx", (long)ret);
+ printf("%#lx", (unsigned long)ret);
}
} else if (error == ERESTART)
printf("RESTART");
@@ -1620,7 +2038,7 @@
void
usage(void)
{
- fprintf(stderr, "usage: kdump [-dEnlHRrsTA] [-f trfile] "
+ fprintf(stderr, "usage: kdump [-dEnlHRrSsTA] [-f trfile] "
"[-m maxdata] [-p pid] [-t trstr]\n");
exit(1);
}
Deleted: trunk/usr.bin/kdump/kdump_subr.h
===================================================================
--- trunk/usr.bin/kdump/kdump_subr.h 2018-07-04 14:15:46 UTC (rev 11313)
+++ trunk/usr.bin/kdump/kdump_subr.h 2018-07-04 14:45:14 UTC (rev 11314)
@@ -1,50 +0,0 @@
-/* $MidnightBSD$ */
-
-void signame (int);
-void semctlname (int);
-void shmctlname (int);
-void semgetname (int);
-void fcntlcmdname (int, int, int);
-void rtprioname (int);
-void modename (int);
-void flagsname (int);
-void flagsandmodename (int, int, int);
-void accessmodename (int);
-void mmapprotname (int);
-void mmapflagsname (int);
-void wait4optname (int);
-void sendrecvflagsname (int);
-void getfsstatflagsname (int);
-void mountflagsname (int);
-void rebootoptname (int);
-void flockname (int);
-void sockoptname (int);
-void sockoptlevelname (int, int);
-void sockdomainname (int);
-void sockipprotoname (int);
-void socktypename (int);
-void thrcreateflagsname (int);
-void mlockallname (int);
-void shmatname (int);
-void rforkname (int);
-void nfssvcname (int);
-void whencename (int);
-void rlimitname (int);
-void shutdownhowname (int);
-void prioname (int);
-void fadvisebehavname (int);
-void madvisebehavname (int);
-void msyncflagsname (int);
-void schedpolicyname (int);
-void kldunloadfflagsname (int);
-void extattrctlname (int);
-void kldsymcmdname (int);
-void sendfileflagsname (int);
-void acltypename (int);
-void sigprocmaskhowname (int);
-void lio_listioname (int);
-void minheritname (int);
-void quotactlname (int);
-void ptraceopname (int);
-void vmprotname (int);
-void vmresultname (int);
Added: trunk/usr.bin/kdump/linux32_syscalls.conf
===================================================================
--- trunk/usr.bin/kdump/linux32_syscalls.conf (rev 0)
+++ trunk/usr.bin/kdump/linux32_syscalls.conf 2018-07-04 14:45:14 UTC (rev 11314)
@@ -0,0 +1,11 @@
+# $MidnightBSD$
+sysnames="linux32_syscalls.c"
+sysproto="/dev/null"
+sysproto_h=_LINUX32_SYSPROTO_H_
+syshdr="/dev/null"
+syssw="/dev/null"
+sysmk="/dev/null"
+syscallprefix="LINUX32_SYS_"
+switchname="/dev/null"
+namesname="linux32_syscallnames"
+systrace="/dev/null"
Property changes on: trunk/usr.bin/kdump/linux32_syscalls.conf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Index: trunk/usr.bin/kdump/linux_syscalls.conf
===================================================================
--- trunk/usr.bin/kdump/linux_syscalls.conf 2018-07-04 14:15:46 UTC (rev 11313)
+++ trunk/usr.bin/kdump/linux_syscalls.conf 2018-07-04 14:45:14 UTC (rev 11314)
Property changes on: trunk/usr.bin/kdump/linux_syscalls.conf
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/usr.bin/kdump/mkioctls
===================================================================
--- trunk/usr.bin/kdump/mkioctls 2018-07-04 14:15:46 UTC (rev 11313)
+++ trunk/usr.bin/kdump/mkioctls 2018-07-04 14:45:14 UTC (rev 11314)
@@ -1,36 +1,47 @@
#!/bin/sh
#
# $MidnightBSD$
+# $FreeBSD: stable/10/usr.bin/kdump/mkioctls 327847 2018-01-11 21:31:10Z bdrewery $
+#
+# When editing this script, keep in mind that truss also uses it.
+#
set -e
-if [ "x$1" = "x-s" ]; then
- use_switch=1
- shift
-else
- use_switch=0
-fi
-
-if [ -z "$1" ]; then
- echo "usage: sh $0 [-s] include-dir"
+if [ $# -ne 2 -o \( $1 != "print" -a $1 != "return" \) ]; then
+ echo "usage: sh $0 print|return include-dir"
exit 1
fi
+style="$1"
+includedir="$2"
+
LC_ALL=C; export LC_ALL
# Build a list of headers that have ioctls in them.
# XXX should we use an ANSI cpp?
-ioctl_includes=`
- cd $1
- find -H -s * -name '*.h' |
+ioctl_includes=$(
+ cd $includedir
+ find -H -s * -name '*.h' | \
+ egrep -v '(.*disk.*|net/pfvar|net/if_pfsync)\.h' | \
xargs egrep -l \
'^#[ ]*define[ ]+[A-Za-z_][A-Za-z0-9_]*[ ]+_IO[^a-z0-9_]' |
- awk '{printf("#include <%s>\\\\n", $1)}'
-`
+ awk '{printf("#include <%s>\\n", $1)}'
+)
+: ${MACHINE=$(uname -m)}
+case "${MACHINE}" in
+*pc98*)
+ ioctl_includes="$ioctl_includes#include <sys/diskpc98.h>\\n"
+ ;;
+*)
+ ioctl_includes="$ioctl_includes#include <sys/diskmbr.h>\\n"
+ ;;
+esac
+
awk -v x="$ioctl_includes" 'BEGIN {print x}' |
- $CPP -I$1 -dM -DCOMPAT_43TTY - |
- awk -v ioctl_includes="$ioctl_includes" -v use_switch="$use_switch" '
+ $CPP -nostdinc -I$includedir -dM -DCOMPAT_43TTY - |
+ awk -v ioctl_includes="$ioctl_includes" -v style="$style" '
BEGIN {
print "/* XXX obnoxious prerequisites. */"
print "#define COMPAT_43"
@@ -45,7 +56,10 @@
print "#include <net/ethernet.h>"
print "#include <net/if.h>"
print "#include <net/if_var.h>"
+ print "#ifdef PF"
print "#include <net/pfvar.h>"
+ print "#include <net/if_pfsync.h>"
+ print "#endif"
print "#include <net/route.h>"
print "#include <netinet/in.h>"
print "#include <netinet/ip_mroute.h>"
@@ -57,16 +71,22 @@
print "#include <stddef.h>"
print "#include <stdint.h>"
print ""
- print "const char *ioctlname(u_long val);"
- print ""
print ioctl_includes
print ""
- print "const char *"
- print "ioctlname(u_long val)"
+ if (style == "print") {
+ print "void ioctlname(unsigned long val, int decimal);"
+ print ""
+ print "void"
+ print "ioctlname(unsigned long val, int decimal)"
+ } else {
+ print "const char *ioctlname(unsigned long val);"
+ print ""
+ print "const char *"
+ print "ioctlname(unsigned long val)"
+ }
print "{"
+ print "\tconst char *str = NULL;"
print ""
- if (use_switch)
- print "\tswitch(val) {"
}
/^#[ ]*define[ ]+[A-Za-z_][A-Za-z0-9_]*[ ]+_IO/ {
@@ -77,16 +97,24 @@
break;
++i;
#
- if (use_switch)
- printf("\tcase %s:\n\t\treturn(\"%s\");\n", $i, $i);
- else
- printf("\tif (val == %s)\n\t\treturn(\"%s\");\n", $i, $i);
-
+ printf("\t");
+ if (n++ > 0)
+ printf("else ");
+ printf("if (val == %s)\n", $i);
+ printf("\t\tstr = \"%s\";\n", $i);
}
END {
- if (use_switch)
- print "\t}"
- print "\n\treturn(NULL);"
+ print ""
+ if (style == "print") {
+ print "\tif (str != NULL)"
+ print "\t\tprintf(\"%s\", str);"
+ print "\telse if (decimal)"
+ print "\t\tprintf(\"%lu\", val);"
+ print "\telse"
+ print "\t\tprintf(\"%#lx\", val);"
+ } else {
+ print "\treturn (str);"
+ }
print "}"
}
'
Property changes on: trunk/usr.bin/kdump/mkioctls
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/usr.bin/kdump/mksubr
===================================================================
--- trunk/usr.bin/kdump/mksubr 2018-07-04 14:15:46 UTC (rev 11313)
+++ trunk/usr.bin/kdump/mksubr 2018-07-04 14:45:14 UTC (rev 11314)
@@ -24,6 +24,7 @@
# SUCH DAMAGE.
#
# $MidnightBSD$
+# $FreeBSD: stable/10/usr.bin/kdump/mksubr 280250 2015-03-19 12:32:48Z rwatson $
#
# Generates kdump_subr.c
# mkioctls is a special-purpose script, and works fine as it is
@@ -69,10 +70,10 @@
cat <<_EOF_
/* AUTO */
void
-$name (int arg)
+$name(intmax_t arg)
{
- int or = 0;
- printf("%#x<", arg);
+ int or = 0;
+ printf("%#jx<", (uintmax_t)arg);
_EOF_
egrep "^#[[:space:]]*define[[:space:]]+"${grep}"[[:space:]]*" \
$include_dir/$file | \
@@ -80,11 +81,11 @@
if ($i ~ /define/) \
break; \
++i; \
- printf "\tif(!((arg>0)^((%s)>0)))\n\t\tif_print_or(arg, %s, or);\n", $i, $i }'
+ printf "\tif (!((arg > 0) ^ ((%s) > 0)))\n\t\tif_print_or(arg, %s, or);\n", $i, $i }'
cat <<_EOF_
printf(">");
if (or == 0)
- (void)printf("<invalid>%ld", (long)arg);
+ printf("<invalid>%jd", arg);
}
_EOF_
@@ -103,7 +104,7 @@
cat <<_EOF_
/* AUTO */
void
-$name (int arg)
+$name(intmax_t arg)
{
switch (arg) {
_EOF_
@@ -113,10 +114,10 @@
if ($i ~ /define/) \
break; \
++i; \
- printf "\tcase %s:\n\t\t(void)printf(\"%s\");\n\t\tbreak;\n", $i, $i }'
+ printf "\tcase %s:\n\t\tprintf(\"%s\");\n\t\tbreak;\n", $i, $i }'
cat <<_EOF_
default: /* Should not reach */
- (void)printf("<invalid=%ld>", (long)arg);
+ printf("<invalid=%jd>", arg);
}
}
@@ -136,7 +137,7 @@
cat <<_EOF_
/* AUTO */
void
-$name (int arg)
+$name(intmax_t arg)
{
_EOF_
egrep "^#[[:space:]]*define[[:space:]]+"${grep}"[[:space:]]*" \
@@ -147,7 +148,7 @@
printf "if (arg == %s) \n\t\tprintf(\"%s\");\n", $2, $2 }'
cat <<_EOF_
else /* Should not reach */
- (void)printf("<invalid=%ld>", (long)arg);
+ printf("<invalid=%jd>", arg);
}
_EOF_
@@ -156,6 +157,8 @@
# C start
cat <<_EOF_
+#include <errno.h>
+#include <stdint.h>
#include <stdio.h>
#include <sys/fcntl.h>
#include <sys/stat.h>
@@ -168,6 +171,7 @@
#include <netinet/in.h>
#include <sys/param.h>
#include <sys/mount.h>
+#include <sys/procctl.h>
#include <sys/ptrace.h>
#include <sys/resource.h>
#include <sys/reboot.h>
@@ -183,8 +187,11 @@
#include <sys/ipc.h>
#include <sys/rtprio.h>
#include <sys/shm.h>
+#include <machine/atomic.h>
+#include <sys/umtx.h>
#include <nfsserver/nfs.h>
#include <ufs/ufs/quota.h>
+#include <sys/capsicum.h>
#include <vm/vm.h>
#include <vm/vm_param.h>
@@ -207,78 +214,92 @@
while (0)
/* MANUAL */
+void
+atfdname(int fd, int decimal)
+{
+ if (fd == AT_FDCWD)
+ printf("AT_FDCWD");
+ else if (decimal)
+ printf("%d", fd);
+ else
+ printf("%#x", fd);
+}
+
+/* MANUAL */
extern char *signames[]; /* from kdump.c */
void
-signame (int sig)
+signame(int sig)
{
if (sig > 0 && sig < NSIG)
- (void)printf("SIG%s",signames[sig]);
+ printf("SIG%s",signames[sig]);
else
- (void)printf("SIG %d", sig);
+ printf("SIG %d", sig);
}
/* MANUAL */
void
-semctlname (int cmd)
+semctlname(int cmd)
{
switch (cmd) {
case GETNCNT:
- (void)printf("GETNCNT");
+ printf("GETNCNT");
break;
case GETPID:
- (void)printf("GETPID");
+ printf("GETPID");
break;
case GETVAL:
- (void)printf("GETVAL");
+ printf("GETVAL");
break;
case GETALL:
- (void)printf("GETALL");
+ printf("GETALL");
break;
case GETZCNT:
- (void)printf("GETZCNT");
+ printf("GETZCNT");
break;
case SETVAL:
- (void)printf("SETVAL");
+ printf("SETVAL");
break;
case SETALL:
- (void)printf("SETALL");
+ printf("SETALL");
break;
case IPC_RMID:
- (void)printf("IPC_RMID");
+ printf("IPC_RMID");
break;
case IPC_SET:
- (void)printf("IPC_SET");
+ printf("IPC_SET");
break;
case IPC_STAT:
- (void)printf("IPC_STAT");
+ printf("IPC_STAT");
break;
default: /* Should not reach */
- (void)printf("<invalid=%ld>", (long)cmd);
+ printf("<invalid=%d>", cmd);
}
}
/* MANUAL */
void
-shmctlname (int cmd) {
+shmctlname(int cmd)
+{
switch (cmd) {
case IPC_RMID:
- (void)printf("IPC_RMID");
+ printf("IPC_RMID");
break;
case IPC_SET:
- (void)printf("IPC_SET");
+ printf("IPC_SET");
break;
case IPC_STAT:
- (void)printf("IPC_STAT");
+ printf("IPC_STAT");
break;
default: /* Should not reach */
- (void)printf("<invalid=%ld>", (long)cmd);
+ printf("<invalid=%d>", cmd);
}
}
/* MANUAL */
void
-semgetname (int flag) {
- int or = 0;
+semgetname(int flag)
+{
+ int or = 0;
if_print_or(flag, IPC_CREAT, or);
if_print_or(flag, IPC_EXCL, or);
if_print_or(flag, SEM_R, or);
@@ -296,20 +317,83 @@
* mode argument is unused (and often bogus and misleading).
*/
void
-flagsandmodename (int flags, int mode, int decimal) {
- flagsname (flags);
- (void)putchar(',');
+flagsandmodename(int flags, int mode, int decimal)
+{
+ flagsname(flags);
+ putchar(',');
if ((flags & O_CREAT) == O_CREAT) {
modename (mode);
} else {
if (decimal) {
- (void)printf("<unused>%ld", (long)mode);
+ printf("<unused>%d", mode);
} else {
- (void)printf("<unused>%#lx", (long)mode);
+ printf("<unused>%#x", (unsigned int)mode);
}
}
}
+/* MANUAL */
+void
+idtypename(idtype_t idtype, int decimal)
+{
+ switch(idtype) {
+ case P_PID:
+ printf("P_PID");
+ break;
+ case P_PPID:
+ printf("P_PPID");
+ break;
+ case P_PGID:
+ printf("P_PGID");
+ break;
+ case P_SID:
+ printf("P_SID");
+ break;
+ case P_CID:
+ printf("P_CID");
+ break;
+ case P_UID:
+ printf("P_UID");
+ break;
+ case P_GID:
+ printf("P_GID");
+ break;
+ case P_ALL:
+ printf("P_ALL");
+ break;
+ case P_LWPID:
+ printf("P_LWPID");
+ break;
+ case P_TASKID:
+ printf("P_TASKID");
+ break;
+ case P_PROJID:
+ printf("P_PROJID");
+ break;
+ case P_POOLID:
+ printf("P_POOLID");
+ break;
+ case P_JAILID:
+ printf("P_JAILID");
+ break;
+ case P_CTID:
+ printf("P_CTID");
+ break;
+ case P_CPUID:
+ printf("P_CPUID");
+ break;
+ case P_PSETID:
+ printf("P_PSETID");
+ break;
+ default:
+ if (decimal) {
+ printf("%d", idtype);
+ } else {
+ printf("%#x", idtype);
+ }
+ }
+}
+
/*
* MANUAL
*
@@ -318,15 +402,15 @@
* to use getprotoent(3) here.
*/
void
-sockoptlevelname (int level, int decimal)
+sockoptlevelname(int level, int decimal)
{
if (level == SOL_SOCKET) {
- (void)printf("SOL_SOCKET");
+ printf("SOL_SOCKET");
} else {
if (decimal) {
- (void)printf("%ld", (long)level);
+ printf("%d", level);
} else {
- (void)printf("%#lx", (long)level);
+ printf("%#x", (unsigned int)level);
}
}
}
@@ -351,49 +435,69 @@
if_print_or(type, VM_PROT_EXECUTE, or);
if_print_or(type, VM_PROT_COPY, or);
}
+
+/*
+ * MANUAL
+ */
+void
+socktypenamewithflags(int type)
+{
+ if (type & SOCK_CLOEXEC)
+ printf("SOCK_CLOEXEC|"), type &= ~SOCK_CLOEXEC;
+ if (type & SOCK_NONBLOCK)
+ printf("SOCK_NONBLOCK|"), type &= ~SOCK_NONBLOCK;
+ socktypename(type);
+}
_EOF_
-auto_or_type "modename" "S_[A-Z]+[[:space:]]+[0-6]{7}" "sys/stat.h"
-auto_or_type "flagsname" "O_[A-Z]+[[:space:]]+0x[0-9A-Fa-f]+" "sys/fcntl.h"
-auto_or_type "accessmodename" "[A-Z]_OK[[:space:]]+0?x?[0-9A-Fa-f]+" "sys/unistd.h"
-auto_or_type "mmapprotname" "PROT_[A-Z]+[[:space:]]+0x[0-9A-Fa-f]+" "sys/mman.h"
-auto_or_type "mmapflagsname" "MAP_[A-Z]+[[:space:]]+0x[0-9A-Fa-f]+" "sys/mman.h"
-auto_or_type "wait4optname" "W[A-Z]+[[:space:]]+[0-9]+" "sys/wait.h"
-auto_or_type "getfsstatflagsname" "MNT_[A-Z]+[[:space:]]+[1-9][0-9]*" "sys/mount.h"
-auto_or_type "mountflagsname" "MNT_[A-Z]+[[:space:]]+0x[0-9]+" "sys/mount.h"
-auto_or_type "rebootoptname" "RB_[A-Z]+[[:space:]]+0x[0-9]+" "sys/reboot.h"
-auto_or_type "flockname" "LOCK_[A-Z]+[[:space:]]+0x[0-9]+" "sys/fcntl.h"
-auto_or_type "thrcreateflagsname" "THR_[A-Z]+[[:space:]]+0x[0-9]+" "sys/thr.h"
-auto_or_type "mlockallname" "MCL_[A-Z]+[[:space:]]+0x[0-9]+" "sys/mman.h"
-auto_or_type "shmatname" "SHM_[A-Z]+[[:space:]]+[0-9]{6}+" "sys/shm.h"
-auto_or_type "rforkname" "RF[A-Z]+[[:space:]]+\([0-9]+<<[0-9]+\)" "sys/unistd.h"
-auto_or_type "nfssvcname" "NFSSVC_[A-Z0-9]+[[:space:]]+0x[0-9]+" "nfs/nfssvc.h"
+auto_or_type "accessmodename" "[A-Z]_OK[[:space:]]+0?x?[0-9A-Fa-f]+" "sys/unistd.h"
+auto_switch_type "acltypename" "ACL_TYPE_[A-Z4_]+[[:space:]]+0x[0-9]+" "sys/acl.h"
+auto_or_type "capfcntlname" "CAP_FCNTL_[A-Z]+[[:space:]]+\(1" "sys/capsicum.h"
+auto_switch_type "extattrctlname" "EXTATTR_NAMESPACE_[A-Z]+[[:space:]]+0x[0-9]+" "sys/extattr.h"
+auto_switch_type "fadvisebehavname" "POSIX_FADV_[A-Z]+[[:space:]]+[0-9]+" "sys/fcntl.h"
+auto_or_type "flagsname" "O_[A-Z]+[[:space:]]+0x[0-9A-Fa-f]+" "sys/fcntl.h"
+auto_or_type "flockname" "LOCK_[A-Z]+[[:space:]]+0x[0-9]+" "sys/fcntl.h"
+auto_or_type "getfsstatflagsname" "MNT_[A-Z]+[[:space:]]+[1-9][0-9]*" "sys/mount.h"
+auto_switch_type "kldsymcmdname" "KLDSYM_[A-Z]+[[:space:]]+[0-9]+" "sys/linker.h"
+auto_switch_type "kldunloadfflagsname" "LINKER_UNLOAD_[A-Z]+[[:space:]]+[0-9]+" "sys/linker.h"
+auto_switch_type "lio_listioname" "LIO_(NO)?WAIT[[:space:]]+[0-9]+" "aio.h"
+auto_switch_type "madvisebehavname" "_?MADV_[A-Z]+[[:space:]]+[0-9]+" "sys/mman.h"
+auto_switch_type "minheritname" "INHERIT_[A-Z]+[[:space:]]+[0-9]+" "sys/mman.h"
+auto_or_type "mlockallname" "MCL_[A-Z]+[[:space:]]+0x[0-9]+" "sys/mman.h"
+auto_or_type "mmapprotname" "PROT_[A-Z]+[[:space:]]+0x[0-9A-Fa-f]+" "sys/mman.h"
+auto_or_type "modename" "S_[A-Z]+[[:space:]]+[0-6]{7}" "sys/stat.h"
+auto_or_type "mountflagsname" "MNT_[A-Z]+[[:space:]]+0x[0-9]+" "sys/mount.h"
+auto_switch_type "msyncflagsname" "MS_[A-Z]+[[:space:]]+0x[0-9]+" "sys/mman.h"
+auto_or_type "nfssvcname" "NFSSVC_[A-Z0-9]+[[:space:]]+0x[0-9]+" "nfs/nfssvc.h"
+auto_switch_type "prioname" "PRIO_[A-Z]+[[:space:]]+[0-9]" "sys/resource.h"
+auto_switch_type "procctlcmdname" "PROC_[A-Z]+[[:space:]]+[0-9]" "sys/procctl.h"
+auto_switch_type "ptraceopname" "PT_[[:alnum:]_]+[[:space:]]+[0-9]+" "sys/ptrace.h"
+auto_switch_type "quotactlname" "Q_[A-Z]+[[:space:]]+0x[0-9]+" "ufs/ufs/quota.h"
+auto_or_type "rebootoptname" "RB_[A-Z]+[[:space:]]+0x[0-9]+" "sys/reboot.h"
+auto_or_type "rforkname" "RF[A-Z]+[[:space:]]+\([0-9]+<<[0-9]+\)" "sys/unistd.h"
+auto_switch_type "rlimitname" "RLIMIT_[A-Z]+[[:space:]]+[0-9]+" "sys/resource.h"
+auto_switch_type "schedpolicyname" "SCHED_[A-Z]+[[:space:]]+[0-9]+" "sched.h"
+auto_switch_type "sendfileflagsname" "SF_[A-Z]+[[:space:]]+[0-9]+" "sys/socket.h"
+auto_or_type "shmatname" "SHM_[A-Z]+[[:space:]]+[0-9]{6}+" "sys/shm.h"
+auto_switch_type "shutdownhowname" "SHUT_[A-Z]+[[:space:]]+[0-9]+" "sys/socket.h"
+auto_switch_type "sigbuscodename" "BUS_[A-Z]+[[:space:]]+[0-9]+" "sys/signal.h"
+auto_switch_type "sigchldcodename" "CLD_[A-Z]+[[:space:]]+[0-9]+" "sys/signal.h"
+auto_switch_type "sigfpecodename" "FPE_[A-Z]+[[:space:]]+[0-9]+" "sys/signal.h"
+auto_switch_type "sigprocmaskhowname" "SIG_[A-Z]+[[:space:]]+[0-9]+" "sys/signal.h"
+auto_switch_type "sigillcodename" "ILL_[A-Z]+[[:space:]]+[0-9]+" "sys/signal.h"
+auto_switch_type "sigsegvcodename" "SEGV_[A-Z]+[[:space:]]+[0-9]+" "sys/signal.h"
+auto_switch_type "sigtrapcodename" "TRAP_[A-Z]+[[:space:]]+[0-9]+" "sys/signal.h"
+auto_if_type "sockdomainname" "PF_[[:alnum:]]+[[:space:]]+" "sys/socket.h"
+auto_if_type "sockfamilyname" "AF_[[:alnum:]]+[[:space:]]+" "sys/socket.h"
+auto_if_type "sockipprotoname" "IPPROTO_[[:alnum:]]+[[:space:]]+" "netinet/in.h"
+auto_switch_type "sockoptname" "SO_[A-Z]+[[:space:]]+0x[0-9]+" "sys/socket.h"
+auto_switch_type "socktypename" "SOCK_[A-Z]+[[:space:]]+[1-9]+[0-9]*" "sys/socket.h"
+auto_or_type "thrcreateflagsname" "THR_[A-Z]+[[:space:]]+0x[0-9]+" "sys/thr.h"
+auto_switch_type "umtxopname" "UMTX_OP_[[:alnum:]_]+[[:space:]]+[0-9]+" "sys/umtx.h"
+auto_switch_type "vmresultname" "KERN_[A-Z]+[[:space:]]+[0-9]+" "vm/vm_param.h"
+auto_or_type "wait6optname" "W[A-Z]+[[:space:]]+[0-9]+" "sys/wait.h"
+auto_switch_type "whencename" "SEEK_[A-Z]+[[:space:]]+[0-9]+" "sys/unistd.h"
-auto_switch_type "whencename" "SEEK_[A-Z]+[[:space:]]+[0-9]+" "sys/unistd.h"
-auto_switch_type "rlimitname" "RLIMIT_[A-Z]+[[:space:]]+[0-9]+" "sys/resource.h"
-auto_switch_type "shutdownhowname" "SHUT_[A-Z]+[[:space:]]+[0-9]+" "sys/socket.h"
-auto_switch_type "prioname" "PRIO_[A-Z]+[[:space:]]+[0-9]" "sys/resource.h"
-auto_switch_type "fadvisebehavname" "POSIX_FADV_[A-Z]+[[:space:]]+[0-9]+" "sys/fcntl.h"
-auto_switch_type "madvisebehavname" "_?MADV_[A-Z]+[[:space:]]+[0-9]+" "sys/mman.h"
-auto_switch_type "msyncflagsname" "MS_[A-Z]+[[:space:]]+0x[0-9]+" "sys/mman.h"
-auto_switch_type "schedpolicyname" "SCHED_[A-Z]+[[:space:]]+[0-9]+" "sched.h"
-auto_switch_type "kldunloadfflagsname" "LINKER_UNLOAD_[A-Z]+[[:space:]]+[0-9]+" "sys/linker.h"
-auto_switch_type "extattrctlname" "EXTATTR_NAMESPACE_[A-Z]+[[:space:]]+0x[0-9]+" "sys/extattr.h"
-auto_switch_type "kldsymcmdname" "KLDSYM_[A-Z]+[[:space:]]+[0-9]+" "sys/linker.h"
-auto_switch_type "sendfileflagsname" "SF_[A-Z]+[[:space:]]+[0-9]+" "sys/socket.h"
-auto_switch_type "acltypename" "ACL_TYPE_[A-Z4_]+[[:space:]]+0x[0-9]+" "sys/acl.h"
-auto_switch_type "sigprocmaskhowname" "SIG_[A-Z]+[[:space:]]+[0-9]+" "sys/signal.h"
-auto_switch_type "lio_listioname" "LIO_(NO)?WAIT[[:space:]]+[0-9]+" "aio.h"
-auto_switch_type "minheritname" "INHERIT_[A-Z]+[[:space:]]+[0-9]+" "sys/mman.h"
-auto_switch_type "quotactlname" "Q_[A-Z]+[[:space:]]+0x[0-9]+" "ufs/ufs/quota.h"
-auto_if_type "sockdomainname" "PF_[[:alnum:]]+[[:space:]]+" "sys/socket.h"
-auto_if_type "sockfamilyname" "AF_[[:alnum:]]+[[:space:]]+" "sys/socket.h"
-auto_if_type "sockipprotoname" "IPPROTO_[[:alnum:]]+[[:space:]]+" "netinet/in.h"
-auto_switch_type "sockoptname" "SO_[A-Z]+[[:space:]]+0x[0-9]+" "sys/socket.h"
-auto_switch_type "socktypename" "SOCK_[A-Z]+[[:space:]]+[1-9]+[0-9]*" "sys/socket.h"
-auto_switch_type "ptraceopname" "PT_[[:alnum:]_]+[[:space:]]+[0-9]+" "sys/ptrace.h"
-auto_switch_type "vmresultname" "KERN_[A-Z]+[[:space:]]+[0-9]+" "vm/vm_param.h"
-
cat <<_EOF_
/*
* AUTO - Special
@@ -401,11 +505,11 @@
* grouped in fcntl.h, and this awk script grabs the first group.
*/
void
-fcntlcmdname (int cmd, int arg, int decimal)
+fcntlcmdname(int cmd, int arg, int decimal)
{
switch (cmd) {
_EOF_
-egrep "^#[[:space:]]*define[[:space:]]+F_[A-Z]+[[:space:]]+[0-9]+[[:space:]]*" \
+egrep "^#[[:space:]]*define[[:space:]]+F_[A-Z0-9_]+[[:space:]]+[0-9]+[[:space:]]*" \
$include_dir/sys/fcntl.h | \
awk 'BEGIN { o=0 } { for (i = 1; i <= NF; i++) \
if ($i ~ /define/) \
@@ -412,33 +516,33 @@
break; \
++i; \
if (o <= $(i+1)) \
- printf "\tcase %s:\n\t\t(void)printf(\"%s\");\n\t\tbreak;\n", $i, $i; \
+ printf "\tcase %s:\n\t\tprintf(\"%s\");\n\t\tbreak;\n", $i, $i; \
else \
exit; \
o = $(i+1) }'
cat <<_EOF_
default: /* Should not reach */
- (void)printf("<invalid=%ld>", (long)cmd);
+ printf("<invalid=%d>", cmd);
}
- (void)putchar(',');
+ putchar(',');
if (cmd == F_GETFD || cmd == F_SETFD) {
if (arg == FD_CLOEXEC)
- (void)printf("FD_CLOEXEC");
+ printf("FD_CLOEXEC");
else if (arg == 0)
- (void)printf("0");
+ printf("0");
else {
if (decimal)
- (void)printf("<invalid>%ld", (long)arg);
+ printf("<invalid>%d", arg);
else
- (void)printf("<invalid>%#lx", (long)arg);
+ printf("<invalid>%#x", (unsigned int)arg);
}
} else if (cmd == F_SETFL) {
flagsname(arg);
} else {
if (decimal)
- (void)printf("%ld", (long)arg);
+ printf("%d", arg);
else
- (void)printf("%#lx", (long)arg);
+ printf("%#x", (unsigned int)arg);
}
}
@@ -445,12 +549,50 @@
/*
* AUTO - Special
*
+ * The MAP_ALIGNED flag requires special handling.
+ */
+void
+mmapflagsname(int flags)
+{
+ int align;
+ int or = 0;
+ printf("%#x<", flags);
+_EOF_
+egrep "^#[[:space:]]*define[[:space:]]+MAP_[A-Z_]+[[:space:]]+0x[0-9A-Fa-f]+[[:space:]]*" \
+ $include_dir/sys/mman.h | grep -v MAP_ALIGNED | \
+ awk '{ for (i = 1; i <= NF; i++) \
+ if ($i ~ /define/) \
+ break; \
+ ++i; \
+ printf "\tif (!((flags > 0) ^ ((%s) > 0)))\n\t\tif_print_or(flags, %s, or);\n", $i, $i }'
+cat <<_EOF_
+#ifdef MAP_32BIT
+ if (!((flags > 0) ^ ((MAP_32BIT) > 0)))
+ if_print_or(flags, MAP_32BIT, or);
+#endif
+ align = flags & MAP_ALIGNMENT_MASK;
+ if (align != 0) {
+ if (align == MAP_ALIGNED_SUPER)
+ print_or("MAP_ALIGNED_SUPER", or);
+ else {
+ print_or("MAP_ALIGNED", or);
+ printf("(%d)", align >> MAP_ALIGNMENT_SHIFT);
+ }
+ }
+ printf(">");
+ if (or == 0)
+ printf("<invalid>%d", flags);
+}
+
+/*
+ * AUTO - Special
+ *
* The only reason this is not fully automated is due to the
* grep -v RTP_PRIO statement. A better egrep line should
* make this capable of being a auto_switch_type() function.
*/
void
-rtprioname (int func)
+rtprioname(int func)
{
switch (func) {
_EOF_
@@ -460,10 +602,10 @@
if ($i ~ /define/) \
break; \
++i; \
- printf "\tcase %s:\n\t\t(void)printf(\"%s\");\n\t\tbreak;\n", $i, $i }'
+ printf "\tcase %s:\n\t\tprintf(\"%s\");\n\t\tbreak;\n", $i, $i }'
cat <<_EOF_
default: /* Should not reach */
- (void)printf("<invalid=%ld>", (long)func);
+ printf("<invalid=%d>", func);
}
}
@@ -475,12 +617,12 @@
* detect this as "invalid", which is incorrect here.
*/
void
-sendrecvflagsname (int flags)
+sendrecvflagsname(int flags)
{
- int or = 0;
+ int or = 0;
if (flags == 0) {
- (void)printf("0");
+ printf("0");
return;
}
@@ -496,4 +638,125 @@
printf(">");
}
+/*
+ * AUTO - Special
+ *
+ * Check general codes first, then defer to signal-specific codes.
+ */
+void
+sigcodename(int sig, int code)
+{
+ switch (code) {
_EOF_
+egrep "^#[[:space:]]*define[[:space:]]+SI_[A-Z]+[[:space:]]+0(x[0-9abcdef]+)?[[:space:]]*" \
+ $include_dir/sys/signal.h | grep -v SI_UNDEFINED | \
+ awk '{ for (i = 1; i <= NF; i++) \
+ if ($i ~ /define/) \
+ break; \
+ ++i; \
+ printf "\tcase %s:\n\t\tprintf(\"%s\");\n\t\tbreak;\n", $i, $i }'
+cat <<_EOF_
+ default:
+ switch (sig) {
+ case SIGILL:
+ sigillcodename(code);
+ break;
+ case SIGBUS:
+ sigbuscodename(code);
+ break;
+ case SIGSEGV:
+ sigsegvcodename(code);
+ break;
+ case SIGFPE:
+ sigfpecodename(code);
+ break;
+ case SIGTRAP:
+ sigtrapcodename(code);
+ break;
+ case SIGCHLD:
+ sigchldcodename(code);
+ break;
+ default:
+ printf("<invalid=%#x>", code);
+ }
+ }
+}
+
+/*
+ * AUTO - Special
+ *
+ * Just print 0 as 0.
+ */
+void
+umtxcvwaitflags(intmax_t arg)
+{
+ int or = 0;
+ if (arg == 0) {
+ printf("0");
+ return;
+ }
+ printf("%#jx<", (uintmax_t)arg);
+_EOF_
+ egrep "^#[[:space:]]*define[[:space:]]+CVWAIT_[A-Z_]+[[:space:]]+0x[0-9]+[[:space:]]*" \
+ $include_dir/sys/umtx.h | \
+ awk '{ for (i = 1; i <= NF; i++) \
+ if ($i ~ /define/) \
+ break; \
+ ++i; \
+ printf "\tif (!((arg > 0) ^ ((%s) > 0)))\n\t\tif_print_or(arg, %s, or);\n", $i, $i }'
+cat <<_EOF_
+ printf(">");
+ if (or == 0)
+ printf("<invalid>%jd", arg);
+}
+
+
+/*
+ * AUTO - Special
+ *
+ * Just print 0 as 0.
+ */
+void
+umtxrwlockflags(intmax_t arg)
+{
+ int or = 0;
+ if (arg == 0) {
+ printf("0");
+ return;
+ }
+ printf("%#jx<", (uintmax_t)arg);
+_EOF_
+ egrep "^#[[:space:]]*define[[:space:]]+URWLOCK_PREFER_READER[[:space:]]+0x[0-9]+[[:space:]]*" \
+ $include_dir/sys/umtx.h | \
+ awk '{ for (i = 1; i <= NF; i++) \
+ if ($i ~ /define/) \
+ break; \
+ ++i; \
+ printf "\tif (!((arg > 0) ^ ((%s) > 0)))\n\t\tif_print_or(arg, %s, or);\n", $i, $i }'
+cat <<_EOF_
+ printf(">");
+ if (or == 0)
+ printf("<invalid>%jd", arg);
+}
+_EOF_
+egrep '#define[[:space:]]+CAP_[A-Z_]+[[:space:]]+CAPRIGHT\([0-9],[[:space:]]+0x[0-9]{16}ULL\)' \
+ $include_dir/sys/capsicum.h | \
+ sed -E 's/[ ]+/ /g' | \
+ awk -F '[ \(,\)]' '
+ BEGIN {
+ printf "void\n"
+ printf "capname(const cap_rights_t *rightsp)\n"
+ printf "{\n"
+ printf "\tint comma = 0;\n\n"
+ printf "\tprintf(\"<\");\n"
+ }
+ {
+ printf "\tif ((rightsp->cr_rights[%s] & %s) == %s) {\n", $4, $2, $2
+ printf "\t\tif (comma) printf(\",\"); else comma = 1;\n"
+ printf "\t\tprintf(\"%s\");\n", $2
+ printf "\t}\n"
+ }
+ END {
+ printf "\tprintf(\">\");\n"
+ printf "}\n"
+ }'
Property changes on: trunk/usr.bin/kdump/mksubr
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
More information about the Midnightbsd-cvs
mailing list