diff options
| author | Pavel Labath <pavel@labath.sk> | 2019-02-11 16:14:02 +0000 |
|---|---|---|
| committer | Pavel Labath <pavel@labath.sk> | 2019-02-11 16:14:02 +0000 |
| commit | bd334efd0aec3d26d7ace3c5f8b858b07e0bb9bd (patch) | |
| tree | 48a468ce6ce77ac4fc7b841e80a753e8459b8ff1 /lldb/source/Plugins/ObjectFile/ELF | |
| parent | 5caa550649740ee39ec09cbb195129d1687ca880 (diff) | |
| download | bcm5719-llvm-bd334efd0aec3d26d7ace3c5f8b858b07e0bb9bd.tar.gz bcm5719-llvm-bd334efd0aec3d26d7ace3c5f8b858b07e0bb9bd.zip | |
Simplify ObjectFile::GetUUID
instead of returning the UUID through by-ref argument and a boolean
value indicating success, we can just return it directly. Since the UUID
class already has an invalid state, it can be used to denote the failure
without the additional bool.
llvm-svn: 353714
Diffstat (limited to 'lldb/source/Plugins/ObjectFile/ELF')
| -rw-r--r-- | lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp | 60 | ||||
| -rw-r--r-- | lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h | 2 |
2 files changed, 28 insertions, 34 deletions
diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp index 1f1551c0ce5..521e8750858 100644 --- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -896,49 +896,43 @@ bool ObjectFileELF::ParseHeader() { 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() { diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h index 570a8baa087..fb51212a0a5 100644 --- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h +++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h @@ -122,7 +122,7 @@ public: lldb_private::ArchSpec GetArchitecture() override; - bool GetUUID(lldb_private::UUID *uuid) override; + lldb_private::UUID GetUUID() override; lldb_private::FileSpecList GetDebugSymbolFilePaths() override; |

