From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17322 invoked by alias); 16 Oct 2014 17:48:59 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 17312 invoked by uid 89); 16 Oct 2014 17:48:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 16 Oct 2014 17:48:58 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s9GHmtZu027022 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 16 Oct 2014 13:48:55 -0400 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s9GHmr88021052; Thu, 16 Oct 2014 13:48:54 -0400 Message-ID: <54400505.6070908@redhat.com> Date: Thu, 16 Oct 2014 17:48:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.1.1 MIME-Version: 1.0 To: Yao Qi , gdb-patches@sourceware.org Subject: Re: [PATCH] Skip argv0-symlink.exp on target argv[0] isn't available References: <1413440712-3645-1-git-send-email-yao@codesourcery.com> In-Reply-To: <1413440712-3645-1-git-send-email-yao@codesourcery.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2014-10/txt/msg00427.txt.bz2 On 10/16/2014 07:25 AM, Yao Qi wrote: > > When the program is running with gdbserver, argv[1] to argv[N] aren't > available, but argv[0] is. Fortunately, argv0-symlink.exp only > requires argv[0]. argv0-symlink.exp can be run with gdbserver board > file, as what we do now. > > What we need to check is whether argv[0] is available, so I add a new > proc gdb_has_argv0 to do so by starting a program, and check > argc/argv[0] to see whether argv[0] is available. Sounds good. > --- a/gdb/testsuite/gdb.base/argv0-symlink.exp > +++ b/gdb/testsuite/gdb.base/argv0-symlink.exp > @@ -13,6 +13,11 @@ > # You should have received a copy of the GNU General Public License > # along with this program. If not, see . > > +if { ![gdb_has_argv0] } { > + unsupported "Can't get argv\[0\]." > + return > +} > + 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. > > # 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..dd525dc 100644 > --- a/gdb/testsuite/lib/gdb.exp > +++ b/gdb/testsuite/lib/gdb.exp > @@ -4227,6 +4227,85 @@ 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. > + send_gdb "break main\n" > + gdb_expect { > + -re "Breakpoint.*${gdb_prompt} $" { > + } > + -re "${gdb_prompt} $" { > + return 0 > + } > + } > + > + # Run to main. > + gdb_run_cmd > + gdb_expect { > + -re "Breakpoint.*${gdb_prompt} $" { > + } > + -re "${gdb_prompt} $" { > + return 0 > + } > + } > + > + # Check whether argc is 1. > + send_gdb "p argc\n" > + gdb_expect { > + -re " = 1\r\n${gdb_prompt} $" { > + > + 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? > + 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. Thanks, Pedro Alves