Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Move the DDB-specific part of vpanic() to a new db_panic...
details: https://anonhg.NetBSD.org/src/rev/b4e4413b2b7d
branches: trunk
changeset: 784806:b4e4413b2b7d
user: apb <apb%NetBSD.org@localhost>
date: Sun Feb 10 11:04:19 2013 +0000
description:
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"
diffstat:
sys/ddb/db_panic.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++
sys/ddb/ddbvar.h | 4 ++-
sys/kern/subr_prf.c | 34 ++++------------------------
3 files changed, 72 insertions(+), 30 deletions(-)
diffs (154 lines):
diff -r c91c30fed66f -r b4e4413b2b7d sys/ddb/db_panic.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/ddb/db_panic.c Sun Feb 10 11:04:19 2013 +0000
@@ -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;
+}
diff -r c91c30fed66f -r b4e4413b2b7d sys/ddb/ddbvar.h
--- a/sys/ddb/ddbvar.h Sun Feb 10 10:26:12 2013 +0000
+++ b/sys/ddb/ddbvar.h Sun Feb 10 11:04:19 2013 +0000
@@ -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_fromconsole;
extern int db_tee_msgbuf;
+extern void db_panic(void);
+
#endif /* !_DDBVAR_H_ */
diff -r c91c30fed66f -r b4e4413b2b7d sys/kern/subr_prf.c
--- a/sys/kern/subr_prf.c Sun Feb 10 10:26:12 2013 +0000
+++ b/sys/kern/subr_prf.c Sun Feb 10 11:04:19 2013 +0000
@@ -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 @@
#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 @@
#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 @@
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);
}
Home |
Main Index |
Thread Index |
Old Index