]> Zhao Yanbai Git Server - minix.git/commitdiff
Print stacktrace when a system service fails or when a core dump has to be generated...
authorCristiano Giuffrida <cristiano@minix3.org>
Mon, 22 Mar 2010 22:46:29 +0000 (22:46 +0000)
committerCristiano Giuffrida <cristiano@minix3.org>
Mon, 22 Mar 2010 22:46:29 +0000 (22:46 +0000)
include/signal.h
servers/pm/signal.c
servers/rs/main.c
servers/vm/pagefaults.c

index 3095c4f1b32bdaea5cbb373dbe5d40927b76daae..eed41180f161e12d1203eb73ca8239a74f3efe27 100644 (file)
@@ -84,6 +84,7 @@ typedef unsigned long sigset_t;
     || sig == SIGEMT || sig == SIGABRT)
 #define SIGS_IS_TERMINATION(sig) (SIGS_IS_LETHAL(sig) \
     || (sig == SIGKILL || sig == SIGPIPE))
+#define SIGS_IS_STACKTRACE(sig) (SIGS_IS_LETHAL(sig) && sig != SIGABRT)
 
 #endif
 
index 33ca55d62feffa57d13b1f1b3b3d41be886fe7f3..125566436b51b53b399cbed13f67177f1a5d1906 100644 (file)
@@ -364,6 +364,12 @@ int ksig;                  /* non-zero means signal comes from kernel  */
                sys_kill(rmp->mp_endpoint, signo);
                return;
        }
+
+       /* Print stacktrace if necessary. */
+       if(SIGS_IS_STACKTRACE(signo)) {
+               sys_sysctl_stacktrace(rmp->mp_endpoint);
+       }
+
        if(!SIGS_IS_TERMINATION(signo)) {
                /* Translate every non-termination sys signal into a message. */
                message m;
@@ -443,8 +449,11 @@ int signo;                 /* signal that caused termination */
 {
   rmp->mp_sigstatus = (char) signo;
   if (sigismember(&core_sset, signo)) {
-       printf("PM: coredump signal %d for %d / %s\n", signo, rmp->mp_pid,
-               rmp->mp_name);
+       if(!(rmp->mp_flags & PRIV_PROC)) {
+               printf("PM: coredump signal %d for %d / %s\n", signo,
+                       rmp->mp_pid, rmp->mp_name);
+               sys_sysctl_stacktrace(rmp->mp_endpoint);
+       }
        exit_proc(rmp, 0, TRUE /*dump_core*/);
   }
   else {
index b1bb20390febe5c23321c32727a3d5413ed0fb41..aa48f68a485f6a82e7597a3dfbcc11c36d79d403 100644 (file)
@@ -521,6 +521,11 @@ PRIVATE int sef_cb_signal_manager(endpoint_t target, int signo)
       printf("RS: %s got %s signal %d\n", srv_to_string(rp),
           SIGS_IS_TERMINATION(signo) ? "termination" : "non-termination",signo);
 
+  /* Print stacktrace if necessary. */
+  if(SIGS_IS_STACKTRACE(signo)) {
+       sys_sysctl_stacktrace(target);
+  }
+
   /* In case of termination signal handle the event. */
   if(SIGS_IS_TERMINATION(signo)) {
       rp->r_flags |= RS_TERMINATED;
index e2d8a7d76ec04060dff54936e05b14b0b304e4ae..080f281594300baafd683201c4984728fd0d4486 100644 (file)
@@ -73,7 +73,6 @@ PUBLIC void do_pagefaults(void)
                        vm_assert(PFERR_NOPAGE(err));
                        printf("VM: pagefault: SIGSEGV %d bad addr 0x%lx %s\n", 
                                ep, arch_map2vir(vmp, addr), pf_errstr(err));
-                       sys_sysctl_stacktrace(vmp->vm_endpoint);
                        if((s=sys_kill(vmp->vm_endpoint, SIGSEGV)) != OK)
                                panic("sys_kill failed: %d", s);
                        if((s=sys_vmctl(ep, VMCTL_CLEAR_PAGEFAULT, r)) != OK)
@@ -95,7 +94,6 @@ PUBLIC void do_pagefaults(void)
                if(!(region->flags & VR_WRITABLE) && wr) {
                        printf("VM: pagefault: SIGSEGV %d ro map 0x%lx %s\n", 
                                ep, arch_map2vir(vmp, addr), pf_errstr(err));
-                       sys_sysctl_stacktrace(vmp->vm_endpoint);
                        if((s=sys_kill(vmp->vm_endpoint, SIGSEGV)) != OK)
                                panic("sys_kill failed: %d", s);
                        if((s=sys_vmctl(ep, VMCTL_CLEAR_PAGEFAULT, r)) != OK)
@@ -109,7 +107,6 @@ PUBLIC void do_pagefaults(void)
                /* Access is allowed; handle it. */
                if((r=map_pf(vmp, region, offset, wr)) != OK) {
                        printf("VM: pagefault: SIGSEGV %d pagefault not handled\n", ep);
-                       sys_sysctl_stacktrace(vmp->vm_endpoint);
                        if((s=sys_kill(vmp->vm_endpoint, SIGSEGV)) != OK)
                                panic("sys_kill failed: %d", s);
                        if((s=sys_vmctl(ep, VMCTL_CLEAR_PAGEFAULT, r)) != OK)