From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2205) id 8A3EA3896C04; Tue, 15 Nov 2022 14:25:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8A3EA3896C04 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1668522315; bh=tsPsLhZ2ObeUPaln0u1MoYe5eFt9qJBZ8hK1cGnGqlE=; h=From:To:Subject:Date:From; b=ltOoybINrCqtZAk29HJlQsFS6HIqYDOMLM1txTPrDwwvSHOY4/VQiTUP4spz7SH6m 5HBAW/HMN5pT1CPlsBT02FSm4SQQh1FhIN/r03RScr+3M9c8FHT99X9sGOi+2P3CeE cqgfHIzoYN5ydcYMbydoaPsn7LIPYrn5ume9GoRk= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom de Vries To: gdb-cvs@sourceware.org Subject: [binutils-gdb] [gdb/testsuite] Fix gdb.base/print-file-var.exp for remote target X-Act-Checkin: binutils-gdb X-Git-Author: Tom de Vries X-Git-Refname: refs/heads/master X-Git-Oldrev: 2a1742f31c21c852ebc105adc0dfb6b57570f552 X-Git-Newrev: 4b4f2a7d2551ecb98dbb3fbfff3e3ba177916f78 Message-Id: <20221115142515.8A3EA3896C04@sourceware.org> Date: Tue, 15 Nov 2022 14:25:15 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D4b4f2a7d2551= ecb98dbb3fbfff3e3ba177916f78 commit 4b4f2a7d2551ecb98dbb3fbfff3e3ba177916f78 Author: Tom de Vries Date: Tue Nov 15 15:24:54 2022 +0100 [gdb/testsuite] Fix gdb.base/print-file-var.exp for remote target =20 When running test-case gdb.base/print-file-var.exp with target board remote-gdbserver-on-localhost (using REMOTE_TARGET_USERNAME) we run int= o some failures. =20 Fix these by using the name of a shared lib as returned by gdb_load_shl= ib. =20 This required splitting up the gdb_load_shlib functionality, which is n= ow defined as: ... proc gdb_load_shlib { file } { set dest [gdb_download_shlib $file] gdb_locate_shlib $file return $dest } ... such that we can do gdb_download_shlib before gdb is started. =20 Tested on x86_64-linux. =20 Co-Authored-by: Ivan Tetyushkin Diff: --- gdb/testsuite/gdb.base/print-file-var.exp | 6 +++-- gdb/testsuite/lib/gdb.exp | 40 +++++++++++++++++++--------= ---- 2 files changed, 29 insertions(+), 17 deletions(-) diff --git a/gdb/testsuite/gdb.base/print-file-var.exp b/gdb/testsuite/gdb.= base/print-file-var.exp index 9abe87d7758..841eb22d957 100644 --- a/gdb/testsuite/gdb.base/print-file-var.exp +++ b/gdb/testsuite/gdb.base/print-file-var.exp @@ -59,8 +59,10 @@ proc test {hidden dlopen version_id_main lang} { set main_opts [list debug $lang] set link_opts [list debug shlib=3D${libobj1}] =20 + set target_libobj2 [gdb_download_shlib $libobj2] + if {$dlopen} { - lappend main_opts "additional_flags=3D-DSHLIB_NAME=3D\"$libobj2\"" + lappend main_opts "additional_flags=3D-DSHLIB_NAME=3D\"$target_libobj2\"" lappend link_opts "shlib_load" } else { lappend link_opts "shlib=3D${libobj2}" @@ -79,7 +81,7 @@ proc test {hidden dlopen version_id_main lang} { =20 clean_restart $executable gdb_load_shlib $libobj1 - gdb_load_shlib $libobj2 + gdb_locate_shlib $libobj2 =20 if ![runto_main] { return -1 diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 34c7a1cb50f..0543da31da6 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -5870,30 +5870,40 @@ proc gdb_remote_download {dest fromfile {tofile {}}= } { } } =20 -# gdb_load_shlib LIB... -# -# Copy the listed library to the target. +# Copy shlib FILE to the target. =20 -proc gdb_load_shlib { file } { +proc gdb_download_shlib { file } { + return [gdb_remote_download target [shlib_target_file $file]] +} + +# Set solib-search-path to allow gdb to locate shlib FILE. + +proc gdb_locate_shlib { file } { global gdb_spawn_id =20 if ![info exists gdb_spawn_id] { perror "gdb_load_shlib: GDB is not running" } =20 - set dest [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. - gdb_test "set solib-search-path [file dirname $file]" "" \ - "set solib-search-path for [file tail $file]" + # If the target is remote, we need to tell gdb where to find the + # libraries. + if { ![is_remote target] } { + return } =20 + # 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. + gdb_test "set solib-search-path [file dirname $file]" "" \ + "set solib-search-path for [file tail $file]" +} + +# Copy shlib FILE to the target and set solib-search-path to allow gdb to +# locate it. + +proc gdb_load_shlib { file } { + set dest [gdb_download_shlib $file] + gdb_locate_shlib $file return $dest }