waitid(2) and __thrsigdivert(2) and teach kdump(1) to handle them.
Also report more from the siginfo_t inside PSIG tracepoints.
ok mpi@
-/* $OpenBSD: kern_exit.c,v 1.209 2022/12/19 00:22:12 guenther Exp $ */
+/* $OpenBSD: kern_exit.c,v 1.210 2022/12/29 01:36:36 guenther Exp $ */
/* $NetBSD: kern_exit.c,v 1.39 1996/04/22 01:38:25 christos Exp $ */
/*
error = dowait6(q, idtype, SCARG(uap, id), NULL,
options, NULL, &info, retval);
- if (error == 0)
+ if (error == 0) {
error = copyout(&info, SCARG(uap, info), sizeof(info));
+#ifdef KTRACE
+ if (error == 0 && KTRPOINT(q, KTR_STRUCT))
+ ktrsiginfo(q, &info);
+#endif
+ }
if (error == 0)
*retval = 0;
return (error);
-/* $OpenBSD: kern_sig.c,v 1.301 2022/10/16 16:27:02 deraadt Exp $ */
+/* $OpenBSD: kern_sig.c,v 1.302 2022/12/29 01:36:36 guenther Exp $ */
/* $NetBSD: kern_sig.c,v 1.54 1996/04/22 01:38:32 christos Exp $ */
/*
if (error == 0) {
*retval = si.si_signo;
- if (SCARG(uap, info) != NULL)
+ if (SCARG(uap, info) != NULL) {
error = copyout(&si, SCARG(uap, info), sizeof(si));
+#ifdef KTRACE
+ if (error == 0 && KTRPOINT(p, KTR_STRUCT))
+ ktrsiginfo(p, &si);
+#endif
+ }
} else if (error == ERESTART && SCARG(uap, timeout) != NULL) {
/*
* Restarting is wrong if there's a timeout, as it'll be
-/* $OpenBSD: ktrace.h,v 1.42 2022/09/02 13:18:07 mbuhl Exp $ */
+/* $OpenBSD: ktrace.h,v 1.43 2022/12/29 01:36:36 guenther Exp $ */
/* $NetBSD: ktrace.h,v 1.12 1996/02/04 02:12:29 christos Exp $ */
/*
ktrstruct(p, "fds", fds, (count) * sizeof(int))
#define ktrflock(p, fl) \
ktrstruct(p, "flock", (fl), sizeof(struct flock))
+#define ktrsiginfo(p, si) \
+ ktrstruct(p, "siginfo", (si), sizeof(siginfo_t))
#endif /* !_KERNEL */
-/* $OpenBSD: kdump.c,v 1.152 2022/12/20 21:44:19 guenther Exp $ */
+/* $OpenBSD: kdump.c,v 1.153 2022/12/29 01:36:36 guenther Exp $ */
/*-
* Copyright (c) 1988, 1993
showbuf(dp, datalen);
}
-static void
-ktrpsig(struct ktr_psig *psig)
+void
+siginfo(const siginfo_t *si, int show_signo)
{
- signame(psig->signo);
- printf(" ");
- if (psig->action == SIG_DFL)
- (void)printf("SIG_DFL");
- else {
- (void)printf("caught handler=0x%lx mask=",
- (u_long)psig->action);
- sigset(psig->mask);
+ if (show_signo) {
+ printf("signo=");
+ signame(si->si_signo);
}
- if (psig->code) {
- printf(" code ");
- if (fancy) {
- switch (psig->signo) {
+ if (si->si_code) {
+ printf(" code=");
+ if (!fancy)
+ printf("<%d>", si->si_code);
+ else {
+ switch (si->si_signo) {
case SIGILL:
- sigill_name(psig->code);
+ sigill_name(si->si_code);
break;
case SIGTRAP:
- sigtrap_name(psig->code);
+ sigtrap_name(si->si_code);
break;
case SIGEMT:
- sigemt_name(psig->code);
+ sigemt_name(si->si_code);
break;
case SIGFPE:
- sigfpe_name(psig->code);
+ sigfpe_name(si->si_code);
break;
case SIGBUS:
- sigbus_name(psig->code);
+ sigbus_name(si->si_code);
break;
case SIGSEGV:
- sigsegv_name(psig->code);
+ sigsegv_name(si->si_code);
break;
case SIGCHLD:
- sigchld_name(psig->code);
+ sigchld_name(si->si_code);
+ break;
+ default:
+ printf("<%d>", si->si_code);
break;
}
}
- printf("<%d>", psig->code);
}
- switch (psig->signo) {
+ switch (si->si_signo) {
case SIGSEGV:
case SIGILL:
case SIGBUS:
case SIGFPE:
- printf(" addr=%p trapno=%d", psig->si.si_addr,
- psig->si.si_trapno);
+ printf(" addr=%p trapno=%d", si->si_addr, si->si_trapno);
+ break;
+ case SIGCHLD:
+ if (si->si_code == CLD_EXITED) {
+ printf(" status=%d", si->si_status);
+ if (si->si_status < 0 || si->si_status > 9)
+ (void)printf("/%#x", si->si_status);
+ } else {
+ printf(" status=");
+ signame(si->si_status);
+ }
+ printf(" pid=%d uid=", si->si_pid);
+ uidname(si->si_uid);
break;
default:
break;
}
- printf("\n");
+}
+
+static void
+ktrpsig(struct ktr_psig *psig)
+{
+ signame(psig->signo);
+ printf(" ");
+ if (psig->action == SIG_DFL)
+ printf("SIG_DFL");
+ else {
+ printf("caught handler=0x%lx mask=", (u_long)psig->action);
+ sigset(psig->mask);
+ }
+ siginfo(&psig->si, 0);
+ putchar('\n');
}
static void
/* kdump.c */
void sigset(int);
void showbufc(int _column, unsigned char *_dp, size_t _len, int _flags);
+void siginfo(const siginfo_t *_si, int _show_signo);
/* ktrstruct.c */
void ktrstruct(char *, size_t);
-/* $OpenBSD: ktrstruct.c,v 1.30 2022/09/08 16:04:31 mbuhl Exp $ */
+/* $OpenBSD: ktrstruct.c,v 1.31 2022/12/29 01:36:36 guenther Exp $ */
/*-
* Copyright (c) 1988, 1993
printf(" }\n");
}
+static void
+ktrsiginfo(const siginfo_t *si)
+{
+ printf("siginfo_t { ");
+ siginfo(si, 1);
+ printf(" }\n");
+}
+
void
ktrstruct(char *buf, size_t buflen)
{
goto invalid;
memcpy(&fl, data, datalen);
ktrflock(&fl);
+ } else if (strcmp(name, "siginfo") == 0) {
+ siginfo_t si;
+
+ if (datalen != sizeof(si))
+ goto invalid;
+ memcpy(&si, data, datalen);
+ ktrsiginfo(&si);
} else {
printf("unknown structure %s\n", name);
}