ill handler

Link to this paste: http://bugs.dragonflybsd.org/pastes/23

Added by tuxillo over 2 years ago.
Syntax: Plain Text

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
diff --git a/sys/platform/vkernel64/x86_64/exception.c b/sys/platform/vkernel64/x86_64/exception.c
index e7c240f..c67fff8 100644
--- a/sys/platform/vkernel64/x86_64/exception.c
+++ b/sys/platform/vkernel64/x86_64/exception.c
@@ -64,7 +64,7 @@ static void exc_segfault(int signo, siginfo_t *info, void *ctx);
 #ifdef DDB
 static void exc_debugger(int signo, siginfo_t *info, void *ctx);
 #endif
-
+static void exc_illdebug(int signo, siginfo_t *info, void *ctx);
 #ifdef SMP

 /*
@@ -176,6 +176,9 @@ init_exceptions(void)

        sa.sa_flags &= ~SA_NODEFER;

+       sa.sa_sigaction = exc_illdebug;
+       sigaction(SIGILL, &sa, NULL);
+
 #ifdef DDB
        sa.sa_sigaction = exc_debugger;
        sigaction(SIGQUIT, &sa, NULL);
@@ -228,3 +231,20 @@ exc_debugger(int signo, siginfo_t *info, void *ctx)
 }

 #endif
+
+static void
+exc_illdebug(int signo, siginfo_t *info, void *ctxp)
+{
+        ucontext_t *ctx = ctxp;
+
+       kprintf("CAUGHT SIG %d RIP %08lx ERR %08lx TRAPNO %ld "
+               "err %ld addr %08lx\n",
+               signo,
+               ctx->uc_mcontext.mc_rip,
+               ctx->uc_mcontext.mc_err,
+               ctx->uc_mcontext.mc_trapno & 0xFFFF,
+               ctx->uc_mcontext.mc_trapno >> 16,
+               ctx->uc_mcontext.mc_addr);
+
+       print_backtrace(-1);
+}

Download