Fix skip.exp test failure observed with gcc-9.2.0
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / break.c
CommitLineData
a1dea79a
FF
1/* This testcase is part of GDB, the GNU debugger.
2
42a4f53d 3 Copyright 1992-2019 Free Software Foundation, Inc.
a1dea79a
FF
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
a9762ec7 7 the Free Software Foundation; either version 3 of the License, or
a1dea79a
FF
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.
a9762ec7 14
a1dea79a 15 You should have received a copy of the GNU General Public License
c7b778ff 16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
a1dea79a 17
428b16bd
PA
18#include <stdio.h>
19#include <stdlib.h>
c906108c 20
a1dea79a
FF
21extern int marker1 (void);
22extern int marker2 (int a);
23extern void marker3 (char *a, char *b);
24extern void marker4 (long d);
c906108c 25
f0df251a
DJ
26/* We're used by a test that requires malloc, so make sure it is in
27 the executable. */
28void *need_malloc ()
29{
30 return malloc (1);
31}
32
c906108c
SS
33/*
34 * This simple classical example of recursion is useful for
35 * testing stack backtraces and such.
36 */
37
085dd6e6
JM
38int factorial(int);
39
40int
41main (int argc, char **argv, char **envp)
c906108c 42{
a50d3602 43 if (argc == 12345) { /* an unlikely value < 2^16, in case uninited */ /* set breakpoint 6 here */
c906108c
SS
44 fprintf (stderr, "usage: factorial <number>\n");
45 return 1;
46 }
a50d3602
EZ
47 printf ("%d\n", factorial (atoi ("6"))); /* set breakpoint 1 here */
48 /* set breakpoint 12 here */
49 marker1 (); /* set breakpoint 11 here */
a1dea79a
FF
50 marker2 (43); /* set breakpoint 20 here */
51 marker3 ("stack", "trace"); /* set breakpoint 21 here */
c906108c 52 marker4 (177601976L);
d394c993
NS
53 /* We're used by a test that requires malloc, so make sure it is
54 in the executable. */
55 (void)malloc (1);
56
a50d3602
EZ
57 argc = (argc == 12345); /* This is silly, but we can step off of it */ /* set breakpoint 2 here */
58 return argc; /* set breakpoint 10 here */
e1c2defa 59} /* set breakpoint 10a here */
c906108c 60
085dd6e6 61int factorial (int value)
c906108c 62{
a50d3602 63 if (value > 1) { /* set breakpoint 7 here */
c906108c
SS
64 value *= factorial (value - 1);
65 }
a1dea79a 66 return (value); /* set breakpoint 19 here */
c906108c
SS
67}
68
f286b2c3 69int multi_line_if_conditional (int a, int b, int c)
f286b2c3 70{
a50d3602 71 if (a /* set breakpoint 3 here */
f286b2c3
JL
72 && b
73 && c)
74 return 0;
75 else
76 return 1;
77}
78
f286b2c3 79int multi_line_while_conditional (int a, int b, int c)
f286b2c3 80{
a50d3602 81 while (a /* set breakpoint 4 here */
f286b2c3
JL
82 && b
83 && c)
84 {
85 a--, b--, c--;
86 }
87 return 0;
88}
This page took 2.023411 seconds and 4 git commands to generate.