diff options
author | Tom de Vries <tdevries@suse.de> | 2023-03-07 09:59:56 +0100 |
---|---|---|
committer | Tom de Vries <tdevries@suse.de> | 2023-03-07 09:59:56 +0100 |
commit | e8850b52624245a1d7b8ef9fc41abb6175ec74e4 (patch) | |
tree | f2f41add62abe1907f48f099f7701a489d9f822f | |
parent | 07f285934886016ddd82cac99a3873e68b499d5c (diff) | |
download | binutils-e8850b52624245a1d7b8ef9fc41abb6175ec74e4.zip binutils-e8850b52624245a1d7b8ef9fc41abb6175ec74e4.tar.gz binutils-e8850b52624245a1d7b8ef9fc41abb6175ec74e4.tar.bz2 |
[gdb/testsuite] Fix gdb.mi/*.exp with remote-gdbserver-on-localhost
When running test-cases gdb.mi/*.exp with target board
remote-gdbserver-on-localhost, we run into a few fails.
Fix these (and make things more similar to the gdb.exp procs) by:
- factoring out mi_load_shlib out of mi_load_shlibs
- making mi_load_shlib use gdb_download_shlib, like
gdb_load_shlib
- factoring out mi_locate_shlib out of mi_load_shlib
- making mi_locate_shlib check for mi_spawn_id, like
gdb_locate_shlib
- using gdb_download_shlib and mi_locate_shlib in the test-cases.
Tested on x86_64-linux, with and without target board
remote-gdbserver-on-localhost.
-rw-r--r-- | gdb/testsuite/gdb.mi/mi-catch-load.exp | 4 | ||||
-rw-r--r-- | gdb/testsuite/gdb.mi/mi-var-invalidate-shlib.exp | 5 | ||||
-rw-r--r-- | gdb/testsuite/lib/mi-support.exp | 40 |
3 files changed, 36 insertions, 13 deletions
diff --git a/gdb/testsuite/gdb.mi/mi-catch-load.exp b/gdb/testsuite/gdb.mi/mi-catch-load.exp index 842f4b4..9d15e84 100644 --- a/gdb/testsuite/gdb.mi/mi-catch-load.exp +++ b/gdb/testsuite/gdb.mi/mi-catch-load.exp @@ -32,9 +32,12 @@ if { [gdb_compile_shlib "${srcdir}/${subdir}/${srcfile2}" ${binfile2} {debug}] ! return -1 } +gdb_download_shlib $binfile2 + # test -catch-load with_test_prefix "catch-load" { mi_clean_restart $binfile + mi_locate_shlib $binfile2 mi_runto_main mi_gdb_test "111-gdb-set auto-solib-add on" "111\\^done" \ @@ -61,6 +64,7 @@ with_test_prefix "catch-load" { # test -catch-unload with_test_prefix "catch-unload" { mi_clean_restart $binfile + mi_locate_shlib $binfile2 mi_runto_main mi_gdb_test "111-gdb-set auto-solib-add on" "111\\^done" "auto-solib-add on" diff --git a/gdb/testsuite/gdb.mi/mi-var-invalidate-shlib.exp b/gdb/testsuite/gdb.mi/mi-var-invalidate-shlib.exp index 94eccdf..47ac54f 100644 --- a/gdb/testsuite/gdb.mi/mi-var-invalidate-shlib.exp +++ b/gdb/testsuite/gdb.mi/mi-var-invalidate-shlib.exp @@ -30,8 +30,9 @@ if { [gdb_compile_shlib $srcdir/$subdir/$srcfile2 $shlib_path {debug}] != "" } { return -1 } +set shlib_path_target [gdb_download_shlib $shlib_path] -set opts [list shlib_load debug additional_flags=-DSHLIB_PATH="${shlib_path}"] +set opts [list shlib_load debug additional_flags=-DSHLIB_PATH="${shlib_path_target}"] if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable $opts] != "" } { untested "failed to compile" return -1 @@ -45,7 +46,7 @@ proc do_test { separate_debuginfo } { # Start the process once and create varobjs referencing the loaded objfiles. with_test_prefix "setup" { - mi_load_shlibs $::shlib_path + mi_locate_shlib $::shlib_path if { $separate_debuginfo } { mi_load_shlibs ${::shlib_path}.debug } diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp index ab251da..3c2dd2f 100644 --- a/gdb/testsuite/lib/mi-support.exp +++ b/gdb/testsuite/lib/mi-support.exp @@ -2069,20 +2069,38 @@ proc check_mi_and_console_threads {name} { } } +# Set solib-search-path to allow gdb to locate shlib FILE. +proc mi_locate_shlib { file } { + global mi_spawn_id + + if ![info exists mi_spawn_id] { + perror "mi_locate_shlib: GDB is not running" + } + + # If the target is remote, we need to tell gdb where to find the + # libraries. + if { ![is_remote target] } { + return + } + + # We could set this even when not testing remotely, but a user + # generally won't set it unless necessary. In order to make the tests + # more like the real-life scenarios, we don't set it for local testing. + mi_gdb_test "set solib-search-path [file dirname $file]" "\^done" "" +} + +# Copy shlib FILE to the target and set solib-search-path to allow gdb to +# locate it. +proc mi_load_shlib { file } { + set dest [gdb_download_shlib $file] + mi_locate_shlib $file + return $dest +} + # Download shared libraries to the target. proc mi_load_shlibs { args } { foreach file $args { - gdb_remote_download target [shlib_target_file $file] - } - - if {[is_remote target]} { - # If the target is remote, we need to tell gdb where to find the - # libraries. - # - # We could set this even when not testing remotely, but a user - # generally won't set it unless necessary. In order to make the tests - # more like the real-life scenarios, we don't set it for local testing. - mi_gdb_test "set solib-search-path [file dirname [lindex $args 0]]" "\^done" "" + mi_load_shlib $file } } |