[Lldb-commits] [lldb] [llvm] Revert "[lldb] Switch debuginfod cache to use lldb index cache settings" (PR #122816)

via lldb-commits lldb-commits at lists.llvm.org
Mon Jan 13 14:58:24 PST 2025


https://github.com/GeorgeHuyubo created https://github.com/llvm/llvm-project/pull/122816

This reverts commit 7b808e73aa0193c8a42eae8f2420a803f424bee1.

Previous commit which change default debuginfod cache path and pruning policy settings is problematic. It broke multiple tests across lldb and llvm. Reverting for now.

>From af2a4169e165b725dbfe8fa6a7bd254d7ddb2dfc Mon Sep 17 00:00:00 2001
From: George Hu <georgehuyubo at gmail.com>
Date: Mon, 13 Jan 2025 14:54:02 -0800
Subject: [PATCH] Revert "[lldb] Switch debuginfod cache to use lldb index
 cache settings"

This reverts commit 7b808e73aa0193c8a42eae8f2420a803f424bee1.
---
 .../Debuginfod/SymbolLocatorDebuginfod.cpp    | 17 ++++-------
 llvm/include/llvm/Debuginfod/Debuginfod.h     |  4 +--
 llvm/lib/Debuginfod/Debuginfod.cpp            | 29 ++++++-------------
 llvm/unittests/Debuginfod/DebuginfodTests.cpp |  3 +-
 4 files changed, 17 insertions(+), 36 deletions(-)

diff --git a/lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp b/lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp
index 905f4d783ac958..f9aa6b1a987652 100644
--- a/lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp
+++ b/lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp
@@ -8,7 +8,6 @@
 
 #include "SymbolLocatorDebuginfod.h"
 
-#include "lldb/Core/DataFileCache.h"
 #include "lldb/Core/PluginManager.h"
 #include "lldb/Interpreter/OptionValueString.h"
 #include "lldb/Utility/Args.h"
@@ -173,14 +172,11 @@ GetFileForModule(const ModuleSpec &module_spec,
   // Grab LLDB's Debuginfod overrides from the
   // plugin.symbol-locator.debuginfod.* settings.
   PluginProperties &plugin_props = GetGlobalPluginProperties();
-  // Grab the lldb index cache settings from the global module list properties.
-  ModuleListProperties &properties =
-      ModuleList::GetGlobalModuleListProperties();
-  std::string cache_path = properties.GetLLDBIndexCachePath().GetPath();
-
-  llvm::CachePruningPolicy pruning_policy =
-      DataFileCache::GetLLDBIndexCachePolicy();
-
+  llvm::Expected<std::string> cache_path_or_err = plugin_props.GetCachePath();
+  // A cache location is *required*.
+  if (!cache_path_or_err)
+    return {};
+  std::string cache_path = *cache_path_or_err;
   llvm::SmallVector<llvm::StringRef> debuginfod_urls =
       llvm::getDefaultDebuginfodUrls();
   std::chrono::milliseconds timeout = plugin_props.GetTimeout();
@@ -193,8 +189,7 @@ GetFileForModule(const ModuleSpec &module_spec,
   if (!file_name.empty())
     cache_file_name += "-" + file_name.str();
   llvm::Expected<std::string> result = llvm::getCachedOrDownloadArtifact(
-      cache_file_name, url_path, cache_path, debuginfod_urls, timeout,
-      pruning_policy);
+      cache_file_name, url_path, cache_path, debuginfod_urls, timeout);
   if (result)
     return FileSpec(*result);
 
diff --git a/llvm/include/llvm/Debuginfod/Debuginfod.h b/llvm/include/llvm/Debuginfod/Debuginfod.h
index aebcf31cd48227..99fe15ad859794 100644
--- a/llvm/include/llvm/Debuginfod/Debuginfod.h
+++ b/llvm/include/llvm/Debuginfod/Debuginfod.h
@@ -25,7 +25,6 @@
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Object/BuildID.h"
-#include "llvm/Support/CachePruning.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Mutex.h"
@@ -96,8 +95,7 @@ Expected<std::string> getCachedOrDownloadArtifact(StringRef UniqueKey,
 /// found, uses the UniqueKey for the local cache file.
 Expected<std::string> getCachedOrDownloadArtifact(
     StringRef UniqueKey, StringRef UrlPath, StringRef CacheDirectoryPath,
-    ArrayRef<StringRef> DebuginfodUrls, std::chrono::milliseconds Timeout,
-    llvm::CachePruningPolicy policy);
+    ArrayRef<StringRef> DebuginfodUrls, std::chrono::milliseconds Timeout);
 
 class ThreadPoolInterface;
 
diff --git a/llvm/lib/Debuginfod/Debuginfod.cpp b/llvm/lib/Debuginfod/Debuginfod.cpp
index 17efaea892c669..4c785117ae8ef7 100644
--- a/llvm/lib/Debuginfod/Debuginfod.cpp
+++ b/llvm/lib/Debuginfod/Debuginfod.cpp
@@ -106,14 +106,6 @@ Expected<std::string> getDefaultDebuginfodCacheDirectory() {
   return std::string(CacheDirectory);
 }
 
-Expected<llvm::CachePruningPolicy> getDefaultDebuginfodCachePruningPolicy() {
-  Expected<CachePruningPolicy> PruningPolicyOrErr =
-      parseCachePruningPolicy(std::getenv("DEBUGINFOD_CACHE_POLICY"));
-  if (!PruningPolicyOrErr)
-    return PruningPolicyOrErr.takeError();
-  return *PruningPolicyOrErr;
-}
-
 std::chrono::milliseconds getDefaultDebuginfodTimeout() {
   long Timeout;
   const char *DebuginfodTimeoutEnv = std::getenv("DEBUGINFOD_TIMEOUT");
@@ -177,15 +169,9 @@ Expected<std::string> getCachedOrDownloadArtifact(StringRef UniqueKey,
     return CacheDirOrErr.takeError();
   CacheDir = *CacheDirOrErr;
 
-  Expected<llvm::CachePruningPolicy> PruningPolicyOrErr =
-      getDefaultDebuginfodCachePruningPolicy();
-  if (!PruningPolicyOrErr)
-    return PruningPolicyOrErr.takeError();
-  llvm::CachePruningPolicy PruningPolicy = *PruningPolicyOrErr;
-
-  return getCachedOrDownloadArtifact(
-      UniqueKey, UrlPath, CacheDir, getDefaultDebuginfodUrls(),
-      getDefaultDebuginfodTimeout(), PruningPolicy);
+  return getCachedOrDownloadArtifact(UniqueKey, UrlPath, CacheDir,
+                                     getDefaultDebuginfodUrls(),
+                                     getDefaultDebuginfodTimeout());
 }
 
 namespace {
@@ -264,8 +250,7 @@ static SmallVector<std::string, 0> getHeaders() {
 
 Expected<std::string> getCachedOrDownloadArtifact(
     StringRef UniqueKey, StringRef UrlPath, StringRef CacheDirectoryPath,
-    ArrayRef<StringRef> DebuginfodUrls, std::chrono::milliseconds Timeout,
-    llvm::CachePruningPolicy policy) {
+    ArrayRef<StringRef> DebuginfodUrls, std::chrono::milliseconds Timeout) {
   SmallString<64> AbsCachedArtifactPath;
   sys::path::append(AbsCachedArtifactPath, CacheDirectoryPath,
                     "llvmcache-" + UniqueKey);
@@ -319,7 +304,11 @@ Expected<std::string> getCachedOrDownloadArtifact(
         continue;
     }
 
-    pruneCache(CacheDirectoryPath, policy);
+    Expected<CachePruningPolicy> PruningPolicyOrErr =
+        parseCachePruningPolicy(std::getenv("DEBUGINFOD_CACHE_POLICY"));
+    if (!PruningPolicyOrErr)
+      return PruningPolicyOrErr.takeError();
+    pruneCache(CacheDirectoryPath, *PruningPolicyOrErr);
 
     // Return the path to the artifact on disk.
     return std::string(AbsCachedArtifactPath);
diff --git a/llvm/unittests/Debuginfod/DebuginfodTests.cpp b/llvm/unittests/Debuginfod/DebuginfodTests.cpp
index 8dacf2ae5b3f8a..5312912599e933 100644
--- a/llvm/unittests/Debuginfod/DebuginfodTests.cpp
+++ b/llvm/unittests/Debuginfod/DebuginfodTests.cpp
@@ -37,7 +37,6 @@ TEST(DebuginfodClient, CacheHit) {
   sys::fs::createTemporaryFile("llvmcache-key", "temp", FD, CachedFilePath);
   StringRef CacheDir = sys::path::parent_path(CachedFilePath);
   StringRef UniqueKey = sys::path::filename(CachedFilePath);
-  llvm::CachePruningPolicy policy;
   EXPECT_TRUE(UniqueKey.consume_front("llvmcache-"));
   raw_fd_ostream OF(FD, true, /*unbuffered=*/true);
   OF << "contents\n";
@@ -45,7 +44,7 @@ TEST(DebuginfodClient, CacheHit) {
   OF.close();
   Expected<std::string> PathOrErr = getCachedOrDownloadArtifact(
       UniqueKey, /*UrlPath=*/"/null", CacheDir,
-      /*DebuginfodUrls=*/{}, /*Timeout=*/std::chrono::milliseconds(1), policy);
+      /*DebuginfodUrls=*/{}, /*Timeout=*/std::chrono::milliseconds(1));
   EXPECT_THAT_EXPECTED(PathOrErr, HasValue(CachedFilePath));
 }
 



More information about the lldb-commits mailing list