/// bytes for the object file (or memory for memory based object files).
///
/// @return
- /// Returns \b true if a UUID was successfully extracted into
- /// \a uuid, \b false otherwise.
+ /// The object file's UUID. In case of an error, an empty UUID is
+ /// returned.
//------------------------------------------------------------------
- virtual bool GetUUID(lldb_private::UUID *uuid) = 0;
+ virtual UUID GetUUID() = 0;
//------------------------------------------------------------------
/// Gets the symbol file spec list for this object file.
ObjectFile *obj_file = GetObjectFile();
if (obj_file != nullptr) {
- obj_file->GetUUID(&m_uuid);
+ m_uuid = obj_file->GetUUID();
m_did_set_uuid = true;
}
}
return nullptr;
}
-bool ObjectFileBreakpad::GetUUID(UUID *uuid) {
- *uuid = m_uuid;
- return true;
-}
-
void ObjectFileBreakpad::CreateSections(SectionList &unified_section_list) {
if (m_sections_ap)
return;
ArchSpec GetArchitecture() override { return m_arch; }
- bool GetUUID(UUID *uuid) override;
+ UUID GetUUID() override { return m_uuid; }
FileSpecList GetDebugSymbolFilePaths() override { return FileSpecList(); }
return m_header.Parse(m_data, &offset);
}
-bool ObjectFileELF::GetUUID(lldb_private::UUID *uuid) {
+UUID ObjectFileELF::GetUUID() {
// Need to parse the section list to get the UUIDs, so make sure that's been
// done.
if (!ParseSectionHeaders() && GetType() != ObjectFile::eTypeCoreFile)
- return false;
+ return UUID();
- using u32le = llvm::support::ulittle32_t;
- if (m_uuid.IsValid()) {
- // We have the full build id uuid.
- *uuid = m_uuid;
- return true;
- } else if (GetType() == ObjectFile::eTypeCoreFile) {
- uint32_t core_notes_crc = 0;
+ if (!m_uuid) {
+ using u32le = llvm::support::ulittle32_t;
+ if (GetType() == ObjectFile::eTypeCoreFile) {
+ uint32_t core_notes_crc = 0;
- if (!ParseProgramHeaders())
- return false;
+ if (!ParseProgramHeaders())
+ return UUID();
- core_notes_crc = CalculateELFNotesSegmentsCRC32(m_program_headers, m_data);
+ core_notes_crc =
+ CalculateELFNotesSegmentsCRC32(m_program_headers, m_data);
- if (core_notes_crc) {
- // Use 8 bytes - first 4 bytes for *magic* prefix, mainly to make it look
- // different form .gnu_debuglink crc - followed by 4 bytes of note
- // segments crc.
- u32le data[] = {u32le(g_core_uuid_magic), u32le(core_notes_crc)};
- m_uuid = UUID::fromData(data, sizeof(data));
- }
- } else {
- if (!m_gnu_debuglink_crc)
- m_gnu_debuglink_crc =
- calc_gnu_debuglink_crc32(m_data.GetDataStart(), m_data.GetByteSize());
- if (m_gnu_debuglink_crc) {
- // Use 4 bytes of crc from the .gnu_debuglink section.
- u32le data(m_gnu_debuglink_crc);
- m_uuid = UUID::fromData(&data, sizeof(data));
+ if (core_notes_crc) {
+ // Use 8 bytes - first 4 bytes for *magic* prefix, mainly to make it
+ // look different form .gnu_debuglink crc - followed by 4 bytes of note
+ // segments crc.
+ u32le data[] = {u32le(g_core_uuid_magic), u32le(core_notes_crc)};
+ m_uuid = UUID::fromData(data, sizeof(data));
+ }
+ } else {
+ if (!m_gnu_debuglink_crc)
+ m_gnu_debuglink_crc = calc_gnu_debuglink_crc32(m_data.GetDataStart(),
+ m_data.GetByteSize());
+ if (m_gnu_debuglink_crc) {
+ // Use 4 bytes of crc from the .gnu_debuglink section.
+ u32le data(m_gnu_debuglink_crc);
+ m_uuid = UUID::fromData(&data, sizeof(data));
+ }
}
}
- if (m_uuid.IsValid()) {
- *uuid = m_uuid;
- return true;
- }
-
- return false;
+ return m_uuid;
}
lldb_private::FileSpecList ObjectFileELF::GetDebugSymbolFilePaths() {
lldb_private::ArchSpec GetArchitecture() override;
- bool GetUUID(lldb_private::UUID *uuid) override;
+ lldb_private::UUID GetUUID() override;
lldb_private::FileSpecList GetDebugSymbolFilePaths() override;
}
}
-bool ObjectFileJIT::GetUUID(lldb_private::UUID *uuid) {
+UUID ObjectFileJIT::GetUUID() {
// TODO: maybe get from delegate, not needed for first pass
- return false;
+ return UUID();
}
uint32_t ObjectFileJIT::GetDependentModules(FileSpecList &files) {
lldb_private::ArchSpec GetArchitecture() override;
- bool GetUUID(lldb_private::UUID *uuid) override;
+ lldb_private::UUID GetUUID() override;
uint32_t GetDependentModules(lldb_private::FileSpecList &files) override;
spec.GetArchitecture() = GetArchitecture(header, data, data_offset);
if (spec.GetArchitecture().IsValid()) {
- GetUUID(header, data, data_offset, spec.GetUUID());
+ spec.GetUUID() = GetUUID(header, data, data_offset);
specs.Append(spec);
}
}
}
}
-bool ObjectFileMachO::GetUUID(const llvm::MachO::mach_header &header,
+UUID ObjectFileMachO::GetUUID(const llvm::MachO::mach_header &header,
const lldb_private::DataExtractor &data,
- lldb::offset_t lc_offset,
- lldb_private::UUID &uuid) {
+ lldb::offset_t lc_offset) {
uint32_t i;
struct uuid_command load_cmd;
0xbb, 0x14, 0xf0, 0x0d};
if (!memcmp(uuid_bytes, opencl_uuid, 16))
- return false;
+ return UUID();
- uuid = UUID::fromOptionalData(uuid_bytes, 16);
- return true;
+ return UUID::fromOptionalData(uuid_bytes, 16);
}
- return false;
+ return UUID();
}
offset = cmd_offset + load_cmd.cmdsize;
}
- return false;
+ return UUID();
}
static llvm::StringRef GetOSName(uint32_t cmd) {
return arch;
}
-bool ObjectFileMachO::GetUUID(lldb_private::UUID *uuid) {
+UUID ObjectFileMachO::GetUUID() {
ModuleSP module_sp(GetModule());
if (module_sp) {
std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
lldb::offset_t offset = MachHeaderSizeFromMagic(m_header.magic);
- return GetUUID(m_header, m_data, offset, *uuid);
+ return GetUUID(m_header, m_data, offset);
}
- return false;
+ return UUID();
}
uint32_t ObjectFileMachO::GetDependentModules(FileSpecList &files) {
if (GetAddressByteSize() == 4) {
// 32 bit kexts are just object files, but they do have a valid
// UUID load command.
- UUID uuid;
- if (GetUUID(&uuid)) {
+ if (GetUUID()) {
// this checking for the UUID load command is not enough we could
// eventually look for the symbol named "OSKextGetCurrentIdentifier" as
// this is required of kexts
{
// 32 bit kexts are just object files, but they do have a valid
// UUID load command.
- UUID uuid;
- if (GetUUID(&uuid)) {
+ if (GetUUID()) {
// this checking for the UUID load command is not enough we could
// eventually look for the symbol named "OSKextGetCurrentIdentifier" as
// this is required of kexts
lldb_private::ArchSpec GetArchitecture() override;
- bool GetUUID(lldb_private::UUID *uuid) override;
+ lldb_private::UUID GetUUID() override;
uint32_t GetDependentModules(lldb_private::FileSpecList &files) override;
uint32_t GetPluginVersion() override;
protected:
- static bool
+ static lldb_private::UUID
GetUUID(const llvm::MachO::mach_header &header,
const lldb_private::DataExtractor &data,
- lldb::offset_t lc_offset, // Offset to the first load command
- lldb_private::UUID &uuid);
+ lldb::offset_t lc_offset); // Offset to the first load command
static lldb_private::ArchSpec
GetArchitecture(const llvm::MachO::mach_header &header,
}
}
-bool ObjectFilePECOFF::GetUUID(UUID *uuid) { return false; }
+UUID ObjectFilePECOFF::GetUUID() { return UUID(); }
uint32_t ObjectFilePECOFF::ParseDependentModules() {
ModuleSP module_sp(GetModule());
lldb_private::ArchSpec GetArchitecture() override;
- bool GetUUID(lldb_private::UUID *uuid) override;
+ lldb_private::UUID GetUUID() override;
uint32_t GetDependentModules(lldb_private::FileSpecList &files) override;
if (obj_name != obj_file_elf)
return NULL;
- lldb_private::UUID uuid;
- if (!obj_file->GetUUID(&uuid))
+ lldb_private::UUID uuid = obj_file->GetUUID();
+ if (!uuid)
return NULL;
// Get the .gnu_debuglink file (if specified).