summaryrefslogtreecommitdiff
path: root/usr.bin/kdump
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/kdump')
-rw-r--r--usr.bin/kdump/kdump.c167
-rw-r--r--usr.bin/kdump/kdump_subr.h27
-rw-r--r--usr.bin/kdump/mksubr182
3 files changed, 185 insertions, 191 deletions
diff --git a/usr.bin/kdump/kdump.c b/usr.bin/kdump/kdump.c
index 193c48d71ef..68301892a63 100644
--- a/usr.bin/kdump/kdump.c
+++ b/usr.bin/kdump/kdump.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kdump.c,v 1.82 2013/07/03 06:41:51 guenther Exp $ */
+/* $OpenBSD: kdump.c,v 1.83 2013/07/03 23:04:33 guenther Exp $ */
/*-
* Copyright (c) 1988, 1993
@@ -165,6 +165,14 @@ static void atfd(int);
static void polltimeout(int);
static void pgid(int);
static void wait4pid(int);
+static void signame(int);
+static void sigset(int);
+static void semctlname(int);
+static void shmctlname(int);
+static void semgetname(int);
+static void flagsandmodename(int, int);
+static void clockname(int);
+static void sockoptlevelname(int);
int
main(int argc, char *argv[])
@@ -1675,3 +1683,160 @@ wait4pid(int pid)
else
pgid(pid);
}
+
+static void
+signame(int sig)
+{
+ if (sig > 0 && sig < NSIG)
+ (void)printf("SIG%s", sys_signame[sig]);
+ else
+ (void)printf("SIG %d", sig);
+}
+
+static void
+sigset(int ss)
+{
+ int or = 0;
+ int cnt = 0;
+ int i;
+
+ for (i = 1; i < NSIG; i++)
+ if (sigismember(&ss, i))
+ cnt++;
+ if (cnt > (NSIG-1)/2) {
+ ss = ~ss;
+ putchar('~');
+ }
+
+ if (ss == 0) {
+ (void)printf("0<>");
+ return;
+ }
+
+ printf("%#x<", ss);
+ for (i = 1; i < NSIG; i++)
+ if (sigismember(&ss, i)) {
+ if (or) putchar('|'); else or=1;
+ signame(i);
+ }
+ printf(">");
+}
+
+static void
+semctlname(int cmd)
+{
+ switch (cmd) {
+ case GETNCNT:
+ (void)printf("GETNCNT");
+ break;
+ case GETPID:
+ (void)printf("GETPID");
+ break;
+ case GETVAL:
+ (void)printf("GETVAL");
+ break;
+ case GETALL:
+ (void)printf("GETALL");
+ break;
+ case GETZCNT:
+ (void)printf("GETZCNT");
+ break;
+ case SETVAL:
+ (void)printf("SETVAL");
+ break;
+ case SETALL:
+ (void)printf("SETALL");
+ break;
+ case IPC_RMID:
+ (void)printf("IPC_RMID");
+ break;
+ case IPC_SET:
+ (void)printf("IPC_SET");
+ break;
+ case IPC_STAT:
+ (void)printf("IPC_STAT");
+ break;
+ default: /* Should not reach */
+ (void)printf("<invalid=%ld>", (long)cmd);
+ }
+}
+
+static void
+shmctlname(int cmd) {
+ switch (cmd) {
+ case IPC_RMID:
+ (void)printf("IPC_RMID");
+ break;
+ case IPC_SET:
+ (void)printf("IPC_SET");
+ break;
+ case IPC_STAT:
+ (void)printf("IPC_STAT");
+ break;
+ default: /* Should not reach */
+ (void)printf("<invalid=%ld>", (long)cmd);
+ }
+}
+
+
+static void
+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);
+ if_print_or(flag, SEM_A, or);
+ if_print_or(flag, (SEM_R>>3), or);
+ if_print_or(flag, (SEM_A>>3), or);
+ if_print_or(flag, (SEM_R>>6), or);
+ if_print_or(flag, (SEM_A>>6), or);
+}
+
+
+/*
+ * Only used by SYS_open. Unless O_CREAT is set in flags, the
+ * mode argument is unused (and often bogus and misleading).
+ */
+static void
+flagsandmodename(int flags, int mode) {
+ flagsname (flags);
+ if ((flags & O_CREAT) == O_CREAT) {
+ (void)putchar(',');
+ modename (mode);
+ } else if (!fancy) {
+ (void)putchar(',');
+ if (decimal) {
+ (void)printf("<unused>%ld", (long)mode);
+ } else {
+ (void)printf("<unused>%#lx", (long)mode);
+ }
+ }
+}
+
+static void
+clockname(int clockid)
+{
+ clocktypename(__CLOCK_TYPE(clockid));
+ if (__CLOCK_PTID(clockid) != 0)
+ printf("(%d)", __CLOCK_PTID(clockid));
+}
+
+/*
+ * [g|s]etsockopt's level argument can either be SOL_SOCKET or a value
+ * referring to a line in /etc/protocols . It might be appropriate
+ * to use getprotoent(3) here.
+ */
+static void
+sockoptlevelname(int level)
+{
+ if (level == SOL_SOCKET) {
+ (void)printf("SOL_SOCKET");
+ } else {
+ if (decimal) {
+ (void)printf("%ld", (long)level);
+ } else {
+ (void)printf("%#lx", (long)level);
+ }
+ }
+}
+
diff --git a/usr.bin/kdump/kdump_subr.h b/usr.bin/kdump/kdump_subr.h
index 20c53de4263..0a6cf79d91f 100644
--- a/usr.bin/kdump/kdump_subr.h
+++ b/usr.bin/kdump/kdump_subr.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: kdump_subr.h,v 1.9 2013/06/17 19:11:54 guenther Exp $ */
+/* $OpenBSD: kdump_subr.h,v 1.10 2013/07/03 23:04:34 guenther Exp $ */
/*
* Copyright(c) 2006 2006 David Kirchner <dpk@dpk.net>
*
@@ -17,17 +17,28 @@
/* $FreeBSD: src/usr.bin/kdump/kdump_subr.h,v 1.3 2007/04/09 22:04:27 emaste Exp $ */
-void signame(int);
-void sigset(int);
-void semctlname(int);
-void shmctlname(int);
-void semgetname(int);
+
+/*
+ * These are simple support macros. print_or utilizes a variable
+ * defined in the calling function to track whether or not it should
+ * print a logical-OR character ('|') before a string. if_print_or
+ * simply handles the necessary "if" statement used in many lines
+ * of this file.
+ */
+#define print_or(str,orflag) do { \
+ if (orflag) putchar('|'); else orflag = 1; \
+ printf ("%s", str); } \
+ while (0)
+#define if_print_or(i,flag,orflag) do { \
+ if ((i & flag) == flag) \
+ print_or(#flag,orflag); } \
+ while (0)
+
void fcntlcmdname(int, int);
void rtprioname(int);
void modename(int);
void flagsname(int);
void atflagsname(int);
-void flagsandmodename(int, int);
void accessmodename(int);
void mmapprotname(int);
void mmapflagsname(int);
@@ -38,7 +49,6 @@ void mountflagsname(int);
void rebootoptname(int);
void flockname(int);
void sockoptname(int);
-void sockoptlevelname(int);
void sockdomainname(int);
void sockipprotoname(int);
void socktypename(int);
@@ -54,7 +64,6 @@ void shutdownhowname(int);
void prioname(int);
void madvisebehavname(int);
void msyncflagsname(int);
-void clockname(int);
void clocktypename(int);
void schedpolicyname(int);
void kldunloadfflagsname(int);
diff --git a/usr.bin/kdump/mksubr b/usr.bin/kdump/mksubr
index 83d439d466e..4f423769204 100644
--- a/usr.bin/kdump/mksubr
+++ b/usr.bin/kdump/mksubr
@@ -1,5 +1,5 @@
#!/bin/sh
-# $OpenBSD: mksubr,v 1.16 2013/07/01 17:16:46 guenther Exp $
+# $OpenBSD: mksubr,v 1.17 2013/07/03 23:04:34 guenther Exp $
#
# Copyright (c) 2006 David Kirchner <dpk@dpk.net>
#
@@ -278,186 +278,6 @@ cat <<_EOF_
#include "kdump_subr.h"
-/*
- * These are simple support macros. print_or utilizes a variable
- * defined in the calling function to track whether or not it should
- * print a logical-OR character ('|') before a string. if_print_or
- * simply handles the necessary "if" statement used in many lines
- * of this file.
- */
-#define print_or(str,orflag) do { \\
- if (orflag) putchar('|'); else orflag = 1; \\
- printf ("%s", str); } \\
- while (0)
-#define if_print_or(i,flag,orflag) do { \\
- if ((i & flag) == flag) \\
- print_or(#flag,orflag); } \\
- while (0)
-
-/* MANUAL */
-extern const char *const sys_signame[NSIG];
-void
-signame (int sig)
-{
- if (sig > 0 && sig < NSIG)
- (void)printf("SIG%s", sys_signame[sig]);
- else
- (void)printf("SIG %d", sig);
-}
-
-/* MANUAL */
-void
-sigset (int ss)
-{
- int or = 0;
- int cnt = 0;
- int i;
-
- for (i = 1; i < NSIG; i++)
- if (sigismember(&ss, i))
- cnt++;
- if (cnt > (NSIG-1)/2) {
- ss = ~ss;
- putchar('~');
- }
-
- if (ss == 0) {
- (void)printf("0<>");
- return;
- }
-
- printf("%#x<", ss);
- for (i = 1; i < NSIG; i++)
- if (sigismember(&ss, i)) {
- if (or) putchar('|'); else or=1;
- signame(i);
- }
- printf(">");
-}
-
-/* MANUAL */
-void
-semctlname (int cmd)
-{
- switch (cmd) {
- case GETNCNT:
- (void)printf("GETNCNT");
- break;
- case GETPID:
- (void)printf("GETPID");
- break;
- case GETVAL:
- (void)printf("GETVAL");
- break;
- case GETALL:
- (void)printf("GETALL");
- break;
- case GETZCNT:
- (void)printf("GETZCNT");
- break;
- case SETVAL:
- (void)printf("SETVAL");
- break;
- case SETALL:
- (void)printf("SETALL");
- break;
- case IPC_RMID:
- (void)printf("IPC_RMID");
- break;
- case IPC_SET:
- (void)printf("IPC_SET");
- break;
- case IPC_STAT:
- (void)printf("IPC_STAT");
- break;
- default: /* Should not reach */
- (void)printf("<invalid=%ld>", (long)cmd);
- }
-}
-
-/* MANUAL */
-void
-shmctlname (int cmd) {
- switch (cmd) {
- case IPC_RMID:
- (void)printf("IPC_RMID");
- break;
- case IPC_SET:
- (void)printf("IPC_SET");
- break;
- case IPC_STAT:
- (void)printf("IPC_STAT");
- break;
- default: /* Should not reach */
- (void)printf("<invalid=%ld>", (long)cmd);
- }
-}
-
-/* MANUAL */
-void
-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);
- if_print_or(flag, SEM_A, or);
- if_print_or(flag, (SEM_R>>3), or);
- if_print_or(flag, (SEM_A>>3), or);
- if_print_or(flag, (SEM_R>>6), or);
- if_print_or(flag, (SEM_A>>6), or);
-}
-
-/*
- * MANUAL
- *
- * Only used by SYS_open. Unless O_CREAT is set in flags, the
- * mode argument is unused (and often bogus and misleading).
- */
-void
-flagsandmodename (int flags, int mode) {
- flagsname (flags);
- if ((flags & O_CREAT) == O_CREAT) {
- (void)putchar(',');
- modename (mode);
- } else if (!fancy) {
- (void)putchar(',');
- if (decimal) {
- (void)printf("<unused>%ld", (long)mode);
- } else {
- (void)printf("<unused>%#lx", (long)mode);
- }
- }
-}
-
-void
-clockname (int clockid)
-{
- clocktypename(__CLOCK_TYPE(clockid));
- if (__CLOCK_PTID(clockid) != 0)
- printf("(%d)", __CLOCK_PTID(clockid));
-}
-
-/*
- * MANUAL
- *
- * [g|s]etsockopt's level argument can either be SOL_SOCKET or a value
- * referring to a line in /etc/protocols . It might be appropriate
- * to use getprotoent(3) here.
- */
-void
-sockoptlevelname (int level)
-{
- if (level == SOL_SOCKET) {
- (void)printf("SOL_SOCKET");
- } else {
- if (decimal) {
- (void)printf("%ld", (long)level);
- } else {
- (void)printf("%#lx", (long)level);
- }
- }
-}
-
_EOF_
auto_orz_type "modename" "S_[A-Z]+[[:space:]]+[0-6]{7}" "sys/stat.h"