Module Name:    src
Committed By:   apb
Date:           Sun Feb 10 11:04:20 UTC 2013

Modified Files:
        src/sys/ddb: ddbvar.h
        src/sys/kern: subr_prf.c
Added Files:
        src/sys/ddb: db_panic.c

Log Message:
Move the DDB-specific part of vpanic() to a new db_panic() function,
defined in ddb/db_panic.c and declared in ddb/ddbvar.h.  No functional
change.

The copyright years in db_panic.c are the years in which changes were
made to the code that has now been moved to db_panic.c.  No pre-NetBSD
copyright notice is needed because revision 1.12 of subr_prf.c had only
the trivial "#ifdef DDB \\ Debugger(); \\ #endif"


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/ddb/db_panic.c
cvs rdiff -u -r1.10 -r1.11 src/sys/ddb/ddbvar.h
cvs rdiff -u -r1.149 -r1.150 src/sys/kern/subr_prf.c

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

Modified files:

Index: src/sys/ddb/ddbvar.h
diff -u src/sys/ddb/ddbvar.h:1.10 src/sys/ddb/ddbvar.h:1.11
--- src/sys/ddb/ddbvar.h:1.10	Sun Feb 10 10:26:12 2013
+++ src/sys/ddb/ddbvar.h	Sun Feb 10 11:04:20 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: ddbvar.h,v 1.10 2013/02/10 10:26:12 apb Exp $	*/
+/*	$NetBSD: ddbvar.h,v 1.11 2013/02/10 11:04:20 apb Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -40,4 +40,6 @@ extern	int db_onpanic;
 extern	int db_fromconsole;
 extern	int db_tee_msgbuf;
 
+extern	void db_panic(void);
+
 #endif	/* !_DDBVAR_H_ */

Index: src/sys/kern/subr_prf.c
diff -u src/sys/kern/subr_prf.c:1.149 src/sys/kern/subr_prf.c:1.150
--- src/sys/kern/subr_prf.c:1.149	Mon Mar 12 19:21:07 2012
+++ src/sys/kern/subr_prf.c	Sun Feb 10 11:04:19 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_prf.c,v 1.149 2012/03/12 19:21:07 dholland Exp $	*/
+/*	$NetBSD: subr_prf.c,v 1.150 2013/02/10 11:04:19 apb Exp $	*/
 
 /*-
  * Copyright (c) 1986, 1988, 1991, 1993
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_prf.c,v 1.149 2012/03/12 19:21:07 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_prf.c,v 1.150 2013/02/10 11:04:19 apb Exp $");
 
 #include "opt_ddb.h"
 #include "opt_ipkdb.h"
@@ -68,13 +68,6 @@ __KERNEL_RCSID(0, "$NetBSD: subr_prf.c,v
 
 #include <net/if.h>
 
-#ifdef DDB
-#include <ddb/ddbvar.h>
-#include <machine/db_machdep.h>
-#include <ddb/db_command.h>
-#include <ddb/db_interface.h>
-#endif
-
 #ifdef IPKDB
 #include <ipkdb/ipkdb.h>
 #endif
@@ -85,7 +78,9 @@ static bool kprintf_inited = false;
 #ifdef KGDB
 #include <sys/kgdb.h>
 #endif
+
 #ifdef DDB
+#include <ddb/ddbvar.h>		/* db_panic */
 #include <ddb/db_output.h>	/* db_printf, db_putchar prototypes */
 #endif
 
@@ -284,26 +279,7 @@ vpanic(const char *fmt, va_list ap)
 		kdbpanic();
 #endif
 #ifdef DDB
-	if (db_onpanic == 1)
-		Debugger();
-	else if (db_onpanic >= 0) {
-		static int intrace = 0;
-
-		if (intrace == 0) {
-			intrace = 1;
-			printf("cpu%u: Begin traceback...\n",
-			    cpu_index(curcpu()));
-			db_stack_trace_print(
-			    (db_expr_t)(intptr_t)__builtin_frame_address(0),
-			    true, 65535, "", printf);
-			printf("cpu%u: End traceback...\n",
-			    cpu_index(curcpu()));
-			intrace = 0;
-		} else
-			printf("Faulted in mid-traceback; aborting...");
-		if (db_onpanic == 2)
-			Debugger();
-	}
+	db_panic();
 #endif
 	cpu_reboot(bootopt, NULL);
 }

Added files:

Index: src/sys/ddb/db_panic.c
diff -u /dev/null src/sys/ddb/db_panic.c:1.1
--- /dev/null	Sun Feb 10 11:04:20 2013
+++ src/sys/ddb/db_panic.c	Sun Feb 10 11:04:20 2013
@@ -0,0 +1,64 @@
+/*-
+ * Copyright (c) 2000, 2002, 2006, 2007, 2009, 2013 The NetBSD Foundation, Inc.
+ * 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.
+ *
+ * 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>
+__KERNEL_RCSID(0, "$NetBSD: db_panic.c,v 1.1 2013/02/10 11:04:20 apb Exp $");
+
+#include <sys/cpu.h>
+
+#include <ddb/ddbvar.h>
+#include <ddb/ddb.h>
+
+/*
+ * db_panic: Called by panic().  May print a stack trace; may enter the
+ * kernel debugger; may just return so that panic() will continue to
+ * halt or reboot the system.
+ */
+void db_panic(void)
+{
+
+	if (db_onpanic == 1)
+		Debugger();
+	else if (db_onpanic >= 0) {
+		static int intrace = 0;
+
+		if (intrace == 0) {
+			intrace = 1;
+			printf("cpu%u: Begin traceback...\n",
+			    cpu_index(curcpu()));
+			db_stack_trace_print(
+			    (db_expr_t)(intptr_t)__builtin_frame_address(0),
+			    true, 65535, "", printf);
+			printf("cpu%u: End traceback...\n",
+			    cpu_index(curcpu()));
+			intrace = 0;
+		} else
+			printf("Faulted in mid-traceback; aborting...");
+		if (db_onpanic == 2)
+			Debugger();
+	}
+	return;
+}

Reply via email to