LLDB mainline
MinidumpParser.cpp
Go to the documentation of this file.
1//===-- MinidumpParser.cpp ------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include "MinidumpParser.h"
10#include "NtStructures.h"
12
16#include "lldb/Utility/Log.h"
17
18// C includes
19// C++ includes
20#include <algorithm>
21#include <map>
22#include <optional>
23#include <vector>
24#include <utility>
25
26using namespace lldb_private;
27using namespace minidump;
28
29llvm::Expected<MinidumpParser>
31 auto ExpectedFile = llvm::object::MinidumpFile::create(
32 llvm::MemoryBufferRef(toStringRef(data_sp->GetData()), "minidump"));
33 if (!ExpectedFile)
34 return ExpectedFile.takeError();
35
36 return MinidumpParser(data_sp, std::move(*ExpectedFile));
37}
38
40 std::unique_ptr<llvm::object::MinidumpFile> file)
41 : m_data_sp(std::move(data_sp)), m_file(std::move(file)) {}
42
43llvm::ArrayRef<uint8_t> MinidumpParser::GetData() {
44 return llvm::ArrayRef<uint8_t>(m_data_sp->GetBytes(),
45 m_data_sp->GetByteSize());
46}
47
48llvm::ArrayRef<uint8_t> MinidumpParser::GetStream(StreamType stream_type) {
49 return m_file->getRawStream(stream_type).value_or(llvm::ArrayRef<uint8_t>());
50}
51
52UUID MinidumpParser::GetModuleUUID(const minidump::Module *module) {
53 auto cv_record =
54 GetData().slice(module->CvRecord.RVA, module->CvRecord.DataSize);
55
56 // Read the CV record signature
57 const llvm::support::ulittle32_t *signature = nullptr;
58 Status error = consumeObject(cv_record, signature);
59 if (error.Fail())
60 return UUID();
61
62 const CvSignature cv_signature =
63 static_cast<CvSignature>(static_cast<uint32_t>(*signature));
64
65 if (cv_signature == CvSignature::Pdb70) {
66 const UUID::CvRecordPdb70 *pdb70_uuid = nullptr;
67 Status error = consumeObject(cv_record, pdb70_uuid);
68 if (error.Fail())
69 return UUID();
70 if (GetArchitecture().GetTriple().isOSBinFormatELF()) {
71 if (pdb70_uuid->Age != 0)
72 return UUID(pdb70_uuid, sizeof(*pdb70_uuid));
73 return UUID(&pdb70_uuid->Uuid,
74 sizeof(pdb70_uuid->Uuid));
75 }
76 return UUID(*pdb70_uuid);
77 } else if (cv_signature == CvSignature::ElfBuildId)
78 return UUID(cv_record);
79
80 return UUID();
81}
82
83llvm::ArrayRef<minidump::Thread> MinidumpParser::GetThreads() {
84 auto ExpectedThreads = GetMinidumpFile().getThreadList();
85 if (ExpectedThreads)
86 return *ExpectedThreads;
87
88 LLDB_LOG_ERROR(GetLog(LLDBLog::Thread), ExpectedThreads.takeError(),
89 "Failed to read thread list: {0}");
90 return {};
91}
92
93llvm::ArrayRef<uint8_t>
94MinidumpParser::GetThreadContext(const LocationDescriptor &location) {
95 if (location.RVA + location.DataSize > GetData().size())
96 return {};
97 return GetData().slice(location.RVA, location.DataSize);
98}
99
100llvm::ArrayRef<uint8_t>
101MinidumpParser::GetThreadContext(const minidump::Thread &td) {
102 return GetThreadContext(td.Context);
103}
104
105llvm::ArrayRef<uint8_t>
106MinidumpParser::GetThreadContextWow64(const minidump::Thread &td) {
107 // On Windows, a 32-bit process can run on a 64-bit machine under WOW64. If
108 // the minidump was captured with a 64-bit debugger, then the CONTEXT we just
109 // grabbed from the mini_dump_thread is the one for the 64-bit "native"
110 // process rather than the 32-bit "guest" process we care about. In this
111 // case, we can get the 32-bit CONTEXT from the TEB (Thread Environment
112 // Block) of the 64-bit process.
113 auto teb_mem = GetMemory(td.EnvironmentBlock, sizeof(TEB64));
114 if (teb_mem.empty())
115 return {};
116
117 const TEB64 *wow64teb;
118 Status error = consumeObject(teb_mem, wow64teb);
119 if (error.Fail())
120 return {};
121
122 // Slot 1 of the thread-local storage in the 64-bit TEB points to a structure
123 // that includes the 32-bit CONTEXT (after a ULONG). See:
124 // https://msdn.microsoft.com/en-us/library/ms681670.aspx
125 auto context =
126 GetMemory(wow64teb->tls_slots[1] + 4, sizeof(MinidumpContext_x86_32));
127 if (context.size() < sizeof(MinidumpContext_x86_32))
128 return {};
129
130 return context;
131 // NOTE: We don't currently use the TEB for anything else. If we
132 // need it in the future, the 32-bit TEB is located according to the address
133 // stored in the first slot of the 64-bit TEB (wow64teb.Reserved1[0]).
134}
135
137 if (m_arch.IsValid())
138 return m_arch;
139
140 // Set the architecture in m_arch
141 llvm::Expected<const SystemInfo &> system_info = m_file->getSystemInfo();
142
143 if (!system_info) {
144 LLDB_LOG_ERROR(GetLog(LLDBLog::Process), system_info.takeError(),
145 "Failed to read SystemInfo stream: {0}");
146 return m_arch;
147 }
148
149 // TODO what to do about big endiand flavors of arm ?
150 // TODO set the arm subarch stuff if the minidump has info about it
151
152 llvm::Triple triple;
153 triple.setVendor(llvm::Triple::VendorType::UnknownVendor);
154
155 switch (system_info->ProcessorArch) {
156 case ProcessorArchitecture::X86:
157 triple.setArch(llvm::Triple::ArchType::x86);
158 break;
159 case ProcessorArchitecture::AMD64:
160 triple.setArch(llvm::Triple::ArchType::x86_64);
161 break;
162 case ProcessorArchitecture::ARM:
163 triple.setArch(llvm::Triple::ArchType::arm);
164 break;
165 case ProcessorArchitecture::ARM64:
166 case ProcessorArchitecture::BP_ARM64:
167 triple.setArch(llvm::Triple::ArchType::aarch64);
168 break;
169 default:
170 triple.setArch(llvm::Triple::ArchType::UnknownArch);
171 break;
172 }
173
174 // TODO add all of the OSes that Minidump/breakpad distinguishes?
175 switch (system_info->PlatformId) {
176 case OSPlatform::Win32S:
177 case OSPlatform::Win32Windows:
178 case OSPlatform::Win32NT:
179 case OSPlatform::Win32CE:
180 triple.setOS(llvm::Triple::OSType::Win32);
181 triple.setVendor(llvm::Triple::VendorType::PC);
182 break;
183 case OSPlatform::Linux:
184 triple.setOS(llvm::Triple::OSType::Linux);
185 break;
186 case OSPlatform::MacOSX:
187 triple.setOS(llvm::Triple::OSType::MacOSX);
188 triple.setVendor(llvm::Triple::Apple);
189 break;
190 case OSPlatform::IOS:
191 triple.setOS(llvm::Triple::OSType::IOS);
192 triple.setVendor(llvm::Triple::Apple);
193 break;
194 case OSPlatform::Android:
195 triple.setOS(llvm::Triple::OSType::Linux);
196 triple.setEnvironment(llvm::Triple::EnvironmentType::Android);
197 break;
198 default: {
199 triple.setOS(llvm::Triple::OSType::UnknownOS);
200 auto ExpectedCSD = m_file->getString(system_info->CSDVersionRVA);
201 if (!ExpectedCSD) {
202 LLDB_LOG_ERROR(GetLog(LLDBLog::Process), ExpectedCSD.takeError(),
203 "Failed to CSD Version string: {0}");
204 } else {
205 if (ExpectedCSD->find("Linux") != std::string::npos)
206 triple.setOS(llvm::Triple::OSType::Linux);
207 }
208 break;
209 }
210 }
211 m_arch.SetTriple(triple);
212 return m_arch;
213}
214
216 llvm::ArrayRef<uint8_t> data = GetStream(StreamType::MiscInfo);
217
218 if (data.size() == 0)
219 return nullptr;
220
221 return MinidumpMiscInfo::Parse(data);
222}
223
224std::optional<LinuxProcStatus> MinidumpParser::GetLinuxProcStatus() {
225 llvm::ArrayRef<uint8_t> data = GetStream(StreamType::LinuxProcStatus);
226
227 if (data.size() == 0)
228 return std::nullopt;
229
230 return LinuxProcStatus::Parse(data);
231}
232
233std::optional<lldb::pid_t> MinidumpParser::GetPid() {
234 const MinidumpMiscInfo *misc_info = GetMiscInfo();
235 if (misc_info != nullptr) {
236 return misc_info->GetPid();
237 }
238
239 std::optional<LinuxProcStatus> proc_status = GetLinuxProcStatus();
240 if (proc_status) {
241 return proc_status->GetPid();
242 }
243
244 return std::nullopt;
245}
246
247llvm::ArrayRef<minidump::Module> MinidumpParser::GetModuleList() {
248 auto ExpectedModules = GetMinidumpFile().getModuleList();
249 if (ExpectedModules)
250 return *ExpectedModules;
251
252 LLDB_LOG_ERROR(GetLog(LLDBLog::Modules), ExpectedModules.takeError(),
253 "Failed to read module list: {0}");
254 return {};
255}
256
257static bool
259 std::vector<MemoryRegionInfo> &regions) {
260 auto data = parser.GetStream(StreamType::LinuxMaps);
261 if (data.empty())
262 return false;
263
266 llvm::toStringRef(data),
267 [&regions, &log](llvm::Expected<MemoryRegionInfo> region) -> bool {
268 if (region)
269 regions.push_back(*region);
270 else
271 LLDB_LOG_ERROR(log, region.takeError(),
272 "Reading memory region from minidump failed: {0}");
273 return true;
274 });
275 return !regions.empty();
276}
277
278/// Check for the memory regions starting at \a load_addr for a contiguous
279/// section that has execute permissions that matches the module path.
280///
281/// When we load a breakpad generated minidump file, we might have the
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
284/// regions for a section that has execute permissions. A sample maps files
285/// might look like:
286///
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
292/// ...
293///
294/// This function should return true when given 0x00400000 and "/tmp/a.out"
295/// is passed in as the path since it has a consecutive memory region for
296/// "/tmp/a.out" that has execute permissions at 0x00401000. This will help us
297/// differentiate if a file has been memory mapped into a process for reading
298/// and breakpad ends up saving a minidump file that has two module entries for
299/// a given file: one that is read only for the entire file, and then one that
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
302/// matcning the entire range of the file on disk:
303///
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
306///
307/// This function should return false when asked about 0x00800000 with
308/// "/tmp/a.out" as the path.
309///
310/// \param[in] path
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
313/// for execute permissions.
314///
315/// \param[in] regions
316/// A sorted list of memory regions obtained from a call to
317/// CreateRegionsCacheFromLinuxMaps.
318///
319/// \param[in] base_of_image
320/// The load address of this module from BaseOfImage in the modules list.
321///
322/// \return
323/// True if a contiguous region of memory belonging to the module with a
324/// matching path exists that has executable permissions. Returns false if
325/// \a regions is empty or if there are no regions with execute permissions
326/// that match \a path.
327
329 const MemoryRegionInfos &regions,
330 lldb::addr_t base_of_image) {
331 if (regions.empty())
332 return false;
333 lldb::addr_t addr = base_of_image;
335 while (region.GetName() == path) {
337 return true;
338 addr += region.GetRange().GetByteSize();
339 region = MinidumpParser::GetMemoryRegionInfo(regions, addr);
340 }
341 return false;
342}
343
344std::vector<const minidump::Module *> MinidumpParser::GetFilteredModuleList() {
346 auto ExpectedModules = GetMinidumpFile().getModuleList();
347 if (!ExpectedModules) {
348 LLDB_LOG_ERROR(log, ExpectedModules.takeError(),
349 "Failed to read module list: {0}");
350 return {};
351 }
352
353 // Create memory regions from the linux maps only. We do this to avoid issues
354 // with breakpad generated minidumps where if someone has mmap'ed a shared
355 // library into memory to access its data in the object file, we can get a
356 // minidump with two mappings for a binary: one whose base image points to a
357 // memory region that is read + execute and one that is read only.
358 MemoryRegionInfos linux_regions;
359 if (CreateRegionsCacheFromLinuxMaps(*this, linux_regions))
360 llvm::sort(linux_regions);
361
362 // map module_name -> filtered_modules index
363 typedef llvm::StringMap<size_t> MapType;
364 MapType module_name_to_filtered_index;
365
366 std::vector<const minidump::Module *> filtered_modules;
367
368 for (const auto &module : *ExpectedModules) {
369 auto ExpectedName = m_file->getString(module.ModuleNameRVA);
370 if (!ExpectedName) {
371 LLDB_LOG_ERROR(log, ExpectedName.takeError(),
372 "Failed to get module name: {0}");
373 continue;
374 }
375
376 MapType::iterator iter;
377 bool inserted;
378 // See if we have inserted this module aready into filtered_modules. If we
379 // haven't insert an entry into module_name_to_filtered_index with the
380 // index where we will insert it if it isn't in the vector already.
381 std::tie(iter, inserted) = module_name_to_filtered_index.try_emplace(
382 *ExpectedName, filtered_modules.size());
383
384 if (inserted) {
385 // This module has not been seen yet, insert it into filtered_modules at
386 // the index that was inserted into module_name_to_filtered_index using
387 // "filtered_modules.size()" above.
388 filtered_modules.push_back(&module);
389 } else {
390 // We have a duplicate module entry. Check the linux regions to see if
391 // either module is not really a mapped executable. If one but not the
392 // other is a real mapped executable, prefer the executable one. This
393 // can happen when a process mmap's in the file for an executable in
394 // order to read bytes from the executable file. A memory region mapping
395 // will exist for the mmap'ed version and for the loaded executable, but
396 // only one will have a consecutive region that is executable in the
397 // memory regions.
398 auto dup_module = filtered_modules[iter->second];
399 ConstString name(*ExpectedName);
400 bool is_executable =
401 CheckForLinuxExecutable(name, linux_regions, module.BaseOfImage);
402 bool dup_is_executable =
403 CheckForLinuxExecutable(name, linux_regions, dup_module->BaseOfImage);
404
405 if (is_executable != dup_is_executable) {
406 if (is_executable)
407 filtered_modules[iter->second] = &module;
408 continue;
409 }
410 // This module has been seen. Modules are sometimes mentioned multiple
411 // times when they are mapped discontiguously, so find the module with
412 // the lowest "base_of_image" and use that as the filtered module.
413 if (module.BaseOfImage < dup_module->BaseOfImage)
414 filtered_modules[iter->second] = &module;
415 }
416 }
417 return filtered_modules;
418}
419
420const minidump::ExceptionStream *MinidumpParser::GetExceptionStream() {
421 auto ExpectedStream = GetMinidumpFile().getExceptionStream();
422 if (ExpectedStream)
423 return &*ExpectedStream;
424
425 LLDB_LOG_ERROR(GetLog(LLDBLog::Process), ExpectedStream.takeError(),
426 "Failed to read minidump exception stream: {0}");
427 return nullptr;
428}
429
430std::optional<minidump::Range>
433
434 auto ExpectedMemory = GetMinidumpFile().getMemoryList();
435 if (!ExpectedMemory) {
436 LLDB_LOG_ERROR(log, ExpectedMemory.takeError(),
437 "Failed to read memory list: {0}");
438 } else {
439 for (const auto &memory_desc : *ExpectedMemory) {
440 const LocationDescriptor &loc_desc = memory_desc.Memory;
441 const lldb::addr_t range_start = memory_desc.StartOfMemoryRange;
442 const size_t range_size = loc_desc.DataSize;
443
444 if (loc_desc.RVA + loc_desc.DataSize > GetData().size())
445 return std::nullopt;
446
447 if (range_start <= addr && addr < range_start + range_size) {
448 auto ExpectedSlice = GetMinidumpFile().getRawData(loc_desc);
449 if (!ExpectedSlice) {
450 LLDB_LOG_ERROR(log, ExpectedSlice.takeError(),
451 "Failed to get memory slice: {0}");
452 return std::nullopt;
453 }
454 return minidump::Range(range_start, *ExpectedSlice);
455 }
456 }
457 }
458
459 if (!GetStream(StreamType::Memory64List).empty()) {
460 llvm::Error err = llvm::Error::success();
461 for (const auto &memory_desc : GetMinidumpFile().getMemory64List(err)) {
462 if (memory_desc.first.StartOfMemoryRange <= addr
463 && addr < memory_desc.first.StartOfMemoryRange + memory_desc.first.DataSize) {
464 return minidump::Range(memory_desc.first.StartOfMemoryRange, memory_desc.second);
465 }
466 }
467
468 if (err)
469 LLDB_LOG_ERROR(log, std::move(err), "Failed to read memory64 list: {0}");
470 }
471
472 return std::nullopt;
473}
474
475llvm::ArrayRef<uint8_t> MinidumpParser::GetMemory(lldb::addr_t addr,
476 size_t size) {
477 // I don't have a sense of how frequently this is called or how many memory
478 // ranges a Minidump typically has, so I'm not sure if searching for the
479 // appropriate range linearly each time is stupid. Perhaps we should build
480 // an index for faster lookups.
481 std::optional<minidump::Range> range = FindMemoryRange(addr);
482 if (!range)
483 return {};
484
485 // There's at least some overlap between the beginning of the desired range
486 // (addr) and the current range. Figure out where the overlap begins and how
487 // much overlap there is.
488
489 const size_t offset = addr - range->start;
490
491 if (addr < range->start || offset >= range->range_ref.size())
492 return {};
493
494 const size_t overlap = std::min(size, range->range_ref.size() - offset);
495 return range->range_ref.slice(offset, overlap);
496}
497
498llvm::iterator_range<FallibleMemory64Iterator> MinidumpParser::GetMemory64Iterator(llvm::Error &err) {
499 llvm::ErrorAsOutParameter ErrAsOutParam(&err);
500 return m_file->getMemory64List(err);
501}
502
503static bool
505 std::vector<MemoryRegionInfo> &regions) {
507 auto ExpectedInfo = parser.GetMinidumpFile().getMemoryInfoList();
508 if (!ExpectedInfo) {
509 LLDB_LOG_ERROR(log, ExpectedInfo.takeError(),
510 "Failed to read memory info list: {0}");
511 return false;
512 }
513 constexpr auto yes = MemoryRegionInfo::eYes;
514 constexpr auto no = MemoryRegionInfo::eNo;
515 for (const MemoryInfo &entry : *ExpectedInfo) {
516 MemoryRegionInfo region;
517 region.GetRange().SetRangeBase(entry.BaseAddress);
518 region.GetRange().SetByteSize(entry.RegionSize);
519
520 MemoryProtection prot = entry.Protect;
521 region.SetReadable(bool(prot & MemoryProtection::NoAccess) ? no : yes);
522 region.SetWritable(
523 bool(prot & (MemoryProtection::ReadWrite | MemoryProtection::WriteCopy |
524 MemoryProtection::ExecuteReadWrite |
525 MemoryProtection::ExeciteWriteCopy))
526 ? yes
527 : no);
528 region.SetExecutable(
529 bool(prot & (MemoryProtection::Execute | MemoryProtection::ExecuteRead |
530 MemoryProtection::ExecuteReadWrite |
531 MemoryProtection::ExeciteWriteCopy))
532 ? yes
533 : no);
534 region.SetMapped(entry.State != MemoryState::Free ? yes : no);
535 regions.push_back(region);
536 }
537 return !regions.empty();
538}
539
540static bool
542 std::vector<MemoryRegionInfo> &regions) {
544 // Cache the expected memory32 into an optional
545 // because it is possible to just have a memory64 list
546 auto ExpectedMemory = parser.GetMinidumpFile().getMemoryList();
547 if (!ExpectedMemory) {
548 LLDB_LOG_ERROR(log, ExpectedMemory.takeError(),
549 "Failed to read memory list: {0}");
550 } else {
551 for (const MemoryDescriptor &memory_desc : *ExpectedMemory) {
552 if (memory_desc.Memory.DataSize == 0)
553 continue;
554 MemoryRegionInfo region;
555 region.GetRange().SetRangeBase(memory_desc.StartOfMemoryRange);
556 region.GetRange().SetByteSize(memory_desc.Memory.DataSize);
559 regions.push_back(region);
560 }
561 }
562
563 if (!parser.GetStream(StreamType::Memory64List).empty()) {
564 llvm::Error err = llvm::Error::success();
565 for (const auto &memory_desc : parser.GetMemory64Iterator(err)) {
566 if (memory_desc.first.DataSize == 0)
567 continue;
568 MemoryRegionInfo region;
569 region.GetRange().SetRangeBase(memory_desc.first.StartOfMemoryRange);
570 region.GetRange().SetByteSize(memory_desc.first.DataSize);
573 regions.push_back(region);
574 }
575
576 if (err) {
577 LLDB_LOG_ERROR(log, std::move(err), "Failed to read memory64 list: {0}");
578 return false;
579 }
580 }
581
582 regions.shrink_to_fit();
583 return !regions.empty();
584}
585
586std::pair<MemoryRegionInfos, bool> MinidumpParser::BuildMemoryRegions() {
587 // We create the region cache using the best source. We start with
588 // the linux maps since they are the most complete and have names for the
589 // regions. Next we try the MemoryInfoList since it has
590 // read/write/execute/map data, and then fall back to the MemoryList and
591 // Memory64List to just get a list of the memory that is mapped in this
592 // core file
593 MemoryRegionInfos result;
594 const auto &return_sorted = [&](bool is_complete) {
595 llvm::sort(result);
596 return std::make_pair(std::move(result), is_complete);
597 };
598 if (CreateRegionsCacheFromLinuxMaps(*this, result))
599 return return_sorted(true);
600 if (CreateRegionsCacheFromMemoryInfoList(*this, result))
601 return return_sorted(true);
603 return return_sorted(false);
604}
605
606#define ENUM_TO_CSTR(ST) \
607 case StreamType::ST: \
608 return #ST
609
610llvm::StringRef
612 switch (stream_type) {
613 ENUM_TO_CSTR(Unused);
616 ENUM_TO_CSTR(MemoryList);
618 ENUM_TO_CSTR(SystemInfo);
619 ENUM_TO_CSTR(ThreadExList);
620 ENUM_TO_CSTR(Memory64List);
621 ENUM_TO_CSTR(CommentA);
622 ENUM_TO_CSTR(CommentW);
623 ENUM_TO_CSTR(HandleData);
624 ENUM_TO_CSTR(FunctionTable);
625 ENUM_TO_CSTR(UnloadedModuleList);
626 ENUM_TO_CSTR(MiscInfo);
627 ENUM_TO_CSTR(MemoryInfoList);
628 ENUM_TO_CSTR(ThreadInfoList);
629 ENUM_TO_CSTR(HandleOperationList);
630 ENUM_TO_CSTR(Token);
631 ENUM_TO_CSTR(JavascriptData);
632 ENUM_TO_CSTR(SystemMemoryInfo);
633 ENUM_TO_CSTR(ProcessVMCounters);
634 ENUM_TO_CSTR(LastReserved);
635 ENUM_TO_CSTR(BreakpadInfo);
636 ENUM_TO_CSTR(AssertionInfo);
637 ENUM_TO_CSTR(LinuxCPUInfo);
639 ENUM_TO_CSTR(LinuxLSBRelease);
640 ENUM_TO_CSTR(LinuxCMDLine);
641 ENUM_TO_CSTR(LinuxEnviron);
642 ENUM_TO_CSTR(LinuxAuxv);
643 ENUM_TO_CSTR(LinuxMaps);
644 ENUM_TO_CSTR(LinuxDSODebug);
645 ENUM_TO_CSTR(LinuxProcStat);
646 ENUM_TO_CSTR(LinuxProcUptime);
647 ENUM_TO_CSTR(LinuxProcFD);
648 ENUM_TO_CSTR(FacebookAppCustomData);
649 ENUM_TO_CSTR(FacebookBuildID);
650 ENUM_TO_CSTR(FacebookAppVersionName);
651 ENUM_TO_CSTR(FacebookJavaStack);
652 ENUM_TO_CSTR(FacebookDalvikInfo);
653 ENUM_TO_CSTR(FacebookUnwindSymbols);
654 ENUM_TO_CSTR(FacebookDumpErrorLog);
655 ENUM_TO_CSTR(FacebookAppStateLog);
656 ENUM_TO_CSTR(FacebookAbortReason);
657 ENUM_TO_CSTR(FacebookThreadName);
658 ENUM_TO_CSTR(FacebookLogcat);
659 }
660 return "unknown stream type";
661}
662
665 lldb::addr_t load_addr) {
666 MemoryRegionInfo region;
667 auto pos = llvm::upper_bound(regions, load_addr);
668 if (pos != regions.begin() &&
669 std::prev(pos)->GetRange().Contains(load_addr)) {
670 return *std::prev(pos);
671 }
672
673 if (pos == regions.begin())
674 region.GetRange().SetRangeBase(0);
675 else
676 region.GetRange().SetRangeBase(std::prev(pos)->GetRange().GetRangeEnd());
677
678 if (pos == regions.end())
680 else
681 region.GetRange().SetRangeEnd(pos->GetRange().GetRangeBase());
682
687 return region;
688}
static llvm::raw_ostream & error(Stream &strm)
#define ENUM_TO_CSTR(eee)
#define LLDB_LOG_ERROR(log, error,...)
Definition: Log.h:382
static bool CreateRegionsCacheFromLinuxMaps(MinidumpParser &parser, std::vector< MemoryRegionInfo > &regions)
static bool CheckForLinuxExecutable(ConstString path, const MemoryRegionInfos &regions, lldb::addr_t base_of_image)
Check for the memory regions starting at load_addr for a contiguous section that has execute permissi...
static bool CreateRegionsCacheFromMemoryInfoList(MinidumpParser &parser, std::vector< MemoryRegionInfo > &regions)
static bool CreateRegionsCacheFromMemoryList(MinidumpParser &parser, std::vector< MemoryRegionInfo > &regions)
An architecture specification class.
Definition: ArchSpec.h:31
bool IsValid() const
Tests if this ArchSpec is valid.
Definition: ArchSpec.h:348
bool SetTriple(const llvm::Triple &triple)
Architecture triple setter.
Definition: ArchSpec.cpp:747
A uniqued constant string class.
Definition: ConstString.h:40
void SetMapped(OptionalBool val)
void SetReadable(OptionalBool val)
void SetExecutable(OptionalBool val)
void SetWritable(OptionalBool val)
OptionalBool GetExecutable() const
A collection class for Module objects.
Definition: ModuleList.h:103
An error handling class.
Definition: Status.h:44
static std::optional< LinuxProcStatus > Parse(llvm::ArrayRef< uint8_t > &data)
MinidumpParser(lldb::DataBufferSP data_sp, std::unique_ptr< llvm::object::MinidumpFile > file)
std::pair< MemoryRegionInfos, bool > BuildMemoryRegions()
Returns a list of memory regions and a flag indicating whether the list is complete (includes all reg...
llvm::ArrayRef< minidump::Module > GetModuleList()
llvm::object::MinidumpFile & GetMinidumpFile()
llvm::ArrayRef< uint8_t > GetData()
static MemoryRegionInfo GetMemoryRegionInfo(const MemoryRegionInfos &regions, lldb::addr_t load_addr)
llvm::ArrayRef< uint8_t > GetStream(StreamType stream_type)
std::optional< lldb::pid_t > GetPid()
std::optional< Range > FindMemoryRange(lldb::addr_t addr)
const llvm::minidump::ExceptionStream * GetExceptionStream()
static llvm::Expected< MinidumpParser > Create(const lldb::DataBufferSP &data_buf_sp)
std::unique_ptr< llvm::object::MinidumpFile > m_file
std::vector< const minidump::Module * > GetFilteredModuleList()
llvm::iterator_range< FallibleMemory64Iterator > GetMemory64Iterator(llvm::Error &err)
std::optional< LinuxProcStatus > GetLinuxProcStatus()
llvm::ArrayRef< uint8_t > GetThreadContext(const LocationDescriptor &location)
llvm::ArrayRef< uint8_t > GetMemory(lldb::addr_t addr, size_t size)
llvm::ArrayRef< uint8_t > GetThreadContextWow64(const minidump::Thread &td)
UUID GetModuleUUID(const minidump::Module *module)
static llvm::StringRef GetStreamTypeAsString(StreamType stream_type)
llvm::ArrayRef< minidump::Thread > GetThreads()
const MinidumpMiscInfo * GetMiscInfo()
#define UINT64_MAX
Definition: lldb-defines.h:23
Status consumeObject(llvm::ArrayRef< uint8_t > &Buffer, const T *&Object)
Definition: MinidumpTypes.h:50
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
Definition: Log.h:331
void ParseLinuxMapRegions(llvm::StringRef linux_map, LinuxMapCallback const &callback)
std::shared_ptr< lldb_private::DataBuffer > DataBufferSP
Definition: lldb-forward.h:334
uint64_t addr_t
Definition: lldb-types.h:80
void SetRangeEnd(BaseType end)
Definition: RangeMap.h:80
SizeType GetByteSize() const
Definition: RangeMap.h:87
void SetRangeBase(BaseType b)
Set the start value for the range, and keep the same size.
Definition: RangeMap.h:48
void SetByteSize(SizeType s)
Definition: RangeMap.h:89
struct lldb_private::UUID::CvRecordPdb70::@41 Uuid
llvm::support::ulittle32_t Age
Definition: UUID.h:46
static const MinidumpMiscInfo * Parse(llvm::ArrayRef< uint8_t > &data)
std::optional< lldb::pid_t > GetPid() const
llvm::support::ulittle64_t tls_slots[64]