66//
77// ===----------------------------------------------------------------------===//
88
9- #include < cstddef>
109#include < cstdlib>
1110
1211#include < memory>
1312#include < mutex>
14- #include < tuple>
1513
1614#include " lldb/Core/Module.h"
1715#include " lldb/Core/ModuleSpec.h"
@@ -212,9 +210,6 @@ Status ProcessElfCore::DoLoadCore() {
212210 }
213211 }
214212
215- // We need to update uuid after address range is populated.
216- UpdateBuildIdForNTFileEntries ();
217-
218213 if (!ranges_are_sorted) {
219214 m_core_aranges.Sort ();
220215 m_core_range_infos.Sort ();
@@ -263,7 +258,6 @@ Status ProcessElfCore::DoLoadCore() {
263258 if (!m_nt_file_entries.empty ()) {
264259 ModuleSpec exe_module_spec;
265260 exe_module_spec.GetArchitecture () = arch;
266- exe_module_spec.GetUUID () = m_nt_file_entries[0 ].uuid ;
267261 exe_module_spec.GetFileSpec ().SetFile (m_nt_file_entries[0 ].path ,
268262 FileSpec::Style::native);
269263 if (exe_module_spec.GetFileSpec ()) {
@@ -277,16 +271,6 @@ Status ProcessElfCore::DoLoadCore() {
277271 return error;
278272}
279273
280- void ProcessElfCore::UpdateBuildIdForNTFileEntries () {
281- if (!m_nt_file_entries.empty ()) {
282- for (NT_FILE_Entry &entry : m_nt_file_entries) {
283- std::optional<UUID> uuid = FindBuildId (entry);
284- if (uuid)
285- entry.uuid = uuid.value ();
286- }
287- }
288- }
289-
290274lldb_private::DynamicLoader *ProcessElfCore::GetDynamicLoader () {
291275 if (m_dyld_up.get () == nullptr )
292276 m_dyld_up.reset (DynamicLoader::FindPlugin (
@@ -999,40 +983,6 @@ llvm::Error ProcessElfCore::ParseThreadContextsFromNoteSegment(
999983 }
1000984}
1001985
1002- bool ProcessElfCore::IsElf (const NT_FILE_Entry entry) {
1003- size_t size = strlen (llvm::ELF::ElfMagic);
1004- uint8_t buf[size];
1005- Status error;
1006- size_t byte_read = ReadMemory (entry.start , buf, size, error);
1007- if (byte_read == size)
1008- return memcmp (llvm::ELF::ElfMagic, buf, size) == 0 ;
1009- else
1010- return false ;
1011- }
1012-
1013- std::optional<UUID> ProcessElfCore::FindBuildId (const NT_FILE_Entry entry) {
1014- if (!IsElf (entry))
1015- return std::nullopt ;
1016- // Build ID is stored in the ELF file as a section named ".note.gnu.build-id"
1017- uint8_t gnu_build_id_bytes[8 ] = {0x03 , 0x00 , 0x00 , 0x00 ,
1018- 0x47 , 0x4e , 0x55 , 0x00 };
1019- lldb::addr_t gnu_build_id_addr =
1020- FindInMemory (entry.start , entry.end , gnu_build_id_bytes, 8 );
1021- if (gnu_build_id_addr == LLDB_INVALID_ADDRESS)
1022- return std::nullopt ;
1023- uint8_t buf[36 ];
1024- Status error;
1025- size_t byte_read = ReadMemory (gnu_build_id_addr - 8 , buf, 36 , error);
1026- // .note.gnu.build-id starts with 04 00 00 00 {id_byte_size} 00 00 00 03 00 00
1027- // 00 47 4e 55 00
1028- if (byte_read == 36 ) {
1029- if (buf[0 ] == 0x04 ) {
1030- return UUID (llvm::ArrayRef<uint8_t >(buf + 16 , buf[4 ] /* byte size*/ ));
1031- }
1032- }
1033- return std::nullopt ;
1034- }
1035-
1036986uint32_t ProcessElfCore::GetNumThreadContexts () {
1037987 if (!m_thread_data_valid)
1038988 DoLoadCore ();
0 commit comments