1 /* Test case for forgotten hw-watchpoints after fork()-off of a process.
3 Copyright 2012-2015 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, see <http://www.gnu.org/licenses/>. */
26 /* pthread_yield is a GNU extension. */
30 #include <asm/unistd.h>
32 #define gettid() syscall (__NR_gettid)
34 #include "watchpoint-fork.h"
36 /* Non-atomic `var++' should not hurt as we synchronize the threads by the STEP
37 variable. Hit-comments need to be duplicated there to catch both at-stops
38 and behind-stops, depending on the target. */
74 var
++; /* validity-thread-B */
75 empty (); /* validity-thread-B */
90 var
++; /* after-fork1-B */
91 empty (); /* after-fork1-B */
103 var
++; /* after-fork2-B */
104 empty (); /* after-fork2-B */
108 /* We must not get caught here (against a forgotten breakpoint). */
111 return (void *) 99UL;
120 setbuf (stdout
, NULL
);
121 printf ("main: %d\n", (int) gettid ());
123 /* General hardware breakpoints and watchpoints validity. */
125 var
++; /* validity-first */
126 empty (); /* validity-first */
128 i
= pthread_create (&thread
, NULL
, start
, NULL
);
131 var
++; /* validity-thread-A */
132 empty (); /* validity-thread-A */
136 i
= pthread_yield ();
140 /* Hardware watchpoints got disarmed here. */
143 var
++; /* after-fork1-A */
144 empty (); /* after-fork1-A */
147 /* Spawn new thread as it was deleted in the child of FORK. */
148 i
= pthread_create (&thread
, NULL
, start
, NULL
);
153 i
= pthread_yield ();
157 /* A sanity check for double hardware watchpoints removal. */
160 var
++; /* after-fork2-A */
161 empty (); /* after-fork2-A */
164 /* Spawn new thread as it was deleted in the child of FORK. */
165 i
= pthread_create (&thread
, NULL
, start
, NULL
);
169 i
= pthread_join (thread
, &thread_result
);
171 assert (thread_result
== (void *) 5UL);
This page took 0.032704 seconds and 4 git commands to generate.