summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/ObjectFile
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Plugins/ObjectFile')
-rw-r--r--lldb/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp5
-rw-r--r--lldb/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.h2
-rw-r--r--lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp23
-rw-r--r--lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h2
-rw-r--r--lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp12
-rw-r--r--lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.h2
-rw-r--r--lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp42
-rw-r--r--lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h10
-rw-r--r--lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp14
-rw-r--r--lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h2
10 files changed, 50 insertions, 64 deletions
diff --git a/lldb/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp b/lldb/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp
index a148ab525b9..7eebac2c693 100644
--- a/lldb/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp
+++ b/lldb/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp
@@ -230,11 +230,6 @@ Symtab *ObjectFileBreakpad::GetSymtab() {
return nullptr;
}
-bool ObjectFileBreakpad::GetArchitecture(ArchSpec &arch) {
- arch = m_arch;
- return true;
-}
-
bool ObjectFileBreakpad::GetUUID(UUID *uuid) {
*uuid = m_uuid;
return true;
diff --git a/lldb/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.h b/lldb/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.h
index ea3b8685aad..ba2a3ad30e5 100644
--- a/lldb/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.h
+++ b/lldb/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.h
@@ -82,7 +82,7 @@ public:
void Dump(Stream *s) override {}
- bool GetArchitecture(ArchSpec &arch) override;
+ ArchSpec GetArchitecture() override { return m_arch; }
bool GetUUID(UUID *uuid) override;
diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
index 95685c23ec1..e3a86f352c0 100644
--- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -434,9 +434,8 @@ ObjectFile *ObjectFileELF::CreateInstance(const lldb::ModuleSP &module_sp,
if (address_size == 4 || address_size == 8) {
std::unique_ptr<ObjectFileELF> objfile_ap(new ObjectFileELF(
module_sp, data_sp, data_offset, file, file_offset, length));
- ArchSpec spec;
- if (objfile_ap->GetArchitecture(spec) &&
- objfile_ap->SetModulesArchitecture(spec))
+ ArchSpec spec = objfile_ap->GetArchitecture();
+ if (spec && objfile_ap->SetModulesArchitecture(spec))
return objfile_ap.release();
}
@@ -453,9 +452,8 @@ ObjectFile *ObjectFileELF::CreateMemoryInstance(
if (address_size == 4 || address_size == 8) {
std::unique_ptr<ObjectFileELF> objfile_ap(
new ObjectFileELF(module_sp, data_sp, process_sp, header_addr));
- ArchSpec spec;
- if (objfile_ap->GetArchitecture(spec) &&
- objfile_ap->SetModulesArchitecture(spec))
+ ArchSpec spec = objfile_ap->GetArchitecture();
+ if (spec && objfile_ap->SetModulesArchitecture(spec))
return objfile_ap.release();
}
}
@@ -1957,8 +1955,7 @@ unsigned ObjectFileELF::ParseSymbols(Symtab *symtab, user_id_t start_id,
bool skip_oatdata_oatexec = file_extension == ConstString(".oat") ||
file_extension == ConstString(".odex");
- ArchSpec arch;
- GetArchitecture(arch);
+ ArchSpec arch = GetArchitecture();
ModuleSP module_sp(GetModule());
SectionList *module_section_list =
module_sp ? module_sp->GetSectionList() : nullptr;
@@ -2885,8 +2882,7 @@ void ObjectFileELF::Dump(Stream *s) {
s->Indent();
s->PutCString("ObjectFileELF");
- ArchSpec header_arch;
- GetArchitecture(header_arch);
+ ArchSpec header_arch = GetArchitecture();
*s << ", file = '" << m_file
<< "', arch = " << header_arch.GetArchitectureName() << "\n";
@@ -3172,9 +3168,9 @@ void ObjectFileELF::DumpDependentModules(lldb_private::Stream *s) {
}
}
-bool ObjectFileELF::GetArchitecture(ArchSpec &arch) {
+ArchSpec ObjectFileELF::GetArchitecture() {
if (!ParseHeader())
- return false;
+ return ArchSpec();
if (m_section_headers.empty()) {
// Allow elf notes to be parsed which may affect the detected architecture.
@@ -3195,8 +3191,7 @@ bool ObjectFileELF::GetArchitecture(ArchSpec &arch) {
}
}
}
- arch = m_arch_spec;
- return true;
+ return m_arch_spec;
}
ObjectFile::Type ObjectFileELF::CalculateType() {
diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
index 2e6478a8244..ff08eb2a1bb 100644
--- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
+++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
@@ -121,7 +121,7 @@ public:
void Dump(lldb_private::Stream *s) override;
- bool GetArchitecture(lldb_private::ArchSpec &arch) override;
+ lldb_private::ArchSpec GetArchitecture() override;
bool GetUUID(lldb_private::UUID *uuid) override;
diff --git a/lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp b/lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp
index bce35224550..cfe61992be0 100644
--- a/lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp
+++ b/lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp
@@ -153,8 +153,7 @@ void ObjectFileJIT::Dump(Stream *s) {
s->Indent();
s->PutCString("ObjectFileJIT");
- ArchSpec arch;
- if (GetArchitecture(arch))
+ if (ArchSpec arch = GetArchitecture())
*s << ", arch = " << arch.GetArchitectureName();
s->EOL();
@@ -190,11 +189,10 @@ ObjectFile::Type ObjectFileJIT::CalculateType() { return eTypeJIT; }
ObjectFile::Strata ObjectFileJIT::CalculateStrata() { return eStrataJIT; }
-bool ObjectFileJIT::GetArchitecture(ArchSpec &arch) {
- ObjectFileJITDelegateSP delegate_sp(m_delegate_wp.lock());
- if (delegate_sp)
- return delegate_sp->GetArchitecture(arch);
- return false;
+ArchSpec ObjectFileJIT::GetArchitecture() {
+ if (ObjectFileJITDelegateSP delegate_sp = m_delegate_wp.lock())
+ return delegate_sp->GetArchitecture();
+ return ArchSpec();
}
//------------------------------------------------------------------
diff --git a/lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.h b/lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.h
index ec01f1f3eb6..3d9e4748d3d 100644
--- a/lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.h
+++ b/lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.h
@@ -73,7 +73,7 @@ public:
void Dump(lldb_private::Stream *s) override;
- bool GetArchitecture(lldb_private::ArchSpec &arch) override;
+ lldb_private::ArchSpec GetArchitecture() override;
bool GetUUID(lldb_private::UUID *uuid) override;
diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index 593a4e5cf22..06908fecf98 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -915,12 +915,10 @@ size_t ObjectFileMachO::GetModuleSpecifications(
spec.SetObjectOffset(file_offset);
spec.SetObjectSize(length);
- if (GetArchitecture(header, data, data_offset,
- spec.GetArchitecture())) {
- if (spec.GetArchitecture().IsValid()) {
- GetUUID(header, data, data_offset, spec.GetUUID());
- specs.Append(spec);
- }
+ spec.GetArchitecture() = GetArchitecture(header, data, data_offset);
+ if (spec.GetArchitecture().IsValid()) {
+ GetUUID(header, data, data_offset, spec.GetUUID());
+ specs.Append(spec);
}
}
}
@@ -1103,9 +1101,7 @@ bool ObjectFileMachO::ParseHeader() {
if (can_parse) {
m_data.GetU32(&offset, &m_header.cputype, 6);
- ArchSpec mach_arch;
-
- if (GetArchitecture(mach_arch)) {
+ if (ArchSpec mach_arch = GetArchitecture()) {
// Check if the module has a required architecture
const ArchSpec &module_arch = module_sp->GetArchitecture();
if (module_arch.IsValid() && !module_arch.IsCompatibleMatch(mach_arch))
@@ -4838,8 +4834,7 @@ void ObjectFileMachO::Dump(Stream *s) {
else
s->PutCString("ObjectFileMachO32");
- ArchSpec header_arch;
- GetArchitecture(header_arch);
+ ArchSpec header_arch = GetArchitecture();
*s << ", file = '" << m_file
<< "', triple = " << header_arch.GetTriple().getTriple() << "\n";
@@ -4962,10 +4957,11 @@ namespace {
};
} // namespace
-bool ObjectFileMachO::GetArchitecture(const llvm::MachO::mach_header &header,
- const lldb_private::DataExtractor &data,
- lldb::offset_t lc_offset,
- ArchSpec &arch) {
+ArchSpec
+ObjectFileMachO::GetArchitecture(const llvm::MachO::mach_header &header,
+ const lldb_private::DataExtractor &data,
+ lldb::offset_t lc_offset) {
+ ArchSpec arch;
arch.SetArchitecture(eArchTypeMachO, header.cputype, header.cpusubtype);
if (arch.IsValid()) {
@@ -4990,7 +4986,7 @@ bool ObjectFileMachO::GetArchitecture(const llvm::MachO::mach_header &header,
triple.setVendor(llvm::Triple::UnknownVendor);
triple.setVendorName(llvm::StringRef());
}
- return true;
+ return arch;
} else {
struct load_command load_cmd;
llvm::SmallString<16> os_name;
@@ -5019,7 +5015,7 @@ bool ObjectFileMachO::GetArchitecture(const llvm::MachO::mach_header &header,
os << GetOSName(load_cmd.cmd) << min_os.major_version << '.'
<< min_os.minor_version << '.' << min_os.patch_version;
triple.setOSName(os.str());
- return true;
+ return arch;
}
default:
break;
@@ -5055,7 +5051,7 @@ bool ObjectFileMachO::GetArchitecture(const llvm::MachO::mach_header &header,
triple.setOSName(os.str());
if (!os_env.environment.empty())
triple.setEnvironmentName(os_env.environment);
- return true;
+ return arch;
}
} while (0);
offset = cmd_offset + load_cmd.cmdsize;
@@ -5070,7 +5066,7 @@ bool ObjectFileMachO::GetArchitecture(const llvm::MachO::mach_header &header,
}
}
}
- return arch.IsValid();
+ return arch;
}
bool ObjectFileMachO::GetUUID(lldb_private::UUID *uuid) {
@@ -5692,14 +5688,16 @@ llvm::VersionTuple ObjectFileMachO::GetVersion() {
return llvm::VersionTuple();
}
-bool ObjectFileMachO::GetArchitecture(ArchSpec &arch) {
+ArchSpec ObjectFileMachO::GetArchitecture() {
ModuleSP module_sp(GetModule());
+ ArchSpec arch;
if (module_sp) {
std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
+
return GetArchitecture(m_header, m_data,
- MachHeaderSizeFromMagic(m_header.magic), arch);
+ MachHeaderSizeFromMagic(m_header.magic));
}
- return false;
+ return arch;
}
void ObjectFileMachO::GetProcessSharedCacheUUID(Process *process, addr_t &base_addr, UUID &uuid) {
diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
index e68ead87677..196abae807e 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
@@ -92,7 +92,7 @@ public:
void Dump(lldb_private::Stream *s) override;
- bool GetArchitecture(lldb_private::ArchSpec &arch) override;
+ lldb_private::ArchSpec GetArchitecture() override;
bool GetUUID(lldb_private::UUID *uuid) override;
@@ -147,10 +147,10 @@ protected:
lldb::offset_t lc_offset, // Offset to the first load command
lldb_private::UUID &uuid);
- static bool GetArchitecture(const llvm::MachO::mach_header &header,
- const lldb_private::DataExtractor &data,
- lldb::offset_t lc_offset,
- lldb_private::ArchSpec &arch);
+ static lldb_private::ArchSpec
+ GetArchitecture(const llvm::MachO::mach_header &header,
+ const lldb_private::DataExtractor &data,
+ lldb::offset_t lc_offset);
// Intended for same-host arm device debugging where lldb needs to
// detect libraries in the shared cache and augment the nlist entries
diff --git a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
index da7b3f2ebbe..6a3d8ddf091 100644
--- a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -944,8 +944,7 @@ void ObjectFilePECOFF::Dump(Stream *s) {
s->Indent();
s->PutCString("ObjectFilePECOFF");
- ArchSpec header_arch;
- GetArchitecture(header_arch);
+ ArchSpec header_arch = GetArchitecture();
*s << ", file = '" << m_file
<< "', arch = " << header_arch.GetArchitectureName() << "\n";
@@ -1148,9 +1147,11 @@ bool ObjectFilePECOFF::IsWindowsSubsystem() {
}
}
-bool ObjectFilePECOFF::GetArchitecture(ArchSpec &arch) {
+ArchSpec ObjectFilePECOFF::GetArchitecture() {
uint16_t machine = m_coff_header.machine;
switch (machine) {
+ default:
+ break;
case llvm::COFF::IMAGE_FILE_MACHINE_AMD64:
case llvm::COFF::IMAGE_FILE_MACHINE_I386:
case llvm::COFF::IMAGE_FILE_MACHINE_POWERPC:
@@ -1158,14 +1159,13 @@ bool ObjectFilePECOFF::GetArchitecture(ArchSpec &arch) {
case llvm::COFF::IMAGE_FILE_MACHINE_ARM:
case llvm::COFF::IMAGE_FILE_MACHINE_ARMNT:
case llvm::COFF::IMAGE_FILE_MACHINE_THUMB:
+ ArchSpec arch;
arch.SetArchitecture(eArchTypeCOFF, machine, LLDB_INVALID_CPUTYPE,
IsWindowsSubsystem() ? llvm::Triple::Win32
: llvm::Triple::UnknownOS);
- return true;
- default:
- break;
+ return arch;
}
- return false;
+ return ArchSpec();
}
ObjectFile::Type ObjectFilePECOFF::CalculateType() {
diff --git a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
index f93b83144b3..cf815b60eb4 100644
--- a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
+++ b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
@@ -110,7 +110,7 @@ public:
void Dump(lldb_private::Stream *s) override;
- bool GetArchitecture(lldb_private::ArchSpec &arch) override;
+ lldb_private::ArchSpec GetArchitecture() override;
bool GetUUID(lldb_private::UUID *uuid) override;
OpenPOWER on IntegriCloud