1 /* Test case for forgotten hw-watchpoints after fork()-off of a process.
3 Copyright 2012-2020 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/>. */
20 #include "watchpoint-fork.h"
29 #include <asm/unistd.h>
31 #define gettid() syscall (__NR_gettid)
33 /* Non-atomic `var++' should not hurt as we synchronize the threads by the STEP
34 variable. Hit-comments need to be duplicated there to catch both at-stops
35 and behind-stops, depending on the target. */
71 var
++; /* validity-thread-B */
72 empty (); /* validity-thread-B */
87 var
++; /* after-fork1-B */
88 empty (); /* after-fork1-B */
100 var
++; /* after-fork2-B */
101 empty (); /* after-fork2-B */
105 /* We must not get caught here (against a forgotten breakpoint). */
108 return (void *) 99UL;
118 setbuf (stdout
, NULL
);
119 printf ("main: %d\n", (int) gettid ());
122 /* General hardware breakpoints and watchpoints validity. */
124 var
++; /* validity-first */
125 empty (); /* validity-first */
127 i
= pthread_create (&thread
, NULL
, start
, NULL
);
130 var
++; /* validity-thread-A */
131 empty (); /* validity-thread-A */
135 i
= pthread_yield ();
139 /* Hardware watchpoints got disarmed here. */
142 var
++; /* after-fork1-A */
143 empty (); /* after-fork1-A */
146 /* Spawn new thread as it was deleted in the child of FORK. */
147 i
= pthread_create (&thread
, NULL
, start
, NULL
);
152 i
= pthread_yield ();
156 /* A sanity check for double hardware watchpoints removal. */
159 var
++; /* after-fork2-A */
160 empty (); /* after-fork2-A */
163 /* Spawn new thread as it was deleted in the child of FORK. */
164 i
= pthread_create (&thread
, NULL
, start
, NULL
);
168 i
= pthread_join (thread
, &thread_result
);
170 assert (thread_result
== (void *) 5UL);
This page took 0.037382 seconds and 4 git commands to generate.