Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] gdb/testsuite: Fix set_unbuffered_mode.o handling in parallel mode
@ 2024-03-22 19:40 Pedro Alves
  2024-03-23 20:41 ` Kevin Buettner
  0 siblings, 1 reply; 3+ messages in thread
From: Pedro Alves @ 2024-03-22 19:40 UTC (permalink / raw)
  To: gdb-patches

Cygwin/MinGW testing links in a set_unbuffered_mode.o object to all
test programs.  When running the testsuite in parallel mode, on
Cygwin, I noticed errors like:

  ERROR: remote_download to host of ..../build/set_unbuffered_mode.o to ..../build/set_unbuffered_mode_saved.o: cp: cannot open '..../build/set_unbuffered_mode.o' for reading: No such file or directory
...
  ERROR: remote_download to host of ..../build/set_unbuffered_mode.o to ..../build/set_unbuffered_mode_saved.o: cp: cannot stat '..../build/set_unbuffered_mode.o': No such file or directory
...
  ERROR: remote_download to host of ..../build/set_unbuffered_mode.o to ..../build/set_unbuffered_mode_saved.o: cp: skipping file '..../build/set_unbuffered_mode.o', as it was replaced while being copied

(Absolute paths elided above.)

The problem is that gdb_compile's unbuffered_mode_obj cache isn't
parallel safe.  This is fixed in this commit.

Change-Id: I67a289473c14ce0603d4b0beb755b124588f18d2
---
 gdb/testsuite/lib/gdb.exp | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index a0c4855ffc5..fbfa6f81b8f 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -5565,10 +5565,20 @@ proc gdb_compile {source dest type options} {
 	    #  which is time consuming, especially if we're remote
 	    #  host testing.
 	    #
+	    # Note the special care for GDB_PARALLEL.  In that
+	    # scenario, multiple expect instances will potentially try
+	    # to compile the object file at the same time.  The result
+	    # should be identical for every one of them, so we just
+	    # need to make sure that the final objfile is written to
+	    # atomically.
+
 	    if { $gdb_saved_set_unbuffered_mode_obj == "" } {
 		verbose "compiling gdb_saved_set_unbuffered_obj"
 		set unbuf_src ${srcdir}/lib/set_unbuffered_mode.c
-		set unbuf_obj ${objdir}/set_unbuffered_mode.o
+		# This gives us a per-expect-instance unique filename,
+		# which is important for GDB_PARALLEL.  See comments
+		# above.
+		set unbuf_obj [standard_temp_file set_unbuffered_mode.o]
 
 		set result [gdb_compile "${unbuf_src}" "${unbuf_obj}" object {nowarnings}]
 		if { $result != "" } {
@@ -5581,7 +5591,14 @@ proc gdb_compile {source dest type options} {
 		}
 		# Link a copy of the output object, because the
 		# original may be automatically deleted.
-		remote_download host $unbuf_obj $gdb_saved_set_unbuffered_mode_obj
+		if {[info exists ::GDB_PARALLEL]} {
+		    # Make sure to write the .o file atomically.
+		    # (Note GDB_PARALLEL mode does not support remote
+		    # host testing.)
+		    file rename -force -- $unbuf_obj $gdb_saved_set_unbuffered_mode_obj
+		} else {
+		    remote_download host $unbuf_obj $gdb_saved_set_unbuffered_mode_obj
+		}
 	    } else {
 		verbose "gdb_saved_set_unbuffered_obj already compiled"
 	    }

base-commit: c05dd51122c2d654031b04e02ad0ea5b53ffe5e2
-- 
2.43.2


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] gdb/testsuite: Fix set_unbuffered_mode.o handling in parallel mode
  2024-03-22 19:40 [PATCH] gdb/testsuite: Fix set_unbuffered_mode.o handling in parallel mode Pedro Alves
@ 2024-03-23 20:41 ` Kevin Buettner
  2024-03-25 20:07   ` Pedro Alves
  0 siblings, 1 reply; 3+ messages in thread
From: Kevin Buettner @ 2024-03-23 20:41 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

On Fri, 22 Mar 2024 19:40:38 +0000
Pedro Alves <pedro@palves.net> wrote:

> Cygwin/MinGW testing links in a set_unbuffered_mode.o object to all
> test programs.  When running the testsuite in parallel mode, on
> Cygwin, I noticed errors like:
> 
>   ERROR: remote_download to host of ..../build/set_unbuffered_mode.o to ..../build/set_unbuffered_mode_saved.o: cp: cannot open '..../build/set_unbuffered_mode.o' for reading: No such file or directory
> ...
>   ERROR: remote_download to host of ..../build/set_unbuffered_mode.o to ..../build/set_unbuffered_mode_saved.o: cp: cannot stat '..../build/set_unbuffered_mode.o': No such file or directory
> ...
>   ERROR: remote_download to host of ..../build/set_unbuffered_mode.o to ..../build/set_unbuffered_mode_saved.o: cp: skipping file '..../build/set_unbuffered_mode.o', as it was replaced while being copied
> 
> (Absolute paths elided above.)
> 
> The problem is that gdb_compile's unbuffered_mode_obj cache isn't
> parallel safe.  This is fixed in this commit.

LGTM.

Reviewed-by: Kevin Buettner <kevinb@redhat.com>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] gdb/testsuite: Fix set_unbuffered_mode.o handling in parallel mode
  2024-03-23 20:41 ` Kevin Buettner
@ 2024-03-25 20:07   ` Pedro Alves
  0 siblings, 0 replies; 3+ messages in thread
From: Pedro Alves @ 2024-03-25 20:07 UTC (permalink / raw)
  To: Kevin Buettner; +Cc: gdb-patches

Hi Kevin!

On 2024-03-23 20:41, Kevin Buettner wrote:

> LGTM.
> 
> Reviewed-by: Kevin Buettner <kevinb@redhat.com>
> 

Thanks, I've merged it.

Pedro Alves

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-03-25 20:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-22 19:40 [PATCH] gdb/testsuite: Fix set_unbuffered_mode.o handling in parallel mode Pedro Alves
2024-03-23 20:41 ` Kevin Buettner
2024-03-25 20:07   ` Pedro Alves

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox