From patchwork Fri Oct 17 07:20:27 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 3258 Received: (qmail 21611 invoked by alias); 17 Oct 2014 07:24:32 -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 21596 invoked by uid 89); 17 Oct 2014 07:24:30 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 17 Oct 2014 07:24:28 +0000 Received: from svr-orw-fem-04.mgc.mentorg.com ([147.34.97.41]) by relay1.mentorg.com with esmtp id 1Xf1tg-0004oW-BT from Yao_Qi@mentor.com ; Fri, 17 Oct 2014 00:24:24 -0700 Received: from GreenOnly (147.34.91.1) by svr-orw-fem-04.mgc.mentorg.com (147.34.97.41) with Microsoft SMTP Server id 14.3.181.6; Fri, 17 Oct 2014 00:24:23 -0700 From: Yao Qi To: Pedro Alves CC: Subject: Re: [PATCH] Skip argv0-symlink.exp on target argv[0] isn't available References: <1413440712-3645-1-git-send-email-yao@codesourcery.com> <54400505.6070908@redhat.com> Date: Fri, 17 Oct 2014 15:20:27 +0800 In-Reply-To: <54400505.6070908@redhat.com> (Pedro Alves's message of "Thu, 16 Oct 2014 18:48:53 +0100") Message-ID: <87lhofkvr8.fsf@codesourcery.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 X-IsSubscribed: yes Pedro Alves writes: > I think we shouldn't skip the whole test though; only the > printing argv[0] test. The test file also makes sure > that "info inferiors" shows the symlink name, not the target > of the symlink, and that is host-dependent, not target > dependent. See git 4856b6bc. Yeah, we can wrap the test on argv[0] with if { $has_argv0 } {...}. See below in the updated patch. >> + >> + send_gdb "p argv\[0\]\n" >> + gdb_expect { >> + -re " = $hex \".*$exe\"\r\n${gdb_prompt} $" { > > I suspect this may break if remote (host|target) testing, > and not sharing the filesystem between build/host/target. > Isn't $exe here a full path on the build? > $exe can be a full path, and can be a base name too. It depends on proc standard_temp_file. You are right that it is a mistake to use the build file path on host. I change it to ".*[file tail $exe]\"\r\n${gdb_prompt} $" >> + return 1 >> + } >> + -re "${gdb_prompt} $" { >> + return 0 >> + } >> + } >> + } >> + -re "${gdb_prompt} $" { >> + return 0 >> + } >> + } >> + return 0 >> + } >> + > > I think these gdb_expect's should be gdb_test_multiple's instead. Fixed. diff --git a/gdb/testsuite/gdb.base/argv0-symlink.exp b/gdb/testsuite/gdb.base/argv0-symlink.exp index d849b4c..cda2128 100644 --- a/gdb/testsuite/gdb.base/argv0-symlink.exp +++ b/gdb/testsuite/gdb.base/argv0-symlink.exp @@ -15,6 +15,8 @@ standard_testfile +set has_argv0 [gdb_has_argv0] + if { [build_executable ${testfile}.exp ${testfile} ${srcfile}] == -1 } { return -1 } @@ -39,7 +41,9 @@ if ![runto_main] { gdb_test_no_output "set print repeats 10000" gdb_test_no_output "set print elements 10000" -gdb_test {print argv[0]} "/$filelink\"" $test +if { $has_argv0 } { + gdb_test {print argv[0]} "/$filelink\"" $test +} # For a link named /PATH/TO/DIR/LINK, we want to check the output # against "/DIR/LINK", but computed in a way that doesn't make @@ -73,9 +77,12 @@ if ![runto_main] { gdb_test_no_output "set print repeats 10000" gdb_test_no_output "set print elements 10000" -# gdbserver does not have this issue. -if ![is_remote target] { - setup_kfail "*-*-*" gdb/15934 +if { $has_argv0 } { + # gdbserver does not have this issue. + if ![is_remote target] { + setup_kfail "*-*-*" gdb/15934 + } + gdb_test {print argv[0]} "/$dirlink/$filelink\"" $test } -gdb_test {print argv[0]} "/$dirlink/$filelink\"" $test + gdb_test "info inferiors" "/$lastdir/$filelink *" "$test for info inferiors" diff --git a/gdb/testsuite/gdb.guile/scm-value.exp b/gdb/testsuite/gdb.guile/scm-value.exp index ae80d1b..2b49134 100644 --- a/gdb/testsuite/gdb.guile/scm-value.exp +++ b/gdb/testsuite/gdb.guile/scm-value.exp @@ -20,6 +20,8 @@ load_lib gdb-guile.exp standard_testfile +set has_argv0 [gdb_has_argv0] + # Build inferior to language specification. # LANG is one of "c" or "c++". proc build_inferior {exefile lang} { @@ -86,7 +88,8 @@ proc test_value_in_inferior {} { "set arg0" # Check that the dereferenced value is sane. - if { ! [target_info exists noargs] } { + global has_argv0 + if { $has_argv0 } { gdb_test "gu (print arg0)" \ "0x.*$testfile\"" "verify dereferenced value" } diff --git a/gdb/testsuite/gdb.python/py-value.exp b/gdb/testsuite/gdb.python/py-value.exp index 0d18bef..afa55a5 100644 --- a/gdb/testsuite/gdb.python/py-value.exp +++ b/gdb/testsuite/gdb.python/py-value.exp @@ -20,6 +20,8 @@ load_lib gdb-python.exp standard_testfile +set has_argv0 [gdb_has_argv0] + # Build inferior to language specification. # LANG is one of "c" or "c++". proc build_inferior {exefile lang} { @@ -221,7 +223,8 @@ proc test_value_in_inferior {} { gdb_py_test_silent_cmd "python arg0 = argv.dereference ()" "dereference value" 1 # Check that the dereferenced value is sane - if { ! [target_info exists noargs] } { + global has_argv0 + if { $has_argv0 } { gdb_test "python print (arg0)" "0x.*$testfile\"" "verify dereferenced value" } diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 7b2a402..53a7b1f 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -4227,6 +4227,82 @@ gdb_caching_proc gdb_skip_xml_test { return $xml_missing } +# Return true if argv[0] is available. + +gdb_caching_proc gdb_has_argv0 { + set result 0 + + # Set up, compile, and execute a test program to check whether + # argv[0] is available. + set src [standard_temp_file has_argv0[pid].c] + set exe [standard_temp_file has_argv0[pid].x] + + gdb_produce_source $src { + int main (int argc, char **argv) { + return 0; + } + } + + gdb_compile $src $exe executable {debug} + + # Helper proc. + proc gdb_has_argv0_1 { exe } { + global srcdir subdir + global gdb_prompt hex decimal + + gdb_exit + gdb_start + gdb_reinitialize_dir $srcdir/$subdir + gdb_load "$exe" + + # Set breakpoint on main. + gdb_test_multiple "break main" "break main" { + -re "Breakpoint.*${gdb_prompt} $" { + } + -re "${gdb_prompt} $" { + return 0 + } + } + + # Run to main. + gdb_run_cmd + gdb_test_multiple "" "run to main" { + -re "Breakpoint.*${gdb_prompt} $" { + } + -re "${gdb_prompt} $" { + return 0 + } + } + + # Check whether argc is 1. + gdb_test_multiple "p argc" "p argc" { + -re " = 1\r\n${gdb_prompt} $" { + + gdb_test_multiple "p argv\[0\]" "p argv\[0\]" { + -re " = $hex \".*[file tail $exe]\"\r\n${gdb_prompt} $" { + return 1 + } + -re "${gdb_prompt} $" { + return 0 + } + } + } + -re "${gdb_prompt} $" { + return 0 + } + } + return 0 + } + + set result [gdb_has_argv0_1 $exe] + + gdb_exit + file delete $src + file delete $exe + + return $result +} + # Note: the procedure gdb_gnu_strip_debug will produce an executable called # ${binfile}.dbglnk, which is just like the executable ($binfile) but without # the debuginfo. Instead $binfile has a .gnu_debuglink section which contains