This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] Improve gdb_remote_download, remove gdb_download


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=7817ea46148df2931cf00d17aeedb844b6e4e4db

commit 7817ea46148df2931cf00d17aeedb844b6e4e4db
Author: Simon Marchi <simon.marchi@ericsson.com>
Date:   Tue Apr 5 13:59:49 2016 -0400

    Improve gdb_remote_download, remove gdb_download
    
    This patch removes gdb_download in favor of gdb_remote_download, since
    they are very close in functionality.  Also, in preparation for the
    following patch about shared library handling during tests, it improves
    gdb_remote_download so that it uses standard_output_file for any
    destination board that is local, not only host.
    
    If the destination board is remote, gdb_remote_download will use the
    standard remote_download from DejaGnu, resulting in the file being
    transferred on the remote system.
    
    If the destination is local, gdb_remote_download will copy the file to
    the standard test directory (found using standard_output_file).  Tcl's
    file copy seems to handle gracefully cases where the source file is the
    same as the destination, so I don't think it's necessary to check for
    that case ourselves, as a previous version of the patch did.
    
    I'd prefer to keep the name gdb_download instead of gdb_remote_download,
    since I don't like the fact that gdb_remote_download implies that the
    destination is remote, when it's not always the case.  However,
    gdb_remote_download is used at many more places than gdb_download, so
    it's easier to reuse that.  Also, since it's a wrapper around DejaGnu's
    remote_download, it might be better to keep that name.  I don't know.
    
    I ran the testsuite native, with native-gdbserver and with a
    remote gdbserver, and didn't see any related failure.
    
    gdb/testsuite/ChangeLog:
    
    	* gdb.base/jit-so.exp: Use gdb_remote_download instead of
    	gdb_download.  Use it even if the target is not remote.
    	* gdb.base/jit.exp (compile_jit_test): Likewise.
    	* lib/gdb.exp (gdb_remote_download): Copy files to the standard
    	output directory if the destination board is local, otherwise use
    	the standard remote_download from DejaGnu.
    	(gdb_download): Remove.
    	(gdb_load_shlibs): Use gdb_remote_download instead of
    	gdb_download.
    	* lib/gdbserver-support.exp (gdbserver_download_current_prog):
    	Use gdb_remote_download instead of gdb_download.  Use it even if
    	the target is not remote.
    	* lib/mi-support.exp (mi_load_shlibs): Use gdb_remote_download
    	instead of gdb_download.

Diff:
---
 gdb/testsuite/ChangeLog                 | 17 +++++++++++
 gdb/testsuite/gdb.base/jit-so.exp       |  6 +---
 gdb/testsuite/gdb.base/jit.exp          |  6 +---
 gdb/testsuite/lib/gdb.exp               | 52 +++++++++++++++++++--------------
 gdb/testsuite/lib/gdbserver-support.exp |  6 +---
 gdb/testsuite/lib/mi-support.exp        |  2 +-
 6 files changed, 51 insertions(+), 38 deletions(-)

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index ec99787..32c20de 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,20 @@
+2016-04-05  Simon Marchi  <simon.marchi@ericsson.com>
+
+	* gdb.base/jit-so.exp: Use gdb_remote_download instead of
+	gdb_download.  Use it even if the target is not remote.
+	* gdb.base/jit.exp (compile_jit_test): Likewise.
+	* lib/gdb.exp (gdb_remote_download): Copy files to the standard
+	output directory if the destination board is local, otherwise use
+	the standard remote_download from DejaGnu.
+	(gdb_download): Remove.
+	(gdb_load_shlibs): Use gdb_remote_download instead of
+	gdb_download.
+	* lib/gdbserver-support.exp (gdbserver_download_current_prog):
+	Use gdb_remote_download instead of gdb_download.  Use it even if
+	the target is not remote.
+	* lib/mi-support.exp (mi_load_shlibs): Use gdb_remote_download
+	instead of gdb_download.
+
 2016-04-04  Simon Marchi  <simon.marchi@polymtl.ca>
 
 	* gdb.mi/mi-breakpoint-changed.exp: Add some with_test_prefix.
diff --git a/gdb/testsuite/gdb.base/jit-so.exp b/gdb/testsuite/gdb.base/jit-so.exp
index adb21ea..0135473 100644
--- a/gdb/testsuite/gdb.base/jit-so.exp
+++ b/gdb/testsuite/gdb.base/jit-so.exp
@@ -61,11 +61,7 @@ if { [gdb_compile_shlib ${solib_srcfile} ${solib_binfile} {}] != "" } {
     return -1
 }
 
-if {[is_remote target]} {
-    set solib_binfile_target [gdb_download ${solib_binfile}]
-} else {
-    set solib_binfile_target $solib_binfile
-}
+set solib_binfile_target [gdb_remote_download target ${solib_binfile}]
 
 proc one_jit_test {count match_str} {
     with_test_prefix "one_jit_test-$count" {
diff --git a/gdb/testsuite/gdb.base/jit.exp b/gdb/testsuite/gdb.base/jit.exp
index da9449b..17024e4 100644
--- a/gdb/testsuite/gdb.base/jit.exp
+++ b/gdb/testsuite/gdb.base/jit.exp
@@ -57,11 +57,7 @@ proc compile_jit_test {testname binsuffix options} {
 	return -1
     }
 
-    if {[is_remote target]} {
-	set solib_binfile_target [gdb_download ${solib_binfile}]
-    } else {
-	set solib_binfile_target $solib_binfile
-    }
+    set solib_binfile_target [gdb_remote_download target ${solib_binfile}]
 
     return 0
 }
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index a77bce4..4e5c89b 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -4183,34 +4183,42 @@ proc gdb_touch_execfile { binfile } {
     }
 }
 
-# Like remote_download but provides a gdb-specific behavior.  If DEST
-# is "host", and the host is not remote, and TOFILE is not specified,
-# then the [file tail] of FROMFILE is passed through
-# standard_output_file to compute the destination.
+# Like remote_download but provides a gdb-specific behavior.
+#
+# If the destination board is remote, the local file FROMFILE is transferred as
+# usual with remote_download to TOFILE on the remote board.  The destination
+# filename is added to the CLEANFILES global, so it can be cleaned up at the
+# end of the test.
+#
+# If the destination board is local, the destination path TOFILE is passed
+# through standard_output_file, and FROMFILE is copied there.
+#
+# In both cases, if TOFILE is omitted, it defaults to the [file tail] of
+# FROMFILE.
 
 proc gdb_remote_download {dest fromfile {tofile {}}} {
-    if {$dest == "host" && ![is_remote host] && $tofile == ""} {
-	set tofile [standard_output_file [file tail $fromfile]]
+    # If TOFILE is not given, default to the same filename as FROMFILE.
+    if {[string length $tofile] == 0} {
+	set tofile [file tail $fromfile]
     }
 
-    if { $tofile == "" } {
-	return [remote_download $dest $fromfile]
-    } else {
-	return [remote_download $dest $fromfile $tofile]
-    }
-}
+    if {[is_remote $dest]} {
+	# When the DEST is remote, we simply send the file to DEST.
+	global cleanfiles
 
-# gdb_download
-#
-# Copy a file to the remote target and return its target filename.
-# Schedule the file to be deleted at the end of this test.
+	set destname [remote_download $dest $fromfile $tofile]
+	lappend cleanfiles $destname
 
-proc gdb_download { filename } {
-    global cleanfiles
+	return $destname
+    } else {
+	# When the DEST is local, we copy the file to the test directory
+	# (where the executable is), except if that's already where it is.
+	set tofile [standard_output_file $tofile]
 
-    set destname [remote_download target $filename]
-    lappend cleanfiles $destname
-    return $destname
+	file copy -force $fromfile $tofile
+
+	return $tofile
+    }
 }
 
 # gdb_load_shlibs LIB...
@@ -4223,7 +4231,7 @@ proc gdb_load_shlibs { args } {
     }
 
     foreach file $args {
-	gdb_download [shlib_target_file $file]
+	gdb_remote_download target [shlib_target_file $file]
     }
 
     # Even if the target supplies full paths for shared libraries,
diff --git a/gdb/testsuite/lib/gdbserver-support.exp b/gdb/testsuite/lib/gdbserver-support.exp
index 60ac3af..67a8333 100644
--- a/gdb/testsuite/lib/gdbserver-support.exp
+++ b/gdb/testsuite/lib/gdbserver-support.exp
@@ -176,11 +176,7 @@ proc gdbserver_download_current_prog { } {
     if { $reuse == 0 } {
 	set gdbserver_host_exec $host_exec
 	set gdbserver_host_mtime [file mtime $host_exec]
-	if [is_remote target] {
-	    set gdbserver_server_exec [gdb_download $host_exec]
-	} else {
-	    set gdbserver_server_exec $host_exec
-	}
+	set gdbserver_server_exec [gdb_remote_download target $host_exec]
     }
 
     return $gdbserver_server_exec
diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp
index 7f9a3f5..cf3005d 100644
--- a/gdb/testsuite/lib/mi-support.exp
+++ b/gdb/testsuite/lib/mi-support.exp
@@ -1960,7 +1960,7 @@ proc mi_load_shlibs { args } {
     }
 
     foreach file $args {
-	gdb_download [shlib_target_file $file]
+	gdb_remote_download target [shlib_target_file $file]
     }
 
     # Even if the target supplies full paths for shared libraries,


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]