mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
Only catch SIGINFO (for dumping thread states) when LIBPTHREAD_DEBUG
is defined in the environment. Requested by: jmg & a few others
This commit is contained in:
parent
c322e13c55
commit
4f0d668324
6 changed files with 56 additions and 32 deletions
|
|
@ -518,6 +518,8 @@ init_private(void)
|
|||
else if (getenv("LIBPTHREAD_PROCESS_SCOPE") != NULL)
|
||||
_thread_scope_system = -1;
|
||||
#endif
|
||||
if (getenv("LIBPTHREAD_DEBUG") != NULL)
|
||||
_thr_debug_flags |= DBG_INFO_DUMP;
|
||||
|
||||
/*
|
||||
* _thread_list_lock and _kse_count are initialized
|
||||
|
|
|
|||
|
|
@ -82,6 +82,7 @@
|
|||
|
||||
#define DBG_MUTEX 0x0001
|
||||
#define DBG_SIG 0x0002
|
||||
#define DBG_INFO_DUMP 0x0004
|
||||
|
||||
#ifdef _PTHREADS_INVARIANTS
|
||||
#define THR_ASSERT(cond, msg) do { \
|
||||
|
|
|
|||
|
|
@ -98,6 +98,12 @@ static int sigproptbl[NSIG] = {
|
|||
#define DBG_MSG(x...)
|
||||
#endif
|
||||
|
||||
static __inline int
|
||||
_thr_dump_enabled(void)
|
||||
{
|
||||
return ((_thr_debug_flags & DBG_INFO_DUMP) != 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Signal setup and delivery.
|
||||
*
|
||||
|
|
@ -253,7 +259,7 @@ _thr_sig_dispatch(struct kse *curkse, int sig, siginfo_t *info)
|
|||
DBG_MSG(">>> _thr_sig_dispatch(%d)\n", sig);
|
||||
|
||||
/* Check if the signal requires a dump of thread information: */
|
||||
if (sig == SIGINFO) {
|
||||
if (_thr_dump_enabled() && (sig == SIGINFO)) {
|
||||
/* Dump thread information to file: */
|
||||
_thread_dump_info();
|
||||
}
|
||||
|
|
@ -347,7 +353,7 @@ _thr_sig_handler(int sig, siginfo_t *info, ucontext_t *ucp)
|
|||
}
|
||||
|
||||
/* Check if the signal requires a dump of thread information: */
|
||||
if (sig == SIGINFO) {
|
||||
if (_thr_dump_enabled() && (sig == SIGINFO)) {
|
||||
/* Dump thread information to file: */
|
||||
_thread_dump_info();
|
||||
}
|
||||
|
|
@ -521,7 +527,7 @@ handle_signal(struct pthread *curthread, struct sighandle_info *shi)
|
|||
_kse_critical_leave(&curthread->tcb->tcb_tmbx);
|
||||
|
||||
/* Check if the signal requires a dump of thread information: */
|
||||
if (shi->sig == SIGINFO) {
|
||||
if (_thr_dump_enabled() && (shi->sig == SIGINFO)) {
|
||||
/* Dump thread information to file: */
|
||||
_thread_dump_info();
|
||||
}
|
||||
|
|
@ -1200,21 +1206,24 @@ _thr_signal_init(void)
|
|||
__sys_sigaction(i, &act, NULL);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Install the signal handler for SIGINFO. It isn't
|
||||
* really needed, but it is nice to have for debugging
|
||||
* purposes.
|
||||
*/
|
||||
_thread_sigact[SIGINFO - 1].sa_flags = SA_SIGINFO | SA_RESTART;
|
||||
SIGEMPTYSET(act.sa_mask);
|
||||
act.sa_flags = SA_SIGINFO | SA_RESTART;
|
||||
act.sa_sigaction = (__siginfohandler_t *)&_thr_sig_handler;
|
||||
if (__sys_sigaction(SIGINFO, &act, NULL) != 0) {
|
||||
__sys_sigprocmask(SIG_SETMASK, &_thr_initial->sigmask, NULL);
|
||||
if (_thr_dump_enabled()) {
|
||||
/*
|
||||
* Abort this process if signal initialisation fails:
|
||||
* Install the signal handler for SIGINFO. It isn't
|
||||
* really needed, but it is nice to have for debugging
|
||||
* purposes.
|
||||
*/
|
||||
PANIC("Cannot initialize signal handler");
|
||||
_thread_sigact[SIGINFO - 1].sa_flags = SA_SIGINFO | SA_RESTART;
|
||||
SIGEMPTYSET(act.sa_mask);
|
||||
act.sa_flags = SA_SIGINFO | SA_RESTART;
|
||||
act.sa_sigaction = (__siginfohandler_t *)&_thr_sig_handler;
|
||||
if (__sys_sigaction(SIGINFO, &act, NULL) != 0) {
|
||||
__sys_sigprocmask(SIG_SETMASK, &_thr_initial->sigmask,
|
||||
NULL);
|
||||
/*
|
||||
* Abort this process if signal initialisation fails:
|
||||
*/
|
||||
PANIC("Cannot initialize signal handler");
|
||||
}
|
||||
}
|
||||
__sys_sigprocmask(SIG_SETMASK, &_thr_initial->sigmask, NULL);
|
||||
__sys_sigaltstack(NULL, &_thr_initial->sigstk);
|
||||
|
|
|
|||
|
|
@ -518,6 +518,8 @@ init_private(void)
|
|||
else if (getenv("LIBPTHREAD_PROCESS_SCOPE") != NULL)
|
||||
_thread_scope_system = -1;
|
||||
#endif
|
||||
if (getenv("LIBPTHREAD_DEBUG") != NULL)
|
||||
_thr_debug_flags |= DBG_INFO_DUMP;
|
||||
|
||||
/*
|
||||
* _thread_list_lock and _kse_count are initialized
|
||||
|
|
|
|||
|
|
@ -82,6 +82,7 @@
|
|||
|
||||
#define DBG_MUTEX 0x0001
|
||||
#define DBG_SIG 0x0002
|
||||
#define DBG_INFO_DUMP 0x0004
|
||||
|
||||
#ifdef _PTHREADS_INVARIANTS
|
||||
#define THR_ASSERT(cond, msg) do { \
|
||||
|
|
|
|||
|
|
@ -98,6 +98,12 @@ static int sigproptbl[NSIG] = {
|
|||
#define DBG_MSG(x...)
|
||||
#endif
|
||||
|
||||
static __inline int
|
||||
_thr_dump_enabled(void)
|
||||
{
|
||||
return ((_thr_debug_flags & DBG_INFO_DUMP) != 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Signal setup and delivery.
|
||||
*
|
||||
|
|
@ -253,7 +259,7 @@ _thr_sig_dispatch(struct kse *curkse, int sig, siginfo_t *info)
|
|||
DBG_MSG(">>> _thr_sig_dispatch(%d)\n", sig);
|
||||
|
||||
/* Check if the signal requires a dump of thread information: */
|
||||
if (sig == SIGINFO) {
|
||||
if (_thr_dump_enabled() && (sig == SIGINFO)) {
|
||||
/* Dump thread information to file: */
|
||||
_thread_dump_info();
|
||||
}
|
||||
|
|
@ -347,7 +353,7 @@ _thr_sig_handler(int sig, siginfo_t *info, ucontext_t *ucp)
|
|||
}
|
||||
|
||||
/* Check if the signal requires a dump of thread information: */
|
||||
if (sig == SIGINFO) {
|
||||
if (_thr_dump_enabled() && (sig == SIGINFO)) {
|
||||
/* Dump thread information to file: */
|
||||
_thread_dump_info();
|
||||
}
|
||||
|
|
@ -521,7 +527,7 @@ handle_signal(struct pthread *curthread, struct sighandle_info *shi)
|
|||
_kse_critical_leave(&curthread->tcb->tcb_tmbx);
|
||||
|
||||
/* Check if the signal requires a dump of thread information: */
|
||||
if (shi->sig == SIGINFO) {
|
||||
if (_thr_dump_enabled() && (shi->sig == SIGINFO)) {
|
||||
/* Dump thread information to file: */
|
||||
_thread_dump_info();
|
||||
}
|
||||
|
|
@ -1200,21 +1206,24 @@ _thr_signal_init(void)
|
|||
__sys_sigaction(i, &act, NULL);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Install the signal handler for SIGINFO. It isn't
|
||||
* really needed, but it is nice to have for debugging
|
||||
* purposes.
|
||||
*/
|
||||
_thread_sigact[SIGINFO - 1].sa_flags = SA_SIGINFO | SA_RESTART;
|
||||
SIGEMPTYSET(act.sa_mask);
|
||||
act.sa_flags = SA_SIGINFO | SA_RESTART;
|
||||
act.sa_sigaction = (__siginfohandler_t *)&_thr_sig_handler;
|
||||
if (__sys_sigaction(SIGINFO, &act, NULL) != 0) {
|
||||
__sys_sigprocmask(SIG_SETMASK, &_thr_initial->sigmask, NULL);
|
||||
if (_thr_dump_enabled()) {
|
||||
/*
|
||||
* Abort this process if signal initialisation fails:
|
||||
* Install the signal handler for SIGINFO. It isn't
|
||||
* really needed, but it is nice to have for debugging
|
||||
* purposes.
|
||||
*/
|
||||
PANIC("Cannot initialize signal handler");
|
||||
_thread_sigact[SIGINFO - 1].sa_flags = SA_SIGINFO | SA_RESTART;
|
||||
SIGEMPTYSET(act.sa_mask);
|
||||
act.sa_flags = SA_SIGINFO | SA_RESTART;
|
||||
act.sa_sigaction = (__siginfohandler_t *)&_thr_sig_handler;
|
||||
if (__sys_sigaction(SIGINFO, &act, NULL) != 0) {
|
||||
__sys_sigprocmask(SIG_SETMASK, &_thr_initial->sigmask,
|
||||
NULL);
|
||||
/*
|
||||
* Abort this process if signal initialisation fails:
|
||||
*/
|
||||
PANIC("Cannot initialize signal handler");
|
||||
}
|
||||
}
|
||||
__sys_sigprocmask(SIG_SETMASK, &_thr_initial->sigmask, NULL);
|
||||
__sys_sigaltstack(NULL, &_thr_initial->sigstk);
|
||||
|
|
|
|||
Loading…
Reference in a new issue