Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/x86_64/x86_64 Add some optional debug goop.



details:   https://anonhg.NetBSD.org/src/rev/af4a2582069b
branches:  trunk
changeset: 542468:af4a2582069b
user:      fvdl <fvdl%NetBSD.org@localhost>
date:      Thu Jan 30 02:03:35 2003 +0000

description:
Add some optional debug goop.

diffstat:

 sys/arch/x86_64/x86_64/trap.c |  36 +++++++++++++++++++++++++++++++++++-
 1 files changed, 35 insertions(+), 1 deletions(-)

diffs (73 lines):

diff -r 7cd771b76b09 -r af4a2582069b sys/arch/x86_64/x86_64/trap.c
--- a/sys/arch/x86_64/x86_64/trap.c     Thu Jan 30 02:02:51 2003 +0000
+++ b/sys/arch/x86_64/x86_64/trap.c     Thu Jan 30 02:03:35 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: trap.c,v 1.9 2003/01/26 00:05:39 fvdl Exp $    */
+/*     $NetBSD: trap.c,v 1.10 2003/01/30 02:03:35 fvdl Exp $   */
 
 /*-
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -150,6 +150,10 @@
 
 #define        IDTVEC(name)    __CONCAT(X, name)
 
+#ifdef DEBUG
+static void frame_dump(struct trapframe *);
+#endif
+
 /*
  * trap(frame):
  *     Exception, fault, and trap interface to BSD kernel. This
@@ -305,11 +309,19 @@
        case T_NMI|T_USER:
                printf("pid %d (%s): BUS at rip %lx addr %lx\n",
                    p->p_pid, p->p_comm, frame.tf_rip, rcr2());
+#ifdef DEBUG
+               frame_dump(&frame);
+#endif
                (*p->p_emul->e_trapsignal)(l, SIGBUS, type & ~T_USER);
                goto out;
 
        case T_PRIVINFLT|T_USER:        /* privileged instruction fault */
        case T_FPOPFLT|T_USER:          /* coprocessor operand fault */
+               printf("pid %d (%s): ILL at rip %lx addr %lx\n",
+                   p->p_pid, p->p_comm, frame.tf_rip, rcr2());
+#ifdef DEBUG
+               frame_dump(&frame);
+#endif
                (*p->p_emul->e_trapsignal)(l, SIGILL, type & ~T_USER);
                goto out;
 
@@ -441,6 +453,9 @@
 #if 1
                        printf("pid %d (%s): SEGV at rip %lx addr %lx\n",
                            p->p_pid, p->p_comm, frame.tf_rip, va);
+#ifdef DEBUG
+                       frame_dump(&frame);
+#endif
 #endif
                        (*p->p_emul->e_trapsignal)(l, SIGSEGV, T_PAGEFLT);
                }
@@ -513,3 +528,22 @@
 {
        userret(l);
 }
+
+#ifdef DEBUG
+static void
+frame_dump(struct trapframe *tf)
+{
+       printf("rip %p  rsp %p  rfl %p\n",
+           (void *)tf->tf_rip, (void *)tf->tf_rsp, (void *)tf->tf_rflags);
+       printf("rdi %p  rsi %p  rdx %p\n",
+           (void *)tf->tf_rdi, (void *)tf->tf_rsi, (void *)tf->tf_rdx);
+       printf("rcx %p  r8  %p  r9  %p\n",
+           (void *)tf->tf_rcx, (void *)tf->tf_r8, (void *)tf->tf_r9);
+       printf("r10 %p  r11 %p  r12 %p\n",
+           (void *)tf->tf_r10, (void *)tf->tf_r11, (void *)tf->tf_r12);
+       printf("r13 %p  r14 %p  r15 %p\n",
+           (void *)tf->tf_r13, (void *)tf->tf_r14, (void *)tf->tf_r15);
+       printf("rbp %p  rbx %p  rax %p\n",
+           (void *)tf->tf_rbp, (void *)tf->tf_rbx, (void *)tf->tf_rax);
+}
+#endif



Home | Main Index | Thread Index | Old Index