Commit | Line | Data |
---|---|---|
8363f9d5 RB |
1 | /* This testcase is part of GDB, the GNU debugger. |
2 | ||
b811d2c2 | 3 | Copyright 2018-2020 Free Software Foundation, Inc. |
8363f9d5 RB |
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 <stdio.h> | |
19 | #include <sys/types.h> | |
20 | #include <unistd.h> | |
21 | ||
22 | /* This is set to 1 by the debugger post attach to continue to the | |
23 | watchpoint trigger. */ | |
24 | volatile int should_continue = 0; | |
25 | /* The variable to place a watchpoint on. */ | |
26 | volatile int watched_variable = 0; | |
27 | ||
28 | int | |
29 | main (void) | |
30 | { | |
31 | unsigned int counter = 1; | |
32 | int mypid = getpid (); | |
33 | ||
34 | /* Wait for the debugger to attach, but not indefinitely so this | |
35 | test program is not left hanging around. */ | |
36 | for (counter = 0; !should_continue && counter < 100; counter++) | |
37 | sleep (1); /* pidacquired */ | |
38 | ||
8363f9d5 RB |
39 | /* Trigger a watchpoint. */ |
40 | watched_variable = 4; | |
41 | printf ("My variable is %d\n", watched_variable); | |
42 | return 0; | |
43 | } |