From: Cristiano Giuffrida Date: Mon, 22 Mar 2010 22:46:29 +0000 (+0000) Subject: Print stacktrace when a system service fails or when a core dump has to be generated... X-Git-Tag: v3.1.7~213 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/jquery.js?a=commitdiff_plain;h=ef95bf1bb95a12a0ba034ada23332193415846ef;p=minix.git Print stacktrace when a system service fails or when a core dump has to be generated for a user process. --- diff --git a/include/signal.h b/include/signal.h index 3095c4f1b..eed41180f 100644 --- a/include/signal.h +++ b/include/signal.h @@ -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 diff --git a/servers/pm/signal.c b/servers/pm/signal.c index 33ca55d62..125566436 100644 --- a/servers/pm/signal.c +++ b/servers/pm/signal.c @@ -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 { diff --git a/servers/rs/main.c b/servers/rs/main.c index b1bb20390..aa48f68a4 100644 --- a/servers/rs/main.c +++ b/servers/rs/main.c @@ -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; diff --git a/servers/vm/pagefaults.c b/servers/vm/pagefaults.c index e2d8a7d76..080f28159 100644 --- a/servers/vm/pagefaults.c +++ b/servers/vm/pagefaults.c @@ -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)