#define liblldb_ModuleSpec_h_
// Project includes
+#include "lldb/Host/FileSystem.h"
#include "lldb/Target/PathMappingList.h"
#include "lldb/Utility/ArchSpec.h"
#include "lldb/Utility/FileSpec.h"
m_object_name(), m_object_offset(0), m_object_size(0),
m_source_mappings() {}
- ModuleSpec(const FileSpec &file_spec, const UUID& uuid = UUID())
+ ModuleSpec(const FileSpec &file_spec, const UUID &uuid = UUID())
: m_file(file_spec), m_platform_file(), m_symbol_file(), m_arch(),
m_uuid(uuid), m_object_name(), m_object_offset(0),
- m_object_size(file_spec.GetByteSize()), m_source_mappings() {}
+ m_object_size(FileSystem::Instance().GetByteSize(file_spec)),
+ m_source_mappings() {}
ModuleSpec(const FileSpec &file_spec, const ArchSpec &arch)
: m_file(file_spec), m_platform_file(), m_symbol_file(), m_arch(arch),
m_uuid(), m_object_name(), m_object_offset(0),
- m_object_size(file_spec.GetByteSize()), m_source_mappings() {}
+ m_object_size(FileSystem::Instance().GetByteSize(file_spec)),
+ m_source_mappings() {}
ModuleSpec(const ModuleSpec &rhs)
: m_file(rhs.m_file), m_platform_file(rhs.m_platform_file),
//------------------------------------------------------------------
bool ResolvePath();
- uint64_t GetByteSize() const;
-
Style GetPathStyle() const;
//------------------------------------------------------------------
GetFileSpec().GetFilename().AsCString(""));
DataBufferSP data_sp;
lldb::offset_t data_offset = 0;
- const lldb::offset_t file_size = m_file.GetByteSize();
+ const lldb::offset_t file_size =
+ FileSystem::Instance().GetByteSize(m_file);
if (file_size > m_object_offset) {
m_did_load_objfile = true;
m_objfile_sp = ObjectFile::FindPlugin(
// C++ Includes
#include <csignal>
+#include "lldb/Host/FileSystem.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Host/HostProcess.h"
if (command_output_ptr) {
command_output_ptr->clear();
- uint64_t file_size = output_file_spec.GetByteSize();
+ uint64_t file_size =
+ FileSystem::Instance().GetByteSize(output_file_spec);
if (file_size > 0) {
if (file_size > command_output_ptr->max_size()) {
error.SetErrorStringWithFormat(
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/Section.h"
+#include "lldb/Host/FileSystem.h"
#include "lldb/Symbol/DWARFCallFrameInfo.h"
#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Target/SectionLoadList.h"
func_cat,
"Calculating module crc32 %s with size %" PRIu64 " KiB",
file.GetLastPathComponent().AsCString(),
- (file.GetByteSize() - file_offset) / 1024);
+ (FileSystem::Instance().GetByteSize(file) - file_offset) /
+ 1024);
// For core files - which usually don't happen to have a
// gnu_debuglink, and are pretty bulky - calculating whole
lldb::offset_t dwo_file_data_offset = 0;
ObjectFileSP dwo_obj_file = ObjectFile::FindPlugin(
GetObjectFile()->GetModule(), &dwo_file, file_offset,
- dwo_file.GetByteSize(), dwo_file_data_sp, dwo_file_data_offset);
+ FileSystem::Instance().GetByteSize(dwo_file), dwo_file_data_sp,
+ dwo_file_data_offset);
if (dwo_obj_file == nullptr)
return nullptr;
lldb::DataBufferSP file_data_sp;
lldb::offset_t file_data_offset = 0;
lldb::ObjectFileSP obj_file = lldb_private::ObjectFile::FindPlugin(
- module_sp, &file_spec, file_offset, file_spec.GetByteSize(), file_data_sp,
+ module_sp, &file_spec, file_offset,
+ lldb_private::FileSystem::Instance().GetByteSize(file_spec), file_data_sp,
file_data_offset);
if (obj_file == nullptr)
return nullptr;
if (dsym_fspec) {
DataBufferSP dsym_file_data_sp;
lldb::offset_t dsym_file_data_offset = 0;
- ObjectFileSP dsym_objfile_sp = ObjectFile::FindPlugin(
- module_sp, &dsym_fspec, 0, dsym_fspec.GetByteSize(),
- dsym_file_data_sp, dsym_file_data_offset);
+ ObjectFileSP dsym_objfile_sp =
+ ObjectFile::FindPlugin(module_sp, &dsym_fspec, 0,
+ FileSystem::Instance().GetByteSize(dsym_fspec),
+ dsym_file_data_sp, dsym_file_data_offset);
if (dsym_objfile_sp) {
// This objfile is for debugging purposes. Sadly, ObjectFileELF won't
// be able to figure this out consistently as the symbol file may not
if (dsym_fspec) {
DataBufferSP dsym_file_data_sp;
lldb::offset_t dsym_file_data_offset = 0;
- dsym_objfile_sp = ObjectFile::FindPlugin(
- module_sp, &dsym_fspec, 0, dsym_fspec.GetByteSize(),
- dsym_file_data_sp, dsym_file_data_offset);
+ dsym_objfile_sp =
+ ObjectFile::FindPlugin(module_sp, &dsym_fspec, 0,
+ FileSystem::Instance().GetByteSize(dsym_fspec),
+ dsym_file_data_sp, dsym_file_data_offset);
if (UUIDsMatch(module_sp.get(), dsym_objfile_sp.get(), feedback_strm)) {
// We need a XML parser if we hope to parse a plist...
if (XMLDocument::XMLEnabled()) {
const bool must_exist = true;
if (ObjectFile::SplitArchivePathWithObject(
path_with_object, archive_file, archive_object, must_exist)) {
- file_size = archive_file.GetByteSize();
+ file_size = FileSystem::Instance().GetByteSize(archive_file);
if (file_size > 0) {
file = &archive_file;
module_sp->SetFileSpecAndObjectName(archive_file, archive_object);
DataBufferSP data_sp = DataBufferLLVM::CreateSliceFromPath(file.GetPath(), 512, file_offset);
if (data_sp) {
if (file_size == 0) {
- const lldb::offset_t actual_file_size = file.GetByteSize();
+ const lldb::offset_t actual_file_size =
+ FileSystem::Instance().GetByteSize(file);
if (actual_file_size > file_offset)
file_size = actual_file_size - file_offset;
}
if (!module_file_path.Exists())
return Status("Module %s not found", module_file_path.GetPath().c_str());
- if (module_file_path.GetByteSize() != module_spec.GetObjectSize())
+ if (FileSystem::Instance().GetByteSize(module_file_path) !=
+ module_spec.GetObjectSize())
return Status("Module %s has invalid file size",
module_file_path.GetPath().c_str());
return m_is_resolved;
}
-uint64_t FileSpec::GetByteSize() const {
- uint64_t Size = 0;
- if (llvm::sys::fs::file_size(GetPath(), Size))
- return 0;
- return Size;
-}
-
FileSpec::Style FileSpec::GetPathStyle() const { return m_style; }
uint32_t FileSpec::GetPermissions() const {
static void VerifyDiskState(const FileSpec &cache_dir, const char *hostname) {
FileSpec uuid_view = GetUuidView(cache_dir);
EXPECT_TRUE(uuid_view.Exists()) << "uuid_view is: " << uuid_view.GetCString();
- EXPECT_EQ(module_size, uuid_view.GetByteSize());
+ EXPECT_EQ(module_size, FileSystem::Instance().GetByteSize(uuid_view));
FileSpec sysroot_view = GetSysrootView(cache_dir, hostname);
EXPECT_TRUE(sysroot_view.Exists()) << "sysroot_view is: "
<< sysroot_view.GetCString();
- EXPECT_EQ(module_size, sysroot_view.GetByteSize());
+ EXPECT_EQ(module_size, FileSystem::Instance().GetByteSize(sysroot_view));
}
void ModuleCacheTest::TryGetAndPut(const FileSpec &cache_dir,