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/>. */
27 #include "watchpoint-fork.h"
29 /* `pid_t' may not be available. */
31 static volatile int usr1_got
;
34 handler_usr1 (int signo
)
42 int child
, save_parent
= getpid ();
44 struct sigaction act
, oldact
;
49 memset (&act
, 0, sizeof act
);
50 act
.sa_flags
= SA_RESTART
;
51 act
.sa_handler
= handler_usr1
;
52 sigemptyset (&act
.sa_mask
);
53 i
= sigaction (SIGUSR1
, &act
, &oldact
);
62 printf ("parent%d: %d\n", nr
, (int) child
);
64 /* Sleep for a while to possibly get incorrectly ATTACH_THREADed by GDB
65 tracing the child fork with no longer valid thread/lwp entries of the
71 /* We must not get caught here (against a forgotten breakpoint). */
77 /* And neither got caught our thread. */
80 i
= pthread_join (thread
, &thread_result
);
82 assert (thread_result
== (void *) 99UL);
85 /* Be sure our child knows we did not get caught above. */
87 i
= kill (child
, SIGUSR1
);
90 /* Sleep for a while to check GDB's `info threads' no longer tracks us in
98 printf ("child%d: %d\n", nr
, (int) getpid ());
100 /* Let the parent signal us about its success. Be careful of races. */
104 /* Parent either died (and USR1_GOT is zero) or it succeeded. */
105 if (getppid () != save_parent
)
107 if (kill (getppid (), 0) != 0)
109 /* Parent succeeded? */
114 i
= pthread_yield ();
120 /* We must get caught here (against a false watchpoint removal). */
125 i
= sigaction (SIGUSR1
, &oldact
, NULL
);
This page took 0.035448 seconds and 4 git commands to generate.