mirror of
https://github.com/tobast/libunwind-eh_elf.git
synced 2025-03-10 02:20:07 +01:00
When libunwind is configured with --enable-block-signals=no,
we must block recursion via sighandlers by "external" means.
This commit is contained in:
parent
839db77b7b
commit
b7e3444fea
1 changed files with 19 additions and 0 deletions
|
@ -32,6 +32,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||||
|
|
||||||
#define UNW_LOCAL_ONLY
|
#define UNW_LOCAL_ONLY
|
||||||
#include <libunwind.h>
|
#include <libunwind.h>
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
static const int nerrors_max = 100;
|
static const int nerrors_max = 100;
|
||||||
|
|
||||||
|
@ -45,6 +46,14 @@ int verbose;
|
||||||
int nerrors;
|
int nerrors;
|
||||||
int sigcount;
|
int sigcount;
|
||||||
|
|
||||||
|
#ifndef CONFIG_BLOCK_SIGNALS
|
||||||
|
/* When libunwind is configured with --enable-block-signals=no, the caller
|
||||||
|
is responsible for preventing recursion via signal handlers.
|
||||||
|
We use a simple global here. In a multithreaded program, one would use
|
||||||
|
a thread-local variable. */
|
||||||
|
int recurcount;
|
||||||
|
#endif
|
||||||
|
|
||||||
#define panic(args...) \
|
#define panic(args...) \
|
||||||
{ ++nerrors; fprintf (stderr, args); return; }
|
{ ++nerrors; fprintf (stderr, args); return; }
|
||||||
|
|
||||||
|
@ -58,6 +67,12 @@ do_backtrace (int may_print, int get_proc_name)
|
||||||
int ret;
|
int ret;
|
||||||
int depth = 0;
|
int depth = 0;
|
||||||
|
|
||||||
|
#ifndef CONFIG_BLOCK_SIGNALS
|
||||||
|
if (recurcount > 0)
|
||||||
|
return;
|
||||||
|
recurcount += 1;
|
||||||
|
#endif
|
||||||
|
|
||||||
unw_getcontext (&uc);
|
unw_getcontext (&uc);
|
||||||
if (unw_init_local (&cursor, &uc) < 0)
|
if (unw_init_local (&cursor, &uc) < 0)
|
||||||
panic ("unw_init_local failed!\n");
|
panic ("unw_init_local failed!\n");
|
||||||
|
@ -102,6 +117,10 @@ do_backtrace (int may_print, int get_proc_name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (ret > 0);
|
while (ret > 0);
|
||||||
|
|
||||||
|
#ifndef CONFIG_BLOCK_SIGNALS
|
||||||
|
recurcount -= 1;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Add table
Reference in a new issue