Remove support for testing against dead "target vxworks"
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / break.c
1 /* This testcase is part of GDB, the GNU debugger.
2
3 Copyright 1992-2014 Free Software Foundation, Inc.
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17
18 #include <stdio.h>
19 #include <stdlib.h>
20
21 #ifdef PROTOTYPES
22 extern int marker1 (void);
23 extern int marker2 (int a);
24 extern void marker3 (char *a, char *b);
25 extern void marker4 (long d);
26 #else
27 extern int marker1 ();
28 extern int marker2 ();
29 extern void marker3 ();
30 extern void marker4 ();
31 #endif
32
33 /* We're used by a test that requires malloc, so make sure it is in
34 the executable. */
35 void *need_malloc ()
36 {
37 return malloc (1);
38 }
39
40 /*
41 * This simple classical example of recursion is useful for
42 * testing stack backtraces and such.
43 */
44
45 #ifdef PROTOTYPES
46 int factorial(int);
47
48 int
49 main (int argc, char **argv, char **envp)
50 #else
51 int
52 main (argc, argv, envp)
53 int argc;
54 char *argv[], **envp;
55 #endif
56 {
57 if (argc == 12345) { /* an unlikely value < 2^16, in case uninited */ /* set breakpoint 6 here */
58 fprintf (stderr, "usage: factorial <number>\n");
59 return 1;
60 }
61 printf ("%d\n", factorial (atoi ("6"))); /* set breakpoint 1 here */
62 /* set breakpoint 12 here */
63 marker1 (); /* set breakpoint 11 here */
64 marker2 (43); /* set breakpoint 20 here */
65 marker3 ("stack", "trace"); /* set breakpoint 21 here */
66 marker4 (177601976L);
67 /* We're used by a test that requires malloc, so make sure it is
68 in the executable. */
69 (void)malloc (1);
70
71 argc = (argc == 12345); /* This is silly, but we can step off of it */ /* set breakpoint 2 here */
72 return argc; /* set breakpoint 10 here */
73 } /* set breakpoint 10a here */
74
75 #ifdef PROTOTYPES
76 int factorial (int value)
77 #else
78 int factorial (value)
79 int value;
80 #endif
81 {
82 if (value > 1) { /* set breakpoint 7 here */
83 value *= factorial (value - 1);
84 }
85 return (value); /* set breakpoint 19 here */
86 }
87
88 #ifdef PROTOTYPES
89 int multi_line_if_conditional (int a, int b, int c)
90 #else
91 int multi_line_if_conditional (a, b, c)
92 int a, b, c;
93 #endif
94 {
95 if (a /* set breakpoint 3 here */
96 && b
97 && c)
98 return 0;
99 else
100 return 1;
101 }
102
103 #ifdef PROTOTYPES
104 int multi_line_while_conditional (int a, int b, int c)
105 #else
106 int multi_line_while_conditional (a, b, c)
107 int a, b, c;
108 #endif
109 {
110 while (a /* set breakpoint 4 here */
111 && b
112 && c)
113 {
114 a--, b--, c--;
115 }
116 return 0;
117 }
This page took 0.033717 seconds and 5 git commands to generate.