1
0
Fork 0
mirror of https://github.com/tobast/libunwind-eh_elf.git synced 2024-05-19 03:25:18 +02:00

Fix up a little so it's silent by default.

(Logical change 1.259)
This commit is contained in:
hp.com!davidm 2004-08-31 13:59:10 +00:00
parent 3b57368f67
commit f789a1e1d1

View file

@ -1,5 +1,5 @@
/* libunwind - a platform-independent unwind library /* libunwind - a platform-independent unwind library
Copyright (C) 2001-2003 Hewlett-Packard Co Copyright (C) 2001-2004 Hewlett-Packard Co
Contributed by David Mosberger-Tang <davidm@hpl.hp.com> Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person obtaining
@ -21,7 +21,7 @@ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/* This shows how to use the unwind interface to modify any ancestor /* This test uses the unwind interface to modify the IP in an ancestor
frame while still returning to the parent frame. */ frame while still returning to the parent frame. */
#include <signal.h> #include <signal.h>
@ -33,6 +33,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#define panic(args...) \ #define panic(args...) \
{ fprintf (stderr, args); exit (-1); } { fprintf (stderr, args); exit (-1); }
int verbose;
static void static void
sighandler (int signal) sighandler (int signal)
{ {
@ -40,7 +42,8 @@ sighandler (int signal)
unw_word_t ip; unw_word_t ip;
unw_context_t uc; unw_context_t uc;
printf ("caught signal %d\n", signal); if (verbose)
printf ("caught signal %d\n", signal);
unw_getcontext (&uc); unw_getcontext (&uc);
if (unw_init_local (&cursor, &uc) < 0) if (unw_init_local (&cursor, &uc) < 0)
@ -81,13 +84,19 @@ doit (volatile char *p)
ch = *p; /* trigger SIGSEGV */ ch = *p; /* trigger SIGSEGV */
printf ("doit: finishing execution!\n"); if (verbose)
printf ("doit: finishing execution!\n");
} }
int int
main (int argc, char **argv) main (int argc, char **argv)
{ {
if (argc > 1)
verbose = 1;
signal (SIGSEGV, sighandler); signal (SIGSEGV, sighandler);
doit (0); doit (0);
if (verbose)
printf ("SUCCESS\n");
return 0; return 0;
} }