update copyright year range in GDB files
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / sepdebug.c
CommitLineData
61baf725 1/* Copyright 1994-2017 Free Software Foundation, Inc.
1f8a6abb
EZ
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
a9762ec7 5 the Free Software Foundation; either version 3 of the License, or
1f8a6abb 6 (at your option) any later version.
a9762ec7 7
1f8a6abb
EZ
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
a9762ec7 12
1f8a6abb 13 You should have received a copy of the GNU General Public License
c7b778ff 14 along with this program. If not, see <http://www.gnu.org/licenses/>. */
1f8a6abb 15
428b16bd
PA
16#include <stdio.h>
17#include <stdlib.h>
1f8a6abb
EZ
18
19/*
20 * The following functions do nothing useful. They are included simply
21 * as places to try setting breakpoints at. They are explicitly
22 * "one-line functions" to verify that this case works (some versions
23 * of gcc have or have had problems with this).
24 */
25
1f8a6abb
EZ
26int marker1 (void) { return (0); }
27int marker2 (int a) { return (1); } /* set breakpoint 8 here */
28void marker3 (char *a, char *b) {}
29void marker4 (long d) {} /* set breakpoint 14 here */
1f8a6abb
EZ
30
31/*
32 * This simple classical example of recursion is useful for
33 * testing stack backtraces and such.
34 */
35
1f8a6abb
EZ
36int factorial(int);
37
38int
39main (int argc, char **argv, char **envp)
1f8a6abb 40{
1f8a6abb
EZ
41 if (argc == 12345) { /* an unlikely value < 2^16, in case uninited */ /* set breakpoint 6 here */
42 fprintf (stderr, "usage: factorial <number>\n");
43 return 1;
44 }
45 printf ("%d\n", factorial (atoi ("6"))); /* set breakpoint 1 here */
46 /* set breakpoint 12 here */
47 marker1 (); /* set breakpoint 11 here */
48 marker2 (43);
49 marker3 ("stack", "trace");
50 marker4 (177601976L);
51 argc = (argc == 12345); /* This is silly, but we can step off of it */ /* set breakpoint 2 here */
52 return argc; /* set breakpoint 10 here */
53}
54
1f8a6abb 55int factorial (int value)
1f8a6abb
EZ
56{
57 if (value > 1) { /* set breakpoint 7 here */
58 value *= factorial (value - 1);
59 }
60 return (value);
61}
62
1f8a6abb 63int multi_line_if_conditional (int a, int b, int c)
1f8a6abb
EZ
64{
65 if (a /* set breakpoint 3 here */
66 && b
67 && c)
68 return 0;
69 else
70 return 1;
71}
72
1f8a6abb 73int multi_line_while_conditional (int a, int b, int c)
1f8a6abb
EZ
74{
75 while (a /* set breakpoint 4 here */
76 && b
77 && c)
78 {
79 a--, b--, c--;
80 }
81 return 0;
82}
This page took 1.353248 seconds and 4 git commands to generate.