From 93f02886fd15eef1d38f073c54031c812e564128 Mon Sep 17 00:00:00 2001 From: Daniel Jacobowitz Date: Wed, 16 May 2007 14:21:47 +0000 Subject: [PATCH] * lib/gdb.exp (gdb_compile): Add support for Windows DLLs. (gdb_compile_shlib): Likewise. (skip_shlib_tests, gdb_download, gdb_load_shlibs): New. (default_gdb_init): Clear cleanfiles. (gdb_finish): Delete recorded cleanfiles. * lib/gdbserver-support.exp (gdbserver_spawn): Use gdb_download. * gdb.base/gdb1555.exp: Use skip_shlib_tests and gdb_load_shlibs. Do not use isnative. * gdb.base/pending.exp, gdb.base/shlib-call.exp, gdb.base/shreloc.exp, gdb.base/so-impl-ld.exp: Likewise. * gdb.base/solib-weak.exp: Likewise. Skip for DLL targets. * gdb.base/unload.exp: Likewise. Do not pass empty option to gdb_compile. --- gdb/testsuite/ChangeLog | 17 +++++ gdb/testsuite/gdb.base/gdb1555.exp | 11 ++-- gdb/testsuite/gdb.base/pending.exp | 4 +- gdb/testsuite/gdb.base/shlib-call.exp | 5 +- gdb/testsuite/gdb.base/shreloc.exp | 4 +- gdb/testsuite/gdb.base/so-impl-ld.exp | 6 +- gdb/testsuite/gdb.base/solib-weak.exp | 12 +++- gdb/testsuite/gdb.base/unload.exp | 23 ++++--- gdb/testsuite/lib/gdb.exp | 88 +++++++++++++++++++++++-- gdb/testsuite/lib/gdbserver-support.exp | 2 +- 10 files changed, 142 insertions(+), 30 deletions(-) diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 6ac9e34daae..4eb5d8b16c5 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,20 @@ +2007-05-16 Daniel Jacobowitz + + * lib/gdb.exp (gdb_compile): Add support for Windows DLLs. + (gdb_compile_shlib): Likewise. + (skip_shlib_tests, gdb_download, gdb_load_shlibs): New. + (default_gdb_init): Clear cleanfiles. + (gdb_finish): Delete recorded cleanfiles. + * lib/gdbserver-support.exp (gdbserver_spawn): Use gdb_download. + + * gdb.base/gdb1555.exp: Use skip_shlib_tests and gdb_load_shlibs. + Do not use isnative. + * gdb.base/pending.exp, gdb.base/shlib-call.exp, gdb.base/shreloc.exp, + gdb.base/so-impl-ld.exp: Likewise. + * gdb.base/solib-weak.exp: Likewise. Skip for DLL targets. + * gdb.base/unload.exp: Likewise. Do not pass empty option to + gdb_compile. + 2007-05-15 Vladimir Prus * config/unknown.exp: Remove. diff --git a/gdb/testsuite/gdb.base/gdb1555.exp b/gdb/testsuite/gdb.base/gdb1555.exp index 2aad73a5313..ea7d4df1d13 100644 --- a/gdb/testsuite/gdb.base/gdb1555.exp +++ b/gdb/testsuite/gdb.base/gdb1555.exp @@ -25,6 +25,10 @@ if $tracelevel then { strace $tracelevel } +if {[skip_shlib_tests]} { + return 0 +} + set testfile gdb1555-main set libfile gdb1555 set srcfile ${testfile}.c @@ -36,12 +40,6 @@ set execsrc "${srcdir}/${subdir}/${srcfile}" remote_exec build "rm -f ${binfile}" -# Are we on a target board? No support for downloading shared libraries -# to a target yet. -if ![isnative] then { - return 0 -} - # get the value of gcc_compiled if [get_compiler_info ${binfile}] { return -1 @@ -57,6 +55,7 @@ gdb_exit gdb_start gdb_reinitialize_dir $srcdir/$subdir gdb_load ${binfile} +gdb_load_shlibs $libobj if ![runto_main] then { fail "Can't run to main" diff --git a/gdb/testsuite/gdb.base/pending.exp b/gdb/testsuite/gdb.base/pending.exp index 3ba51767247..2c98f6e3dba 100644 --- a/gdb/testsuite/gdb.base/pending.exp +++ b/gdb/testsuite/gdb.base/pending.exp @@ -26,8 +26,7 @@ if $tracelevel then { set prms_id 0 set bug_id 0 -# are we on a target board? -if ![isnative] then { +if {[skip_shlib_tests]} { return 0 } @@ -57,6 +56,7 @@ gdb_exit gdb_start gdb_reinitialize_dir $srcdir/$subdir gdb_load ${binfile} +gdb_load_shlibs $lib_sl if [target_info exists gdb_stub] { gdb_step_for_stub; diff --git a/gdb/testsuite/gdb.base/shlib-call.exp b/gdb/testsuite/gdb.base/shlib-call.exp index 48390f3b6c1..29ac1cb8b59 100644 --- a/gdb/testsuite/gdb.base/shlib-call.exp +++ b/gdb/testsuite/gdb.base/shlib-call.exp @@ -40,8 +40,7 @@ if $tracelevel then { set prms_id 0 set bug_id 0 -# are we on a target board? -if ![isnative] then { +if {[skip_shlib_tests]} { return 0 } @@ -75,6 +74,8 @@ gdb_exit gdb_start gdb_reinitialize_dir $srcdir/$subdir gdb_load ${binfile} +gdb_load_shlibs $lib1 $lib2 + send_gdb "set print sevenbit-strings\n" ; gdb_expect -re "$gdb_prompt $" send_gdb "set print address off\n" ; gdb_expect -re "$gdb_prompt $" send_gdb "set width 0\n" ; gdb_expect -re "$gdb_prompt $" diff --git a/gdb/testsuite/gdb.base/shreloc.exp b/gdb/testsuite/gdb.base/shreloc.exp index e9e39f40cc9..b3408a87ad4 100644 --- a/gdb/testsuite/gdb.base/shreloc.exp +++ b/gdb/testsuite/gdb.base/shreloc.exp @@ -20,8 +20,7 @@ # them gets relocated at load-time. Check that gdb gets the right # values for the debugging and minimal symbols. -if {[istarget *-elf*] || [istarget *-coff] || [istarget *-aout]} then { - verbose "test skipped - shared object files not supported by this target." +if {[skip_shlib_tests]} { return 0 } @@ -85,6 +84,7 @@ gdb_exit gdb_start gdb_reinitialize_dir $srcdir/$subdir gdb_load ${workdir}/shreloc +gdb_load_shlibs $lib1_sl $lib2_sl # Load up the shared objects if ![runto_main] then { diff --git a/gdb/testsuite/gdb.base/so-impl-ld.exp b/gdb/testsuite/gdb.base/so-impl-ld.exp index cb0691b95e4..1d1a05e7c3e 100644 --- a/gdb/testsuite/gdb.base/so-impl-ld.exp +++ b/gdb/testsuite/gdb.base/so-impl-ld.exp @@ -22,9 +22,8 @@ if $tracelevel then { set prms_id 0 set bug_id 0 -# are we on a target board -if ![isnative] then { - return +if {[skip_shlib_tests]} { + return 0 } set testfile "so-impl-ld" @@ -61,6 +60,7 @@ gdb_exit gdb_start gdb_reinitialize_dir $srcdir/$subdir gdb_load ${binfile} +gdb_load_shlibs $lib_sl # This program implicitly loads SOM shared libraries. # diff --git a/gdb/testsuite/gdb.base/solib-weak.exp b/gdb/testsuite/gdb.base/solib-weak.exp index 687276910ec..85d943cb3ea 100644 --- a/gdb/testsuite/gdb.base/solib-weak.exp +++ b/gdb/testsuite/gdb.base/solib-weak.exp @@ -18,8 +18,15 @@ # than one shared library, when one of the implementations is a "weak" # symbol. GDB should set a breakpoint at the first copy it finds. -# Don't try to run shared library test cases on a remote target for now. -if ![isnative] then { +if {[skip_shlib_tests]} { + return 0 +} + +# These targets have shared libraries, but weak symbols are not meaningful. +if {([istarget arm*-*-symbianelf*] + || [istarget *-*-mingw*] + || [istarget *-*-cygwin*] + || [istarget *-*-pe*])} { return 0 } @@ -81,6 +88,7 @@ proc do_test { lib1opts lib2opts lib1first } { gdb_start gdb_reinitialize_dir $srcdir/$subdir gdb_load ${binfile} + gdb_load_shlibs $lib1 $lib2 runto_main diff --git a/gdb/testsuite/gdb.base/unload.exp b/gdb/testsuite/gdb.base/unload.exp index 105ddc40728..1b731f01121 100644 --- a/gdb/testsuite/gdb.base/unload.exp +++ b/gdb/testsuite/gdb.base/unload.exp @@ -26,8 +26,15 @@ if $tracelevel then { set prms_id 0 set bug_id 0 -# are we on a target board? -if ![isnative] then { +if {[skip_shlib_tests]} { + return 0 +} + +# TODO: Use LoadLibrary on these targets instead of dlopen. +if {([istarget arm*-*-symbianelf*] + || [istarget *-*-mingw*] + || [istarget *-*-cygwin*] + || [istarget *-*-pe*])} { return 0 } @@ -40,17 +47,16 @@ set shlibdir ${objdir}/${subdir} set libsrc $srcdir/$subdir/$libfile.c set lib_sl $objdir/$subdir/$libfile.sl -set dl_lib_flag "" +set lib_opts debug +set exec_opts [list debug additional_flags=-DSHLIB_DIR\=\"${shlibdir}\"] + switch -glob [istarget] { "hppa*-hp-hpux*" { } - "*-*-linux*" { set dl_lib_flag "libs=-ldl" } - "*-*-solaris*" { set dl_lib_flag "libs=-ldl" } + "*-*-linux*" { lappend exec_opts "libs=-ldl" } + "*-*-solaris*" { lappend exec_opts "libs=-ldl" } default { } } -set lib_opts debug -set exec_opts [list debug $dl_lib_flag additional_flags=-DSHLIB_DIR\=\"${shlibdir}\"] - if [get_compiler_info ${binfile}] { return -1 } @@ -67,6 +73,7 @@ gdb_exit gdb_start gdb_reinitialize_dir $srcdir/$subdir gdb_load ${binfile} +gdb_load_shlibs $lib_sl if [target_info exists gdb_stub] { gdb_step_for_stub; diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 5493a5cb445..d17185da941 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -1212,6 +1212,29 @@ proc skip_fortran_tests {} { return 0 } +# Return a 1 if we should skip shared library tests. + +proc skip_shlib_tests {} { + # Run the shared library tests on native systems. + if {[isnative]} { + return 0 + } + + # An abbreviated list of remote targets where we should be able to + # run shared library tests. + if {([istarget *-*-linux*] + || [istarget *-*-*bsd*] + || [istarget *-*-solaris2*] + || [istarget arm*-*-symbianelf*] + || [istarget *-*-mingw*] + || [istarget *-*-cygwin*] + || [istarget *-*-pe*])} { + return 0 + } + + return 1 +} + # Run a test on the target to see if it supports vmx hardware. Return 0 if so, # 1 if it does not. Based on 'check_vmx_hw_available' from the GCC testsuite. @@ -1500,9 +1523,13 @@ proc gdb_compile {source dest type options} { foreach opt $options { if [regexp {^shlib=(.*)} $opt dummy_var shlib_name] { if [test_compiler_info "xlc-*"] { - # IBM xlc compiler doesn't accept shared library named other - # than .so: use "-Wl," to bypass this - lappend source "-Wl,$shlib_name" + # IBM xlc compiler doesn't accept shared library named other + # than .so: use "-Wl," to bypass this + lappend source "-Wl,$shlib_name" + } elseif { ([istarget "*-*-mingw*"] + || [istarget *-*-cygwin*] + || [istarget *-*-pe*])} { + lappend source "${shlib_name}.a" } else { lappend source $shlib_name } @@ -1560,8 +1587,13 @@ proc gdb_compile {source dest type options} { } set result [target_compile $source $dest $type $options]; + + # Prune uninteresting compiler (and linker) output. + regsub "Creating library file: \[^\r\n\]*\[\r\n\]+" $result "" result + regsub "\[\r\n\]*$" "$result" "" result; regsub "^\[\r\n\]*" "$result" "" result; + if { $result != "" && [lsearch $options quiet] == -1} { clone_output "gdb compile failed, $result" } @@ -1657,6 +1689,12 @@ proc gdb_compile_shlib {sources dest options} { lappend link_options "additional_flags=-qmkshrobj" } else { lappend link_options "additional_flags=-shared" + + if { ([istarget "*-*-mingw*"] + || [istarget *-*-cygwin*] + || [istarget *-*-pe*])} { + lappend link_options "additional_flags=-Wl,--out-implib,${dest}.a" + } } if {[gdb_compile "${objects}" "${dest}" executable $link_options] != ""} { return -1 @@ -1963,6 +2001,37 @@ proc gdb_load_cmd { args } { return -1 } +# 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. + +proc gdb_download { filename } { + global cleanfiles + + set destname [remote_download target $filename] + lappend cleanfiles $destname + return $destname +} + +# gdb_load_shlibs LIB... +# +# Copy the listed libraries to the target. + +proc gdb_load_shlibs { args } { + if {![is_remote target]} { + return + } + + foreach file $args { + gdb_download $file + } + + # Even if the target supplies full paths for shared libraries, + # they may not be paths for this system. + gdb_test "set solib-search-path [file dirname [lindex $args 0]]" "" "" +} + # # gdb_load -- load a file into the debugger. # Many files in config/*.exp override this procedure. @@ -1991,7 +2060,10 @@ proc gdb_continue { function } { proc default_gdb_init { args } { global gdb_wrapper_initialized + global cleanfiles + set cleanfiles {} + gdb_clear_suppressed; # Make sure that the wrapper is rebuilt @@ -2023,7 +2095,15 @@ proc gdb_init { args } { } proc gdb_finish { } { - gdb_exit; + global cleanfiles + + # Exit first, so that the files are no longer in use. + gdb_exit + + if { [llength $cleanfiles] > 0 } { + eval remote_file target delete $cleanfiles + set cleanfiles {} + } } global debug_format diff --git a/gdb/testsuite/lib/gdbserver-support.exp b/gdb/testsuite/lib/gdbserver-support.exp index b7d7708b1d8..0a8b1117bb5 100644 --- a/gdb/testsuite/lib/gdbserver-support.exp +++ b/gdb/testsuite/lib/gdbserver-support.exp @@ -164,7 +164,7 @@ proc gdbserver_spawn { child_args } { set gdbserver_host_exec $host_exec set gdbserver_host_mtime [file mtime $host_exec] if [is_remote target] { - set gdbserver_server_exec [remote_download target $host_exec /tmp/[file tail $host_exec].[pid]] + set gdbserver_server_exec [gdb_download $host_exec] } else { set gdbserver_server_exec $host_exec } -- 2.30.2