Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch trap: move out info printing to trap_print() on amd...
details: https://anonhg.NetBSD.org/src/rev/f97fa87e5935
branches: trunk
changeset: 779949:f97fa87e5935
user: rmind <rmind%NetBSD.org@localhost>
date: Sat Jun 30 23:33:10 2012 +0000
description:
trap: move out info printing to trap_print() on amd64, reduce the differences
between amd64 and i386, add lowest kernel stack address.
diffstat:
sys/arch/amd64/amd64/trap.c | 45 ++++++++++++++++++++++++++-------------------
sys/arch/i386/i386/trap.c | 38 +++++++++++++++++++++-----------------
2 files changed, 47 insertions(+), 36 deletions(-)
diffs (162 lines):
diff -r e7268bb388aa -r f97fa87e5935 sys/arch/amd64/amd64/trap.c
--- a/sys/arch/amd64/amd64/trap.c Sat Jun 30 22:50:36 2012 +0000
+++ b/sys/arch/amd64/amd64/trap.c Sat Jun 30 23:33:10 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: trap.c,v 1.71 2012/05/22 21:14:37 dsl Exp $ */
+/* $NetBSD: trap.c,v 1.72 2012/06/30 23:33:10 rmind Exp $ */
/*-
* Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.71 2012/05/22 21:14:37 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.72 2012/06/30 23:33:10 rmind Exp $");
#include "opt_ddb.h"
#include "opt_kgdb.h"
@@ -184,6 +184,27 @@
return NULL;
}
+static void
+trap_print(const struct trapframe *frame, const lwp_t *l)
+{
+ const int type = frame->tf_trapno;
+
+ if (frame->tf_trapno < trap_types) {
+ printf("fatal %s", trap_type[type]);
+ } else {
+ printf("unknown trap %d", type);
+ }
+ printf(" in %s mode\n", (type & T_USER) ? "user" : "supervisor");
+
+ printf("trap type %d code %lx rip %lx cs %lx rflags %lx cr2 %lx "
+ "ilevel %x rsp %lx\n",
+ type, frame->tf_err, (u_long)frame->tf_rip, frame->tf_cs,
+ frame->tf_rflags, rcr2(), curcpu()->ci_ilevel, frame->tf_rsp);
+
+ printf("curlwp %p pid %d lid %d lowest kstack %p\n",
+ l, l->l_proc->p_pid, l->l_lid, KSTACK_LOWEST_ADDR(l));
+}
+
/*
* trap(frame): exception, fault, and trap interface to BSD kernel.
*
@@ -192,7 +213,6 @@
* exception has been processed. Note that the effect is as if the arguments
* were passed call by reference.
*/
-
void
trap(struct trapframe *frame)
{
@@ -226,13 +246,7 @@
#ifdef DEBUG
if (trapdebug) {
- printf("trap %d code %lx eip %lx cs %lx rflags %lx cr2 %lx "
- "cpl %x\n",
- type, frame->tf_err, frame->tf_rip, frame->tf_cs,
- frame->tf_rflags, rcr2(), curcpu()->ci_ilevel);
- printf("curlwp %p%s", curlwp, curlwp ? " " : "\n");
- if (curlwp)
- printf("pid %d lid %d\n", l->l_proc->p_pid, l->l_lid);
+ trap_print(frame, l);
}
#endif
if (type != T_NMI && !KERNELMODE(frame->tf_cs, frame->tf_rflags)) {
@@ -266,15 +280,8 @@
default:
we_re_toast:
- if (frame->tf_trapno < trap_types)
- printf("fatal %s", trap_type[frame->tf_trapno]);
- else
- printf("unknown trap %ld", (u_long)frame->tf_trapno);
- printf(" in %s mode\n", (type & T_USER) ? "user" : "supervisor");
- printf("trap type %d code %lx rip %lx cs %lx rflags %lx cr2 "
- " %lx cpl %x rsp %lx\n",
- type, frame->tf_err, (u_long)frame->tf_rip, frame->tf_cs,
- frame->tf_rflags, rcr2(), curcpu()->ci_ilevel, frame->tf_rsp);
+ trap_print(frame, l);
+
if (kdb_trap(type, 0, frame))
return;
if (kgdb_trap(type, frame))
diff -r e7268bb388aa -r f97fa87e5935 sys/arch/i386/i386/trap.c
--- a/sys/arch/i386/i386/trap.c Sat Jun 30 22:50:36 2012 +0000
+++ b/sys/arch/i386/i386/trap.c Sat Jun 30 23:33:10 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: trap.c,v 1.263 2012/02/19 21:06:11 rmind Exp $ */
+/* $NetBSD: trap.c,v 1.264 2012/06/30 23:33:10 rmind Exp $ */
/*-
* Copyright (c) 1998, 2000, 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.263 2012/02/19 21:06:11 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.264 2012/06/30 23:33:10 rmind Exp $");
#include "opt_ddb.h"
#include "opt_kgdb.h"
@@ -262,16 +262,24 @@
}
static void
-trap_print(int type, struct trapframe *frame)
+trap_print(const struct trapframe *frame, const lwp_t *l)
{
- if (frame->tf_trapno < trap_types)
- printf("fatal %s", trap_type[frame->tf_trapno]);
- else
- printf("unknown trap %d", frame->tf_trapno);
+ const int type = frame->tf_trapno;
+
+ if (frame->tf_trapno < trap_types) {
+ printf("fatal %s", trap_type[type]);
+ } else {
+ printf("unknown trap %d", type);
+ }
printf(" in %s mode\n", (type & T_USER) ? "user" : "supervisor");
- printf("trap type %d code %x eip %x cs %x eflags %x cr2 %lx ilevel %x\n",
- type, frame->tf_err, frame->tf_eip, frame->tf_cs,
- frame->tf_eflags, (long)rcr2(), curcpu()->ci_ilevel);
+
+ printf("trap type %d code %x eip %x cs %x eflags %x cr2 %lx "
+ "ilevel %x esp %x\n",
+ type, frame->tf_err, frame->tf_eip, frame->tf_cs, frame->tf_eflags,
+ (long)rcr2(), curcpu()->ci_ilevel, frame->tf_esp);
+
+ printf("curlwp %p pid %d lid %d lowest kstack %p\n",
+ l, l->l_proc->p_pid, l->l_lid, KSTACK_LOWEST_ADDR(l));
}
static void
@@ -329,12 +337,7 @@
#ifdef DEBUG
if (trapdebug) {
- printf("trap %d code %x eip %x cs %x eflags %x cr2 %lx cpl %x\n",
- type, frame->tf_err, frame->tf_eip, frame->tf_cs,
- frame->tf_eflags, rcr2(), curcpu()->ci_ilevel);
- printf("curlwp %p%s", curlwp, curlwp ? " " : "\n");
- if (curlwp)
- printf("pid %d lid %d\n", l->l_proc->p_pid, l->l_lid);
+ trap_print(frame, l);
}
#endif
if (type != T_NMI && !KVM86MODE &&
@@ -379,7 +382,8 @@
if (type == T_TRCTRAP)
check_dr0();
else
- trap_print(type, frame);
+ trap_print(frame, l);
+
if (kdb_trap(type, 0, frame))
return;
if (kgdb_trap(type, frame))
Home |
Main Index |
Thread Index |
Old Index