From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28455 invoked by alias); 11 Oct 2013 18:10:19 -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 28370 invoked by uid 89); 11 Oct 2013 18:10:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.3 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS 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 ESMTP; Fri, 11 Oct 2013 18:10:18 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r9BIAEX9031479 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 11 Oct 2013 14:10:14 -0400 Received: from host2.jankratochvil.net (ovpn-116-94.ams2.redhat.com [10.36.116.94]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r9BIA9c9014535 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO); Fri, 11 Oct 2013 14:10:13 -0400 Date: Fri, 11 Oct 2013 18:10:00 -0000 From: Jan Kratochvil To: Luis Machado Cc: "'gdb-patches@sourceware.org'" Subject: Re: [PATCH] Fix calling gcore when gdb is not in $PATH. Message-ID: <20131011181008.GA2115@host2.jankratochvil.net> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <52583B08.3010907@codesourcery.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes X-SW-Source: 2013-10/txt/msg00395.txt.bz2 On Fri, 11 Oct 2013 19:53:12 +0200, Luis Machado wrote: > 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? Great we agree. But your code does pick /usr/bin/gdb for ./gcore, doesn't it? Which is why I proposed the change I proposed. Jan