Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/crash Share the amd64 and i386 files.
details: https://anonhg.NetBSD.org/src/rev/640d9be3525d
branches: trunk
changeset: 764676:640d9be3525d
user: christos <christos%NetBSD.org@localhost>
date: Sat Apr 30 16:57:58 2011 +0000
description:
Share the amd64 and i386 files.
XXX: Is there a better way to get the cpu family?
diffstat:
usr.sbin/crash/Makefile | 9 +++-
usr.sbin/crash/arch/i386.c | 72 ---------------------------------------------
usr.sbin/crash/arch/x86.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 79 insertions(+), 75 deletions(-)
diffs (186 lines):
diff -r 9bf13c810f88 -r 640d9be3525d usr.sbin/crash/Makefile
--- a/usr.sbin/crash/Makefile Sat Apr 30 14:24:27 2011 +0000
+++ b/usr.sbin/crash/Makefile Sat Apr 30 16:57:58 2011 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.10 2011/04/14 08:21:06 mrg Exp $
+# $NetBSD: Makefile,v 1.11 2011/04/30 16:57:58 christos Exp $
PROG= crash
MAN= crash.8
@@ -37,9 +37,12 @@
. if ${MACHINE} == "amd64" \
|| ${MACHINE} == "i386"
+MACHINE_FAMILY = x86
.PATH: ${S}/arch/x86/x86
SRCS+= db_trace.c
SRCS+= db_machdep.c
+. else
+MACHINE_FAMILY = ${MACHINE}
. endif
. if ${MACHINE} == "sparc64"
@@ -51,8 +54,8 @@
# arch.c
.PATH: ${.CURDIR}/arch
-. if (exists(${.CURDIR}/arch/${MACHINE_ARCH}.c))
-SRCS+= ${MACHINE_ARCH}.c
+. if (exists(${.CURDIR}/arch/${MACHINE_FAMILY}.c))
+SRCS+= ${MACHINE_FAMILY}.c
. else
SRCS+= generic.c
. endif
diff -r 9bf13c810f88 -r 640d9be3525d usr.sbin/crash/arch/i386.c
--- a/usr.sbin/crash/arch/i386.c Sat Apr 30 14:24:27 2011 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,72 +0,0 @@
-/* $NetBSD: i386.c,v 1.1 2009/03/07 22:08:08 ad Exp $ */
-
-/*-
- * Copyright (c) 2009 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Andrew Doran.
- *
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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
-__RCSID("$NetBSD: i386.c,v 1.1 2009/03/07 22:08:08 ad Exp $");
-#endif /* not lint */
-
-#include <ddb/ddb.h>
-
-#include <kvm.h>
-#include <nlist.h>
-#include <err.h>
-#include <stdlib.h>
-
-#include <machine/frame.h>
-#include <machine/pcb.h>
-
-#include "extern.h"
-
-static struct nlist nl[] = {
- { .n_name = "_dumppcb" },
- { .n_name = NULL },
-};
-
-struct pcb pcb;
-
-void
-db_mach_init(kvm_t *kd)
-{
-
- if (kvm_nlist(kd, nl) == -1) {
- errx(EXIT_FAILURE, "kvm_nlist: %s", kvm_geterr(kd));
- }
- if ((size_t)kvm_read(kd, nl[0].n_value, &pcb, sizeof(pcb)) !=
- sizeof(pcb)) {
- errx(EXIT_FAILURE, "cannot read dumppcb: %s", kvm_geterr(kd));
- }
- ddb_regs.tf_esp = pcb.pcb_esp;
- ddb_regs.tf_ebp = pcb.pcb_ebp;
- if (ddb_regs.tf_ebp != 0 && ddb_regs.tf_esp != 0) {
- printf("Backtrace from time of crash is available.\n");
- }
-}
diff -r 9bf13c810f88 -r 640d9be3525d usr.sbin/crash/arch/x86.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.sbin/crash/arch/x86.c Sat Apr 30 16:57:58 2011 +0000
@@ -0,0 +1,73 @@
+/* $NetBSD: x86.c,v 1.1 2011/04/30 16:57:58 christos Exp $ */
+
+/*-
+ * Copyright (c) 2009 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Andrew Doran.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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
+__RCSID("$NetBSD: x86.c,v 1.1 2011/04/30 16:57:58 christos Exp $");
+#endif /* not lint */
+
+#include <ddb/ddb.h>
+
+#include <kvm.h>
+#include <nlist.h>
+#include <err.h>
+#include <stdlib.h>
+
+#include <machine/frame.h>
+#include <machine/pcb.h>
+#include <x86/db_machdep.h>
+
+#include "extern.h"
+
+static struct nlist nl[] = {
+ { .n_name = "_dumppcb" },
+ { .n_name = NULL },
+};
+
+struct pcb pcb;
+
+void
+db_mach_init(kvm_t *kd)
+{
+
+ if (kvm_nlist(kd, nl) == -1) {
+ errx(EXIT_FAILURE, "kvm_nlist: %s", kvm_geterr(kd));
+ }
+ if ((size_t)kvm_read(kd, nl[0].n_value, &pcb, sizeof(pcb)) !=
+ sizeof(pcb)) {
+ errx(EXIT_FAILURE, "cannot read dumppcb: %s", kvm_geterr(kd));
+ }
+ ddb_regs.tf_sp = pcb.pcb_sp;
+ ddb_regs.tf_bp = pcb.pcb_bp;
+ if (ddb_regs.tf_bp != 0 && ddb_regs.tf_sp != 0) {
+ printf("Backtrace from time of crash is available.\n");
+ }
+}
Home |
Main Index |
Thread Index |
Old Index