summaryrefslogtreecommitdiffstats
path: root/usr.bin/kdump
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>1997-07-06 06:54:14 +0000
committerbde <bde@FreeBSD.org>1997-07-06 06:54:14 +0000
commit4d7f45e2595cdda6921d9ed62f7ce9ba08453d13 (patch)
tree8a1e564deb1b54debb4947f8ee448223b4ef4fb3 /usr.bin/kdump
parente9b5b21c359ab94dbe38c62aa507bd29c30d295c (diff)
downloadFreeBSD-src-4d7f45e2595cdda6921d9ed62f7ce9ba08453d13.zip
FreeBSD-src-4d7f45e2595cdda6921d9ed62f7ce9ba08453d13.tar.gz
Finish importing Lite2's src/usr.bin, except for ex, diff, grep, mail,
pascal and vmstat.sparc. All changed files on the vendor branch should already have been imported.
Diffstat (limited to 'usr.bin/kdump')
-rw-r--r--usr.bin/kdump/kdump.c125
-rw-r--r--usr.bin/kdump/mkioctls35
2 files changed, 88 insertions, 72 deletions
diff --git a/usr.bin/kdump/kdump.c b/usr.bin/kdump/kdump.c
index 988bbbc..5a1f279 100644
--- a/usr.bin/kdump/kdump.c
+++ b/usr.bin/kdump/kdump.c
@@ -38,7 +38,7 @@ static char copyright[] =
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)kdump.c 8.1 (Berkeley) 6/6/93";
+static char sccsid[] = "@(#)kdump.c 8.4 (Berkeley) 4/28/95";
#endif /* not lint */
#include <sys/param.h>
@@ -51,10 +51,15 @@ static char sccsid[] = "@(#)kdump.c 8.1 (Berkeley) 6/6/93";
#define KERNEL
#include <sys/errno.h>
#undef KERNEL
-#include <vis.h>
+
+#include <err.h>
+#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
+#include <vis.h>
+
#include "ktrace.h"
int timestamp, decimal, fancy = 1, tail, maxdata;
@@ -63,18 +68,17 @@ struct ktr_header ktr_header;
#define eqs(s1, s2) (strcmp((s1), (s2)) == 0)
+int
main(argc, argv)
int argc;
char *argv[];
{
- extern int optind;
- extern char *optarg;
int ch, ktrlen, size;
register void *m;
int trpoints = ALL_POINTS;
- while ((ch = getopt(argc,argv,"f:dlm:nRTt:")) != EOF)
- switch((char)ch) {
+ while ((ch = getopt(argc, argv, "f:dlm:nRTt:")) != -1)
+ switch (ch) {
case 'f':
tracefile = optarg;
break;
@@ -98,12 +102,8 @@ main(argc, argv)
break;
case 't':
trpoints = getpoints(optarg);
- if (trpoints < 0) {
- (void)fprintf(stderr,
- "kdump: unknown trace point in %s\n",
- optarg);
- exit(1);
- }
+ if (trpoints < 0)
+ errx(1, "unknown trace point in %s", optarg);
break;
default:
usage();
@@ -115,36 +115,23 @@ main(argc, argv)
usage();
m = (void *)malloc(size = 1025);
- if (m == NULL) {
- (void)fprintf(stderr, "kdump: %s.\n", strerror(ENOMEM));
- exit(1);
- }
- if (!freopen(tracefile, "r", stdin)) {
- (void)fprintf(stderr,
- "kdump: %s: %s.\n", tracefile, strerror(errno));
- exit(1);
- }
+ if (m == NULL)
+ errx(1, "%s", strerror(ENOMEM));
+ if (!freopen(tracefile, "r", stdin))
+ err(1, "%s", tracefile);
while (fread_tail(&ktr_header, sizeof(struct ktr_header), 1)) {
if (trpoints & (1<<ktr_header.ktr_type))
dumpheader(&ktr_header);
- if ((ktrlen = ktr_header.ktr_len) < 0) {
- (void)fprintf(stderr,
- "kdump: bogus length 0x%x\n", ktrlen);
- exit(1);
- }
+ if ((ktrlen = ktr_header.ktr_len) < 0)
+ errx(1, "bogus length 0x%x", ktrlen);
if (ktrlen > size) {
m = (void *)realloc(m, ktrlen+1);
- if (m == NULL) {
- (void)fprintf(stderr,
- "kdump: %s.\n", strerror(ENOMEM));
- exit(1);
- }
+ if (m == NULL)
+ errx(1, "%s", strerror(ENOMEM));
size = ktrlen;
}
- if (ktrlen && fread_tail(m, ktrlen, 1) == 0) {
- (void)fprintf(stderr, "kdump: data too short.\n");
- exit(1);
- }
+ if (ktrlen && fread_tail(m, ktrlen, 1) == 0)
+ errx(1, "data too short");
if ((trpoints & (1<<ktr_header.ktr_type)) == 0)
continue;
switch (ktr_header.ktr_type) {
@@ -244,55 +231,58 @@ static char *ptrace_ops[] = {
ktrsyscall(ktr)
register struct ktr_syscall *ktr;
{
- register narg = ktr->ktr_narg;
- register int *ip;
+ register argsize = ktr->ktr_argsize;
+ register register_t *ap;
char *ioctlname();
if (ktr->ktr_code >= nsyscalls || ktr->ktr_code < 0)
(void)printf("[%d]", ktr->ktr_code);
else
(void)printf("%s", syscallnames[ktr->ktr_code]);
- ip = (int *)((char *)ktr + sizeof(struct ktr_syscall));
- if (narg) {
+ ap = (register_t *)((char *)ktr + sizeof(struct ktr_syscall));
+ if (argsize) {
char c = '(';
if (fancy) {
if (ktr->ktr_code == SYS_ioctl) {
char *cp;
if (decimal)
- (void)printf("(%d", *ip);
+ (void)printf("(%ld", (long)*ap);
else
- (void)printf("(%#x", *ip);
- ip++;
- narg--;
- if ((cp = ioctlname(*ip)) != NULL)
+ (void)printf("(%#lx", (long)*ap);
+ ap++;
+ argsize -= sizeof(register_t);
+ if ((cp = ioctlname(*ap)) != NULL)
(void)printf(",%s", cp);
else {
if (decimal)
- (void)printf(",%d", *ip);
+ (void)printf(",%ld",
+ (long)*ap);
else
- (void)printf(",%#x ", *ip);
+ (void)printf(",%#lx ",
+ (long)*ap);
}
c = ',';
- ip++;
- narg--;
+ ap++;
+ argsize -= sizeof(register_t);
} else if (ktr->ktr_code == SYS_ptrace) {
- if (*ip <= PT_STEP && *ip >= 0)
- (void)printf("(%s", ptrace_ops[*ip]);
+ if (*ap >= 0 && *ap <=
+ sizeof(ptrace_ops) / sizeof(ptrace_ops[0]))
+ (void)printf("(%s", ptrace_ops[*ap]);
else
- (void)printf("(%d", *ip);
+ (void)printf("(%ld", (long)*ap);
c = ',';
- ip++;
- narg--;
+ ap++;
+ argsize -= sizeof(register_t);
}
}
- while (narg) {
+ while (argsize) {
if (decimal)
- (void)printf("%c%d", c, *ip);
+ (void)printf("%c%ld", c, (long)*ap);
else
- (void)printf("%c%#x", c, *ip);
+ (void)printf("%c%#lx", c, (long)*ap);
c = ',';
- ip++;
- narg--;
+ ap++;
+ argsize -= sizeof(register_t);
}
(void)putchar(')');
}
@@ -366,7 +356,7 @@ ktrgenio(ktr, len)
datalen = maxdata;
(void)printf(" \"");
col = 8;
- for (;datalen > 0; datalen--, dp++) {
+ for (; datalen > 0; datalen--, dp++) {
(void) vis(visbuf, *dp, VIS_CSTYLE, *(dp+1));
cp = visbuf;
/*
@@ -402,31 +392,22 @@ ktrgenio(ktr, len)
(void)printf("\"\n");
}
-char *signames[] = {
- "NULL", "HUP", "INT", "QUIT", "ILL", "TRAP", "IOT", /* 1 - 6 */
- "EMT", "FPE", "KILL", "BUS", "SEGV", "SYS", /* 7 - 12 */
- "PIPE", "ALRM", "TERM", "URG", "STOP", "TSTP", /* 13 - 18 */
- "CONT", "CHLD", "TTIN", "TTOU", "IO", "XCPU", /* 19 - 24 */
- "XFSZ", "VTALRM", "PROF", "WINCH", "29", "USR1", /* 25 - 30 */
- "USR2", NULL, /* 31 - 32 */
-};
-
ktrpsig(psig)
struct ktr_psig *psig;
{
- (void)printf("SIG%s ", signames[psig->signo]);
+ (void)printf("SIG%s ", sys_signame[psig->signo]);
if (psig->action == SIG_DFL)
(void)printf("SIG_DFL\n");
else
- (void)printf("caught handler=0x%x mask=0x%x code=0x%x\n",
- (u_int)psig->action, psig->mask, psig->code);
+ (void)printf("caught handler=0x%lx mask=0x%x code=0x%x\n",
+ (u_long)psig->action, psig->mask, psig->code);
}
ktrcsw(cs)
struct ktr_csw *cs;
{
(void)printf("%s %s\n", cs->out ? "stop" : "resume",
- cs->user ? "user" : "kernel");
+ cs->user ? "user" : "kernel");
}
usage()
diff --git a/usr.bin/kdump/mkioctls b/usr.bin/kdump/mkioctls
index acba53b..b165d05 100644
--- a/usr.bin/kdump/mkioctls
+++ b/usr.bin/kdump/mkioctls
@@ -1,3 +1,38 @@
+#!/bin/sh -
+#
+# Copyright (c) 1994
+# The Regents of the University of California. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. All advertising materials mentioning features or use of this software
+# must display the following acknowledgement:
+# This product includes software developed by the University of
+# California, Berkeley and its contributors.
+# 4. Neither the name of the University nor the names of its contributors
+# may be used to endorse or promote products derived from this software
+# without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# @(#)mkioctls 8.2 (Berkeley) 4/28/95
+#
awk '
BEGIN {
print "#include <sys/param.h>"
OpenPOWER on IntegriCloud