(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-16 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * 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 <vladimir@codesourcery.com>
* config/unknown.exp: Remove.
strace $tracelevel
}
+if {[skip_shlib_tests]} {
+ return 0
+}
+
set testfile gdb1555-main
set libfile gdb1555
set srcfile ${testfile}.c
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
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
gdb_load ${binfile}
+gdb_load_shlibs $libobj
if ![runto_main] then {
fail "Can't run to main"
set prms_id 0
set bug_id 0
-# are we on a target board?
-if ![isnative] then {
+if {[skip_shlib_tests]} {
return 0
}
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;
set prms_id 0
set bug_id 0
-# are we on a target board?
-if ![isnative] then {
+if {[skip_shlib_tests]} {
return 0
}
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 $"
# 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
}
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 {
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"
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
gdb_load ${binfile}
+gdb_load_shlibs $lib_sl
# This program implicitly loads SOM shared libraries.
#
# 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
}
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
gdb_load ${binfile}
+ gdb_load_shlibs $lib1 $lib2
runto_main
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
}
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
}
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;
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.
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
}
}
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"
}
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
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.
proc default_gdb_init { args } {
global gdb_wrapper_initialized
+ global cleanfiles
+ set cleanfiles {}
+
gdb_clear_suppressed;
# Make sure that the wrapper is rebuilt
}
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
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
}