diff options
author | Ed Maste <emaste@FreeBSD.org> | 2017-10-27 14:26:03 +0000 |
---|---|---|
committer | Ed Maste <emaste@FreeBSD.org> | 2023-08-05 23:18:35 +0000 |
commit | 6edbe5616c761bff9e570d9c77db0644a9487174 (patch) | |
tree | 7d57c6bfc1b535ea0ee7f260a32d425756785d80 | |
parent | 6f15b7e199527e50aa459340607ff98bbff8e905 (diff) | |
download | src-6edbe5616c761bff9e570d9c77db0644a9487174.tar.gz src-6edbe5616c761bff9e570d9c77db0644a9487174.zip |
Provide some more information for userland core dumps
Previously the log message indicated only "(core dumped)" if a core was
successfully created, or nothing if it was not. This provides
insufficient information to faciliate debugging. Dtrace is no help as
coredump() is static and we cannot find the return value via fbt.
Expand the log message to include error return value information.
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D39942
-rw-r--r-- | sys/kern/kern_sig.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index 5876e2e93920..df3ebc0103c4 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -3598,6 +3598,8 @@ void sigexit(struct thread *td, int sig) { struct proc *p = td->td_proc; + const char *coreinfo; + int rv; PROC_LOCK_ASSERT(p, MA_OWNED); proc_set_p2_wexit(p); @@ -3622,16 +3624,31 @@ sigexit(struct thread *td, int sig) * XXX : Todo, as well as euid, write out ruid too * Note that coredump() drops proc lock. */ - if (coredump(td) == 0) + rv = coredump(td); + switch (rv) { + case 0: sig |= WCOREFLAG; + coreinfo = " (core dumped)"; + break; + case EFAULT: + coreinfo = " (no core dump - bad address)"; + break; + case EINVAL: + coreinfo = " (no core dump - invalid argument)"; + break; + case EFBIG: + coreinfo = " (no core dump - too large)"; + break; + default: + coreinfo = " (no core dump - other error)"; + } if (kern_logsigexit) log(LOG_INFO, "pid %d (%s), jid %d, uid %d: exited on " "signal %d%s\n", p->p_pid, p->p_comm, p->p_ucred->cr_prison->pr_id, td->td_ucred->cr_uid, - sig &~ WCOREFLAG, - sig & WCOREFLAG ? " (core dumped)" : ""); + sig &~ WCOREFLAG, coreinfo); } else PROC_UNLOCK(p); exit1(td, 0, sig); |