From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16117 invoked by alias); 11 Oct 2013 17:53: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 16049 invoked by uid 89); 11 Oct 2013 17:53: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; Fri, 11 Oct 2013 17:53:25 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1VUgtt-0006jo-JP from Luis_Gustavo@mentor.com ; Fri, 11 Oct 2013 10:53:21 -0700 Received: from NA1-MAIL.mgc.mentorg.com ([147.34.98.181]) by svr-orw-fem-01.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Fri, 11 Oct 2013 10:53:21 -0700 Received: from [172.30.8.57] ([172.30.8.57]) by NA1-MAIL.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.3959); Fri, 11 Oct 2013 10:53:20 -0700 Message-ID: <52583B08.3010907@codesourcery.com> Date: Fri, 11 Oct 2013 17:53: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> In-Reply-To: <20131011165622.GA20960@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/msg00394.txt.bz2 On 10/11/2013 01:56 PM, Jan Kratochvil wrote: > On Fri, 11 Oct 2013 18:46:15 +0200, Luis Machado wrote: >> --- a/gdb/gcore.in >> +++ b/gdb/gcore.in >> @@ -49,9 +49,26 @@ rc=0 >> # Loop through pids >> for pid in $* >> do >> +# Attempt to fetch the absolute path to the gcore script that was >> +# called. >> +binary_path=`dirname "$0"` >> + >> + if test "x$binary_path" = x. ; then >> + # 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). We use >> + # the "which" command to locate the real path of the gcore >> + # script, disambiguating this situation. >> + binary_path_from_env=`which "$0"` >> + binary_path=`dirname $binary_path_from_env` > > In generally OK, just still ... is there some reason for this 'which' search? > Moreover if one really runs ./gcore then it should IMO take ./gdb (and not some > other gdb), if we should really pick GDB from the directory of gcore. Yes. The reason is to pick the gdb binary from the directory that contains the gcore script the user invoked. If the user issued "sh gcore" and /usr/bin/gcore was picked (based on $PATH), then we should use /usr/bin/gdb. Now, if the user issued "./gcore", ./gdb will be picked up, and so on. Does it make sense? Luis