Revert "[lldb] Switch debuginfod cache to use lldb index cache settings" (#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. Co-authored-by: George Hu <georgehuyubo@gmail.com>
This commit is contained in:
@@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
#include "SymbolLocatorDebuginfod.h"
|
#include "SymbolLocatorDebuginfod.h"
|
||||||
|
|
||||||
#include "lldb/Core/DataFileCache.h"
|
|
||||||
#include "lldb/Core/PluginManager.h"
|
#include "lldb/Core/PluginManager.h"
|
||||||
#include "lldb/Interpreter/OptionValueString.h"
|
#include "lldb/Interpreter/OptionValueString.h"
|
||||||
#include "lldb/Utility/Args.h"
|
#include "lldb/Utility/Args.h"
|
||||||
@@ -173,14 +172,11 @@ GetFileForModule(const ModuleSpec &module_spec,
|
|||||||
// Grab LLDB's Debuginfod overrides from the
|
// Grab LLDB's Debuginfod overrides from the
|
||||||
// plugin.symbol-locator.debuginfod.* settings.
|
// plugin.symbol-locator.debuginfod.* settings.
|
||||||
PluginProperties &plugin_props = GetGlobalPluginProperties();
|
PluginProperties &plugin_props = GetGlobalPluginProperties();
|
||||||
// Grab the lldb index cache settings from the global module list properties.
|
llvm::Expected<std::string> cache_path_or_err = plugin_props.GetCachePath();
|
||||||
ModuleListProperties &properties =
|
// A cache location is *required*.
|
||||||
ModuleList::GetGlobalModuleListProperties();
|
if (!cache_path_or_err)
|
||||||
std::string cache_path = properties.GetLLDBIndexCachePath().GetPath();
|
return {};
|
||||||
|
std::string cache_path = *cache_path_or_err;
|
||||||
llvm::CachePruningPolicy pruning_policy =
|
|
||||||
DataFileCache::GetLLDBIndexCachePolicy();
|
|
||||||
|
|
||||||
llvm::SmallVector<llvm::StringRef> debuginfod_urls =
|
llvm::SmallVector<llvm::StringRef> debuginfod_urls =
|
||||||
llvm::getDefaultDebuginfodUrls();
|
llvm::getDefaultDebuginfodUrls();
|
||||||
std::chrono::milliseconds timeout = plugin_props.GetTimeout();
|
std::chrono::milliseconds timeout = plugin_props.GetTimeout();
|
||||||
@@ -193,8 +189,7 @@ GetFileForModule(const ModuleSpec &module_spec,
|
|||||||
if (!file_name.empty())
|
if (!file_name.empty())
|
||||||
cache_file_name += "-" + file_name.str();
|
cache_file_name += "-" + file_name.str();
|
||||||
llvm::Expected<std::string> result = llvm::getCachedOrDownloadArtifact(
|
llvm::Expected<std::string> result = llvm::getCachedOrDownloadArtifact(
|
||||||
cache_file_name, url_path, cache_path, debuginfod_urls, timeout,
|
cache_file_name, url_path, cache_path, debuginfod_urls, timeout);
|
||||||
pruning_policy);
|
|
||||||
if (result)
|
if (result)
|
||||||
return FileSpec(*result);
|
return FileSpec(*result);
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,6 @@
|
|||||||
#include "llvm/ADT/StringMap.h"
|
#include "llvm/ADT/StringMap.h"
|
||||||
#include "llvm/ADT/StringRef.h"
|
#include "llvm/ADT/StringRef.h"
|
||||||
#include "llvm/Object/BuildID.h"
|
#include "llvm/Object/BuildID.h"
|
||||||
#include "llvm/Support/CachePruning.h"
|
|
||||||
#include "llvm/Support/Error.h"
|
#include "llvm/Support/Error.h"
|
||||||
#include "llvm/Support/MemoryBuffer.h"
|
#include "llvm/Support/MemoryBuffer.h"
|
||||||
#include "llvm/Support/Mutex.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.
|
/// found, uses the UniqueKey for the local cache file.
|
||||||
Expected<std::string> getCachedOrDownloadArtifact(
|
Expected<std::string> getCachedOrDownloadArtifact(
|
||||||
StringRef UniqueKey, StringRef UrlPath, StringRef CacheDirectoryPath,
|
StringRef UniqueKey, StringRef UrlPath, StringRef CacheDirectoryPath,
|
||||||
ArrayRef<StringRef> DebuginfodUrls, std::chrono::milliseconds Timeout,
|
ArrayRef<StringRef> DebuginfodUrls, std::chrono::milliseconds Timeout);
|
||||||
llvm::CachePruningPolicy policy);
|
|
||||||
|
|
||||||
class ThreadPoolInterface;
|
class ThreadPoolInterface;
|
||||||
|
|
||||||
|
|||||||
@@ -106,14 +106,6 @@ Expected<std::string> getDefaultDebuginfodCacheDirectory() {
|
|||||||
return std::string(CacheDirectory);
|
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() {
|
std::chrono::milliseconds getDefaultDebuginfodTimeout() {
|
||||||
long Timeout;
|
long Timeout;
|
||||||
const char *DebuginfodTimeoutEnv = std::getenv("DEBUGINFOD_TIMEOUT");
|
const char *DebuginfodTimeoutEnv = std::getenv("DEBUGINFOD_TIMEOUT");
|
||||||
@@ -177,15 +169,9 @@ Expected<std::string> getCachedOrDownloadArtifact(StringRef UniqueKey,
|
|||||||
return CacheDirOrErr.takeError();
|
return CacheDirOrErr.takeError();
|
||||||
CacheDir = *CacheDirOrErr;
|
CacheDir = *CacheDirOrErr;
|
||||||
|
|
||||||
Expected<llvm::CachePruningPolicy> PruningPolicyOrErr =
|
return getCachedOrDownloadArtifact(UniqueKey, UrlPath, CacheDir,
|
||||||
getDefaultDebuginfodCachePruningPolicy();
|
getDefaultDebuginfodUrls(),
|
||||||
if (!PruningPolicyOrErr)
|
getDefaultDebuginfodTimeout());
|
||||||
return PruningPolicyOrErr.takeError();
|
|
||||||
llvm::CachePruningPolicy PruningPolicy = *PruningPolicyOrErr;
|
|
||||||
|
|
||||||
return getCachedOrDownloadArtifact(
|
|
||||||
UniqueKey, UrlPath, CacheDir, getDefaultDebuginfodUrls(),
|
|
||||||
getDefaultDebuginfodTimeout(), PruningPolicy);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@@ -264,8 +250,7 @@ static SmallVector<std::string, 0> getHeaders() {
|
|||||||
|
|
||||||
Expected<std::string> getCachedOrDownloadArtifact(
|
Expected<std::string> getCachedOrDownloadArtifact(
|
||||||
StringRef UniqueKey, StringRef UrlPath, StringRef CacheDirectoryPath,
|
StringRef UniqueKey, StringRef UrlPath, StringRef CacheDirectoryPath,
|
||||||
ArrayRef<StringRef> DebuginfodUrls, std::chrono::milliseconds Timeout,
|
ArrayRef<StringRef> DebuginfodUrls, std::chrono::milliseconds Timeout) {
|
||||||
llvm::CachePruningPolicy policy) {
|
|
||||||
SmallString<64> AbsCachedArtifactPath;
|
SmallString<64> AbsCachedArtifactPath;
|
||||||
sys::path::append(AbsCachedArtifactPath, CacheDirectoryPath,
|
sys::path::append(AbsCachedArtifactPath, CacheDirectoryPath,
|
||||||
"llvmcache-" + UniqueKey);
|
"llvmcache-" + UniqueKey);
|
||||||
@@ -319,7 +304,11 @@ Expected<std::string> getCachedOrDownloadArtifact(
|
|||||||
continue;
|
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 the path to the artifact on disk.
|
||||||
return std::string(AbsCachedArtifactPath);
|
return std::string(AbsCachedArtifactPath);
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ TEST(DebuginfodClient, CacheHit) {
|
|||||||
sys::fs::createTemporaryFile("llvmcache-key", "temp", FD, CachedFilePath);
|
sys::fs::createTemporaryFile("llvmcache-key", "temp", FD, CachedFilePath);
|
||||||
StringRef CacheDir = sys::path::parent_path(CachedFilePath);
|
StringRef CacheDir = sys::path::parent_path(CachedFilePath);
|
||||||
StringRef UniqueKey = sys::path::filename(CachedFilePath);
|
StringRef UniqueKey = sys::path::filename(CachedFilePath);
|
||||||
llvm::CachePruningPolicy policy;
|
|
||||||
EXPECT_TRUE(UniqueKey.consume_front("llvmcache-"));
|
EXPECT_TRUE(UniqueKey.consume_front("llvmcache-"));
|
||||||
raw_fd_ostream OF(FD, true, /*unbuffered=*/true);
|
raw_fd_ostream OF(FD, true, /*unbuffered=*/true);
|
||||||
OF << "contents\n";
|
OF << "contents\n";
|
||||||
@@ -45,7 +44,7 @@ TEST(DebuginfodClient, CacheHit) {
|
|||||||
OF.close();
|
OF.close();
|
||||||
Expected<std::string> PathOrErr = getCachedOrDownloadArtifact(
|
Expected<std::string> PathOrErr = getCachedOrDownloadArtifact(
|
||||||
UniqueKey, /*UrlPath=*/"/null", CacheDir,
|
UniqueKey, /*UrlPath=*/"/null", CacheDir,
|
||||||
/*DebuginfodUrls=*/{}, /*Timeout=*/std::chrono::milliseconds(1), policy);
|
/*DebuginfodUrls=*/{}, /*Timeout=*/std::chrono::milliseconds(1));
|
||||||
EXPECT_THAT_EXPECTED(PathOrErr, HasValue(CachedFilePath));
|
EXPECT_THAT_EXPECTED(PathOrErr, HasValue(CachedFilePath));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user