MCPcopy Create free account
hub / github.com/chromium/crashpad / InitializeModules

Method InitializeModules

snapshot/linux/process_reader_linux.cc:424–562  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

422}
423
424void ProcessReaderLinux::InitializeModules() {
425 INITIALIZATION_STATE_DCHECK_VALID(initialized_);
426 initialized_modules_ = true;
427
428 AuxiliaryVector aux;
429 if (!aux.Initialize(connection_)) {
430 return;
431 }
432
433 LinuxVMAddress phdrs;
434 if (!aux.GetValue(AT_PHDR, &phdrs)) {
435 return;
436 }
437
438 ProcessMemoryRange range;
439 if (!range.Initialize(Memory(), is_64_bit_)) {
440 return;
441 }
442
443 // The strategy used for identifying loaded modules depends on ELF files
444 // conventionally loading their header and program headers into memory.
445 // Locating the correct module could fail if the headers aren't mapped, are
446 // mapped at an unexpected location, or if there are other mappings
447 // constructed to look like the ELF module being searched for.
448 const MemoryMap::Mapping* exe_mapping = nullptr;
449 std::unique_ptr<ElfImageReader> exe_reader;
450 {
451 const MemoryMap::Mapping* phdr_mapping = memory_map_.FindMapping(phdrs);
452 if (!phdr_mapping) {
453 return;
454 }
455
456 auto possible_mappings =
457 memory_map_.FindFilePossibleMmapStarts(*phdr_mapping);
458 const MemoryMap::Mapping* mapping = nullptr;
459 while ((mapping = possible_mappings->Next())) {
460 auto parsed_exe = std::make_unique<ElfImageReader>();
461 if (parsed_exe->Initialize(
462 range,
463 mapping->range.Base(),
464 /* verbose= */ possible_mappings->Count() == 0) &&
465 parsed_exe->GetProgramHeaderTableAddress() == phdrs) {
466 exe_mapping = mapping;
467 exe_reader = std::move(parsed_exe);
468 break;
469 }
470 }
471 if (!exe_mapping) {
472 LOG(ERROR) << "no exe mappings 0x" << std::hex
473 << phdr_mapping->range.Base();
474 return;
475 }
476 }
477
478 LinuxVMAddress debug_address;
479 if (!exe_reader->GetDebugAddress(&debug_address)) {
480 return;
481 }

Callers

nothing calls this directly

Calls 15

FindMappingMethod · 0.80
GetDebugAddressMethod · 0.80
ReverseIteratorFromMethod · 0.80
SoNameMethod · 0.80
InitializeMethod · 0.45
GetValueMethod · 0.45
NextMethod · 0.45
BaseMethod · 0.45
CountMethod · 0.45

Tested by

no test coverage detected