From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 94720 invoked by alias); 24 Jul 2015 18:43:48 -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 94699 invoked by uid 89); 24 Jul 2015 18:43:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS 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, 24 Jul 2015 18:43:43 +0000 Received: from svr-orw-fem-03.mgc.mentorg.com ([147.34.97.39]) by relay1.mentorg.com with esmtp id 1ZIhwZ-0005rU-GD from Luis_Gustavo@mentor.com ; Fri, 24 Jul 2015 11:43:39 -0700 Received: from [172.30.10.102] (147.34.91.1) by svr-orw-fem-03.mgc.mentorg.com (147.34.97.39) with Microsoft SMTP Server id 14.3.224.2; Fri, 24 Jul 2015 11:43:38 -0700 Message-ID: <55B28758.8050305@codesourcery.com> Date: Fri, 24 Jul 2015 18:43:00 -0000 From: Luis Machado Reply-To: Luis Machado User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Sergio Durigan Junior , GDB Patches Subject: Re: [PATCH] Make sure GDB uses a valid shell when starting the inferior and to perform the "shell" command References: <1437761993-18758-1-git-send-email-sergiodj@redhat.com> In-Reply-To: <1437761993-18758-1-git-send-email-sergiodj@redhat.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2015-07/txt/msg00713.txt.bz2 On 07/24/2015 03:19 PM, Sergio Durigan Junior wrote: > diff --git a/gdb/testsuite/gdb.base/invalid-shell.exp b/gdb/testsuite/gdb.base/invalid-shell.exp > new file mode 100644 > index 0000000..252ef13 > --- /dev/null > +++ b/gdb/testsuite/gdb.base/invalid-shell.exp > @@ -0,0 +1,38 @@ > +# Copyright 2015 Free Software Foundation, Inc. > + > +# This program is free software; you can redistribute it and/or modify > +# it under the terms of the GNU General Public License as published by > +# the Free Software Foundation; either version 3 of the License, or > +# (at your option) any later version. > +# > +# This program is distributed in the hope that it will be useful, > +# but WITHOUT ANY WARRANTY; without even the implied warranty of > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > +# GNU General Public License for more details. > +# > +# You should have received a copy of the GNU General Public License > +# along with this program. If not, see. > + > +standard_testfile normal.c > + > +if { [prepare_for_testing "failed to prepare" $testfile $srcfile debug] } { > + untested "could not compile test program" > + return -1 > +} > + > +gdb_exit > + > +# Set the $SHELL to an invalid file. This will cause GDB to use > +# /bin/sh instead. > +set oldshell $env(SHELL) > +set env(SHELL) "/invalid/path/to/file" > + > +clean_restart $binfile > + > +# Running the inferior must work. > +gdb_test "run" "Starting program: .*\r\nwarning: Invalid shell \\\'/invalid/path/to/file\\\'; using \\\'/bin/sh\\\' instead.\r\n\\\[Inferior $decimal \\\(process $decimal\\\) exited normally\\\]" "starting with /bin/sh instead of invalid shell" > + > +# Invoking a shell command must also work. > +gdb_test "shell echo hi" "hi" "invoking shell command from prompt" > + > +set env(SHELL) $oldshell I think this test, as is, will not be meaningful for non-linux targets or, in general, for remote targets. Also, the assumption of a path like "/invalid/path/to/file" may not work for mingw32. "run" will also not work for remote targets unless they are running in extended-remote mode. We should either make tests more general or restrict them appropriately so they don't cause spurious failures for targets for which these should not be executed.