1 //===-- ProcessElfCore.cpp --------------------------------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // C Includes 11 #include <stdlib.h> 12 13 // C++ Includes 14 #include <mutex> 15 16 // Other libraries and framework includes 17 #include "lldb/Core/DataBufferHeap.h" 18 #include "lldb/Core/Log.h" 19 #include "lldb/Core/Module.h" 20 #include "lldb/Core/ModuleSpec.h" 21 #include "lldb/Core/PluginManager.h" 22 #include "lldb/Core/Section.h" 23 #include "lldb/Core/State.h" 24 #include "lldb/Target/DynamicLoader.h" 25 #include "lldb/Target/MemoryRegionInfo.h" 26 #include "lldb/Target/Target.h" 27 #include "lldb/Target/UnixSignals.h" 28 29 #include "llvm/Support/ELF.h" 30 31 #include "Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h" 32 #include "Plugins/ObjectFile/ELF/ObjectFileELF.h" 33 34 // Project includes 35 #include "ProcessElfCore.h" 36 #include "ThreadElfCore.h" 37 38 using namespace lldb_private; 39 40 ConstString ProcessElfCore::GetPluginNameStatic() { 41 static ConstString g_name("elf-core"); 42 return g_name; 43 } 44 45 const char *ProcessElfCore::GetPluginDescriptionStatic() { 46 return "ELF core dump plug-in."; 47 } 48 49 void ProcessElfCore::Terminate() { 50 PluginManager::UnregisterPlugin(ProcessElfCore::CreateInstance); 51 } 52 53 lldb::ProcessSP ProcessElfCore::CreateInstance(lldb::TargetSP target_sp, 54 lldb::ListenerSP listener_sp, 55 const FileSpec *crash_file) { 56 lldb::ProcessSP process_sp; 57 if (crash_file) { 58 // Read enough data for a ELF32 header or ELF64 header 59 const size_t header_size = sizeof(llvm::ELF::Elf64_Ehdr); 60 61 lldb::DataBufferSP data_sp(crash_file->ReadFileContents(0, header_size)); 62 if (data_sp && data_sp->GetByteSize() == header_size && 63 elf::ELFHeader::MagicBytesMatch(data_sp->GetBytes())) { 64 elf::ELFHeader elf_header; 65 DataExtractor data(data_sp, lldb::eByteOrderLittle, 4); 66 lldb::offset_t data_offset = 0; 67 if (elf_header.Parse(data, &data_offset)) { 68 if (elf_header.e_type == llvm::ELF::ET_CORE) 69 process_sp.reset( 70 new ProcessElfCore(target_sp, listener_sp, *crash_file)); 71 } 72 } 73 } 74 return process_sp; 75 } 76 77 bool ProcessElfCore::CanDebug(lldb::TargetSP target_sp, 78 bool plugin_specified_by_name) { 79 // For now we are just making sure the file exists for a given module 80 if (!m_core_module_sp && m_core_file.Exists()) { 81 ModuleSpec core_module_spec(m_core_file, target_sp->GetArchitecture()); 82 Error error(ModuleList::GetSharedModule(core_module_spec, m_core_module_sp, 83 NULL, NULL, NULL)); 84 if (m_core_module_sp) { 85 ObjectFile *core_objfile = m_core_module_sp->GetObjectFile(); 86 if (core_objfile && core_objfile->GetType() == ObjectFile::eTypeCoreFile) 87 return true; 88 } 89 } 90 return false; 91 } 92 93 //---------------------------------------------------------------------- 94 // ProcessElfCore constructor 95 //---------------------------------------------------------------------- 96 ProcessElfCore::ProcessElfCore(lldb::TargetSP target_sp, 97 lldb::ListenerSP listener_sp, 98 const FileSpec &core_file) 99 : Process(target_sp, listener_sp), m_core_module_sp(), 100 m_core_file(core_file), m_dyld_plugin_name(), 101 m_os(llvm::Triple::UnknownOS), m_thread_data_valid(false), 102 m_thread_data(), m_core_aranges() {} 103 104 //---------------------------------------------------------------------- 105 // Destructor 106 //---------------------------------------------------------------------- 107 ProcessElfCore::~ProcessElfCore() { 108 Clear(); 109 // We need to call finalize on the process before destroying ourselves 110 // to make sure all of the broadcaster cleanup goes as planned. If we 111 // destruct this class, then Process::~Process() might have problems 112 // trying to fully destroy the broadcaster. 113 Finalize(); 114 } 115 116 //---------------------------------------------------------------------- 117 // PluginInterface 118 //---------------------------------------------------------------------- 119 ConstString ProcessElfCore::GetPluginName() { return GetPluginNameStatic(); } 120 121 uint32_t ProcessElfCore::GetPluginVersion() { return 1; } 122 123 lldb::addr_t ProcessElfCore::AddAddressRangeFromLoadSegment( 124 const elf::ELFProgramHeader *header) { 125 const lldb::addr_t addr = header->p_vaddr; 126 FileRange file_range(header->p_offset, header->p_filesz); 127 VMRangeToFileOffset::Entry range_entry(addr, header->p_memsz, file_range); 128 129 VMRangeToFileOffset::Entry *last_entry = m_core_aranges.Back(); 130 if (last_entry && last_entry->GetRangeEnd() == range_entry.GetRangeBase() && 131 last_entry->data.GetRangeEnd() == range_entry.data.GetRangeBase() && 132 last_entry->GetByteSize() == last_entry->data.GetByteSize()) { 133 last_entry->SetRangeEnd(range_entry.GetRangeEnd()); 134 last_entry->data.SetRangeEnd(range_entry.data.GetRangeEnd()); 135 } else { 136 m_core_aranges.Append(range_entry); 137 } 138 139 // Keep a separate map of permissions that that isn't coalesced so all ranges 140 // are maintained. 141 const uint32_t permissions = 142 ((header->p_flags & llvm::ELF::PF_R) ? lldb::ePermissionsReadable : 0u) | 143 ((header->p_flags & llvm::ELF::PF_W) ? lldb::ePermissionsWritable : 0u) | 144 ((header->p_flags & llvm::ELF::PF_X) ? lldb::ePermissionsExecutable : 0u); 145 146 m_core_range_infos.Append( 147 VMRangeToPermissions::Entry(addr, header->p_memsz, permissions)); 148 149 return addr; 150 } 151 152 //---------------------------------------------------------------------- 153 // Process Control 154 //---------------------------------------------------------------------- 155 Error ProcessElfCore::DoLoadCore() { 156 Error error; 157 if (!m_core_module_sp) { 158 error.SetErrorString("invalid core module"); 159 return error; 160 } 161 162 ObjectFileELF *core = (ObjectFileELF *)(m_core_module_sp->GetObjectFile()); 163 if (core == NULL) { 164 error.SetErrorString("invalid core object file"); 165 return error; 166 } 167 168 const uint32_t num_segments = core->GetProgramHeaderCount(); 169 if (num_segments == 0) { 170 error.SetErrorString("core file has no segments"); 171 return error; 172 } 173 174 SetCanJIT(false); 175 176 m_thread_data_valid = true; 177 178 bool ranges_are_sorted = true; 179 lldb::addr_t vm_addr = 0; 180 /// Walk through segments and Thread and Address Map information. 181 /// PT_NOTE - Contains Thread and Register information 182 /// PT_LOAD - Contains a contiguous range of Process Address Space 183 for (uint32_t i = 1; i <= num_segments; i++) { 184 const elf::ELFProgramHeader *header = core->GetProgramHeaderByIndex(i); 185 assert(header != NULL); 186 187 DataExtractor data = core->GetSegmentDataByIndex(i); 188 189 // Parse thread contexts and auxv structure 190 if (header->p_type == llvm::ELF::PT_NOTE) { 191 error = ParseThreadContextsFromNoteSegment(header, data); 192 if (error.Fail()) 193 return error; 194 } 195 // PT_LOAD segments contains address map 196 if (header->p_type == llvm::ELF::PT_LOAD) { 197 lldb::addr_t last_addr = AddAddressRangeFromLoadSegment(header); 198 if (vm_addr > last_addr) 199 ranges_are_sorted = false; 200 vm_addr = last_addr; 201 } 202 } 203 204 if (!ranges_are_sorted) { 205 m_core_aranges.Sort(); 206 m_core_range_infos.Sort(); 207 } 208 209 // Even if the architecture is set in the target, we need to override 210 // it to match the core file which is always single arch. 211 ArchSpec arch(m_core_module_sp->GetArchitecture()); 212 if (arch.IsValid()) 213 GetTarget().SetArchitecture(arch); 214 215 SetUnixSignals(UnixSignals::Create(GetArchitecture())); 216 217 // Core files are useless without the main executable. See if we can locate 218 // the main 219 // executable using data we found in the core file notes. 220 lldb::ModuleSP exe_module_sp = GetTarget().GetExecutableModule(); 221 if (!exe_module_sp) { 222 // The first entry in the NT_FILE might be our executable 223 if (!m_nt_file_entries.empty()) { 224 ModuleSpec exe_module_spec; 225 exe_module_spec.GetArchitecture() = arch; 226 exe_module_spec.GetFileSpec().SetFile( 227 m_nt_file_entries[0].path.GetCString(), false); 228 if (exe_module_spec.GetFileSpec()) { 229 exe_module_sp = GetTarget().GetSharedModule(exe_module_spec); 230 if (exe_module_sp) 231 GetTarget().SetExecutableModule(exe_module_sp, false); 232 } 233 } 234 } 235 return error; 236 } 237 238 lldb_private::DynamicLoader *ProcessElfCore::GetDynamicLoader() { 239 if (m_dyld_ap.get() == NULL) 240 m_dyld_ap.reset(DynamicLoader::FindPlugin( 241 this, DynamicLoaderPOSIXDYLD::GetPluginNameStatic().GetCString())); 242 return m_dyld_ap.get(); 243 } 244 245 bool ProcessElfCore::UpdateThreadList(ThreadList &old_thread_list, 246 ThreadList &new_thread_list) { 247 const uint32_t num_threads = GetNumThreadContexts(); 248 if (!m_thread_data_valid) 249 return false; 250 251 for (lldb::tid_t tid = 0; tid < num_threads; ++tid) { 252 const ThreadData &td = m_thread_data[tid]; 253 lldb::ThreadSP thread_sp(new ThreadElfCore(*this, td)); 254 new_thread_list.AddThread(thread_sp); 255 } 256 return new_thread_list.GetSize(false) > 0; 257 } 258 259 void ProcessElfCore::RefreshStateAfterStop() {} 260 261 Error ProcessElfCore::DoDestroy() { return Error(); } 262 263 //------------------------------------------------------------------ 264 // Process Queries 265 //------------------------------------------------------------------ 266 267 bool ProcessElfCore::IsAlive() { return true; } 268 269 //------------------------------------------------------------------ 270 // Process Memory 271 //------------------------------------------------------------------ 272 size_t ProcessElfCore::ReadMemory(lldb::addr_t addr, void *buf, size_t size, 273 Error &error) { 274 // Don't allow the caching that lldb_private::Process::ReadMemory does 275 // since in core files we have it all cached our our core file anyway. 276 return DoReadMemory(addr, buf, size, error); 277 } 278 279 Error ProcessElfCore::GetMemoryRegionInfo(lldb::addr_t load_addr, 280 MemoryRegionInfo ®ion_info) { 281 region_info.Clear(); 282 const VMRangeToPermissions::Entry *permission_entry = 283 m_core_range_infos.FindEntryThatContainsOrFollows(load_addr); 284 if (permission_entry) { 285 if (permission_entry->Contains(load_addr)) { 286 region_info.GetRange().SetRangeBase(permission_entry->GetRangeBase()); 287 region_info.GetRange().SetRangeEnd(permission_entry->GetRangeEnd()); 288 const Flags permissions(permission_entry->data); 289 region_info.SetReadable(permissions.Test(lldb::ePermissionsReadable) 290 ? MemoryRegionInfo::eYes 291 : MemoryRegionInfo::eNo); 292 region_info.SetWritable(permissions.Test(lldb::ePermissionsWritable) 293 ? MemoryRegionInfo::eYes 294 : MemoryRegionInfo::eNo); 295 region_info.SetExecutable(permissions.Test(lldb::ePermissionsExecutable) 296 ? MemoryRegionInfo::eYes 297 : MemoryRegionInfo::eNo); 298 region_info.SetMapped(MemoryRegionInfo::eYes); 299 } else if (load_addr < permission_entry->GetRangeBase()) { 300 region_info.GetRange().SetRangeBase(load_addr); 301 region_info.GetRange().SetRangeEnd(permission_entry->GetRangeBase()); 302 region_info.SetReadable(MemoryRegionInfo::eNo); 303 region_info.SetWritable(MemoryRegionInfo::eNo); 304 region_info.SetExecutable(MemoryRegionInfo::eNo); 305 region_info.SetMapped(MemoryRegionInfo::eNo); 306 } 307 return Error(); 308 } 309 310 region_info.GetRange().SetRangeBase(load_addr); 311 region_info.GetRange().SetRangeEnd(LLDB_INVALID_ADDRESS); 312 region_info.SetReadable(MemoryRegionInfo::eNo); 313 region_info.SetWritable(MemoryRegionInfo::eNo); 314 region_info.SetExecutable(MemoryRegionInfo::eNo); 315 region_info.SetMapped(MemoryRegionInfo::eNo); 316 return Error(); 317 } 318 319 size_t ProcessElfCore::DoReadMemory(lldb::addr_t addr, void *buf, size_t size, 320 Error &error) { 321 ObjectFile *core_objfile = m_core_module_sp->GetObjectFile(); 322 323 if (core_objfile == NULL) 324 return 0; 325 326 // Get the address range 327 const VMRangeToFileOffset::Entry *address_range = 328 m_core_aranges.FindEntryThatContains(addr); 329 if (address_range == NULL || address_range->GetRangeEnd() < addr) { 330 error.SetErrorStringWithFormat("core file does not contain 0x%" PRIx64, 331 addr); 332 return 0; 333 } 334 335 // Convert the address into core file offset 336 const lldb::addr_t offset = addr - address_range->GetRangeBase(); 337 const lldb::addr_t file_start = address_range->data.GetRangeBase(); 338 const lldb::addr_t file_end = address_range->data.GetRangeEnd(); 339 size_t bytes_to_read = size; // Number of bytes to read from the core file 340 size_t bytes_copied = 0; // Number of bytes actually read from the core file 341 size_t zero_fill_size = 0; // Padding 342 lldb::addr_t bytes_left = 343 0; // Number of bytes available in the core file from the given address 344 345 // Figure out how many on-disk bytes remain in this segment 346 // starting at the given offset 347 if (file_end > file_start + offset) 348 bytes_left = file_end - (file_start + offset); 349 350 // Figure out how many bytes we need to zero-fill if we are 351 // reading more bytes than available in the on-disk segment 352 if (bytes_to_read > bytes_left) { 353 zero_fill_size = bytes_to_read - bytes_left; 354 bytes_to_read = bytes_left; 355 } 356 357 // If there is data available on the core file read it 358 if (bytes_to_read) 359 bytes_copied = 360 core_objfile->CopyData(offset + file_start, bytes_to_read, buf); 361 362 assert(zero_fill_size <= size); 363 // Pad remaining bytes 364 if (zero_fill_size) 365 memset(((char *)buf) + bytes_copied, 0, zero_fill_size); 366 367 return bytes_copied + zero_fill_size; 368 } 369 370 void ProcessElfCore::Clear() { 371 m_thread_list.Clear(); 372 m_os = llvm::Triple::UnknownOS; 373 374 SetUnixSignals(std::make_shared<UnixSignals>()); 375 } 376 377 void ProcessElfCore::Initialize() { 378 static std::once_flag g_once_flag; 379 380 std::call_once(g_once_flag, []() { 381 PluginManager::RegisterPlugin(GetPluginNameStatic(), 382 GetPluginDescriptionStatic(), CreateInstance); 383 }); 384 } 385 386 lldb::addr_t ProcessElfCore::GetImageInfoAddress() { 387 ObjectFile *obj_file = GetTarget().GetExecutableModule()->GetObjectFile(); 388 Address addr = obj_file->GetImageInfoAddress(&GetTarget()); 389 390 if (addr.IsValid()) 391 return addr.GetLoadAddress(&GetTarget()); 392 return LLDB_INVALID_ADDRESS; 393 } 394 395 /// Core files PT_NOTE segment descriptor types 396 enum { 397 NT_PRSTATUS = 1, 398 NT_FPREGSET, 399 NT_PRPSINFO, 400 NT_TASKSTRUCT, 401 NT_PLATFORM, 402 NT_AUXV, 403 NT_FILE = 0x46494c45 404 }; 405 406 namespace FREEBSD { 407 408 enum { 409 NT_PRSTATUS = 1, 410 NT_FPREGSET, 411 NT_PRPSINFO, 412 NT_THRMISC = 7, 413 NT_PROCSTAT_AUXV = 16, 414 NT_PPC_VMX = 0x100 415 }; 416 } 417 418 // Parse a FreeBSD NT_PRSTATUS note - see FreeBSD sys/procfs.h for details. 419 static void ParseFreeBSDPrStatus(ThreadData &thread_data, DataExtractor &data, 420 ArchSpec &arch) { 421 lldb::offset_t offset = 0; 422 bool lp64 = (arch.GetMachine() == llvm::Triple::aarch64 || 423 arch.GetMachine() == llvm::Triple::mips64 || 424 arch.GetMachine() == llvm::Triple::ppc64 || 425 arch.GetMachine() == llvm::Triple::x86_64); 426 int pr_version = data.GetU32(&offset); 427 428 Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS)); 429 if (log) { 430 if (pr_version > 1) 431 log->Printf("FreeBSD PRSTATUS unexpected version %d", pr_version); 432 } 433 434 // Skip padding, pr_statussz, pr_gregsetsz, pr_fpregsetsz, pr_osreldate 435 if (lp64) 436 offset += 32; 437 else 438 offset += 16; 439 440 thread_data.signo = data.GetU32(&offset); // pr_cursig 441 thread_data.tid = data.GetU32(&offset); // pr_pid 442 if (lp64) 443 offset += 4; 444 445 size_t len = data.GetByteSize() - offset; 446 thread_data.gpregset = DataExtractor(data, offset, len); 447 } 448 449 static void ParseFreeBSDThrMisc(ThreadData &thread_data, DataExtractor &data) { 450 lldb::offset_t offset = 0; 451 thread_data.name = data.GetCStr(&offset, 20); 452 } 453 454 /// Parse Thread context from PT_NOTE segment and store it in the thread list 455 /// Notes: 456 /// 1) A PT_NOTE segment is composed of one or more NOTE entries. 457 /// 2) NOTE Entry contains a standard header followed by variable size data. 458 /// (see ELFNote structure) 459 /// 3) A Thread Context in a core file usually described by 3 NOTE entries. 460 /// a) NT_PRSTATUS - Register context 461 /// b) NT_PRPSINFO - Process info(pid..) 462 /// c) NT_FPREGSET - Floating point registers 463 /// 4) The NOTE entries can be in any order 464 /// 5) If a core file contains multiple thread contexts then there is two data 465 /// forms 466 /// a) Each thread context(2 or more NOTE entries) contained in its own 467 /// segment (PT_NOTE) 468 /// b) All thread context is stored in a single segment(PT_NOTE). 469 /// This case is little tricker since while parsing we have to find where 470 /// the 471 /// new thread starts. The current implementation marks beginning of 472 /// new thread when it finds NT_PRSTATUS or NT_PRPSINFO NOTE entry. 473 /// For case (b) there may be either one NT_PRPSINFO per thread, or a single 474 /// one that applies to all threads (depending on the platform type). 475 Error ProcessElfCore::ParseThreadContextsFromNoteSegment( 476 const elf::ELFProgramHeader *segment_header, DataExtractor segment_data) { 477 assert(segment_header && segment_header->p_type == llvm::ELF::PT_NOTE); 478 479 lldb::offset_t offset = 0; 480 std::unique_ptr<ThreadData> thread_data(new ThreadData); 481 bool have_prstatus = false; 482 bool have_prpsinfo = false; 483 484 ArchSpec arch = GetArchitecture(); 485 ELFLinuxPrPsInfo prpsinfo; 486 ELFLinuxPrStatus prstatus; 487 size_t header_size; 488 size_t len; 489 Error error; 490 491 // Loop through the NOTE entires in the segment 492 while (offset < segment_header->p_filesz) { 493 ELFNote note = ELFNote(); 494 note.Parse(segment_data, &offset); 495 496 // Beginning of new thread 497 if ((note.n_type == NT_PRSTATUS && have_prstatus) || 498 (note.n_type == NT_PRPSINFO && have_prpsinfo)) { 499 assert(thread_data->gpregset.GetByteSize() > 0); 500 // Add the new thread to thread list 501 m_thread_data.push_back(*thread_data); 502 *thread_data = ThreadData(); 503 have_prstatus = false; 504 have_prpsinfo = false; 505 } 506 507 size_t note_start, note_size; 508 note_start = offset; 509 note_size = llvm::alignTo(note.n_descsz, 4); 510 511 // Store the NOTE information in the current thread 512 DataExtractor note_data(segment_data, note_start, note_size); 513 note_data.SetAddressByteSize( 514 m_core_module_sp->GetArchitecture().GetAddressByteSize()); 515 if (note.n_name == "FreeBSD") { 516 m_os = llvm::Triple::FreeBSD; 517 switch (note.n_type) { 518 case FREEBSD::NT_PRSTATUS: 519 have_prstatus = true; 520 ParseFreeBSDPrStatus(*thread_data, note_data, arch); 521 break; 522 case FREEBSD::NT_FPREGSET: 523 thread_data->fpregset = note_data; 524 break; 525 case FREEBSD::NT_PRPSINFO: 526 have_prpsinfo = true; 527 break; 528 case FREEBSD::NT_THRMISC: 529 ParseFreeBSDThrMisc(*thread_data, note_data); 530 break; 531 case FREEBSD::NT_PROCSTAT_AUXV: 532 // FIXME: FreeBSD sticks an int at the beginning of the note 533 m_auxv = DataExtractor(segment_data, note_start + 4, note_size - 4); 534 break; 535 case FREEBSD::NT_PPC_VMX: 536 thread_data->vregset = note_data; 537 break; 538 default: 539 break; 540 } 541 } else if (note.n_name == "CORE") { 542 switch (note.n_type) { 543 case NT_PRSTATUS: 544 have_prstatus = true; 545 error = prstatus.Parse(note_data, arch); 546 if (error.Fail()) 547 return error; 548 thread_data->signo = prstatus.pr_cursig; 549 thread_data->tid = prstatus.pr_pid; 550 header_size = ELFLinuxPrStatus::GetSize(arch); 551 len = note_data.GetByteSize() - header_size; 552 thread_data->gpregset = DataExtractor(note_data, header_size, len); 553 break; 554 case NT_FPREGSET: 555 thread_data->fpregset = note_data; 556 break; 557 case NT_PRPSINFO: 558 have_prpsinfo = true; 559 error = prpsinfo.Parse(note_data, arch); 560 if (error.Fail()) 561 return error; 562 thread_data->name = prpsinfo.pr_fname; 563 SetID(prpsinfo.pr_pid); 564 break; 565 case NT_AUXV: 566 m_auxv = DataExtractor(note_data); 567 break; 568 case NT_FILE: { 569 m_nt_file_entries.clear(); 570 lldb::offset_t offset = 0; 571 const uint64_t count = note_data.GetAddress(&offset); 572 note_data.GetAddress(&offset); // Skip page size 573 for (uint64_t i = 0; i < count; ++i) { 574 NT_FILE_Entry entry; 575 entry.start = note_data.GetAddress(&offset); 576 entry.end = note_data.GetAddress(&offset); 577 entry.file_ofs = note_data.GetAddress(&offset); 578 m_nt_file_entries.push_back(entry); 579 } 580 for (uint64_t i = 0; i < count; ++i) { 581 const char *path = note_data.GetCStr(&offset); 582 if (path && path[0]) 583 m_nt_file_entries[i].path.SetCString(path); 584 } 585 } break; 586 default: 587 break; 588 } 589 } 590 591 offset += note_size; 592 } 593 // Add last entry in the note section 594 if (thread_data && thread_data->gpregset.GetByteSize() > 0) { 595 m_thread_data.push_back(*thread_data); 596 } 597 598 return error; 599 } 600 601 uint32_t ProcessElfCore::GetNumThreadContexts() { 602 if (!m_thread_data_valid) 603 DoLoadCore(); 604 return m_thread_data.size(); 605 } 606 607 ArchSpec ProcessElfCore::GetArchitecture() { 608 ObjectFileELF *core_file = 609 (ObjectFileELF *)(m_core_module_sp->GetObjectFile()); 610 ArchSpec arch; 611 core_file->GetArchitecture(arch); 612 return arch; 613 } 614 615 const lldb::DataBufferSP ProcessElfCore::GetAuxvData() { 616 const uint8_t *start = m_auxv.GetDataStart(); 617 size_t len = m_auxv.GetByteSize(); 618 lldb::DataBufferSP buffer(new lldb_private::DataBufferHeap(start, len)); 619 return buffer; 620 } 621 622 bool ProcessElfCore::GetProcessInfo(ProcessInstanceInfo &info) { 623 info.Clear(); 624 info.SetProcessID(GetID()); 625 info.SetArchitecture(GetArchitecture()); 626 lldb::ModuleSP module_sp = GetTarget().GetExecutableModule(); 627 if (module_sp) { 628 const bool add_exe_file_as_first_arg = false; 629 info.SetExecutableFile(GetTarget().GetExecutableModule()->GetFileSpec(), 630 add_exe_file_as_first_arg); 631 } 632 return true; 633 } 634