]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.reverse/until-reverse.c
Update copyright year range in all GDB files
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.reverse / until-reverse.c
CommitLineData
28d41a99
MS
1/* This testcase is part of GDB, the GNU debugger.
2
3666a048 3 Copyright 2008-2021 Free Software Foundation, Inc.
28d41a99
MS
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
428b16bd
PA
18#include <stdio.h>
19#include <stdlib.h>
28d41a99 20
28d41a99
MS
21extern int marker1 (void);
22extern int marker2 (int a);
23extern void marker3 (char *a, char *b);
24extern void marker4 (long d);
28d41a99
MS
25
26/*
27 * This simple classical example of recursion is useful for
28 * testing stack backtraces and such.
29 */
30
28d41a99
MS
31int factorial(int);
32
33int
34main (int argc, char **argv, char **envp)
28d41a99 35{
e6359af3
YQ
36 if (argc == 12345)
37 {
38 /* We're used by a test that requires malloc, so make sure it is
39 in the executable. */
53ae0aa9
TV
40 void *p = malloc (1);
41 free (p);
e6359af3 42 return 1;
28d41a99 43 }
e6359af3
YQ
44
45 factorial (atoi ("6")); /* set breakpoint 1 here */
28d41a99
MS
46 /* set breakpoint 12 here */
47 marker1 (); /* set breakpoint 11 here */
48 marker2 (43); /* set breakpoint 20 here */
49 marker3 ("stack", "trace"); /* set breakpoint 21 here */
50 marker4 (177601976L);
28d41a99
MS
51
52 argc = (argc == 12345); /* This is silly, but we can step off of it */ /* set breakpoint 2 here */
53 return argc; /* set breakpoint 10 here */
54} /* set breakpoint 10a here */
55
28d41a99 56int factorial (int value)
28d41a99
MS
57{
58 if (value > 1) { /* set breakpoint 7 here */
59 value *= factorial (value - 1);
60 }
61 return (value); /* set breakpoint 19 here */
62}
63
28d41a99 64int multi_line_if_conditional (int a, int b, int c)
28d41a99
MS
65{
66 if (a /* set breakpoint 3 here */
67 && b
68 && c)
69 return 0;
70 else
71 return 1;
72}
73
28d41a99 74int multi_line_while_conditional (int a, int b, int c)
28d41a99
MS
75{
76 while (a /* set breakpoint 4 here */
77 && b
78 && c)
79 {
80 a--, b--, c--;
81 }
82 return 0;
83}