From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1764 invoked by alias); 16 Oct 2013 15:13:27 -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 1752 invoked by uid 89); 16 Oct 2013 15:13:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 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; Wed, 16 Oct 2013 15:13:24 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1VWSmm-0004f6-RJ from Luis_Gustavo@mentor.com ; Wed, 16 Oct 2013 08:13:20 -0700 Received: from NA1-MAIL.mgc.mentorg.com ([147.34.98.181]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Wed, 16 Oct 2013 08:13:20 -0700 Received: from [172.30.0.204] ([172.30.0.204]) by NA1-MAIL.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 16 Oct 2013 08:13:20 -0700 Message-ID: <525EAD04.5040506@codesourcery.com> Date: Wed, 16 Oct 2013 15:13:00 -0000 From: Luis Machado Reply-To: lgustavo@codesourcery.com User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.0 MIME-Version: 1.0 To: Jan Kratochvil CC: "'gdb-patches@sourceware.org'" Subject: Re: [PATCH] Fix calling gcore when gdb is not in $PATH. References: <525806C8.8040108@codesourcery.com> <20131011143145.GA1517@host2.jankratochvil.net> <52580F4B.8050306@codesourcery.com> <52582B57.8090006@codesourcery.com> <20131011165622.GA20960@host2.jankratochvil.net> <52583B08.3010907@codesourcery.com> <20131011181008.GA2115@host2.jankratochvil.net> <525841CD.8070506@codesourcery.com> <20131011190020.GA13493@host2.jankratochvil.net> <525BE269.9070907@codesourcery.com> <20131015151015.GA7805@host2.jankratochvil.net> In-Reply-To: <20131015151015.GA7805@host2.jankratochvil.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2013-10/txt/msg00487.txt.bz2 On 10/15/2013 12:10 PM, Jan Kratochvil wrote: > On Mon, 14 Oct 2013 14:24:09 +0200, Luis Machado wrote: >> --- a/gdb/gcore.in >> +++ b/gdb/gcore.in >> @@ -43,6 +43,40 @@ then >> shift; shift >> fi >> >> +# Attempt to fetch the absolute path to the gcore script that was >> +# called. >> +binary_path=`dirname "$0"` >> + >> +if test "x$binary_path" = x. ; then > > I find this test needlessly complicating the code a bit as it is true for both > "sh gcore" and for "./gcore" while the conditionalized block of code is needed > only in the "sh gcore" case. I was proposing a different test before. But it > works even for the "./gcore" execution case so technically it is correct. > > It is a bit messy due to the corner cases unfortunately. >> + # We got "." back as a path. This means the user executed >> + # the gcore script locally (i.e. ./gcore) or called the >> + # script via a shell interpreter (i.e. sh gcore). >> + binary_basename=`basename "$0"` >> + >> + # If the gcore script was called like "sh gcore" and the script >> + # lives in the current directory, "which" will not give us "gcore". >> + # So first we check if the script is in the current directory >> + # before using the output "which". >> + if test -f "$binary_basename" ; then >> + # We have a local gcore script in ".". This covers the case of >> + # doing "./gcore" or "sh gcore". >> + binary_path="." >> + else >> + # The gcore script was not found in ".", which means the script >> + # was called from somewhere else in $PATH. Extract the correct > > # was called from somewhere else in $PATH by "sh gcore". [...] > > >> + # path now. >> + binary_path_from_env=`which "$0"` >> + binary_path=`dirname "$binary_path_from_env"` >> + fi >> +fi >> + >> +# Check if the GDB binary is in the expected path. If not, just >> +# quit with a message. >> +if [ ! -f "$binary_path"/@GDB_TRANSFORM_NAME@ ]; then >> + echo "gcore: GDB binary (${binary_path}/@GDB_TRANSFORM_NAME@) not found" >> + exit 1 >> +fi >> + >> # Initialise return code. >> rc=0 >> >> @@ -51,7 +85,7 @@ for pid in $* >> do >> # `> # available but not accessible as GDB would get stopped on SIGTTIN. >> - @GDB_TRANSFORM_NAME@ > + $binary_path/@GDB_TRANSFORM_NAME@ > -ex "set pagination off" -ex "set height 0" -ex "set width 0" \ >> -ex "attach $pid" -ex "gcore $name.$pid" -ex detach -ex quit >> > > OK for check-in. Fixed and checked in. Thanks! Luis