Module Name:    src
Committed By:   christos
Date:           Sat Apr 30 16:57:59 UTC 2011

Modified Files:
        src/usr.sbin/crash: Makefile
Added Files:
        src/usr.sbin/crash/arch: x86.c
Removed Files:
        src/usr.sbin/crash/arch: i386.c

Log Message:
Share the amd64 and i386 files.
XXX: Is there a better way to get the cpu family?


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/usr.sbin/crash/Makefile
cvs rdiff -u -r1.1 -r0 src/usr.sbin/crash/arch/i386.c
cvs rdiff -u -r0 -r1.1 src/usr.sbin/crash/arch/x86.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/crash/Makefile
diff -u src/usr.sbin/crash/Makefile:1.10 src/usr.sbin/crash/Makefile:1.11
--- src/usr.sbin/crash/Makefile:1.10	Thu Apr 14 04:21:06 2011
+++ src/usr.sbin/crash/Makefile	Sat Apr 30 12:57:58 2011
@@ -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

Added files:

Index: src/usr.sbin/crash/arch/x86.c
diff -u /dev/null src/usr.sbin/crash/arch/x86.c:1.1
--- /dev/null	Sat Apr 30 12:57:59 2011
+++ src/usr.sbin/crash/arch/x86.c	Sat Apr 30 12:57:58 2011
@@ -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");
+	}
+}

Reply via email to