C runtime: enable extended error reporting from kernel

Reviewed by:	brooks
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D50483
This commit is contained in:
Konstantin Belousov 2025-05-23 08:02:41 +03:00
parent 7212b37345
commit b9c8a07d4d
5 changed files with 26 additions and 0 deletions

View file

@ -159,6 +159,7 @@ SRCS+= \
ttyname.c \
ttyslot.c \
ualarm.c \
uexterr_gettext.c \
ulimit.c \
uname.c \
unvis-compat.c \

View file

@ -0,0 +1,15 @@
#include <sys/types.h>
#include <sys/exterrvar.h>
#include <exterr.h>
#include <string.h>
static struct uexterror uexterr = {
.ver = UEXTERROR_VER,
};
static void uexterr_ctr(void) __attribute__((constructor));
static void
uexterr_ctr(void)
{
exterrctl(EXTERRCTL_ENABLE, 0, &uexterr);
}

View file

@ -31,6 +31,7 @@
#include <sys/types.h>
#include <sys/rtprio.h>
#include <sys/signalvar.h>
#include <sys/exterrvar.h>
#include <errno.h>
#include <link.h>
#include <stdlib.h>
@ -285,6 +286,9 @@ thread_start(struct pthread *curthread)
curthread->attr.stacksize_attr;
#endif
curthread->uexterr.ver = UEXTERROR_VER;
exterrctl(EXTERRCTL_ENABLE, 0, &curthread->uexterr);
/* Run the current thread's start routine with argument: */
_pthread_exit(curthread->start_routine(curthread->arg));

View file

@ -433,6 +433,9 @@ init_main_thread(struct pthread *thread)
thread->unwind_stackend = _usrstack;
#endif
thread->uexterr.ver = UEXTERROR_VER;
exterrctl(EXTERRCTL_ENABLE, EXTERRCTLF_FORCE, &thread->uexterr);
/* Others cleared to zero by thr_alloc() */
}

View file

@ -40,6 +40,7 @@
#include <sys/queue.h>
#include <sys/param.h>
#include <sys/cpuset.h>
#include <sys/exterrvar.h>
#include <machine/atomic.h>
#include <errno.h>
#include <limits.h>
@ -576,6 +577,8 @@ struct pthread {
/* pthread_set/get_name_np */
char *name;
struct uexterror uexterr;
};
#define THR_SHOULD_GC(thrd) \