From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by sourceware.org (Postfix) with ESMTPS id D9F7E3858D39 for ; Tue, 7 Mar 2023 09:00:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D9F7E3858D39 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 043591FE14 for ; Tue, 7 Mar 2023 09:00:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678179611; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=hv4ha+4BH6wkLzu54tQerZ/lkiSsxTlHcBP6d2woN90=; b=CVs4QXxMljoDznZUAm6ew+HBOcso35vPskGJD5VRI58nt3kQm6bS4aQYFiXwYA7dP2OR1V /71pT/7RBzdIDXTdJSUCqiv98f5BK+heeqllFaKTenOz49F6BRiWcoxETAaLmDG8aKfNlc dNf8hNRJ1p5LjWbK8dVvB/FHndESp2A= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678179611; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=hv4ha+4BH6wkLzu54tQerZ/lkiSsxTlHcBP6d2woN90=; b=rTHoSdCxHzBcZldSHb1Il6tI79v/uoQoWPbRjsPqjpqIQqUnL74iPvMeIYax2eZ3R5rdnI YtqmdD5uIsnQKYAg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id E43C613440 for ; Tue, 7 Mar 2023 09:00:10 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id JJR7Nhr9BmSGKwAAMHmgww (envelope-from ) for ; Tue, 07 Mar 2023 09:00:10 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [pushed] [gdb/testsuite] Fix gdb.mi/*.exp with remote-gdbserver-on-localhost Date: Tue, 7 Mar 2023 10:00:15 +0100 Message-Id: <20230307090015.1250-1-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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. --- gdb/testsuite/gdb.mi/mi-catch-load.exp | 4 ++ .../gdb.mi/mi-var-invalidate-shlib.exp | 5 ++- 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 842f4b47f1d..9d15e84d5dc 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 94eccdf63a0..47ac54f7088 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 ab251da339c..3c2dd2fab2b 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 } } base-commit: 07f285934886016ddd82cac99a3873e68b499d5c -- 2.35.3