Update get_standard_cache_dir for macOS
authorTom Tromey <tom@tromey.com>
Fri, 14 Sep 2018 14:48:22 +0000 (08:48 -0600)
committerTom Tromey <tom@tromey.com>
Mon, 17 Sep 2018 14:43:12 +0000 (08:43 -0600)
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-17  Tom Tromey  <tom@tromey.com>

* 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-17  Tom Tromey  <tom@tromey.com>

* gdb.texinfo (Index Files): Update for cache directory change on
macOS.

gdb/ChangeLog
gdb/common/pathstuff.c
gdb/common/pathstuff.h
gdb/doc/ChangeLog
gdb/doc/gdb.texinfo

index 7fb64d639e6f9024eb4da545b17002b5316513ef..673d35be113c417dcbaa0d76775a545a79803765 100644 (file)
@@ -1,3 +1,9 @@
+2018-09-17  Tom Tromey  <tom@tromey.com>
+
+       * common/pathstuff.c (get_standard_cache_dir): Use
+       ~/Library/Caches on macOS.
+       * common/pathstuff.h (get_standard_cache_dir): Update comment.
+
 2018-09-17  Simon Marchi  <simon.marchi@polymtl.ca>
 
        PR python/23669
index 2d9dcb25d40f08fedf4de7b090b28ea14f89ff7d..3dd58e31aa41817fb98c9f486f9c14afc033a414 100644 (file)
@@ -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<char> 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<char> abs (gdb_abspath (home));
-      return string_printf ("%s/.cache/gdb", abs.get ());
+      return string_printf ("%s/" HOME_CACHE_DIR "/gdb", abs.get ());
     }
 
   return {};
index d1aa6b306c35701391281f36f5b67fd3dd00bc07..a43b9636514d26231367561e97a5c6d075135a7c 100644 (file)
@@ -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 ();
 
index 6d7566483f2a559127557d34a9b9900f11d13aed..dc8f39293f4ca679c78203279f2b92a6ee44fb40 100644 (file)
@@ -1,3 +1,8 @@
+2018-09-17  Tom Tromey  <tom@tromey.com>
+
+       * gdb.texinfo (Index Files): Update for cache directory change on
+       macOS.
+
 2018-09-16  Tom Tromey  <tom@tromey.com>
 
        * python.texi (Basic Python): Update docs for find_pc_line,
index efbec3debffdc01f40dabec23a2294fc99d3a6a7..96fa77d9abc9c85adbfdbb58a543cdc417a09636 100644 (file)
@@ -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 some systems, the default may
+differ according to local convention.
 
 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.
This page took 0.08695 seconds and 4 git commands to generate.