Lines Matching +full:memory +full:- +full:region
1 //===-- MinidumpParser.cpp ------------------------------------------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
32 llvm::MemoryBufferRef(toStringRef(data_sp->GetData()), "minidump")); in Create()
44 return llvm::ArrayRef<uint8_t>(m_data_sp->GetBytes(), in GetData()
45 m_data_sp->GetByteSize()); in GetData()
49 return m_file->getRawStream(stream_type).value_or(llvm::ArrayRef<uint8_t>()); in GetStream()
54 GetData().slice(module->CvRecord.RVA, module->CvRecord.DataSize); in GetModuleUUID()
71 if (pdb70_uuid->Age != 0) in GetModuleUUID()
73 return UUID(&pdb70_uuid->Uuid, in GetModuleUUID()
74 sizeof(pdb70_uuid->Uuid)); in GetModuleUUID()
107 // On Windows, a 32-bit process can run on a 64-bit machine under WOW64. If in GetThreadContextWow64()
108 // the minidump was captured with a 64-bit debugger, then the CONTEXT we just in GetThreadContextWow64()
109 // grabbed from the mini_dump_thread is the one for the 64-bit "native" in GetThreadContextWow64()
110 // process rather than the 32-bit "guest" process we care about. In this in GetThreadContextWow64()
111 // case, we can get the 32-bit CONTEXT from the TEB (Thread Environment in GetThreadContextWow64()
112 // Block) of the 64-bit process. in GetThreadContextWow64()
122 // Slot 1 of the thread-local storage in the 64-bit TEB points to a structure in GetThreadContextWow64()
123 // that includes the 32-bit CONTEXT (after a ULONG). See: in GetThreadContextWow64()
124 // https://msdn.microsoft.com/en-us/library/ms681670.aspx in GetThreadContextWow64()
126 GetMemory(wow64teb->tls_slots[1] + 4, sizeof(MinidumpContext_x86_32)); in GetThreadContextWow64()
132 // need it in the future, the 32-bit TEB is located according to the address in GetThreadContextWow64()
133 // stored in the first slot of the 64-bit TEB (wow64teb.Reserved1[0]). in GetThreadContextWow64()
141 llvm::Expected<const SystemInfo &> system_info = m_file->getSystemInfo(); in GetArchitecture()
155 switch (system_info->ProcessorArch) { in GetArchitecture()
175 switch (system_info->PlatformId) { in GetArchitecture()
200 auto ExpectedCSD = m_file->getString(system_info->CSDVersionRVA); in GetArchitecture()
205 if (ExpectedCSD->find("Linux") != std::string::npos) in GetArchitecture()
236 return misc_info->GetPid(); in GetPid()
241 return proc_status->GetPid(); in GetPid()
267 [®ions, &log](llvm::Expected<MemoryRegionInfo> region) -> bool { in CreateRegionsCacheFromLinuxMaps() argument
268 if (region) in CreateRegionsCacheFromLinuxMaps()
269 regions.push_back(*region); in CreateRegionsCacheFromLinuxMaps()
271 LLDB_LOG_ERROR(log, region.takeError(), in CreateRegionsCacheFromLinuxMaps()
272 "Reading memory region from minidump failed: {0}"); in CreateRegionsCacheFromLinuxMaps()
278 /// Check for the memory regions starting at \a load_addr for a contiguous
282 /// /proc/<pid>/maps text for a process that details the memory map of the
283 /// process that the minidump is describing. This checks the sorted memory
287 /// 00400000-00401000 r--p 00000000 fd:01 2838574 /tmp/a.out
288 /// 00401000-00402000 r-xp 00001000 fd:01 2838574 /tmp/a.out
289 /// 00402000-00403000 r--p 00002000 fd:01 2838574 /tmp/a.out
290 /// 00403000-00404000 r--p 00002000 fd:01 2838574 /tmp/a.out
291 /// 00404000-00405000 rw-p 00003000 fd:01 2838574 /tmp/a.out
295 /// is passed in as the path since it has a consecutive memory region for
297 /// differentiate if a file has been memory mapped into a process for reading
300 /// is the real executable that is loaded into memory for execution. For memory
301 /// mapped files they will typically show up and r--p permissions and a range
304 /// 00800000-00805000 r--p 00000000 fd:01 2838574 /tmp/a.out
305 /// 00805000-00806000 r-xp 00001000 fd:01 1234567 /usr/lib/libc.so
311 /// The path to the module to check for in the memory regions. Only sequential
312 /// memory regions whose paths match this path will be considered when looking
316 /// A sorted list of memory regions obtained from a call to
323 /// True if a contiguous region of memory belonging to the module with a
334 MemoryRegionInfo region = MinidumpParser::GetMemoryRegionInfo(regions, addr); in CheckForLinuxExecutable() local
335 while (region.GetName() == path) { in CheckForLinuxExecutable()
336 if (region.GetExecutable() == MemoryRegionInfo::eYes) in CheckForLinuxExecutable()
338 addr += region.GetRange().GetByteSize(); in CheckForLinuxExecutable()
339 region = MinidumpParser::GetMemoryRegionInfo(regions, addr); in CheckForLinuxExecutable()
353 // Create memory regions from the linux maps only. We do this to avoid issues in GetFilteredModuleList()
355 // library into memory to access its data in the object file, we can get a in GetFilteredModuleList()
357 // memory region that is read + execute and one that is read only. in GetFilteredModuleList()
362 // map module_name -> filtered_modules index in GetFilteredModuleList()
369 auto ExpectedName = m_file->getString(module.ModuleNameRVA); in GetFilteredModuleList()
394 // order to read bytes from the executable file. A memory region mapping in GetFilteredModuleList()
396 // only one will have a consecutive region that is executable in the in GetFilteredModuleList()
397 // memory regions. in GetFilteredModuleList()
398 auto dup_module = filtered_modules[iter->second]; in GetFilteredModuleList()
403 CheckForLinuxExecutable(name, linux_regions, dup_module->BaseOfImage); in GetFilteredModuleList()
407 filtered_modules[iter->second] = &module; in GetFilteredModuleList()
413 if (module.BaseOfImage < dup_module->BaseOfImage) in GetFilteredModuleList()
414 filtered_modules[iter->second] = &module; in GetFilteredModuleList()
438 "Failed to read memory list: {0}"); in FindMemoryRange()
441 const LocationDescriptor &loc_desc = memory_desc.Memory; in FindMemoryRange()
452 "Failed to get memory slice: {0}"); in FindMemoryRange()
460 // Some Minidumps have a Memory64ListStream that captures all the heap memory in FindMemoryRange()
461 // (full-memory Minidumps). We can't exactly use the same loop as above, in FindMemoryRange()
494 // I don't have a sense of how frequently this is called or how many memory in GetMemory()
506 const size_t offset = addr - range->start; in GetMemory()
508 if (addr < range->start || offset >= range->range_ref.size()) in GetMemory()
511 const size_t overlap = std::min(size, range->range_ref.size() - offset); in GetMemory()
512 return range->range_ref.slice(offset, overlap); in GetMemory()
522 "Failed to read memory info list: {0}"); in CreateRegionsCacheFromMemoryInfoList()
528 MemoryRegionInfo region; in CreateRegionsCacheFromMemoryInfoList() local
529 region.GetRange().SetRangeBase(entry.BaseAddress); in CreateRegionsCacheFromMemoryInfoList()
530 region.GetRange().SetByteSize(entry.RegionSize); in CreateRegionsCacheFromMemoryInfoList()
533 region.SetReadable(bool(prot & MemoryProtection::NoAccess) ? no : yes); in CreateRegionsCacheFromMemoryInfoList()
534 region.SetWritable( in CreateRegionsCacheFromMemoryInfoList()
540 region.SetExecutable( in CreateRegionsCacheFromMemoryInfoList()
546 region.SetMapped(entry.State != MemoryState::Free ? yes : no); in CreateRegionsCacheFromMemoryInfoList()
547 regions.push_back(region); in CreateRegionsCacheFromMemoryInfoList()
559 "Failed to read memory list: {0}"); in CreateRegionsCacheFromMemoryList()
562 regions.reserve(ExpectedMemory->size()); in CreateRegionsCacheFromMemoryList()
564 if (memory_desc.Memory.DataSize == 0) in CreateRegionsCacheFromMemoryList()
566 MemoryRegionInfo region; in CreateRegionsCacheFromMemoryList() local
567 region.GetRange().SetRangeBase(memory_desc.StartOfMemoryRange); in CreateRegionsCacheFromMemoryList()
568 region.GetRange().SetByteSize(memory_desc.Memory.DataSize); in CreateRegionsCacheFromMemoryList()
569 region.SetReadable(MemoryRegionInfo::eYes); in CreateRegionsCacheFromMemoryList()
570 region.SetMapped(MemoryRegionInfo::eYes); in CreateRegionsCacheFromMemoryList()
571 regions.push_back(region); in CreateRegionsCacheFromMemoryList()
596 MemoryRegionInfo region; in CreateRegionsCacheFromMemory64List() local
597 region.GetRange().SetRangeBase(memory_desc.start_of_memory_range); in CreateRegionsCacheFromMemory64List()
598 region.GetRange().SetByteSize(memory_desc.data_size); in CreateRegionsCacheFromMemory64List()
599 region.SetReadable(MemoryRegionInfo::eYes); in CreateRegionsCacheFromMemory64List()
600 region.SetMapped(MemoryRegionInfo::eYes); in CreateRegionsCacheFromMemory64List()
601 regions.push_back(region); in CreateRegionsCacheFromMemory64List()
608 // We create the region cache using the best source. We start with in BuildMemoryRegions()
612 // Memory64List to just get a list of the memory that is mapped in this in BuildMemoryRegions()
689 MemoryRegionInfo region; in GetMemoryRegionInfo() local
692 std::prev(pos)->GetRange().Contains(load_addr)) { in GetMemoryRegionInfo()
697 region.GetRange().SetRangeBase(0); in GetMemoryRegionInfo()
699 region.GetRange().SetRangeBase(std::prev(pos)->GetRange().GetRangeEnd()); in GetMemoryRegionInfo()
702 region.GetRange().SetRangeEnd(UINT64_MAX); in GetMemoryRegionInfo()
704 region.GetRange().SetRangeEnd(pos->GetRange().GetRangeBase()); in GetMemoryRegionInfo()
706 region.SetReadable(MemoryRegionInfo::eNo); in GetMemoryRegionInfo()
707 region.SetWritable(MemoryRegionInfo::eNo); in GetMemoryRegionInfo()
708 region.SetExecutable(MemoryRegionInfo::eNo); in GetMemoryRegionInfo()
709 region.SetMapped(MemoryRegionInfo::eNo); in GetMemoryRegionInfo()
710 return region; in GetMemoryRegionInfo()