]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.python/py-finish-breakpoint.c
Automatic date update in version.in
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.python / py-finish-breakpoint.c
1 /* This testcase is part of GDB, the GNU debugger.
2
3 Copyright 2011-2024 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 <setjmp.h>
19 #include <stdlib.h>
20 #include <string.h>
21 #include <unistd.h>
22
23 /* Defined in py-events-shlib.h. */
24 extern void do_nothing (void);
25
26 int increase_1 (int *a)
27 {
28 *a += 1;
29 return -5;
30 }
31
32 void increase (int *a)
33 {
34 increase_1 (a);
35 }
36
37 int increase_2 (int *a)
38 {
39 *a += 10;
40 return -8;
41 }
42
43 inline void __attribute__((always_inline))
44 increase_inlined (int *a)
45 {
46 increase_2 (a);
47 *a += 5;
48 }
49
50 int
51 test_1 (int i, int j)
52 {
53 return i == j;
54 }
55
56 int
57 test (int i, int j)
58 {
59 return test_1 (i, j);
60 }
61
62 int
63 call_longjmp_1 (jmp_buf *buf)
64 {
65 longjmp (*buf, 1);
66 }
67
68 int
69 call_longjmp (jmp_buf *buf)
70 {
71 call_longjmp_1 (buf);
72 return 0;
73 }
74
75 void
76 test_exec_exit (const char *self_exec)
77 {
78 if (self_exec == NULL)
79 exit (0);
80 else
81 execl (self_exec, self_exec, "exit", (char *)0);
82 }
83
84 int main (int argc, char *argv[])
85 {
86 jmp_buf env;
87 int foo = 5;
88 int bar = 42;
89 int i, j;
90
91 if (argc == 2 && strcmp (argv[1], "exit") == 0)
92 return 0;
93
94 do_nothing ();
95
96 i = 0;
97 /* Break at increase. */
98 increase (&i);
99 increase (&i);
100 increase (&i);
101 increase_inlined (&i);
102
103 for (i = 0; i < 10; i++)
104 {
105 j += 1; /* Condition Break. */
106 }
107
108 if (setjmp (env) == 0) /* longjmp caught */
109 {
110 call_longjmp (&env);
111 }
112 else
113 j += 1; /* after longjmp. */
114
115 test_exec_exit (argv[0]);
116
117 return j; /* Break at end. */
118 }