summaryrefslogtreecommitdiffstats
path: root/usr.bin/kdump
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>2011-10-08 09:57:29 +0000
committerdes <des@FreeBSD.org>2011-10-08 09:57:29 +0000
commitdb03f845e19d2200d2762e8e1cc8bad430a3fe21 (patch)
tree507ee9a9b241856f4c98e2920f65ed6c4cced65c /usr.bin/kdump
parent2e76e4f6aab6b13ff61794f76a85325c2588cbaa (diff)
downloadFreeBSD-src-db03f845e19d2200d2762e8e1cc8bad430a3fe21.zip
FreeBSD-src-db03f845e19d2200d2762e8e1cc8bad430a3fe21.tar.gz
1) Some of the #defines or enums for which we auto-generate naming
functions may be wider than int, so use intmax_t throughout. Also add missing casts in printf() calls. 2) Clean up some of the auto-generated code to improve readability. 3) Auto-generate kdump_subr.h. Note that this requires a semi-ugly hack in the Makefile to make sure it is generated before make(1) tries to build kdump.c, or preprocess it for 'make depend'. MFC after: 3 weeks
Diffstat (limited to 'usr.bin/kdump')
-rw-r--r--usr.bin/kdump/Makefile15
-rw-r--r--usr.bin/kdump/kdump.c1
-rw-r--r--usr.bin/kdump/kdump_subr.h47
-rw-r--r--usr.bin/kdump/mksubr46
4 files changed, 37 insertions, 72 deletions
diff --git a/usr.bin/kdump/Makefile b/usr.bin/kdump/Makefile
index ea33bbd..53804dc 100644
--- a/usr.bin/kdump/Makefile
+++ b/usr.bin/kdump/Makefile
@@ -9,7 +9,7 @@ SFX= 32
PROG= kdump
SRCS= kdump.c ioctl.c kdump_subr.c subr.c
-CFLAGS+= -I${.CURDIR}/../ktrace -I${.CURDIR} -I${.CURDIR}/../..
+CFLAGS+= -I${.CURDIR}/../ktrace -I${.CURDIR} -I${.CURDIR}/../.. -I.
.if ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "i386"
SRCS+= linux_syscalls.c
@@ -22,8 +22,17 @@ CLEANFILES= ioctl.c kdump_subr.c linux_syscalls.c
ioctl.c: mkioctls
sh ${.CURDIR}/mkioctls ${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}
+
+kdump_subr.c: mksubr kdump_subr.h
+ sh ${.CURDIR}/mksubr ${DESTDIR}/usr/include >${.TARGET}
+
+# kdump.c includes kdump_subr.h, which is auto-generated. Add a
+# manual dependency to make sure kdump_subr.h is generated before we
+# try to either compile or preprocess kdump.c.
+${.CURDIR}/kdump.c: kdump_subr.h
linux_syscalls.c:
/bin/sh ${.CURDIR}/../../sys/kern/makesyscalls.sh \
diff --git a/usr.bin/kdump/kdump.c b/usr.bin/kdump/kdump.c
index 1c3807c..7d99c1c 100644
--- a/usr.bin/kdump/kdump.c
+++ b/usr.bin/kdump/kdump.c
@@ -100,7 +100,6 @@ void ktrsockaddr(struct sockaddr *);
void ktrstat(struct stat *);
void ktrstruct(char *, size_t);
void usage(void);
-void sockfamilyname(int);
const char *ioctlname(u_long);
int timestamp, decimal, fancy = 1, suppressdata, tail, threads, maxdata,
diff --git a/usr.bin/kdump/kdump_subr.h b/usr.bin/kdump/kdump_subr.h
deleted file mode 100644
index 50cf9ee..0000000
--- a/usr.bin/kdump/kdump_subr.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/* $FreeBSD$ */
-
-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 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);
diff --git a/usr.bin/kdump/mksubr b/usr.bin/kdump/mksubr
index d6fa870..9d29678 100644
--- a/usr.bin/kdump/mksubr
+++ b/usr.bin/kdump/mksubr
@@ -69,10 +69,10 @@ auto_or_type () {
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 +80,11 @@ _EOF_
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);
+ (void)printf("<invalid>%jd", arg);
}
_EOF_
@@ -103,7 +103,7 @@ auto_switch_type () {
cat <<_EOF_
/* AUTO */
void
-$name (int arg)
+$name(intmax_t arg)
{
switch (arg) {
_EOF_
@@ -116,7 +116,7 @@ _EOF_
printf "\tcase %s:\n\t\t(void)printf(\"%s\");\n\t\tbreak;\n", $i, $i }'
cat <<_EOF_
default: /* Should not reach */
- (void)printf("<invalid=%ld>", (long)arg);
+ (void)printf("<invalid=%jd>", arg);
}
}
@@ -136,7 +136,7 @@ auto_if_type () {
cat <<_EOF_
/* AUTO */
void
-$name (int arg)
+$name(intmax_t arg)
{
_EOF_
egrep "^#[[:space:]]*define[[:space:]]+"${grep}"[[:space:]]*" \
@@ -147,7 +147,7 @@ _EOF_
printf "if (arg == %s) \n\t\tprintf(\"%s\");\n", $2, $2 }'
cat <<_EOF_
else /* Should not reach */
- (void)printf("<invalid=%ld>", (long)arg);
+ (void)printf("<invalid=%jd>", arg);
}
_EOF_
@@ -156,6 +156,7 @@ _EOF_
# C start
cat <<_EOF_
+#include <stdint.h>
#include <stdio.h>
#include <sys/fcntl.h>
#include <sys/stat.h>
@@ -207,7 +208,7 @@ cat <<_EOF_
/* 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]);
@@ -217,7 +218,7 @@ signame (int sig)
/* MANUAL */
void
-semctlname (int cmd)
+semctlname(int cmd)
{
switch (cmd) {
case GETNCNT:
@@ -257,7 +258,8 @@ semctlname (int cmd)
/* MANUAL */
void
-shmctlname (int cmd) {
+shmctlname(int cmd)
+{
switch (cmd) {
case IPC_RMID:
(void)printf("IPC_RMID");
@@ -275,8 +277,9 @@ shmctlname (int 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);
@@ -294,8 +297,9 @@ semgetname (int flag) {
* mode argument is unused (and often bogus and misleading).
*/
void
-flagsandmodename (int flags, int mode, int decimal) {
- flagsname (flags);
+flagsandmodename(int flags, int mode, int decimal)
+{
+ flagsname(flags);
(void)putchar(',');
if ((flags & O_CREAT) == O_CREAT) {
modename (mode);
@@ -316,7 +320,7 @@ flagsandmodename (int flags, int mode, int decimal) {
* to use getprotoent(3) here.
*/
void
-sockoptlevelname (int level, int decimal)
+sockoptlevelname(int level, int decimal)
{
if (level == SOL_SOCKET) {
(void)printf("SOL_SOCKET");
@@ -377,7 +381,7 @@ cat <<_EOF_
* 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_
@@ -426,7 +430,7 @@ cat <<_EOF_
* make this capable of being a auto_switch_type() function.
*/
void
-rtprioname (int func)
+rtprioname(int func)
{
switch (func) {
_EOF_
@@ -451,9 +455,9 @@ cat <<_EOF_
* 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");
OpenPOWER on IntegriCloud