summaryrefslogtreecommitdiff
path: root/source/Symbol/ObjectFile.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2019-01-19 10:06:29 +0000
committerDimitry Andric <dim@FreeBSD.org>2019-01-19 10:06:29 +0000
commit94994d372d014ce4c8758b9605d63fae651bd8aa (patch)
tree51c0b708bd59f205d6b35cb2a8c24d62f0c33d77 /source/Symbol/ObjectFile.cpp
parent39be7ce23363d12ae3e49aeb1fdb2bfeb892e836 (diff)
Notes
Diffstat (limited to 'source/Symbol/ObjectFile.cpp')
-rw-r--r--source/Symbol/ObjectFile.cpp94
1 files changed, 80 insertions, 14 deletions
diff --git a/source/Symbol/ObjectFile.cpp b/source/Symbol/ObjectFile.cpp
index 59012b1f8261..86c18c7beb0b 100644
--- a/source/Symbol/ObjectFile.cpp
+++ b/source/Symbol/ObjectFile.cpp
@@ -19,7 +19,6 @@
#include "lldb/Target/Target.h"
#include "lldb/Utility/DataBuffer.h"
#include "lldb/Utility/DataBufferHeap.h"
-#include "lldb/Utility/DataBufferLLVM.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/RegularExpression.h"
#include "lldb/Utility/Timer.h"
@@ -47,7 +46,7 @@ ObjectFile::FindPlugin(const lldb::ModuleSP &module_sp, const FileSpec *file,
FileSpec archive_file;
ObjectContainerCreateInstance create_object_container_callback;
- const bool file_exists = file->Exists();
+ const bool file_exists = FileSystem::Instance().Exists(*file);
if (!data_sp) {
// We have an object name which most likely means we have a .o file in
// a static archive (.a file). Try and see if we have a cached archive
@@ -75,8 +74,8 @@ ObjectFile::FindPlugin(const lldb::ModuleSP &module_sp, const FileSpec *file,
// container plug-ins can use these bytes to see if they can parse this
// file.
if (file_size > 0) {
- data_sp =
- DataBufferLLVM::CreateSliceFromPath(file->GetPath(), 512, file_offset);
+ data_sp = FileSystem::Instance().CreateDataBuffer(file->GetPath(),
+ 512, file_offset);
data_offset = 0;
}
}
@@ -91,7 +90,7 @@ ObjectFile::FindPlugin(const lldb::ModuleSP &module_sp, const FileSpec *file,
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);
@@ -120,8 +119,8 @@ ObjectFile::FindPlugin(const lldb::ModuleSP &module_sp, const FileSpec *file,
}
// We failed to find any cached object files in the container plug-
// ins, so lets read the first 512 bytes and try again below...
- data_sp = DataBufferLLVM::CreateSliceFromPath(archive_file.GetPath(),
- 512, file_offset);
+ data_sp = FileSystem::Instance().CreateDataBuffer(
+ archive_file.GetPath(), 512, file_offset);
}
}
}
@@ -209,10 +208,12 @@ size_t ObjectFile::GetModuleSpecifications(const FileSpec &file,
lldb::offset_t file_offset,
lldb::offset_t file_size,
ModuleSpecList &specs) {
- DataBufferSP data_sp = DataBufferLLVM::CreateSliceFromPath(file.GetPath(), 512, file_offset);
+ DataBufferSP data_sp =
+ FileSystem::Instance().CreateDataBuffer(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;
}
@@ -344,21 +345,28 @@ AddressClass ObjectFile::GetAddressClass(addr_t file_addr) {
return AddressClass::eData;
case eSectionTypeDebug:
case eSectionTypeDWARFDebugAbbrev:
+ case eSectionTypeDWARFDebugAbbrevDwo:
case eSectionTypeDWARFDebugAddr:
case eSectionTypeDWARFDebugAranges:
case eSectionTypeDWARFDebugCuIndex:
case eSectionTypeDWARFDebugFrame:
case eSectionTypeDWARFDebugInfo:
+ case eSectionTypeDWARFDebugInfoDwo:
case eSectionTypeDWARFDebugLine:
+ case eSectionTypeDWARFDebugLineStr:
case eSectionTypeDWARFDebugLoc:
+ case eSectionTypeDWARFDebugLocLists:
case eSectionTypeDWARFDebugMacInfo:
case eSectionTypeDWARFDebugMacro:
case eSectionTypeDWARFDebugNames:
case eSectionTypeDWARFDebugPubNames:
case eSectionTypeDWARFDebugPubTypes:
case eSectionTypeDWARFDebugRanges:
+ case eSectionTypeDWARFDebugRngLists:
case eSectionTypeDWARFDebugStr:
+ case eSectionTypeDWARFDebugStrDwo:
case eSectionTypeDWARFDebugStrOffsets:
+ case eSectionTypeDWARFDebugStrOffsetsDwo:
case eSectionTypeDWARFDebugTypes:
case eSectionTypeDWARFAppleNames:
case eSectionTypeDWARFAppleTypes:
@@ -578,11 +586,9 @@ bool ObjectFile::SplitArchivePathWithObject(const char *path_with_object,
std::string obj;
if (regex_match.GetMatchAtIndex(path_with_object, 1, path) &&
regex_match.GetMatchAtIndex(path_with_object, 2, obj)) {
- archive_file.SetFile(path, false, FileSpec::Style::native);
+ archive_file.SetFile(path, FileSpec::Style::native);
archive_object.SetCString(obj.c_str());
- if (must_exist && !archive_file.Exists())
- return false;
- return true;
+ return !(must_exist && !FileSystem::Instance().Exists(archive_file));
}
}
return false;
@@ -678,5 +684,65 @@ void ObjectFile::RelocateSection(lldb_private::Section *section)
DataBufferSP ObjectFile::MapFileData(const FileSpec &file, uint64_t Size,
uint64_t Offset) {
- return DataBufferLLVM::CreateSliceFromPath(file.GetPath(), Size, Offset);
+ return FileSystem::Instance().CreateDataBuffer(file.GetPath(), Size, Offset);
+}
+
+void llvm::format_provider<ObjectFile::Type>::format(
+ const ObjectFile::Type &type, raw_ostream &OS, StringRef Style) {
+ switch (type) {
+ case ObjectFile::eTypeInvalid:
+ OS << "invalid";
+ break;
+ case ObjectFile::eTypeCoreFile:
+ OS << "core file";
+ break;
+ case ObjectFile::eTypeExecutable:
+ OS << "executable";
+ break;
+ case ObjectFile::eTypeDebugInfo:
+ OS << "debug info";
+ break;
+ case ObjectFile::eTypeDynamicLinker:
+ OS << "dynamic linker";
+ break;
+ case ObjectFile::eTypeObjectFile:
+ OS << "object file";
+ break;
+ case ObjectFile::eTypeSharedLibrary:
+ OS << "shared library";
+ break;
+ case ObjectFile::eTypeStubLibrary:
+ OS << "stub library";
+ break;
+ case ObjectFile::eTypeJIT:
+ OS << "jit";
+ break;
+ case ObjectFile::eTypeUnknown:
+ OS << "unknown";
+ break;
+ }
+}
+
+void llvm::format_provider<ObjectFile::Strata>::format(
+ const ObjectFile::Strata &strata, raw_ostream &OS, StringRef Style) {
+ switch (strata) {
+ case ObjectFile::eStrataInvalid:
+ OS << "invalid";
+ break;
+ case ObjectFile::eStrataUnknown:
+ OS << "unknown";
+ break;
+ case ObjectFile::eStrataUser:
+ OS << "user";
+ break;
+ case ObjectFile::eStrataKernel:
+ OS << "kernel";
+ break;
+ case ObjectFile::eStrataRawImage:
+ OS << "raw image";
+ break;
+ case ObjectFile::eStrataJIT:
+ OS << "jit";
+ break;
+ }
}