[gdb/testsuite] Fix gdb.threads/watchpoint-fork.exp race
I ran into: ... Thread 3.1 "watchpoint-fork" hit Breakpoint 3, marker () at \ watchpoint-fork-mt.c:42^M 42 }^M (gdb) parent2: 1945^M FAIL: gdb.threads/watchpoint-fork.exp: child: multithreaded: breakpoint (A) \ after the second fork (timeout) ... The problem is that the FAILing gdb_test expects '(gdb) ' to be the last thing printed, but the inferior prints something after that. A similar FAIL is described in the sources in watchpoint-fork-parent.c: ... printf ("child%d: %d\n", nr, (int) getpid ()); /* Delay to get both the "child%d" and "parent%d" message printed without a race breaking expect by its endless wait on `$gdb_prompt$': Breakpoint 3, marker () at watchpoint-fork.c:33 33 } (gdb) parent2: 14223 */ i = sleep (1); ... I noticed that while the executables print output, the output is not verified in the test-case, so it's merely debug output. Fix this by: - guarding the prints in the executables (as well as related sleep and setbuf calls) with #if DEBUG, and - compiling by default with DEBUG=0. gdb/testsuite/ChangeLog: 2020-01-29 Tom de Vries <tdevries@suse.de> * gdb.threads/watchpoint-fork-child.c: Guard prints with #if DEBUG. * gdb.threads/watchpoint-fork-mt.c: Same. * gdb.threads/watchpoint-fork-parent.c: Same. * gdb.threads/watchpoint-fork-st.c: Same. * gdb.threads/watchpoint-fork.exp: Compile with DEBUG=0. Change-Id: I63efd4c7771f96b5f5cd87ef2ab36795484ae2be
This commit is contained in:
parent
ef8f08ca13
commit
ee2a6fc604
|
@ -1,3 +1,11 @@
|
||||||
|
2020-01-29 Tom de Vries <tdevries@suse.de>
|
||||||
|
|
||||||
|
* gdb.threads/watchpoint-fork-child.c: Guard prints with #if DEBUG.
|
||||||
|
* gdb.threads/watchpoint-fork-mt.c: Same.
|
||||||
|
* gdb.threads/watchpoint-fork-parent.c: Same.
|
||||||
|
* gdb.threads/watchpoint-fork-st.c: Same.
|
||||||
|
* gdb.threads/watchpoint-fork.exp: Compile with DEBUG=0.
|
||||||
|
|
||||||
2020-01-27 Luis Machado <luis.machado@linaro.org>
|
2020-01-27 Luis Machado <luis.machado@linaro.org>
|
||||||
|
|
||||||
* gdb.base/step-over-syscall.exp (setup): Check if we're already
|
* gdb.base/step-over-syscall.exp (setup): Check if we're already
|
||||||
|
|
|
@ -59,7 +59,9 @@ forkoff (int nr)
|
||||||
case -1:
|
case -1:
|
||||||
assert (0);
|
assert (0);
|
||||||
default:
|
default:
|
||||||
|
#if DEBUG
|
||||||
printf ("parent%d: %d\n", nr, (int) child);
|
printf ("parent%d: %d\n", nr, (int) child);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Sleep for a while to possibly get incorrectly ATTACH_THREADed by GDB
|
/* Sleep for a while to possibly get incorrectly ATTACH_THREADed by GDB
|
||||||
tracing the child fork with no longer valid thread/lwp entries of the
|
tracing the child fork with no longer valid thread/lwp entries of the
|
||||||
|
@ -95,7 +97,9 @@ forkoff (int nr)
|
||||||
|
|
||||||
_exit (0);
|
_exit (0);
|
||||||
case 0:
|
case 0:
|
||||||
|
#if DEBUG
|
||||||
printf ("child%d: %d\n", nr, (int) getpid ());
|
printf ("child%d: %d\n", nr, (int) getpid ());
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Let the parent signal us about its success. Be careful of races. */
|
/* Let the parent signal us about its success. Be careful of races. */
|
||||||
|
|
||||||
|
|
|
@ -114,8 +114,10 @@ main (void)
|
||||||
int i;
|
int i;
|
||||||
void *thread_result;
|
void *thread_result;
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
setbuf (stdout, NULL);
|
setbuf (stdout, NULL);
|
||||||
printf ("main: %d\n", (int) gettid ());
|
printf ("main: %d\n", (int) gettid ());
|
||||||
|
#endif
|
||||||
|
|
||||||
/* General hardware breakpoints and watchpoints validity. */
|
/* General hardware breakpoints and watchpoints validity. */
|
||||||
marker ();
|
marker ();
|
||||||
|
|
|
@ -40,6 +40,7 @@ forkoff (int nr)
|
||||||
case -1:
|
case -1:
|
||||||
assert (0);
|
assert (0);
|
||||||
case 0:
|
case 0:
|
||||||
|
#if DEBUG
|
||||||
printf ("child%d: %d\n", nr, (int) getpid ());
|
printf ("child%d: %d\n", nr, (int) getpid ());
|
||||||
/* Delay to get both the "child%d" and "parent%d" message printed without
|
/* Delay to get both the "child%d" and "parent%d" message printed without
|
||||||
a race breaking expect by its endless wait on `$gdb_prompt$':
|
a race breaking expect by its endless wait on `$gdb_prompt$':
|
||||||
|
@ -48,6 +49,7 @@ forkoff (int nr)
|
||||||
(gdb) parent2: 14223 */
|
(gdb) parent2: 14223 */
|
||||||
i = sleep (1);
|
i = sleep (1);
|
||||||
assert (i == 0);
|
assert (i == 0);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* We must not get caught here (against a forgotten breakpoint). */
|
/* We must not get caught here (against a forgotten breakpoint). */
|
||||||
var++;
|
var++;
|
||||||
|
@ -55,11 +57,13 @@ forkoff (int nr)
|
||||||
|
|
||||||
_exit (exit_code);
|
_exit (exit_code);
|
||||||
default:
|
default:
|
||||||
|
#if DEBUG
|
||||||
printf ("parent%d: %d\n", nr, (int) child);
|
printf ("parent%d: %d\n", nr, (int) child);
|
||||||
/* Delay to get both the "child%d" and "parent%d" message printed, see
|
/* Delay to get both the "child%d" and "parent%d" message printed, see
|
||||||
above. */
|
above. */
|
||||||
i = sleep (1);
|
i = sleep (1);
|
||||||
assert (i == 0);
|
assert (i == 0);
|
||||||
|
#endif
|
||||||
|
|
||||||
pid_got = wait (&status);
|
pid_got = wait (&status);
|
||||||
assert (pid_got == child);
|
assert (pid_got == child);
|
||||||
|
|
|
@ -40,8 +40,10 @@ mark_exit (void)
|
||||||
int
|
int
|
||||||
main (void)
|
main (void)
|
||||||
{
|
{
|
||||||
|
#if DEBUG
|
||||||
setbuf (stdout, NULL);
|
setbuf (stdout, NULL);
|
||||||
printf ("main: %d\n", (int) getpid ());
|
printf ("main: %d\n", (int) getpid ());
|
||||||
|
#endif
|
||||||
|
|
||||||
/* General hardware breakpoints and watchpoints validity. */
|
/* General hardware breakpoints and watchpoints validity. */
|
||||||
marker ();
|
marker ();
|
||||||
|
|
|
@ -17,7 +17,11 @@
|
||||||
|
|
||||||
set testfile watchpoint-fork
|
set testfile watchpoint-fork
|
||||||
|
|
||||||
|
# Set DEBUG to 0 or 1 in sources
|
||||||
|
set debug 0
|
||||||
|
|
||||||
proc test {type symbol} {
|
proc test {type symbol} {
|
||||||
|
global debug
|
||||||
with_test_prefix "$type" {
|
with_test_prefix "$type" {
|
||||||
global testfile subdir srcdir gdb_prompt
|
global testfile subdir srcdir gdb_prompt
|
||||||
|
|
||||||
|
@ -30,7 +34,8 @@ proc test {type symbol} {
|
||||||
set srcfile_main ${testfile}-st.c
|
set srcfile_main ${testfile}-st.c
|
||||||
if {[build_executable $testfile.exp $executable \
|
if {[build_executable $testfile.exp $executable \
|
||||||
[list $srcfile_main ${testfile}-${type}.c] \
|
[list $srcfile_main ${testfile}-${type}.c] \
|
||||||
[list debug additional_flags=-D$symbol]] == -1} {
|
[list debug additional_flags=-D$symbol \
|
||||||
|
additional_flags=-DDEBUG=$debug]] == -1} {
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,7 +101,11 @@ proc test {type symbol} {
|
||||||
with_test_prefix "multithreaded" {
|
with_test_prefix "multithreaded" {
|
||||||
set executable ${testfile}-${type}-mt
|
set executable ${testfile}-${type}-mt
|
||||||
set srcfile_main ${srcdir}/${subdir}/${testfile}-mt.c
|
set srcfile_main ${srcdir}/${subdir}/${testfile}-mt.c
|
||||||
if { [gdb_compile_pthreads "${srcfile_main} ${srcfile_type}" [standard_output_file ${executable}] executable [list debug "additional_flags=-D$symbol -DTHREAD"]] != "" } {
|
if { [gdb_compile_pthreads "${srcfile_main} ${srcfile_type}" \
|
||||||
|
[standard_output_file ${executable}] executable \
|
||||||
|
[list debug "additional_flags=-D$symbol" \
|
||||||
|
"additional_flags=-DDEBUG=$debug" \
|
||||||
|
"-DTHREAD"]] != "" } {
|
||||||
untested "failed to compile"
|
untested "failed to compile"
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue