[PATCH] fix remote host test failures in testsuite
Hui Zhu
teawater@gmail.com
Fri Jun 7 02:22:00 GMT 2013
Hi,
This patch will make GDB testsuite support remote host test better.
It updates gdb.exp's function build_id_debug_filename_get and
gdb_gnu_strip_debug to support remote host.
It updates dup-sect.exp and sepdebug.exp to let them copy debug file
to remote host if need.
It updates info-fun.exp, solib-display.exp and solib-nodir.exp to let
them skip test if remote host because they base on share libary but I
didn't find good way to handle it in remote host.
Please help me review it.
Thanks,
Hui
2013-06-07 Daniel Jacobowitz <dan@codesourcery.com>
Sandra Loosemore <sandra@codesourcery.com>
Hui Zhu <hui@codesourcery.com>
* gdb.base/dup-sect.exp: Copy debug info file to remote host.
* gdb.base/info-fun.exp: Skip this test if remote host.
* gdb.base/sepdebug.exp: Try to compile with -Wl,--build-id to
enable build-id tests. Download the debug file to the host.
For local hosts, test the .debug subdirectory explicitly.
Comment debug-file-directory test. Run commands on host instead
of build.
* gdb.base/solib-display.exp: Skip this test if remote host.
* gdb.base/solib-nodir.exp: Skip this test if remote host.
* lib/gdb.exp (build_id_debug_filename_get): Run commands on
host instead of build.
(gdb_gnu_strip_debug): Create the debug file in the same directory
as the executable. Run commands on host instead of build.
-------------- next part --------------
--- a/gdb/testsuite/gdb.base/dup-sect.exp
+++ b/gdb/testsuite/gdb.base/dup-sect.exp
@@ -74,6 +74,13 @@ if {$result != 0} {
}
pass $test
+# gdb_gnu_strip_debug puts the debug info in $binfile.debug. Make sure that
+# file is available on the remote host.
+set debugfile $binfile.debug
+if { [is_remote host] } {
+ set debugfile [remote_download host $debugfile]
+}
+
clean_restart $executable
gdb_test "p/d *(const char *) &var1" " = 1" "var1 after strip"
--- a/gdb/testsuite/gdb.base/info-fun.exp
+++ b/gdb/testsuite/gdb.base/info-fun.exp
@@ -16,6 +16,11 @@ if { [skip_shlib_tests] || [is_remote ta
return 0
}
+# The remote host cannot handle the issue about inferior load library.
+if { [is_remote host] } {
+ return 0
+}
+
# Library file.
set libname "info-fun-solib"
set srcfile_lib ${srcdir}/${subdir}/${libname}.c
--- a/gdb/testsuite/gdb.base/sepdebug.exp
+++ b/gdb/testsuite/gdb.base/sepdebug.exp
@@ -33,7 +33,13 @@ set testfile "sepdebug"
set srcfile ${testfile}.c
set binfile ${objdir}/${subdir}/${testfile}${EXEEXT}
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
+# First try manually passing --build-id, in case it is not the
+# default. If that fails, try without it and see if we can run the
+# remaining tests.
+set opts {debug nowarnings}
+set idopts {debug nowarnings additional_flags=-Wl,--build-id quiet}
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable $idopts] != ""
+ && [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable $opts] != "" } {
untested sepdebug.exp
return -1
}
@@ -50,6 +56,11 @@ if [gdb_gnu_strip_debug $binfile] {
return -1
}
+set debugfile ${binfile}.debug
+if { [is_remote host] } {
+ set debugfile [remote_download host ${debugfile}]
+}
+
#
# PR gdb/9538. Verify that symlinked executable still finds the separate
# debuginfo.
@@ -656,8 +667,10 @@ proc test_different_dir {type test_diffe
gdb_exit
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
- gdb_test_no_output "set debug-file-directory ${test_different_dir}" \
- "set separate debug location"
+ if { $type != "debug-subdir" } {
+ gdb_test_no_output "set debug-file-directory ${test_different_dir}" \
+ "set separate debug location"
+ }
gdb_load ${binfile}
#
@@ -751,7 +764,7 @@ proc test_different_dir {type test_diffe
# the "set debug-file-directory" command.
set different_dir "${objdir}/${subdir}/${testfile}.dir"
-set debugfile "${different_dir}/${objdir}/${subdir}/${testfile}.debug"
+set debugfile "${different_dir}/${subdir}/${testfile}.debug"
remote_exec build "rm -rf $different_dir"
remote_exec build "mkdir -p [file dirname $debugfile]"
remote_exec build "mv -f ${objdir}/${subdir}/${testfile}.debug $debugfile"
@@ -764,7 +777,13 @@ test_different_dir debuglink $different_
if {[build_executable sepdebug.exp sepdebug2 sepdebug2.c debug] != -1
&& ![gdb_gnu_strip_debug ${objdir}/${subdir}/sepdebug2]} {
+ set binfile2 ${objdir}/${subdir}/sepdebug2
+ set debugfile2 ${binfile2}.debug
remote_exec build "cp ${debugfile} ${objdir}/${subdir}/sepdebug2.debug"
+ if { [is_remote host] } {
+ set binfile2 [remote_download host ${binfile2}]
+ set debugfile2 [remote_download host ${debugfile2}]
+ }
gdb_exit
gdb_start
@@ -773,6 +792,11 @@ if {[build_executable sepdebug.exp sepde
set escapedobjdirsubdir [string_to_regexp ${objdir}/${subdir}]
gdb_test "file ${objdir}/${subdir}/sepdebug2" "warning: the debug information found in \"${escapedobjdirsubdir}/sepdebug2\\.debug\" does not match \"${escapedobjdirsubdir}/sepdebug2\" \\(CRC mismatch\\)\\..*\\(no debugging symbols found\\).*" "CRC mismatch is reported"
+
+ if { [is_remote host] } {
+ remote_file host delete ${binfile2}
+ remote_file host delete ${debugfile2}
+ }
}
@@ -783,7 +807,7 @@ if ![string compare $build_id_debug_file
unsupported "build-id is not supported by the compiler"
# Spare debug files may confuse testsuite runs in the future.
- remote_exec build "rm -f $debugfile"
+ remote_file host delete "$debugfile"
} else {
set build_id_debugself_filename [build_id_debug_filename_get $debugfile]
set test "build-id support by binutils"
@@ -797,8 +821,8 @@ if ![string compare $build_id_debug_file
pass $test
}
- file mkdir [file dirname ${objdir}/${subdir}/${build_id_debug_filename}]
- remote_exec build "mv $debugfile ${objdir}/${subdir}/${build_id_debug_filename}"
+ remote_exec host "mkdir [file dirname ${objdir}/${subdir}/${build_id_debug_filename}]"
+ remote_exec host "mv $debugfile ${objdir}/${subdir}/${build_id_debug_filename}"
test_different_dir build-id "${objdir}/${subdir}" $xfail
@@ -809,5 +833,5 @@ if ![string compare $build_id_debug_file
test_different_dir multiple-dirs "/doesnotexist:${objdir}/${subdir}" $xfail
# Spare debug files may confuse testsuite runs in the future.
- remote_exec build "rm -f ${objdir}/${subdir}/${build_id_debug_filename}"
+ remote_file host delete "${objdir}/${subdir}/${build_id_debug_filename}"
}
--- a/gdb/testsuite/gdb.base/solib-display.exp
+++ b/gdb/testsuite/gdb.base/solib-display.exp
@@ -32,6 +32,11 @@ if { [skip_shlib_tests] || [is_remote ta
return 0
}
+# The remote host cannot handle the issue about inferior load library.
+if { [is_remote host] } {
+ return 0
+}
+
# Library file.
set libname "solib-display-lib"
set srcfile_lib ${srcdir}/${subdir}/${libname}.c
--- a/gdb/testsuite/gdb.base/solib-nodir.exp
+++ b/gdb/testsuite/gdb.base/solib-nodir.exp
@@ -18,6 +18,11 @@ if {[is_remote target] || [skip_shlib_te
return
}
+# The remote host cannot handle the issue about inferior load library.
+if { [is_remote host] } {
+ return 0
+}
+
set testfile "solib-nodir"
# Arbitrary file, possibly not containing main, even an empty one.
set srclibfile foo.c
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -3876,12 +3876,15 @@ proc build_id_debug_filename_get { exec
set tmp "${exec}-tmp"
set objcopy_program [transform objcopy]
- set result [catch "exec $objcopy_program -j .note.gnu.build-id -O binary $exec $tmp" output]
+ set result [remote_exec host "$objcopy_program -j .note.gnu.build-id -O binary $exec $tmp"]
+ set output [lindex $result 1]
+ set result [lindex $result 0]
verbose "result is $result"
verbose "output is $output"
if {$result == 1} {
return ""
}
+ set local_tmp [remote_upload host "$tmp"]
set fi [open $tmp]
fconfigure $fi -translation binary
# Skip the NOTE header.
@@ -3915,25 +3918,40 @@ proc gdb_gnu_strip_debug { dest args } {
set objcopy_program [transform objcopy]
set debug_link [file tail $debug_file]
- set stripped_file "${dest}.stripped"
+ set host_dest [remote_download host ${dest}]
+ set host_debug_file ${host_dest}.debug
+ set stripped_file "${host_dest}.stripped"
# Get rid of the debug info, and store result in stripped_file
# something like gdb/testsuite/gdb.base/blah.stripped.
- set result [catch "exec $strip_to_file_program --strip-debug ${dest} -o ${stripped_file}" output]
+ set result [remote_exec host "$strip_to_file_program --strip-debug ${host_dest} -o ${stripped_file}"]
+ set output [lindex $result 1]
+ set result [lindex $result 0]
verbose "result is $result"
verbose "output is $output"
if {$result == 1} {
return 1
}
- # Workaround PR binutils/10802:
- # Preserve the 'x' bit also for PIEs (Position Independent Executables).
- set perm [file attributes ${dest} -permissions]
- file attributes ${stripped_file} -permissions $perm
+ remote_upload host "$host_dest" "$dest"
+ remote_upload host "$host_debug_file" "$debug_file"
+
+ if { ! [is_remote host] } {
+ # Workaround PR binutils/10802:
+ # Preserve the 'x' bit also for PIEs (Position Independent Executables).
+ set perm [file attributes ${dest} -permissions]
+ file attributes ${stripped_file} -permissions $perm
+ }
+
+ remote_file delete "$host_dest"
+ remote_file delete "$host_debug_file"
+ remote_file delete "$stripped_file"
# Get rid of everything but the debug info, and store result in debug_file
# This will be in the .debug subdirectory, see above.
- set result [catch "exec $strip_to_file_program --only-keep-debug ${dest} -o ${debug_file}" output]
+ set result [remote_exec host "$strip_to_file_program --only-keep-debug ${host_dest} -o ${host_debug_file}"]
+ set output [lindex $result 1]
+ set result [lindex $result 0]
verbose "result is $result"
verbose "output is $output"
if {$result == 1} {
@@ -3946,31 +3964,50 @@ proc gdb_gnu_strip_debug { dest args } {
# objcopy or strip to remove the symbol table without also removing the
# debugging sections, so this is as close as we can get.
if { [llength $args] == 1 && [lindex $args 0] == "no-main" } {
- set result [catch "exec $objcopy_program -N main ${debug_file} ${debug_file}-tmp" output]
+ set result [remote_exec host "exec $objcopy_program -N main ${host_debug_file} ${host_debug_file}-tmp"]
+ set output [lindex $result 1]
+ set result [lindex $result 0]
verbose "result is $result"
verbose "output is $output"
if {$result == 1} {
return 1
}
- file delete "${debug_file}"
- file rename "${debug_file}-tmp" "${debug_file}"
+ remote_file host delete "${host_debug_file}"
+ if { ! [is_remote host] } {
+ file rename "${host_debug_file}-tmp" "${host_debug_file}"
+ } else {
+ # There is no remote_file "rename" operation.
+ set local_file [remote_upload host "${host_debug_file}-tmp"]
+ remote_download host "${local_file}" "${host_debug_file}"
+ }
}
# Link the two previous output files together, adding the .gnu_debuglink
# section to the stripped_file, containing a pointer to the debug_file,
# save the new file in dest.
# This will be the regular executable filename, in the usual location.
- set result [catch "exec $objcopy_program --add-gnu-debuglink=${debug_file} ${stripped_file} ${dest}" output]
+ set result [remote_exec host "$objcopy_program --add-gnu-debuglink=${host_debug_file} ${stripped_file} ${host_dest}"]
+ set output [lindex $result 1]
+ set result [lindex $result 0]
verbose "result is $result"
verbose "output is $output"
if {$result == 1} {
return 1
}
- # Workaround PR binutils/10802:
- # Preserve the 'x' bit also for PIEs (Position Independent Executables).
- set perm [file attributes ${stripped_file} -permissions]
- file attributes ${dest} -permissions $perm
+ remote_upload host "$host_dest" "$dest"
+ remote_upload host "$host_debug_file" "$debug_file"
+
+ if { ! [is_remote host] } {
+ # Workaround PR binutils/10802:
+ # Preserve the 'x' bit also for PIEs (Position Independent Executables).
+ set perm [file attributes ${stripped_file} -permissions]
+ file attributes ${dest} -permissions $perm
+ }
+
+ remote_file delete "$host_dest"
+ remote_file delete "$host_debug_file"
+ remote_file delete "$stripped_file"
return 0
}
More information about the Gdb-patches
mailing list