From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16738 invoked by alias); 27 Dec 2013 19:54:15 -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 16726 invoked by uid 89); 27 Dec 2013 19:54:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-vc0-f173.google.com Received: from mail-vc0-f173.google.com (HELO mail-vc0-f173.google.com) (209.85.220.173) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Fri, 27 Dec 2013 19:54:10 +0000 Received: by mail-vc0-f173.google.com with SMTP id ht17so4896937vcb.18 for ; Fri, 27 Dec 2013 11:54:08 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=t+aFUdPujy/zn/w0ciQm2zQdge67mwzkm2p1OZGvhd0=; b=TEjd+xkYVAybZIu+ozXOLWrQrBAyIxh6FhxjoGBrh8T0pTpDznozG2c9OZYZNax+tH RP9iOeMVQFMA8IeYJ6p9Eu7IITrzqYqSvdltVTjoMwfUgRKvsfNRtSssPjWbO2tUFqV0 +uy21dcKcDq0NylpifVgvyUGAjNjztGo+htDJ1ca1FQdjMQpAkpOE51XEYpAHoHeUER6 vLGLT6GJElscorrHR9D6zrxJqyv3GDVdj3leQqVxP12UfAimszY3BGyz88wpHe92EUkK WCG1IS/1wy6uZqTMIBywcCPuNjUjcnfxim1VaprDCGoyyrZ/nj3sGn6XbDbj9NuvBiX5 EAfA== X-Gm-Message-State: ALoCoQmnzmdQ5A3O4xCZNY5Uv+XN+1xm0fRx6Rg8H8hsOuXVn2KjMqEcwBAufws7uKVwdhbhEBqWvoC2VlYzlq1k2MYurkgHDc+HRvBAixp8bZDTfpJzmRPw5Ea+7z0APn/PFWZwCgX9yso8rELR35edSpv+XLxaqPUGNoSNNNSWCj90LrMMtLRSECnu7IKbAe+R1fNmh/44hMEfs6Yq+4rb+HhcuXjGNA== MIME-Version: 1.0 X-Received: by 10.58.46.171 with SMTP id w11mr28156544vem.5.1388174048649; Fri, 27 Dec 2013 11:54:08 -0800 (PST) Received: by 10.52.248.65 with HTTP; Fri, 27 Dec 2013 11:54:08 -0800 (PST) In-Reply-To: References: Date: Fri, 27 Dec 2013 19:54:00 -0000 Message-ID: Subject: Re: [RFC] New option -B: simplify running gdb from build directory From: Doug Evans To: gdb-patches Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2013-12/txt/msg00967.txt.bz2 On Fri, Dec 27, 2013 at 11:42 AM, Doug Evans wrote: > Hi. > > The "make run" Makefile rule simplifies running gdb from the shell, > but it doesn't simplify running gdb from gdb: I'm always typing > "--data-directory=$(pwd)/data-directory". > And since we can't agree on a way to let gdb auto-detect being run > from the build directory, how about this? > > This patch provides a new option, -B, which if provided tells gdb > it *may* have been run from the build directory. If -B was provided > and --data-directory was not provided, use a heuristic to determine > if gdb was run from the build directory and if so set gdb_datadir > appropriately. > > We can certainly discuss what's the best heuristic to use here. > We don't, IMO, have to employ too complicated a heuristic because > the user has explicitly passed -B. > OTOH, I'm sure one can improve a bit on the heuristic that's here. > One thought I have is to have the Makefile create a file with a name that > is reasonably obscure (maybe even pseudo-cryptographically secure and encode > the name in gdb?), and then simplify the test by just checking for that file. > > If we can agree on this approach, I'll add NEWS and docs. > > 2013-12-27 Doug Evans > > * main.c (maybe_run_from_builddir): New global. > (get_builddir): New function. > (captured_main): New option enum OPT_BATCH_SILENT, use it for > --batch-silent instead of 'B'. Add option -B: If -B is provided > and --data-directory is not, see if being run from build directory > and use that for gdb_datadir if so. Blech, I shouldn't assume gdb_program_name is an absolute path. I'll fix that in the next revision. [OTOH, the caller could be the one to ensure gdb_datadir is an absolute path since we don't do that yet if a relative path is passed to --data-directory.]