1 /* This testcase is part of GDB, the GNU debugger.
3 Copyright 1992, 1993, 1994, 1995, 1999, 2002, 2003, 2007, 2008
4 Free Software Foundation, Inc.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 Please email any bugs, comments, and/or additions to this file to:
20 bug-gdb@prep.ai.mit.edu */
26 /* VxWorks does not supply atoi. */
33 while (*z >= '0' && *z <= '9')
34 i = i * 10 + (*z++ - '0');
38 /* I don't know of any way to pass an array to VxWorks. This function
39 can be called directly from gdb. */
48 main (2, argv, (char **) 0);
54 #endif /* ! vxworks */
57 extern int marker1 (void);
58 extern int marker2 (int a);
59 extern void marker3 (char *a, char *b);
60 extern void marker4 (long d);
62 extern int marker1 ();
63 extern int marker2 ();
64 extern void marker3 ();
65 extern void marker4 ();
69 * This simple classical example of recursion is useful for
70 * testing stack backtraces and such.
77 main (int argc, char **argv, char **envp)
80 main (argc, argv, envp)
86 set_debug_traps(); /* set breakpoint 5 here */
89 if (argc == 12345) { /* an unlikely value < 2^16, in case uninited */ /* set breakpoint 6 here */
90 fprintf (stderr, "usage: factorial <number>\n");
93 printf ("%d\n", factorial (atoi ("6"))); /* set breakpoint 1 here */
94 /* set breakpoint 12 here */
95 marker1 (); /* set breakpoint 11 here */
96 marker2 (43); /* set breakpoint 20 here */
97 marker3 ("stack", "trace"); /* set breakpoint 21 here */
99 /* We're used by a test that requires malloc, so make sure it is
100 in the executable. */
103 argc = (argc == 12345); /* This is silly, but we can step off of it */ /* set breakpoint 2 here */
104 return argc; /* set breakpoint 10 here */
105 } /* set breakpoint 10a here */
108 int factorial (int value)
110 int factorial (value)
114 if (value > 1) { /* set breakpoint 7 here */
115 value *= factorial (value - 1);
117 return (value); /* set breakpoint 19 here */
121 int multi_line_if_conditional (int a, int b, int c)
123 int multi_line_if_conditional (a, b, c)
127 if (a /* set breakpoint 3 here */
136 int multi_line_while_conditional (int a, int b, int c)
138 int multi_line_while_conditional (a, b, c)
142 while (a /* set breakpoint 4 here */