2003-02-02 06:51:09 +01:00
|
|
|
#include <signal.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
void foo (void);
|
|
|
|
void bar (void);
|
|
|
|
|
|
|
|
void subroutine (int);
|
|
|
|
void handler (int);
|
|
|
|
void have_a_very_merry_interrupt (void);
|
|
|
|
|
2014-10-28 13:39:22 +01:00
|
|
|
int
|
2003-02-02 06:51:09 +01:00
|
|
|
main ()
|
|
|
|
{
|
|
|
|
foo (); /* Put a breakpoint on foo() and call it to see a dummy frame */
|
|
|
|
|
|
|
|
|
|
|
|
have_a_very_merry_interrupt ();
|
2014-10-28 13:39:22 +01:00
|
|
|
return 0;
|
2003-02-02 06:51:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
foo (void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
bar (void)
|
|
|
|
{
|
2011-08-14 17:58:40 +02:00
|
|
|
*(char *)0 = 0; /* try to cause a segfault */
|
|
|
|
|
|
|
|
/* On MMU-less system, previous memory access to address zero doesn't
|
|
|
|
trigger a SIGSEGV. Trigger a SIGILL. Each arch should define its
|
|
|
|
own illegal instruction here. */
|
|
|
|
#if defined(__arm__)
|
|
|
|
asm(".word 0xf8f00000");
|
|
|
|
#elif defined(__TMS320C6X__)
|
|
|
|
asm(".word 0x56454313");
|
|
|
|
#else
|
|
|
|
#endif
|
2003-02-02 06:51:09 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
handler (int sig)
|
|
|
|
{
|
|
|
|
subroutine (sig);
|
|
|
|
}
|
|
|
|
|
2003-02-06 19:26:20 +01:00
|
|
|
/* The first statement in subroutine () is a place for a breakpoint.
|
|
|
|
Without it, the breakpoint is put on the while comparison and will
|
|
|
|
be hit at each iteration. */
|
|
|
|
|
2003-02-02 06:51:09 +01:00
|
|
|
void
|
|
|
|
subroutine (int in)
|
|
|
|
{
|
2003-02-06 07:27:01 +01:00
|
|
|
int count = in;
|
|
|
|
while (count < 100)
|
|
|
|
count++;
|
2003-02-02 06:51:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
have_a_very_merry_interrupt (void)
|
|
|
|
{
|
|
|
|
signal (SIGALRM, handler);
|
|
|
|
alarm (1);
|
|
|
|
sleep (2); /* We'll receive that signal while sleeping */
|
|
|
|
}
|
|
|
|
|