diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 4fd5dc8..6559b7d 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -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>
 
 	* gdb.base/step-over-syscall.exp (setup): Check if we're already
diff --git a/gdb/testsuite/gdb.threads/watchpoint-fork-child.c b/gdb/testsuite/gdb.threads/watchpoint-fork-child.c
index 1da75c9..96860bb 100644
--- a/gdb/testsuite/gdb.threads/watchpoint-fork-child.c
+++ b/gdb/testsuite/gdb.threads/watchpoint-fork-child.c
@@ -59,7 +59,9 @@
     case -1:
       assert (0);
     default:
+#if DEBUG
       printf ("parent%d: %d\n", nr, (int) child);
+#endif
 
       /* 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
@@ -95,7 +97,9 @@
 
       _exit (0);
     case 0:
+#if DEBUG
       printf ("child%d: %d\n", nr, (int) getpid ());
+#endif
 
       /* Let the parent signal us about its success.  Be careful of races.  */
 
diff --git a/gdb/testsuite/gdb.threads/watchpoint-fork-mt.c b/gdb/testsuite/gdb.threads/watchpoint-fork-mt.c
index 4b195f97..7b1bbf4 100644
--- a/gdb/testsuite/gdb.threads/watchpoint-fork-mt.c
+++ b/gdb/testsuite/gdb.threads/watchpoint-fork-mt.c
@@ -114,8 +114,10 @@
   int i;
   void *thread_result;
 
+#if DEBUG
   setbuf (stdout, NULL);
   printf ("main: %d\n", (int) gettid ());
+#endif
 
   /* General hardware breakpoints and watchpoints validity.  */
   marker ();
diff --git a/gdb/testsuite/gdb.threads/watchpoint-fork-parent.c b/gdb/testsuite/gdb.threads/watchpoint-fork-parent.c
index 511c951..2b325b0 100644
--- a/gdb/testsuite/gdb.threads/watchpoint-fork-parent.c
+++ b/gdb/testsuite/gdb.threads/watchpoint-fork-parent.c
@@ -40,6 +40,7 @@
     case -1:
       assert (0);
     case 0:
+#if DEBUG
       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$':
@@ -48,6 +49,7 @@
 	 (gdb) parent2: 14223  */
       i = sleep (1);
       assert (i == 0);
+#endif
 
       /* We must not get caught here (against a forgotten breakpoint).  */
       var++;
@@ -55,11 +57,13 @@
 
       _exit (exit_code);
     default:
+#if DEBUG
       printf ("parent%d: %d\n", nr, (int) child);
       /* Delay to get both the "child%d" and "parent%d" message printed, see
 	 above.  */
       i = sleep (1);
       assert (i == 0);
+#endif
 
       pid_got = wait (&status);
       assert (pid_got == child);
diff --git a/gdb/testsuite/gdb.threads/watchpoint-fork-st.c b/gdb/testsuite/gdb.threads/watchpoint-fork-st.c
index b75deb6..8a7caec 100644
--- a/gdb/testsuite/gdb.threads/watchpoint-fork-st.c
+++ b/gdb/testsuite/gdb.threads/watchpoint-fork-st.c
@@ -40,8 +40,10 @@
 int
 main (void)
 {
+#if DEBUG
   setbuf (stdout, NULL);
   printf ("main: %d\n", (int) getpid ());
+#endif
 
   /* General hardware breakpoints and watchpoints validity.  */
   marker ();
diff --git a/gdb/testsuite/gdb.threads/watchpoint-fork.exp b/gdb/testsuite/gdb.threads/watchpoint-fork.exp
index 5f38fca..6500c0d 100644
--- a/gdb/testsuite/gdb.threads/watchpoint-fork.exp
+++ b/gdb/testsuite/gdb.threads/watchpoint-fork.exp
@@ -17,7 +17,11 @@
 
 set testfile watchpoint-fork
 
+# Set DEBUG to 0 or 1 in sources
+set debug 0
+
 proc test {type symbol} {
+    global debug
     with_test_prefix "$type" {
 	global testfile subdir srcdir gdb_prompt
 
@@ -30,7 +34,8 @@
 	    set srcfile_main ${testfile}-st.c
 	    if {[build_executable $testfile.exp $executable \
 		     [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
 	    }
 
@@ -96,7 +101,11 @@
 	with_test_prefix "multithreaded" {
 	    set executable ${testfile}-${type}-mt
 	    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"
 		return
 	    }
