Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/usermode/usermode Enhance debugging capabilities of...



details:   https://anonhg.NetBSD.org/src/rev/6464c91670b9
branches:  trunk
changeset: 769157:6464c91670b9
user:      reinoud <reinoud%NetBSD.org@localhost>
date:      Thu Sep 01 15:03:41 2011 +0000

description:
Enhance debugging capabilities of NetBSD/usermode by allowing `trap.c' to
write a system image of the memory it traps. Its extremely dirty but at least
you can look at the data and code thats giving the trouble. Its memory or
state is NOT saved in the coredump of the NetBSD/usermode program.

diffstat:

 sys/arch/usermode/usermode/trap.c |  19 +++++++++++--------
 1 files changed, 11 insertions(+), 8 deletions(-)

diffs (56 lines):

diff -r 05601480dd6f -r 6464c91670b9 sys/arch/usermode/usermode/trap.c
--- a/sys/arch/usermode/usermode/trap.c Thu Sep 01 14:55:58 2011 +0000
+++ b/sys/arch/usermode/usermode/trap.c Thu Sep 01 15:03:41 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: trap.c,v 1.14 2011/08/31 12:42:41 reinoud Exp $ */
+/* $NetBSD: trap.c,v 1.15 2011/09/01 15:03:41 reinoud Exp $ */
 
 /*-
  * Copyright (c) 2011 Reinoud Zandijk <reinoud%netbsd.org@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.14 2011/08/31 12:42:41 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.15 2011/09/01 15:03:41 reinoud Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -85,6 +85,8 @@
 mem_access_handler(int sig, siginfo_t *info, void *ctx)
 {
        static volatile int recurse = 0;
+       static vaddr_t old_va, old_old_va = 0;
+
        struct proc *p;
        struct lwp *l;
        struct pcb *pcb;
@@ -106,7 +108,7 @@
                onfault = pcb->pcb_onfault;
                vm = p->p_vmspace;
 
-#if 0
+#if 1
                va = (vaddr_t) info->si_addr;
                printf("trap lwp = %p pid = %d lid = %d, va = %p\n",
                    curlwp,
@@ -163,13 +165,14 @@
                }
 
 #if 0
-//if (!rv) {
-//     static int off = 0;
-       printf("*va = %d\n", *((uint32_t *) va));
+       if (old_old_va)
+               thunk_pwrite(debug_fh, (void *) old_old_va, PAGE_SIZE, old_old_va);
+       if (old_va)
+               thunk_pwrite(debug_fh, (void *) old_va, PAGE_SIZE, old_va);
        thunk_pwrite(debug_fh, (void *) va, PAGE_SIZE, va);
-//     off += PAGE_SIZE;
-//}
 #endif
+       old_old_va = old_va;
+       old_va = va;
 
                if (rv) {
                        aprint_debug("uvm_fault returned error %d\n", rv);



Home | Main Index | Thread Index | Old Index