Skip to content

Commit 1908c41

Browse files
GeorgeHuyuboGeorge Hu
andauthored
Revert "[lldb] Switch debuginfod cache to use lldb index cache settings" (llvm#122816)
This reverts commit 7b808e7. 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. Co-authored-by: George Hu <[email protected]>
1 parent 2201164 commit 1908c41

File tree

4 files changed

+17
-36
lines changed

4 files changed

+17
-36
lines changed

lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
#include "SymbolLocatorDebuginfod.h"
1010

11-
#include "lldb/Core/DataFileCache.h"
1211
#include "lldb/Core/PluginManager.h"
1312
#include "lldb/Interpreter/OptionValueString.h"
1413
#include "lldb/Utility/Args.h"
@@ -173,14 +172,11 @@ GetFileForModule(const ModuleSpec &module_spec,
173172
// Grab LLDB's Debuginfod overrides from the
174173
// plugin.symbol-locator.debuginfod.* settings.
175174
PluginProperties &plugin_props = GetGlobalPluginProperties();
176-
// Grab the lldb index cache settings from the global module list properties.
177-
ModuleListProperties &properties =
178-
ModuleList::GetGlobalModuleListProperties();
179-
std::string cache_path = properties.GetLLDBIndexCachePath().GetPath();
180-
181-
llvm::CachePruningPolicy pruning_policy =
182-
DataFileCache::GetLLDBIndexCachePolicy();
183-
175+
llvm::Expected<std::string> cache_path_or_err = plugin_props.GetCachePath();
176+
// A cache location is *required*.
177+
if (!cache_path_or_err)
178+
return {};
179+
std::string cache_path = *cache_path_or_err;
184180
llvm::SmallVector<llvm::StringRef> debuginfod_urls =
185181
llvm::getDefaultDebuginfodUrls();
186182
std::chrono::milliseconds timeout = plugin_props.GetTimeout();
@@ -193,8 +189,7 @@ GetFileForModule(const ModuleSpec &module_spec,
193189
if (!file_name.empty())
194190
cache_file_name += "-" + file_name.str();
195191
llvm::Expected<std::string> result = llvm::getCachedOrDownloadArtifact(
196-
cache_file_name, url_path, cache_path, debuginfod_urls, timeout,
197-
pruning_policy);
192+
cache_file_name, url_path, cache_path, debuginfod_urls, timeout);
198193
if (result)
199194
return FileSpec(*result);
200195

llvm/include/llvm/Debuginfod/Debuginfod.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include "llvm/ADT/StringMap.h"
2626
#include "llvm/ADT/StringRef.h"
2727
#include "llvm/Object/BuildID.h"
28-
#include "llvm/Support/CachePruning.h"
2928
#include "llvm/Support/Error.h"
3029
#include "llvm/Support/MemoryBuffer.h"
3130
#include "llvm/Support/Mutex.h"
@@ -96,8 +95,7 @@ Expected<std::string> getCachedOrDownloadArtifact(StringRef UniqueKey,
9695
/// found, uses the UniqueKey for the local cache file.
9796
Expected<std::string> getCachedOrDownloadArtifact(
9897
StringRef UniqueKey, StringRef UrlPath, StringRef CacheDirectoryPath,
99-
ArrayRef<StringRef> DebuginfodUrls, std::chrono::milliseconds Timeout,
100-
llvm::CachePruningPolicy policy);
98+
ArrayRef<StringRef> DebuginfodUrls, std::chrono::milliseconds Timeout);
10199

102100
class ThreadPoolInterface;
103101

llvm/lib/Debuginfod/Debuginfod.cpp

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,6 @@ Expected<std::string> getDefaultDebuginfodCacheDirectory() {
106106
return std::string(CacheDirectory);
107107
}
108108

109-
Expected<llvm::CachePruningPolicy> getDefaultDebuginfodCachePruningPolicy() {
110-
Expected<CachePruningPolicy> PruningPolicyOrErr =
111-
parseCachePruningPolicy(std::getenv("DEBUGINFOD_CACHE_POLICY"));
112-
if (!PruningPolicyOrErr)
113-
return PruningPolicyOrErr.takeError();
114-
return *PruningPolicyOrErr;
115-
}
116-
117109
std::chrono::milliseconds getDefaultDebuginfodTimeout() {
118110
long Timeout;
119111
const char *DebuginfodTimeoutEnv = std::getenv("DEBUGINFOD_TIMEOUT");
@@ -177,15 +169,9 @@ Expected<std::string> getCachedOrDownloadArtifact(StringRef UniqueKey,
177169
return CacheDirOrErr.takeError();
178170
CacheDir = *CacheDirOrErr;
179171

180-
Expected<llvm::CachePruningPolicy> PruningPolicyOrErr =
181-
getDefaultDebuginfodCachePruningPolicy();
182-
if (!PruningPolicyOrErr)
183-
return PruningPolicyOrErr.takeError();
184-
llvm::CachePruningPolicy PruningPolicy = *PruningPolicyOrErr;
185-
186-
return getCachedOrDownloadArtifact(
187-
UniqueKey, UrlPath, CacheDir, getDefaultDebuginfodUrls(),
188-
getDefaultDebuginfodTimeout(), PruningPolicy);
172+
return getCachedOrDownloadArtifact(UniqueKey, UrlPath, CacheDir,
173+
getDefaultDebuginfodUrls(),
174+
getDefaultDebuginfodTimeout());
189175
}
190176

191177
namespace {
@@ -264,8 +250,7 @@ static SmallVector<std::string, 0> getHeaders() {
264250

265251
Expected<std::string> getCachedOrDownloadArtifact(
266252
StringRef UniqueKey, StringRef UrlPath, StringRef CacheDirectoryPath,
267-
ArrayRef<StringRef> DebuginfodUrls, std::chrono::milliseconds Timeout,
268-
llvm::CachePruningPolicy policy) {
253+
ArrayRef<StringRef> DebuginfodUrls, std::chrono::milliseconds Timeout) {
269254
SmallString<64> AbsCachedArtifactPath;
270255
sys::path::append(AbsCachedArtifactPath, CacheDirectoryPath,
271256
"llvmcache-" + UniqueKey);
@@ -319,7 +304,11 @@ Expected<std::string> getCachedOrDownloadArtifact(
319304
continue;
320305
}
321306

322-
pruneCache(CacheDirectoryPath, policy);
307+
Expected<CachePruningPolicy> PruningPolicyOrErr =
308+
parseCachePruningPolicy(std::getenv("DEBUGINFOD_CACHE_POLICY"));
309+
if (!PruningPolicyOrErr)
310+
return PruningPolicyOrErr.takeError();
311+
pruneCache(CacheDirectoryPath, *PruningPolicyOrErr);
323312

324313
// Return the path to the artifact on disk.
325314
return std::string(AbsCachedArtifactPath);

llvm/unittests/Debuginfod/DebuginfodTests.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,14 @@ TEST(DebuginfodClient, CacheHit) {
3737
sys::fs::createTemporaryFile("llvmcache-key", "temp", FD, CachedFilePath);
3838
StringRef CacheDir = sys::path::parent_path(CachedFilePath);
3939
StringRef UniqueKey = sys::path::filename(CachedFilePath);
40-
llvm::CachePruningPolicy policy;
4140
EXPECT_TRUE(UniqueKey.consume_front("llvmcache-"));
4241
raw_fd_ostream OF(FD, true, /*unbuffered=*/true);
4342
OF << "contents\n";
4443
OF << CacheDir << "\n";
4544
OF.close();
4645
Expected<std::string> PathOrErr = getCachedOrDownloadArtifact(
4746
UniqueKey, /*UrlPath=*/"/null", CacheDir,
48-
/*DebuginfodUrls=*/{}, /*Timeout=*/std::chrono::milliseconds(1), policy);
47+
/*DebuginfodUrls=*/{}, /*Timeout=*/std::chrono::milliseconds(1));
4948
EXPECT_THAT_EXPECTED(PathOrErr, HasValue(CachedFilePath));
5049
}
5150

0 commit comments

Comments
 (0)