Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/ktruss import Makefile and dump.c required for build...
details: https://anonhg.NetBSD.org/src/rev/d60d5a0f4ccd
branches: trunk
changeset: 474579:d60d5a0f4ccd
user: darrenr <darrenr%NetBSD.org@localhost>
date: Mon Jul 12 03:20:17 1999 +0000
description:
import Makefile and dump.c required for building ktruss.
diffstat:
usr.bin/ktruss/Makefile | 38 +++
usr.bin/ktruss/dump.c | 572 ++++++++++++++++++++++++++++++++++++++++++++++
usr.bin/ktruss/makeerrnos | 62 ++++
3 files changed, 672 insertions(+), 0 deletions(-)
diffs (truncated from 684 to 300 lines):
diff -r 1f4577e956f1 -r d60d5a0f4ccd usr.bin/ktruss/Makefile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/ktruss/Makefile Mon Jul 12 03:20:17 1999 +0000
@@ -0,0 +1,38 @@
+# from: @(#)Makefile 8.1 (Berkeley) 6/6/93
+# $Id: Makefile,v 1.1 1999/07/12 03:20:17 darrenr Exp $
+
+MAN=
+LDSTATIC?=-static
+PROG= ktruss
+CFLAGS+=-g -I${.CURDIR}/../ktrace -I/sys -DKTRUSS
+SRCS= ktrace.c dump.c subr.c ioctl.c misc.c
+CLEANFILES+=misc.c misc.h ktrace.c subr.c ioctl.c
+
+ktruss: links
+
+links: ktrace.c subr.c ioctl.c
+
+ktrace.c: ../ktrace/ktrace.c
+ rm -f ktrace.c
+ ln -s ../ktrace/ktrace.c .
+
+subr.c: ../ktrace/subr.c
+ rm -f subr.c
+ ln -s ../ktrace/subr.c .
+
+ioctl.c: ../kdump/ioctl.c
+ rm -f ioctl.c
+ ln -s ../kdump/ioctl.c .
+
+../kdump/ioctl.c: ../kdump/mkioctls
+ (cd ../kdump; make ioctl.c )
+
+dump.c: misc.h
+
+misc.c: /usr/include/sys/errno.h /usr/include/sys/signal.h
+ ./makeerrnos
+
+misc.h: /usr/include/sys/errno.h /usr/include/sys/signal.h
+ ./makeerrnos
+
+.include <bsd.prog.mk>
diff -r 1f4577e956f1 -r d60d5a0f4ccd usr.bin/ktruss/dump.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/ktruss/dump.c Mon Jul 12 03:20:17 1999 +0000
@@ -0,0 +1,572 @@
+/*-
+ * Copyright (c) 1988, 1993
+ * 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.
+ */
+
+#include <sys/cdefs.h>
+#ifndef lint
+__COPYRIGHT("@(#) Copyright (c) 1988, 1993\n\
+ The Regents of the University of California. All rights reserved.\n");
+#endif /* not lint */
+
+#ifndef lint
+#if 0
+static char sccsid[] = "@(#)kdump.c 8.4 (Berkeley) 4/28/95";
+#endif
+__RCSID("$NetBSD: dump.c,v 1.1 1999/07/12 03:20:17 darrenr Exp $");
+#endif /* not lint */
+
+#include <sys/param.h>
+#define _KERNEL
+#include <sys/errno.h>
+#undef _KERNEL
+#include <sys/time.h>
+#include <sys/uio.h>
+#include <sys/ktrace.h>
+#include <sys/ioctl.h>
+#include <sys/ptrace.h>
+#define _KERNEL
+#include <sys/errno.h>
+#undef _KERNEL
+
+#include <err.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <vis.h>
+
+#include "ktrace.h"
+#include "misc.h"
+
+int timestamp, decimal, fancy = 1, tail, maxdata;
+
+#define eqs(s1, s2) (strcmp((s1), (s2)) == 0)
+
+#include <sys/syscall.h>
+
+#include "../../sys/compat/hpux/hpux_syscall.h"
+#include "../../sys/compat/ibcs2/ibcs2_syscall.h"
+#include "../../sys/compat/linux/linux_syscall.h"
+#include "../../sys/compat/osf1/osf1_syscall.h"
+#include "../../sys/compat/sunos/sunos_syscall.h"
+#include "../../sys/compat/svr4/svr4_syscall.h"
+#include "../../sys/compat/ultrix/ultrix_syscall.h"
+
+#define KTRACE
+#include "../../sys/kern/syscalls.c"
+
+#include "../../sys/compat/hpux/hpux_syscalls.c"
+#include "../../sys/compat/ibcs2/ibcs2_syscalls.c"
+#include "../../sys/compat/linux/linux_syscalls.c"
+#include "../../sys/compat/osf1/osf1_syscalls.c"
+#include "../../sys/compat/sunos/sunos_syscalls.c"
+#include "../../sys/compat/svr4/svr4_syscalls.c"
+#include "../../sys/compat/ultrix/ultrix_syscalls.c"
+#undef KTRACE
+
+struct emulation {
+ char *name; /* Emulation name */
+ char **sysnames; /* Array of system call names */
+ int nsysnames; /* Number of */
+};
+
+static struct emulation emulations[] = {
+ { "netbsd", syscallnames, SYS_MAXSYSCALL },
+ { "hpux", hpux_syscallnames, HPUX_SYS_MAXSYSCALL },
+ { "ibcs2", ibcs2_syscallnames, IBCS2_SYS_MAXSYSCALL },
+ { "linux", linux_syscallnames, LINUX_SYS_MAXSYSCALL },
+ { "osf1", osf1_syscallnames, OSF1_SYS_MAXSYSCALL },
+ { "sunos", sunos_syscallnames, SUNOS_SYS_MAXSYSCALL },
+ { "svr4", svr4_syscallnames, SVR4_SYS_MAXSYSCALL },
+ { "ultrix", ultrix_syscallnames, ULTRIX_SYS_MAXSYSCALL },
+ { NULL, NULL, NULL }
+};
+
+struct emulation *current = &emulations[0]; /* NetBSD */
+
+
+static char *ptrace_ops[] = {
+ "PT_TRACE_ME", "PT_READ_I", "PT_READ_D", "PT_READ_U",
+ "PT_WRITE_I", "PT_WRITE_D", "PT_WRITE_U", "PT_CONTINUE",
+ "PT_KILL", "PT_ATTACH", "PT_DETACH",
+};
+
+
+void dumprecord __P((struct ktr_header *, int, int, void *, FILE *));
+void dumpheader __P((struct ktr_header *, char *, int, int *));
+void dumpfile __P((char *, int, int));
+int fread_tail __P((char *, int, int, FILE *));
+void ioctldecode __P((u_long));
+int ktrsyscall __P((struct ktr_syscall *, int, char *, int, int *));
+void ktrsysret __P((struct ktr_sysret *, char *, int, int *));
+void ktrnamei __P((char *, int, char *, int, int *));
+void ktremul __P((char *, int, char *, int, int *));
+void ktrgenio __P((struct ktr_genio *, int, char *, int, int *));
+void ktrpsig __P((struct ktr_psig *));
+void ktrcsw __P((struct ktr_csw *));
+void setemul __P((char *));
+
+#define KTR_BUFSZ 512
+#define BLEFT (bufsz - (bp - buff))
+
+
+void
+dumprecord(ktr, trpoints, size, m, fp)
+ register struct ktr_header *ktr;
+ int trpoints, size;
+ void *m;
+ FILE *fp;
+{
+ static void *mcopy = NULL;
+ static int linelen = 0, iolinelen = 0;
+ char buff[KTR_BUFSZ], iobuff[KTR_BUFSZ], *bp;
+ int ktrlen, *lenp;
+
+ if (!ktr) {
+ printf("%s\n", buff);
+ if (*iobuff)
+ printf("%s\n", iobuff);
+ return;
+ }
+
+ if (ktr->ktr_type == KTR_GENIO || ktr->ktr_type == KTR_EMUL) {
+ bp = iobuff;
+ lenp = &iolinelen;
+ } else {
+ bp = buff;
+ lenp = &linelen;
+ }
+ if (!mcopy && (trpoints & (1<<ktr->ktr_type)))
+ dumpheader(ktr, bp, KTR_BUFSZ, lenp);
+
+ if ((ktrlen = ktr->ktr_len) < 0)
+ errx(1, "bogus length 0x%x", ktrlen);
+ if (ktrlen > size) {
+ m = (void *)realloc(m, ktrlen+1);
+ if (m == NULL)
+ errx(1, "%s", strerror(ENOMEM));
+ size = ktrlen;
+ }
+ if (ktrlen && fread_tail(m, ktrlen, 1, fp) == 0)
+ errx(1, "data too short");
+ if ((trpoints & (1<<ktr->ktr_type)) == 0)
+ return;
+ switch (ktr->ktr_type)
+ {
+ case KTR_SYSCALL:
+ if (ktrsyscall((struct ktr_syscall *)m, 0, bp, KTR_BUFSZ,
+ lenp) == 0) {
+ mcopy = (void *)malloc(ktrlen + 1);
+ bcopy(m, mcopy, ktrlen);
+ return;
+ }
+ break;
+ case KTR_SYSRET:
+ ktrsysret((struct ktr_sysret *)m, bp, KTR_BUFSZ, lenp);
+ if (*iobuff || iolinelen) {
+ fputs(iobuff, stdout);
+ *iobuff = '\0';
+ iolinelen = 0;
+ }
+ break;
+ case KTR_NAMEI:
+ ktrnamei(m, ktrlen, bp, sizeof(buff), lenp);
+ if (mcopy) {
+ (void) ktrsyscall((struct ktr_syscall *)mcopy, 1, bp,
+ KTR_BUFSZ, lenp);
+ free(mcopy);
+ mcopy = NULL;
+ }
+ break;
+ case KTR_GENIO:
+ ktrgenio((struct ktr_genio *)m, ktrlen, bp, KTR_BUFSZ, lenp);
+ break;
+ case KTR_PSIG:
+ ktrpsig((struct ktr_psig *)m);
+ break;
+ case KTR_CSW:
+ ktrcsw((struct ktr_csw *)m);
+ break;
+ case KTR_EMUL:
+ ktremul(m, ktrlen, bp, sizeof(buff), lenp);
+ break;
+ }
+
+ if (mcopy)
+ free(mcopy);
+}
+
+void
+dumpfile(file, fd, trpoints)
+ char *file;
+ int fd;
+ int trpoints;
+{
+ struct ktr_header ktr_header;
+ register void *m;
+ FILE *fp;
+ int size;
+
+ m = (void *)malloc(size = 1025);
+ if (m == NULL)
+ errx(1, "%s", strerror(ENOMEM));
+ if (!file || !*file) {
+ if (!(fp = fdopen(fd, "r")))
+ err(1, "fdopen(%d)", fd);
+ } else if (!strcmp(file, "-"))
+ fp = stdin;
+ else if (!(fp = fopen(file, "r")))
+ err(1, "%s", file);
+
+ while (fread_tail((char *)&ktr_header,sizeof(struct ktr_header),1,fp)) {
+ dumprecord(&ktr_header, trpoints, size, m, fp);
+ if (tail)
+ (void)fflush(stdout);
Home |
Main Index |
Thread Index |
Old Index