git: 6edbe5616c76 - main - Provide some more information for userland core dumps
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 05 Aug 2023 23:18:46 UTC
The branch main has been updated by emaste:
URL: https://cgit.FreeBSD.org/src/commit/?id=6edbe5616c761bff9e570d9c77db0644a9487174
commit 6edbe5616c761bff9e570d9c77db0644a9487174
Author: Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2017-10-27 14:26:03 +0000
Commit: Ed Maste <emaste@FreeBSD.org>
CommitDate: 2023-08-05 23:18:35 +0000
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
---
sys/kern/kern_sig.c | 23 ++++++++++++++++++++---
1 file 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);