1 /* Test case for forgotten hw-watchpoints after fork()-off of a process.
3 Copyright 2012 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 2 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, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
29 #include <asm/unistd.h>
31 #define gettid() syscall (__NR_gettid)
33 #include "watchpoint-fork.h"
35 /* Non-atomic `var++' should not hurt as we synchronize the threads by the STEP
36 variable. Hit-comments need to be duplicated there to catch both at-stops
37 and behind-stops, depending on the target. */
73 var
++; /* validity-thread-B */
74 empty (); /* validity-thread-B */
89 var
++; /* after-fork1-B */
90 empty (); /* after-fork1-B */
102 var
++; /* after-fork2-B */
103 empty (); /* after-fork2-B */
107 /* We must not get caught here (against a forgotten breakpoint). */
110 return (void *) 99UL;
119 setbuf (stdout
, NULL
);
120 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.032602 seconds and 4 git commands to generate.