From patchwork Wed Apr 27 20:55:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 11921 Received: (qmail 116412 invoked by alias); 27 Apr 2016 20:55:31 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 116394 invoked by uid 89); 27 Apr 2016 20:55:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=BAYES_00, KAM_LAZY_DOMAIN_SECURITY autolearn=no version=3.3.2 spammy=0x40000000 X-HELO: usplmg20.ericsson.net Received: from usplmg20.ericsson.net (HELO usplmg20.ericsson.net) (198.24.6.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Wed, 27 Apr 2016 20:55:27 +0000 Received: from EUSAAHC005.ericsson.se (Unknown_Domain [147.117.188.87]) by usplmg20.ericsson.net (Symantec Mail Security) with SMTP id 9F.7A.09012.00021275; Wed, 27 Apr 2016 22:24:32 +0200 (CEST) Received: from elxcz23q12-y4.dyn.mo.ca.am.ericsson.se (147.117.188.8) by smtps-am.internal.ericsson.com (147.117.188.87) with Microsoft SMTP Server (TLS) id 14.3.248.2; Wed, 27 Apr 2016 16:55:24 -0400 From: Simon Marchi To: CC: Simon Marchi Subject: [PATCH v2 1/3] Make gdb_load_shlibs return the destination path of the library Date: Wed, 27 Apr 2016 16:55:18 -0400 Message-ID: <1461790520-9460-1-git-send-email-simon.marchi@ericsson.com> MIME-Version: 1.0 X-IsSubscribed: yes This patch makes gdb_load_shlibs return the destination path of the copied library. To make the procedure implementation and interface more straightforward, it also changes it so that it accepts a single shared library path at the time. Therefore, calls that are passed multiple libraries: gdb_load_shlibs $lib1 $lib2 must be changed to separate calls: gdb_load_shlibs $lib1 gdb_load_shlibs $lib2 A subtle impact is the solib-search-path handling. In the former version, solib-search-path is set using the directory of the first passed lib (further calls overwrite the value). In the later version, the directory of the library passed to the last call to gdb_load_shlibs remnains. I don't think that's a problem in practice, since if we had tests that needed multiple different paths in solib-search-path, they wouldn't work in the first place. Changed in v2: * Split behavioural and rename changes in two separate patches. gdb/testsuite/ChangeLog: * lib/gdb.exp (gdb_load_shlibs): Accept a single argument. Return result of gdb_remote_download. * gdb.base/ctxobj.exp: Split gdb_load_shlibs call. * gdb.base/dso2dso.exp: Likewise. * gdb.base/global-var-nested-by-dso.exp: Likewise. * gdb.base/print-file-var.exp: Likewise. * gdb.base/shlib-call.exp: Likewise. * gdb.base/shreloc.exp: Likewise. * gdb.base/solib-overlap.exp: Likewise. * gdb.base/solib-weak.exp (do_test): Likewise. * gdb.base/unload.exp: Likewise. --- gdb/testsuite/gdb.base/ctxobj.exp | 3 ++- gdb/testsuite/gdb.base/dso2dso.exp | 3 ++- gdb/testsuite/gdb.base/global-var-nested-by-dso.exp | 3 ++- gdb/testsuite/gdb.base/print-file-var.exp | 3 ++- gdb/testsuite/gdb.base/shlib-call.exp | 3 ++- gdb/testsuite/gdb.base/shreloc.exp | 3 ++- gdb/testsuite/gdb.base/solib-overlap.exp | 3 ++- gdb/testsuite/gdb.base/solib-weak.exp | 3 ++- gdb/testsuite/gdb.base/unload.exp | 3 ++- gdb/testsuite/lib/gdb.exp | 12 ++++++------ 10 files changed, 24 insertions(+), 15 deletions(-) diff --git a/gdb/testsuite/gdb.base/ctxobj.exp b/gdb/testsuite/gdb.base/ctxobj.exp index a4f5f37..4df2a1b 100644 --- a/gdb/testsuite/gdb.base/ctxobj.exp +++ b/gdb/testsuite/gdb.base/ctxobj.exp @@ -55,7 +55,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${executable}.c" \ } clean_restart $executable -gdb_load_shlibs $libobj1 $libobj2 +gdb_load_shlibs $libobj1 +gdb_load_shlibs $libobj2 if ![runto_main] { untested "could not run to main" diff --git a/gdb/testsuite/gdb.base/dso2dso.exp b/gdb/testsuite/gdb.base/dso2dso.exp index 919eda4..7f3a2b9 100644 --- a/gdb/testsuite/gdb.base/dso2dso.exp +++ b/gdb/testsuite/gdb.base/dso2dso.exp @@ -57,7 +57,8 @@ if { [gdb_compile $srcdir/$subdir/$srcfile $binfile executable \ } clean_restart $binfile -gdb_load_shlibs $binfile_libdso2 $binfile_libdso1 +gdb_load_shlibs $binfile_libdso2 +gdb_load_shlibs $binfile_libdso1 if { ![runto_main] } { return -1 diff --git a/gdb/testsuite/gdb.base/global-var-nested-by-dso.exp b/gdb/testsuite/gdb.base/global-var-nested-by-dso.exp index cf70bb1..13a2723 100644 --- a/gdb/testsuite/gdb.base/global-var-nested-by-dso.exp +++ b/gdb/testsuite/gdb.base/global-var-nested-by-dso.exp @@ -45,7 +45,8 @@ if { [gdb_compile $srcdir/$subdir/$srcfile $binfile executable \ } clean_restart $binfile -gdb_load_shlibs $binfile_lib1 $binfile_lib2 +gdb_load_shlibs $binfile_lib1 +gdb_load_shlibs $binfile_lib2 if { ![runto_main] } { return -1 diff --git a/gdb/testsuite/gdb.base/print-file-var.exp b/gdb/testsuite/gdb.base/print-file-var.exp index 112585a..2f8db92 100644 --- a/gdb/testsuite/gdb.base/print-file-var.exp +++ b/gdb/testsuite/gdb.base/print-file-var.exp @@ -46,7 +46,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${executable}.c" \ } clean_restart $executable -gdb_load_shlibs $libobj1 $libobj2 +gdb_load_shlibs $libobj1 +gdb_load_shlibs $libobj2 if ![runto_main] { untested "could not run to main" diff --git a/gdb/testsuite/gdb.base/shlib-call.exp b/gdb/testsuite/gdb.base/shlib-call.exp index 81d2e03..9dac96f 100644 --- a/gdb/testsuite/gdb.base/shlib-call.exp +++ b/gdb/testsuite/gdb.base/shlib-call.exp @@ -57,7 +57,8 @@ if { [gdb_compile_shlib ${lib1src} ${lib1} $lib_opts] != "" # Start with a fresh gdb. clean_restart ${binfile} -gdb_load_shlibs $lib1 $lib2 +gdb_load_shlibs $lib1 +gdb_load_shlibs $lib2 gdb_test_no_output "set print sevenbit-strings" gdb_test_no_output "set print address off" diff --git a/gdb/testsuite/gdb.base/shreloc.exp b/gdb/testsuite/gdb.base/shreloc.exp index 3b1ec24..124fca8 100644 --- a/gdb/testsuite/gdb.base/shreloc.exp +++ b/gdb/testsuite/gdb.base/shreloc.exp @@ -72,7 +72,8 @@ if { [gdb_compile_shlib $lib1src $lib1_sl $lib_opts] != ""} { # Start with a fresh gdb. clean_restart $binfile -gdb_load_shlibs $lib1_sl $lib2_sl +gdb_load_shlibs $lib1_sl +gdb_load_shlibs $lib2_sl # Load up the shared objects if ![runto_main] then { diff --git a/gdb/testsuite/gdb.base/solib-overlap.exp b/gdb/testsuite/gdb.base/solib-overlap.exp index e7e084c..258fce3 100644 --- a/gdb/testsuite/gdb.base/solib-overlap.exp +++ b/gdb/testsuite/gdb.base/solib-overlap.exp @@ -99,7 +99,8 @@ foreach prelink_lib1 {0x40000000 0x50000000} { with_test_prefix "$prelink_lib1" clean_restart ${binfile_base} # This testcase currently does not support remote targets. - # gdb_load_shlibs ${binfile_lib1} ${binfile_lib2} + # gdb_load_shlibs ${binfile_lib1} + # gdb_load_shlibs ${binfile_lib2} # Here we should get: # warning: .dynamic section for ".../solib-overlap-lib1.so" is not at the expected address (wrong library or version mismatch?) diff --git a/gdb/testsuite/gdb.base/solib-weak.exp b/gdb/testsuite/gdb.base/solib-weak.exp index 74bc1f3..b99b473 100644 --- a/gdb/testsuite/gdb.base/solib-weak.exp +++ b/gdb/testsuite/gdb.base/solib-weak.exp @@ -94,7 +94,8 @@ proc do_test { lib1opts lib2opts lib1first } { gdb_start gdb_reinitialize_dir $srcdir/$subdir gdb_load ${binfile} - gdb_load_shlibs $lib1 $lib2 + gdb_load_shlibs $lib1 + gdb_load_shlibs $lib2 runto_main diff --git a/gdb/testsuite/gdb.base/unload.exp b/gdb/testsuite/gdb.base/unload.exp index 6d4133d..8abaf3e 100644 --- a/gdb/testsuite/gdb.base/unload.exp +++ b/gdb/testsuite/gdb.base/unload.exp @@ -62,7 +62,8 @@ gdb_exit gdb_start gdb_reinitialize_dir $srcdir/$subdir gdb_load ${binfile} -gdb_load_shlibs $lib_sl $lib_sl2 +gdb_load_shlibs $lib_sl +gdb_load_shlibs $lib_sl2 # # Test setting a breakpoint in a dynamically loaded library which is diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 8b0241d..441107b 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -4231,12 +4231,10 @@ proc gdb_remote_download {dest fromfile {tofile {}}} { # gdb_load_shlibs LIB... # -# Copy the listed libraries to the target. +# Copy the listed library to the target. -proc gdb_load_shlibs { args } { - foreach file $args { - gdb_remote_download target [shlib_target_file $file] - } +proc gdb_load_shlibs { file } { + 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 @@ -4245,8 +4243,10 @@ proc gdb_load_shlibs { args } { # 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 [lindex $args 0]]" "" "" + gdb_test "set solib-search-path [file dirname $file]" "" "" } + + return $dest } #