#include "llvm/Support/CachePruning.h"
#include "llvm/Support/MemoryBuffer.h"
-using namespace llvm;
using namespace lldb_private;
-DataFileCache::DataFileCache(StringRef path) {
+DataFileCache::DataFileCache(llvm::StringRef path) {
m_cache_dir.SetPath(path);
// Prune the cache based off of the LLDB settings each time we create a cache
// object.
ModuleListProperties &properties =
ModuleList::GetGlobalModuleListProperties();
- CachePruningPolicy policy;
+ llvm::CachePruningPolicy policy;
// Only scan once an hour. If we have lots of debug sessions we don't want
// to scan this directory too often. A timestamp file is written to the
// directory to ensure different processes don't scan the directory too often.
if (m_take_ownership)
m_mem_buff_up = std::move(m);
};
- Expected<FileCache> cache_or_err =
+ llvm::Expected<llvm::FileCache> cache_or_err =
llvm::localCache("LLDBModuleCache", "lldb-module", path, add_buffer);
if (cache_or_err)
m_cache_callback = std::move(*cache_or_err);
}
std::unique_ptr<llvm::MemoryBuffer>
-DataFileCache::GetCachedData(StringRef key) {
+DataFileCache::GetCachedData(llvm::StringRef key) {
std::lock_guard<std::mutex> guard(m_mutex);
const unsigned task = 1;
// call the "add_buffer" lambda function from the constructor which will in
// turn take ownership of the member buffer that is passed to the callback and
// put it into a member variable.
- Expected<AddStreamFn> add_stream_or_err = m_cache_callback(task, key);
+ llvm::Expected<llvm::AddStreamFn> add_stream_or_err =
+ m_cache_callback(task, key);
m_take_ownership = false;
// At this point we either already called the "add_buffer" lambda with
// the data or we haven't. We can tell if we got the cached data by checking
// the add_stream function pointer value below.
if (add_stream_or_err) {
- AddStreamFn &add_stream = *add_stream_or_err;
+ llvm::AddStreamFn &add_stream = *add_stream_or_err;
// If the "add_stream" is nullptr, then the data was cached and we already
// called the "add_buffer" lambda. If it is valid, then if we were to call
// the add_stream function it would cause a cache file to get generated
return std::unique_ptr<llvm::MemoryBuffer>();
}
-bool DataFileCache::SetCachedData(StringRef key, llvm::ArrayRef<uint8_t> data) {
+bool DataFileCache::SetCachedData(llvm::StringRef key,
+ llvm::ArrayRef<uint8_t> data) {
std::lock_guard<std::mutex> guard(m_mutex);
const unsigned task = 2;
// If we call this function and the data is cached, it will call the
// add_buffer lambda function from the constructor which will ignore the
// data.
- Expected<AddStreamFn> add_stream_or_err = m_cache_callback(task, key);
+ llvm::Expected<llvm::AddStreamFn> add_stream_or_err =
+ m_cache_callback(task, key);
// If we reach this code then we either already called the callback with
// the data or we haven't. We can tell if we had the cached data by checking
// the CacheAddStream function pointer value below.
if (add_stream_or_err) {
- AddStreamFn &add_stream = *add_stream_or_err;
+ llvm::AddStreamFn &add_stream = *add_stream_or_err;
// If the "add_stream" is nullptr, then the data was cached. If it is
// valid, then if we call the add_stream function with a task it will
// cause the file to get generated, but we only want to check if the data
// provided, but we won't take ownership of the memory buffer as we just
// want to write the data.
if (add_stream) {
- Expected<std::unique_ptr<CachedFileStream>> file_or_err =
+ llvm::Expected<std::unique_ptr<llvm::CachedFileStream>> file_or_err =
add_stream(task);
if (file_or_err) {
- CachedFileStream *cfs = file_or_err->get();
+ llvm::CachedFileStream *cfs = file_or_err->get();
cfs->OS->write((const char *)data.data(), data.size());
return true;
} else {
return true;
}
-bool CacheSignature::Decode(const DataExtractor &data,
+bool CacheSignature::Decode(const lldb_private::DataExtractor &data,
lldb::offset_t *offset_ptr) {
Clear();
while (uint8_t sig_encoding = data.GetU8(offset_ptr)) {
return true;
}
-bool StringTableReader::Decode(const DataExtractor &data,
+bool StringTableReader::Decode(const lldb_private::DataExtractor &data,
lldb::offset_t *offset_ptr) {
llvm::StringRef identifier((const char *)data.GetData(offset_ptr, 4), 4);
if (identifier != kStringTableIdentifier)
const char *bytes = (const char *)data.GetData(offset_ptr, length);
if (bytes == nullptr)
return false;
- m_data = StringRef(bytes, length);
+ m_data = llvm::StringRef(bytes, length);
return true;
}
-StringRef StringTableReader::Get(uint32_t offset) const {
+llvm::StringRef StringTableReader::Get(uint32_t offset) const {
if (offset >= m_data.size())
- return StringRef();
- return StringRef(m_data.data() + offset);
+ return llvm::StringRef();
+ return llvm::StringRef(m_data.data() + offset);
}