From patchwork Fri Sep 14 14:59:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 29376 Received: (qmail 24814 invoked by alias); 14 Sep 2018 14:59:52 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 24804 invoked by uid 89); 14 Sep 2018 14:59:52 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=HOME X-HELO: gateway30.websitewelcome.com Received: from gateway30.websitewelcome.com (HELO gateway30.websitewelcome.com) (192.185.197.25) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 14 Sep 2018 14:59:50 +0000 Received: from cm12.websitewelcome.com (cm12.websitewelcome.com [100.42.49.8]) by gateway30.websitewelcome.com (Postfix) with ESMTP id A7A7335E24 for ; Fri, 14 Sep 2018 09:59:48 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id 0pZNgGSerSjJA0pZQgsNAW; Fri, 14 Sep 2018 09:59:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version :Content-Type:Content-Transfer-Encoding:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=EQxV4+XFXUElmn/NPtHPsJHhtxpdf2w0mLaUE0c1rZ0=; b=XVkD2e9GCXgpeAdPmkRqRXkcmZ VG2idzvq8HNwRjBUetkjLGSZFihsM82VKkEDhAZeXuhgMzUsntMvta+8Dzw/5q1WgxI6KmgVO5YjQ VXl+MlUxGj2Z+N2u5iZVeTT+p; Received: from 97-122-190-66.hlrn.qwest.net ([97.122.190.66]:43558 helo=pokyo.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1g0pZN-002war-In; Fri, 14 Sep 2018 09:59:41 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] Update get_standard_cache_dir for macOS Date: Fri, 14 Sep 2018 08:59:38 -0600 Message-Id: <20180914145938.12186-1-tom@tromey.com> On macOS the usual cache directory is ~/Library/Caches. This patch changes get_standard_cache_dir to use that instead of XDG. gdb/ChangeLog 2018-09-14 Tom Tromey * common/pathstuff.c (get_standard_cache_dir): Use ~/Library/Caches on macOS. * common/pathstuff.h (get_standard_cache_dir): Update comment. gdb/doc/ChangeLog 2018-09-14 Tom Tromey * gdb.texinfo (Index Files): Update for cache directory change on macOS. --- gdb/ChangeLog | 6 ++++++ gdb/common/pathstuff.c | 10 +++++++++- gdb/common/pathstuff.h | 10 +++++++--- gdb/doc/ChangeLog | 5 +++++ gdb/doc/gdb.texinfo | 12 ++++++++---- 5 files changed, 35 insertions(+), 8 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 49bcd9ff8a..59b47bd9aa 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2018-09-14 Tom Tromey + + * common/pathstuff.c (get_standard_cache_dir): Use + ~/Library/Caches on macOS. + * common/pathstuff.h (get_standard_cache_dir): Update comment. + 2018-09-14 Tom Tromey * infcall.c (call_function_by_hand_dummy): Remove unnecessary diff --git a/gdb/common/pathstuff.c b/gdb/common/pathstuff.c index 2d9dcb25d4..3dd58e31aa 100644 --- a/gdb/common/pathstuff.c +++ b/gdb/common/pathstuff.c @@ -164,6 +164,13 @@ contains_dir_separator (const char *path) std::string get_standard_cache_dir () { +#ifdef __APPLE__ +#define HOME_CACHE_DIR "Library/Caches" +#else +#define HOME_CACHE_DIR ".cache" +#endif + +#ifndef __APPLE__ char *xdg_cache_home = getenv ("XDG_CACHE_HOME"); if (xdg_cache_home != NULL) { @@ -171,13 +178,14 @@ get_standard_cache_dir () gdb::unique_xmalloc_ptr abs (gdb_abspath (xdg_cache_home)); return string_printf ("%s/gdb", abs.get ()); } +#endif char *home = getenv ("HOME"); if (home != NULL) { /* Make sure the path is absolute and tilde-expanded. */ gdb::unique_xmalloc_ptr abs (gdb_abspath (home)); - return string_printf ("%s/.cache/gdb", abs.get ()); + return string_printf ("%s/" HOME_CACHE_DIR "/gdb", abs.get ()); } return {}; diff --git a/gdb/common/pathstuff.h b/gdb/common/pathstuff.h index d1aa6b306c..a43b963651 100644 --- a/gdb/common/pathstuff.h +++ b/gdb/common/pathstuff.h @@ -53,10 +53,14 @@ extern bool contains_dir_separator (const char *path); /* Get the usual user cache directory for the current platform. On Linux, it follows the XDG Base Directory specification: use - $XDG_CACHE_HOME/gdb if the XDG_CACHE_HOME environment variable is defined, - otherwise $HOME/.cache. The return value is absolute and tilde-expanded. + $XDG_CACHE_HOME/gdb if the XDG_CACHE_HOME environment variable is + defined, otherwise $HOME/.cache. - Return an empty string if neither XDG_CACHE_HOME or HOME are defined. */ + On macOS, it follows the local convention and uses + ~/Library/Caches/gdb. + + The return value is absolute and tilde-expanded. Return an empty + string if neither XDG_CACHE_HOME (on Linux) or HOME are defined. */ extern std::string get_standard_cache_dir (); diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index 1a5c70bfc8..bb494362bc 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,8 @@ +2018-09-14 Tom Tromey + + * gdb.texinfo (Index Files): Update for cache directory change on + macOS. + 2018-09-13 Simon Marchi * python.texi (Objfiles In Python): Update gdb.objfiles() doc. diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index efbec3debf..ad090ba17b 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -20128,10 +20128,14 @@ Enable or disable the use of the symbol index cache. @item set index-cache directory @var{directory} @itemx show index-cache directory -Set/show the directory where index files will be saved. By default, the index -is cached in the @file{gdb} subdirectory of the directory pointed to by the -@env{XDG_CACHE_HOME} environment variable, if it is defined, else in the -@file{.cache/gdb} subdirectory of your home directory. +Set/show the directory where index files will be saved. + +The default value for this directory depends on the host platform. On +most systems, the index is cached in the @file{gdb} subdirectory of +the directory pointed to by the @env{XDG_CACHE_HOME} environment +variable, if it is defined, else in the @file{.cache/gdb} subdirectory +of your home directory. However, on macOS, the index is cached in the +@file{~/Library/Caches/gdb/}. There is no limit on the disk space used by index cache. It is perfectly safe to delete the content of that directory to free up disk space.