xref: /netbsd-src/external/gpl3/gdb.old/dist/gdb/testsuite/gdb.mi/mi-syn-frame.c (revision 82650ea59673ac1511a0f5b008a97de18ced4707)
1 #include <signal.h>
2 #include <unistd.h>
3 #include <stdlib.h>
4 
5 void foo (void);
6 void bar (void);
7 
8 void subroutine (int);
9 void handler (int);
10 void have_a_very_merry_interrupt (void);
11 
12 int
main()13 main ()
14 {
15   foo ();   /* Put a breakpoint on foo() and call it to see a dummy frame */
16 
17 
18   have_a_very_merry_interrupt ();
19   return 0;
20 }
21 
22 void
foo(void)23 foo (void)
24 {
25 }
26 
27 void
bar(void)28 bar (void)
29 {
30   *(volatile char *)0 = 0;    /* try to cause a segfault */
31 
32   /* On MMU-less system, previous memory access to address zero doesn't
33      trigger a SIGSEGV.  Trigger a SIGILL.  Each arch should define its
34      own illegal instruction here.  */
35 #if defined(__arm__)
36   asm(".word 0xf8f00000");
37 #elif defined(__TMS320C6X__)
38   asm(".word 0x56454313");
39 #else
40 #endif
41 
42 }
43 
44 void
handler(int sig)45 handler (int sig)
46 {
47   subroutine (sig);
48 }
49 
50 /* The first statement in subroutine () is a place for a breakpoint.
51    Without it, the breakpoint is put on the while comparison and will
52    be hit at each iteration. */
53 
54 void
subroutine(int in)55 subroutine (int in)
56 {
57   int count = in;
58   while (count < 100)
59     count++;
60 }
61 
62 void
have_a_very_merry_interrupt(void)63 have_a_very_merry_interrupt (void)
64 {
65   signal (SIGALRM, handler);
66   alarm (1);
67   sleep (2);  /* We'll receive that signal while sleeping */
68 }
69 
70