[gdb/testsuite] Factor out lib/valgrind.exp
[external/binutils.git] / gdb / testsuite / gdb.base / ending-run.c
1 /* Test program for <next-at-end> and
2  * <leaves-core-file-on-quit> bugs.
3  */
4 #include <stdio.h>
5 #include <stdlib.h>
6
7 #include "../lib/unbuffer_output.c"
8
9 int callee (int x)
10 {
11     int y = x * x;              /* -break1- */
12     return (y - 2);
13 }
14
15 int main()
16 {
17
18     int *p;
19     int i;
20
21     gdb_unbuffer_output ();
22
23     p = (int *) malloc( 4 );
24
25     for (i = 1; i < 10; i++)
26         {
27             printf( "%d ", callee( i ));
28             fflush (stdout);
29         }
30     printf( " Goodbye!\n" ); fflush (stdout); /* -break2- */
31     return 0;
32 }