mirror of
https://github.com/tobast/libunwind-eh_elf.git
synced 2024-11-05 01:09:27 +01:00
Allow caller to block signals.
Greetings, We use libunwind just for stack traces (I suspect many others do as well). The use pattern is: GetStackTrace(void** result, int max_depth) { ... unw_getcontext(&uc); unw_init_local(&cursor, &uc); while (n < max_depth) { if (unw_get_reg(&cursor, UNW_REG_IP, (unw_word_t *) &ip) < 0) { break; } result[n++] = ip; if (unw_step(&cursor) <= 0) { break; } } Given this usage, it is quite convenient for us to block signals (or prevent signal handlers from re-entering libunwind by other means) at the "top level", which makes most of the sigprocmask calls performed by libunwind itself unneccessary. The second patch in this series adds a configure option which removes most of the sigprocmask calls. Attached patch is a preliminary for it -- consolidating all of the "sigprocmask; mutex_lock;" sequences into lock_acquire and "mutex_unlock; sigprocmask;" sequences into lock_release. Thanks, -- Paul Pluzhnikov commit 402d15b123d54a7669db7cf17a76dd315094e472 Author: Paul Pluzhnikov <ppluzhnikov@google.com> Date: Mon Sep 21 10:18:28 2009 -0700 Replace "sigprocmask + mutext_lock" with a single lock_acquire. Likewise, replace "mutext_unlock + sigprocmask" with lock_release.
This commit is contained in:
parent
35e6a1a108
commit
84d4150668
10 changed files with 20 additions and 40 deletions
|
@ -44,8 +44,7 @@ tdep_init (void)
|
|||
|
||||
sigfillset (&unwi_full_mask);
|
||||
|
||||
sigprocmask (SIG_SETMASK, &unwi_full_mask, &saved_mask);
|
||||
mutex_lock (&arm_lock);
|
||||
lock_acquire (&arm_lock, saved_mask);
|
||||
{
|
||||
if (!tdep_needs_initialization)
|
||||
/* another thread else beat us to it... */
|
||||
|
@ -61,6 +60,5 @@ tdep_init (void)
|
|||
tdep_needs_initialization = 0; /* signal that we're initialized... */
|
||||
}
|
||||
out:
|
||||
mutex_unlock (&arm_lock);
|
||||
sigprocmask (SIG_SETMASK, &saved_mask, NULL);
|
||||
lock_release (&arm_lock, saved_mask);
|
||||
}
|
||||
|
|
|
@ -489,11 +489,10 @@ get_rs_cache (unw_addr_space_t as, intrmask_t *saved_maskp)
|
|||
if (AO_test_and_set (&cache->busy) == AO_TS_SET)
|
||||
return NULL;
|
||||
# else
|
||||
sigprocmask (SIG_SETMASK, &unwi_full_mask, saved_maskp);
|
||||
if (likely (caching == UNW_CACHE_GLOBAL))
|
||||
{
|
||||
Debug (16, "%s: acquiring lock\n", __FUNCTION__);
|
||||
mutex_lock (&cache->lock);
|
||||
lock_acquire (&cache->lock, *saved_maskp);
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
@ -521,8 +520,7 @@ put_rs_cache (unw_addr_space_t as, struct dwarf_rs_cache *cache,
|
|||
AO_CLEAR (&cache->busy);
|
||||
# else
|
||||
if (likely (as->caching_policy == UNW_CACHE_GLOBAL))
|
||||
mutex_unlock (&cache->lock);
|
||||
sigprocmask (SIG_SETMASK, saved_maskp, NULL);
|
||||
lock_release (&cache->lock, *saved_maskp);
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -35,8 +35,7 @@ tdep_init (void)
|
|||
|
||||
sigfillset (&unwi_full_mask);
|
||||
|
||||
sigprocmask (SIG_SETMASK, &unwi_full_mask, &saved_mask);
|
||||
mutex_lock (&hppa_lock);
|
||||
lock_acquire (&hppa_lock, saved_mask);
|
||||
{
|
||||
if (!tdep_needs_initialization)
|
||||
/* another thread else beat us to it... */
|
||||
|
@ -52,6 +51,5 @@ tdep_init (void)
|
|||
tdep_needs_initialization = 0; /* signal that we're initialized... */
|
||||
}
|
||||
out:
|
||||
mutex_unlock (&hppa_lock);
|
||||
sigprocmask (SIG_SETMASK, &saved_mask, NULL);
|
||||
lock_release (&hppa_lock, saved_mask);
|
||||
}
|
||||
|
|
|
@ -71,8 +71,7 @@ tdep_init (void)
|
|||
|
||||
sigfillset (&unwi_full_mask);
|
||||
|
||||
sigprocmask (SIG_SETMASK, &unwi_full_mask, &saved_mask);
|
||||
mutex_lock (&unw.lock);
|
||||
lock_acquire (&unw.lock, saved_mask);
|
||||
{
|
||||
if (!tdep_needs_initialization)
|
||||
/* another thread else beat us to it... */
|
||||
|
@ -120,6 +119,5 @@ tdep_init (void)
|
|||
tdep_needs_initialization = 0; /* signal that we're initialized... */
|
||||
}
|
||||
out:
|
||||
mutex_unlock (&unw.lock);
|
||||
sigprocmask (SIG_SETMASK, &saved_mask, NULL);
|
||||
lock_release (&unw.lock, saved_mask);
|
||||
}
|
||||
|
|
|
@ -113,11 +113,10 @@ get_script_cache (unw_addr_space_t as, intrmask_t *saved_maskp)
|
|||
if (AO_test_and_set (&cache->busy) == AO_TS_SET)
|
||||
return NULL;
|
||||
# else
|
||||
sigprocmask (SIG_SETMASK, &unwi_full_mask, saved_maskp);
|
||||
if (likely (caching == UNW_CACHE_GLOBAL))
|
||||
{
|
||||
Debug (16, "%s: acquiring lock\n", __FUNCTION__);
|
||||
mutex_lock (&cache->lock);
|
||||
lock_acquire (&cache->lock, *saved_maskp);
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
@ -144,8 +143,7 @@ put_script_cache (unw_addr_space_t as, struct ia64_script_cache *cache,
|
|||
AO_CLEAR (&cache->busy);
|
||||
# else
|
||||
if (likely (as->caching_policy == UNW_CACHE_GLOBAL))
|
||||
mutex_unlock (&cache->lock);
|
||||
sigprocmask (SIG_SETMASK, saved_maskp, NULL);
|
||||
lock_release (&cache->lock, *saved_maskp);
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -44,8 +44,7 @@ tdep_init (void)
|
|||
|
||||
sigfillset (&unwi_full_mask);
|
||||
|
||||
sigprocmask (SIG_SETMASK, &unwi_full_mask, &saved_mask);
|
||||
mutex_lock (&mips_lock);
|
||||
lock_acquire (&mips_lock, saved_mask);
|
||||
{
|
||||
if (!tdep_needs_initialization)
|
||||
/* another thread else beat us to it... */
|
||||
|
@ -61,6 +60,5 @@ tdep_init (void)
|
|||
tdep_needs_initialization = 0; /* signal that we're initialized... */
|
||||
}
|
||||
out:
|
||||
mutex_unlock (&mips_lock);
|
||||
sigprocmask (SIG_SETMASK, &saved_mask, NULL);
|
||||
lock_release (&mips_lock, saved_mask);
|
||||
}
|
||||
|
|
|
@ -115,8 +115,7 @@ tdep_init (void)
|
|||
|
||||
sigfillset (&unwi_full_mask);
|
||||
|
||||
sigprocmask (SIG_SETMASK, &unwi_full_mask, &saved_mask);
|
||||
mutex_lock (&ppc32_lock);
|
||||
lock_acquire (&ppc32_lock, saved_mask);
|
||||
{
|
||||
if (!tdep_needs_initialization)
|
||||
/* another thread else beat us to it... */
|
||||
|
@ -132,6 +131,5 @@ tdep_init (void)
|
|||
tdep_needs_initialization = 0; /* signal that we're initialized... */
|
||||
}
|
||||
out:
|
||||
mutex_unlock (&ppc32_lock);
|
||||
sigprocmask (SIG_SETMASK, &saved_mask, NULL);
|
||||
lock_release (&ppc32_lock, saved_mask);
|
||||
}
|
||||
|
|
|
@ -162,8 +162,7 @@ tdep_init (void)
|
|||
|
||||
sigfillset (&unwi_full_mask);
|
||||
|
||||
sigprocmask (SIG_SETMASK, &unwi_full_mask, &saved_mask);
|
||||
mutex_lock (&ppc64_lock);
|
||||
lock_acquire (&ppc64_lock, saved_mask);
|
||||
{
|
||||
if (!tdep_needs_initialization)
|
||||
/* another thread else beat us to it... */
|
||||
|
@ -179,6 +178,5 @@ tdep_init (void)
|
|||
tdep_needs_initialization = 0; /* signal that we're initialized... */
|
||||
}
|
||||
out:
|
||||
mutex_unlock (&ppc64_lock);
|
||||
sigprocmask (SIG_SETMASK, &saved_mask, NULL);
|
||||
lock_release (&ppc64_lock, saved_mask);
|
||||
}
|
||||
|
|
|
@ -47,8 +47,7 @@ tdep_init (void)
|
|||
|
||||
sigfillset (&unwi_full_mask);
|
||||
|
||||
sigprocmask (SIG_SETMASK, &unwi_full_mask, &saved_mask);
|
||||
mutex_lock (&x86_lock);
|
||||
lock_acquire (&x86_lock, saved_mask);
|
||||
{
|
||||
if (!tdep_needs_initialization)
|
||||
/* another thread else beat us to it... */
|
||||
|
@ -64,6 +63,5 @@ tdep_init (void)
|
|||
tdep_needs_initialization = 0; /* signal that we're initialized... */
|
||||
}
|
||||
out:
|
||||
mutex_unlock (&x86_lock);
|
||||
sigprocmask (SIG_SETMASK, &saved_mask, NULL);
|
||||
lock_release (&x86_lock, saved_mask);
|
||||
}
|
||||
|
|
|
@ -61,8 +61,7 @@ tdep_init (void)
|
|||
|
||||
sigfillset (&unwi_full_mask);
|
||||
|
||||
sigprocmask (SIG_SETMASK, &unwi_full_mask, &saved_mask);
|
||||
mutex_lock (&x86_64_lock);
|
||||
lock_acquire (&x86_64_lock, saved_mask);
|
||||
{
|
||||
if (!tdep_needs_initialization)
|
||||
/* another thread else beat us to it... */
|
||||
|
@ -78,6 +77,5 @@ tdep_init (void)
|
|||
tdep_needs_initialization = 0; /* signal that we're initialized... */
|
||||
}
|
||||
out:
|
||||
mutex_unlock (&x86_64_lock);
|
||||
sigprocmask (SIG_SETMASK, &saved_mask, NULL);
|
||||
lock_release (&x86_64_lock, saved_mask);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue