30#include "llvm/ADT/StringRef.h"
31#include "llvm/BinaryFormat/Minidump.h"
32#include "llvm/Support/ConvertUTF.h"
33#include "llvm/Support/Endian.h"
34#include "llvm/Support/Error.h"
35#include "llvm/TargetParser/Triple.h"
55using namespace llvm::minidump;
68 llvm::Triple::OSType::Linux)
73 const uint32_t num_threads = thread_list.
GetSize();
74 for (uint32_t thread_idx = 0; thread_idx < num_threads; ++thread_idx) {
76 StopInfoSP stop_info_sp = thread_sp->GetStopInfo();
78 const StopReason &stop_reason = stop_info_sp->GetStopReason();
79 if (stop_reason == StopReason::eStopReasonException ||
80 stop_reason == StopReason::eStopReasonSignal)
90 error.SetErrorStringWithFormat(
"Failed to fill in header and directory "
91 "sections. Written / Expected (%" PRIx64
99 uint64_t stream_size) {
103 error.SetErrorStringWithFormat(
"Unable to add directory for stream type "
104 "%x, offset is greater then 32 bit limit.",
110 error.SetErrorStringWithFormat(
111 "Unable to add directory for stream type %x, exceeded expected number "
112 "of directories %zu.",
117 LocationDescriptor loc;
118 loc.DataSize =
static_cast<llvm::support::ulittle32_t
>(stream_size);
123 dir.Type =
static_cast<llvm::support::little_t<StreamType>
>(type);
132 const llvm::Triple &target_triple =
133 m_process_sp->GetTarget().GetArchitecture().GetTriple();
135 AddDirectory(StreamType::SystemInfo,
sizeof(llvm::minidump::SystemInfo));
139 llvm::minidump::ProcessorArchitecture arch;
140 switch (target_triple.getArch()) {
141 case llvm::Triple::ArchType::x86_64:
142 arch = ProcessorArchitecture::AMD64;
144 case llvm::Triple::ArchType::x86:
145 arch = ProcessorArchitecture::X86;
147 case llvm::Triple::ArchType::arm:
148 arch = ProcessorArchitecture::ARM;
150 case llvm::Triple::ArchType::aarch64:
151 arch = ProcessorArchitecture::ARM64;
153 case llvm::Triple::ArchType::mips64:
154 case llvm::Triple::ArchType::mips64el:
155 case llvm::Triple::ArchType::mips:
156 case llvm::Triple::ArchType::mipsel:
157 arch = ProcessorArchitecture::MIPS;
159 case llvm::Triple::ArchType::ppc64:
160 case llvm::Triple::ArchType::ppc:
161 case llvm::Triple::ArchType::ppc64le:
162 arch = ProcessorArchitecture::PPC;
165 error.SetErrorStringWithFormat(
"Architecture %s not supported.",
166 target_triple.getArchName().str().c_str());
170 llvm::support::little_t<OSPlatform> platform_id;
171 switch (target_triple.getOS()) {
172 case llvm::Triple::OSType::Linux:
173 if (target_triple.getEnvironment() ==
174 llvm::Triple::EnvironmentType::Android)
175 platform_id = OSPlatform::Android;
177 platform_id = OSPlatform::Linux;
179 case llvm::Triple::OSType::Win32:
180 platform_id = OSPlatform::Win32NT;
182 case llvm::Triple::OSType::MacOSX:
183 platform_id = OSPlatform::MacOSX;
185 case llvm::Triple::OSType::IOS:
186 platform_id = OSPlatform::IOS;
189 error.SetErrorStringWithFormat(
"OS %s not supported.",
190 target_triple.getOSName().str().c_str());
194 llvm::minidump::SystemInfo sys_info;
195 sys_info.ProcessorArch =
196 static_cast<llvm::support::little_t<ProcessorArchitecture>
>(arch);
198 sys_info.CSDVersionRVA =
static_cast<llvm::support::ulittle32_t
>(
200 sys_info.PlatformId = platform_id;
203 std::string csd_string;
207 error.SetErrorString(
"Unable to convert the csd string to UTF16.");
218 llvm::StringRef to_write_ref(to_write.c_str(), to_write.size() + 1);
219 llvm::SmallVector<llvm::UTF16, 128> to_write_utf16;
221 bool converted = convertUTF8ToUTF16String(to_write_ref, to_write_utf16);
223 error.SetErrorStringWithFormat(
224 "Unable to convert the string to UTF16. Failed to convert %s",
231 llvm::support::ulittle32_t to_write_size(to_write_utf16.size_in_bytes() - 2);
233 buffer->
AppendData(&to_write_size,
sizeof(llvm::support::ulittle32_t));
234 buffer->
AppendData(to_write_utf16.data(), to_write_utf16.size_in_bytes());
242 uint64_t SizeOfImage = 0;
243 if (mod->GetObjectFile()->CalculateType() == ObjectFile::Type::eTypeJIT) {
244 for (
const auto §ion : *mod->GetObjectFile()->GetSectionList()) {
245 SizeOfImage += section->GetByteSize();
249 SectionSP sect_sp = mod->GetObjectFile()->GetBaseAddress().GetSection();
252 return llvm::createStringError(std::errc::operation_not_supported,
253 "Couldn't obtain the section information.");
255 lldb::addr_t sect_addr = sect_sp->GetLoadBaseAddress(&target);
262 mod->GetObjectFile()->GetBaseAddress().GetLoadAddress(&target) -
264 SizeOfImage = sect_size - base_sect_offset;
269 while (next_sect_sp &&
270 next_sect_sp->GetLoadBaseAddress(&target) == next_sect_addr) {
271 sect_size = sect_sp->GetByteSize();
272 SizeOfImage += sect_size;
273 next_sect_addr += sect_size;
287 constexpr size_t minidump_module_size =
sizeof(llvm::minidump::Module);
292 llvm::support::ulittle32_t modules_count =
293 static_cast<llvm::support::ulittle32_t
>(modules.
GetSize());
303 size_t module_stream_size =
304 sizeof(llvm::support::ulittle32_t) + modules_count * minidump_module_size;
318 for (
size_t i = 0; i < modules_count; ++i) {
320 std::string module_name = mod->GetSpecificationDescription();
322 if (!maybe_mod_size) {
323 llvm::Error mod_size_err = maybe_mod_size.takeError();
324 llvm::handleAllErrors(std::move(mod_size_err),
325 [&](
const llvm::ErrorInfoBase &E) {
326 error.SetErrorStringWithFormat(
327 "Unable to get the size of module %s: %s.",
328 module_name.c_str(), E.message().c_str());
333 uint64_t mod_size = std::move(*maybe_mod_size);
335 llvm::support::ulittle32_t signature =
336 static_cast<llvm::support::ulittle32_t
>(
337 static_cast<uint32_t
>(minidump::CvSignature::ElfBuildId));
338 auto uuid = mod->GetUUID().GetBytes();
340 VSFixedFileInfo info;
341 info.Signature =
static_cast<llvm::support::ulittle32_t
>(0u);
342 info.StructVersion =
static_cast<llvm::support::ulittle32_t
>(0u);
343 info.FileVersionHigh =
static_cast<llvm::support::ulittle32_t
>(0u);
344 info.FileVersionLow =
static_cast<llvm::support::ulittle32_t
>(0u);
345 info.ProductVersionHigh =
static_cast<llvm::support::ulittle32_t
>(0u);
346 info.ProductVersionLow =
static_cast<llvm::support::ulittle32_t
>(0u);
347 info.FileFlagsMask =
static_cast<llvm::support::ulittle32_t
>(0u);
348 info.FileFlags =
static_cast<llvm::support::ulittle32_t
>(0u);
349 info.FileOS =
static_cast<llvm::support::ulittle32_t
>(0u);
350 info.FileType =
static_cast<llvm::support::ulittle32_t
>(0u);
351 info.FileSubtype =
static_cast<llvm::support::ulittle32_t
>(0u);
352 info.FileDateHigh =
static_cast<llvm::support::ulittle32_t
>(0u);
353 info.FileDateLow =
static_cast<llvm::support::ulittle32_t
>(0u);
355 LocationDescriptor ld;
356 ld.DataSize =
static_cast<llvm::support::ulittle32_t
>(0u);
357 ld.RVA =
static_cast<llvm::support::ulittle32_t
>(0u);
361 LocationDescriptor ld_cv;
362 ld_cv.DataSize =
static_cast<llvm::support::ulittle32_t
>(
363 sizeof(llvm::support::ulittle32_t) + uuid.size());
364 ld_cv.RVA =
static_cast<llvm::support::ulittle32_t
>(
365 size_before + module_stream_size + helper_data.
GetByteSize());
367 helper_data.
AppendData(&signature,
sizeof(llvm::support::ulittle32_t));
368 helper_data.
AppendData(uuid.begin(), uuid.size());
370 llvm::minidump::Module m;
371 m.BaseOfImage =
static_cast<llvm::support::ulittle64_t
>(
372 mod->GetObjectFile()->GetBaseAddress().GetLoadAddress(&target));
373 m.SizeOfImage =
static_cast<llvm::support::ulittle32_t
>(mod_size);
374 m.Checksum =
static_cast<llvm::support::ulittle32_t
>(0);
376 static_cast<llvm::support::ulittle32_t
>(std::time(
nullptr));
377 m.ModuleNameRVA =
static_cast<llvm::support::ulittle32_t
>(
378 size_before + module_stream_size + helper_data.
GetByteSize());
379 m.VersionInfo = info;
396 llvm::StringRef reg_name) {
401 bool success = reg_ctx->
ReadRegister(reg_info, reg_value);
408 llvm::StringRef reg_name) {
413 bool success = reg_ctx->
ReadRegister(reg_info, reg_value);
420 llvm::StringRef reg_name) {
425 bool success = reg_ctx->
ReadRegister(reg_info, reg_value);
432 llvm::StringRef reg_name) {
433 return static_cast<llvm::support::ulittle16_t
>(
438 llvm::StringRef reg_name) {
439 return static_cast<llvm::support::ulittle32_t
>(
444 llvm::StringRef reg_name) {
445 return static_cast<llvm::support::ulittle64_t
>(
458 if (bytes_copied == 16)
498 return thread_context;
505 minidump::RegisterContextMinidump_ARM64::Flags::ARM64_Flag |
506 minidump::RegisterContextMinidump_ARM64::Flags::Integer |
507 minidump::RegisterContextMinidump_ARM64::Flags::FloatingPoint);
509 for (uint32_t i = 0; i < 31; ++i) {
510 snprintf(reg_name,
sizeof(reg_name),
"x%u", i);
520 for (uint32_t i = 0; i < 32; ++i) {
521 snprintf(reg_name,
sizeof(reg_name),
"v%u", i);
524 return thread_context;
539 case llvm::Triple::ArchType::x86_64:
542 case llvm::Triple::ArchType::aarch64:
555 case llvm::Triple::ArchType::x86_64:
557 case llvm::Triple::ArchType::aarch64:
558 return sizeof(
arm64);
574 const llvm::minidump::Thread &thread = pair.second;
575 size_t bytes_to_write =
sizeof(llvm::minidump::Thread);
576 size_t bytes_written = bytes_to_write;
578 if (
error.Fail() || bytes_to_write != bytes_written) {
579 error.SetErrorStringWithFormat(
580 "Wrote incorrect number of bytes to minidump file. (written %zd/%zd)",
581 bytes_written, bytes_to_write);
590 constexpr size_t minidump_thread_size =
sizeof(llvm::minidump::Thread);
595 size_t thread_stream_size =
sizeof(llvm::support::ulittle32_t) +
596 thread_list.
GetSize() * minidump_thread_size;
604 llvm::support::ulittle32_t thread_count =
605 static_cast<llvm::support::ulittle32_t
>(thread_list.
GetSize());
612 const uint32_t num_threads = thread_list.
GetSize();
614 for (uint32_t thread_idx = 0; thread_idx < num_threads; ++thread_idx) {
619 error.SetErrorString(
"Unable to get the register context.");
627 error.SetErrorStringWithFormat(
628 "architecture %s not supported.",
629 arch.
GetTriple().getArchName().str().c_str());
633 uint64_t
sp = reg_ctx->
GetSP();
638 MemoryDescriptor stack;
639 LocationDescriptor empty_label;
640 empty_label.DataSize = 0;
642 stack.Memory = empty_label;
643 stack.StartOfMemoryRange = 0;
644 LocationDescriptor thread_context_memory_locator;
645 thread_context_memory_locator.DataSize =
646 static_cast<llvm::support::ulittle32_t
>(thread_context.
size());
647 thread_context_memory_locator.RVA =
static_cast<llvm::support::ulittle32_t
>(
648 size_before + thread_stream_size + helper_data.
GetByteSize());
652 LLDB_LOGF(log,
"AddThreadList for thread %d: thread_context %zu bytes",
653 thread_idx, thread_context.
size());
656 llvm::minidump::Thread t;
657 t.ThreadId =
static_cast<llvm::support::ulittle32_t
>(thread_sp->GetID());
658 t.SuspendCount =
static_cast<llvm::support::ulittle32_t
>(
659 (thread_sp->GetState() == StateType::eStateSuspended) ? 1 : 0);
660 t.PriorityClass =
static_cast<llvm::support::ulittle32_t
>(0);
661 t.Priority =
static_cast<llvm::support::ulittle32_t
>(0);
662 t.EnvironmentBlock =
static_cast<llvm::support::ulittle64_t
>(0);
663 t.Stack = stack, t.Context = thread_context_memory_locator;
670 LLDB_LOGF(log,
"AddThreadList(): total helper_data %" PRIx64
" bytes",
679 const uint32_t num_threads = thread_list.
GetSize();
680 for (uint32_t thread_idx = 0; thread_idx < num_threads; ++thread_idx) {
682 StopInfoSP stop_info_sp = thread_sp->GetStopInfo();
683 bool add_exception =
false;
685 switch (stop_info_sp->GetStopReason()) {
688 add_exception =
true;
695 constexpr size_t minidump_exception_size =
696 sizeof(llvm::minidump::ExceptionStream);
701 StopInfoSP stop_info_sp = thread_sp->GetStopInfo();
704 exp_record.ExceptionCode =
705 static_cast<llvm::support::ulittle32_t
>(stop_info_sp->GetValue());
706 exp_record.ExceptionFlags =
static_cast<llvm::support::ulittle32_t
>(0);
707 exp_record.ExceptionRecord =
static_cast<llvm::support::ulittle64_t
>(0);
708 exp_record.ExceptionAddress = reg_ctx_sp->GetPC();
709 exp_record.NumberParameters =
static_cast<llvm::support::ulittle32_t
>(0);
710 exp_record.UnusedAlignment =
static_cast<llvm::support::ulittle32_t
>(0);
713 ExceptionStream exp_stream;
714 exp_stream.ThreadId =
715 static_cast<llvm::support::ulittle32_t
>(thread_sp->GetID());
716 exp_stream.UnusedAlignment =
static_cast<llvm::support::ulittle32_t
>(0);
717 exp_stream.ExceptionRecord = exp_record;
720 exp_stream.ThreadContext = Iter->second;
722 exp_stream.ThreadContext.DataSize = 0;
723 exp_stream.ThreadContext.RVA = 0;
740 misc_info.
size =
static_cast<llvm::support::ulittle32_t
>(
744 misc_info.
flags1 =
static_cast<llvm::support::ulittle32_t
>(0);
751 static_cast<llvm::support::ulittle32_t
>(
static_cast<uint32_t
>(
754 static_cast<llvm::support::ulittle32_t
>(process_info.
GetProcessID());
762std::unique_ptr<llvm::MemoryBuffer>
764 auto maybe_stream = llvm::MemoryBuffer::getFileAsStream(path);
767 return std::move(maybe_stream.get());
773 if (
m_process_sp->GetTarget().GetArchitecture().GetTriple().getOS() !=
777 std::vector<std::pair<StreamType, std::string>> files_with_stream_types = {
778 {StreamType::LinuxCPUInfo,
"/proc/cpuinfo"},
779 {StreamType::LinuxLSBRelease,
"/etc/lsb-release"},
786 std::string pid_str = std::to_string(pid);
787 files_with_stream_types.push_back(
788 {StreamType::LinuxProcStatus,
"/proc/" + pid_str +
"/status"});
789 files_with_stream_types.push_back(
790 {StreamType::LinuxCMDLine,
"/proc/" + pid_str +
"/cmdline"});
791 files_with_stream_types.push_back(
792 {StreamType::LinuxEnviron,
"/proc/" + pid_str +
"/environ"});
793 files_with_stream_types.push_back(
794 {StreamType::LinuxAuxv,
"/proc/" + pid_str +
"/auxv"});
795 files_with_stream_types.push_back(
796 {StreamType::LinuxMaps,
"/proc/" + pid_str +
"/maps"});
797 files_with_stream_types.push_back(
798 {StreamType::LinuxProcStat,
"/proc/" + pid_str +
"/stat"});
799 files_with_stream_types.push_back(
800 {StreamType::LinuxProcFD,
"/proc/" + pid_str +
"/fd"});
803 for (
const auto &entry : files_with_stream_types) {
804 StreamType stream = entry.first;
805 std::string path = entry.second;
809 size_t size = memory_buffer->getBufferSize();
832 SaveCoreStyle::eSaveCoreStackOnly, ranges_32);
838 total_size += ranges_32.size() *
sizeof(llvm::minidump::MemoryDescriptor);
839 std::unordered_set<addr_t> stack_start_addresses;
840 for (
const auto &core_range : ranges_32) {
841 stack_start_addresses.insert(core_range.range.start());
842 total_size += core_range.range.size();
846 error.SetErrorStringWithFormat(
"Unable to write minidump. Stack memory "
847 "exceeds 32b limit. (Num Stacks %zu)",
853 if (core_style != SaveCoreStyle::eSaveCoreStackOnly) {
855 all_core_memory_ranges);
866 if (!all_core_memory_ranges.empty())
868 256 + (all_core_memory_ranges.size() - stack_start_addresses.size()) *
869 sizeof(llvm::minidump::MemoryDescriptor_64);
871 for (
const auto &core_range : all_core_memory_ranges) {
872 const addr_t range_size = core_range.range.size();
873 if (stack_start_addresses.count(core_range.range.start()) > 0)
878 ranges_32.push_back(core_range);
879 total_size += range_size;
881 ranges_64.push_back(core_range);
890 if (!ranges_64.empty()) {
901 llvm::minidump::Header header;
902 header.Signature =
static_cast<llvm::support::ulittle32_t
>(
903 llvm::minidump::Header::MagicSignature);
904 header.Version =
static_cast<llvm::support::ulittle32_t
>(
905 llvm::minidump::Header::MagicVersion);
906 header.NumberOfStreams =
907 static_cast<llvm::support::ulittle32_t
>(
m_directories.size());
909 header.StreamDirectoryRVA =
910 static_cast<llvm::support::ulittle32_t
>(
HEADER_SIZE);
911 header.Checksum =
static_cast<llvm::support::ulittle32_t
>(
913 header.TimeDateStamp =
914 static_cast<llvm::support::ulittle32_t
>(std::time(
nullptr));
916 static_cast<llvm::support::ulittle64_t
>(0u);
919 size_t bytes_written;
926 error.SetErrorStringWithFormat(
927 "Unable to write the minidump header (written %zd/%zd)",
940 size_t bytes_written;
947 error.SetErrorStringWithFormat(
948 "unable to write the directory (written %zd/%zd)", bytes_written,
959 uint64_t max_size = 0;
960 for (
const auto &core_range : ranges)
961 max_size = std::max(max_size, core_range.range.size());
967 std::vector<MemoryDescriptor> descriptors;
969 if (ranges.size() == 0)
973 size_t region_index = 0;
976 for (
const auto &core_range : ranges) {
979 const addr_t addr = core_range.range.start();
980 const addr_t size = core_range.range.size();
981 const addr_t end = core_range.range.end();
984 "AddMemoryList %zu/%zu reading memory for region "
985 "(%" PRIx64
" bytes) [%" PRIx64
", %" PRIx64
")",
986 region_index, ranges.size(), size, addr, addr + size);
989 const size_t bytes_read =
991 if (
error.Fail() || bytes_read == 0) {
992 LLDB_LOGF(log,
"Failed to read memory region. Bytes read: %zu, error: %s",
993 bytes_read,
error.AsCString());
996 }
else if (bytes_read != size) {
998 log,
"Memory region at: %" PRIx64
" failed to read %" PRIx64
" bytes",
1002 MemoryDescriptor descriptor;
1003 descriptor.StartOfMemoryRange =
1004 static_cast<llvm::support::ulittle64_t
>(addr);
1005 descriptor.Memory.DataSize =
1006 static_cast<llvm::support::ulittle32_t
>(bytes_read);
1007 descriptor.Memory.RVA =
1008 static_cast<llvm::support::ulittle32_t
>(offset_for_data);
1009 descriptors.push_back(descriptor);
1023 sizeof(llvm::support::ulittle32_t) +
1024 descriptors.size() *
1025 sizeof(llvm::minidump::MemoryDescriptor));
1029 llvm::support::ulittle32_t memory_ranges_num =
1030 static_cast<llvm::support::ulittle32_t
>(descriptors.size());
1035 descriptors.size() *
sizeof(MemoryDescriptor));
1047 (
sizeof(llvm::support::ulittle64_t) * 2) +
1049 sizeof(llvm::minidump::MemoryDescriptor_64));
1053 llvm::support::ulittle64_t memory_ranges_num =
1054 static_cast<llvm::support::ulittle64_t
>(ranges.size());
1064 (ranges.size() *
sizeof(llvm::minidump::MemoryDescriptor_64));
1065 llvm::support::ulittle64_t memory_ranges_base_rva =
1066 static_cast<llvm::support::ulittle64_t
>(base_rva);
1068 sizeof(llvm::support::ulittle64_t));
1070 bool cleanup_required =
false;
1071 std::vector<MemoryDescriptor_64> descriptors;
1074 for (
const auto core_range : ranges) {
1076 MemoryDescriptor_64 memory_desc;
1077 memory_desc.StartOfMemoryRange =
1078 static_cast<llvm::support::ulittle64_t
>(core_range.range.start());
1079 memory_desc.DataSize =
1080 static_cast<llvm::support::ulittle64_t
>(core_range.range.size());
1081 descriptors.push_back(memory_desc);
1087 size_t region_index = 0;
1090 for (
const auto &core_range : ranges) {
1091 const addr_t addr = core_range.range.start();
1092 const addr_t size = core_range.range.size();
1095 "AddMemoryList_64 %zu/%zu reading memory for region "
1096 "(%" PRIx64
"bytes) "
1097 "[%" PRIx64
", %" PRIx64
")",
1098 region_index, ranges.size(), size, addr, addr + size);
1101 const size_t bytes_read =
1104 LLDB_LOGF(log,
"Failed to read memory region. Bytes read: %zu, error: %s",
1105 bytes_read,
error.AsCString());
1107 cleanup_required =
true;
1108 descriptors[region_index].DataSize = 0;
1110 if (bytes_read != size) {
1112 log,
"Memory region at: %" PRIx64
" failed to read %" PRIx64
" bytes",
1114 cleanup_required =
true;
1115 descriptors[region_index].DataSize = bytes_read;
1125 if (!cleanup_required) {
1132 size_t bytes_written =
sizeof(MemoryDescriptor_64) * descriptors.size();
1135 bytes_written !=
sizeof(MemoryDescriptor_64) * descriptors.size()) {
1136 error.SetErrorStringWithFormat(
1137 "unable to write the memory descriptors (written %zd/%zd)",
1138 bytes_written,
sizeof(MemoryDescriptor_64) * descriptors.size());
1164 addr_t remaining_bytes = starting_size;
1167 while (remaining_bytes > 0) {
1168 size_t bytes_written = remaining_bytes;
1173 error.SetErrorStringWithFormat(
1174 "Wrote incorrect number of bytes to minidump file. (written %" PRIx64
1176 starting_size - remaining_bytes, starting_size);
1180 offset += bytes_written;
1181 remaining_bytes -= bytes_written;
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_LOGF(log,...)
llvm::support::ulittle16_t read_register_u16(RegisterContext *reg_ctx, llvm::StringRef reg_name)
uint64_t read_register_u64_raw(RegisterContext *reg_ctx, llvm::StringRef reg_name)
Status WriteString(const std::string &to_write, lldb_private::DataBufferHeap *buffer)
lldb_private::minidump::MinidumpContext_x86_64 GetThreadContext_x86_64(RegisterContext *reg_ctx)
llvm::Expected< uint64_t > getModuleFileSize(Target &target, const ModuleSP &mod)
uint16_t read_register_u16_raw(RegisterContext *reg_ctx, llvm::StringRef reg_name)
llvm::support::ulittle32_t read_register_u32(RegisterContext *reg_ctx, llvm::StringRef reg_name)
void read_register_u128(RegisterContext *reg_ctx, llvm::StringRef reg_name, uint8_t *dst)
static uint64_t GetLargestRangeSize(const Process::CoreFileMemoryRanges &ranges)
std::unique_ptr< llvm::MemoryBuffer > getFileStreamHelper(const std::string &path)
llvm::support::ulittle64_t read_register_u64(RegisterContext *reg_ctx, llvm::StringRef reg_name)
minidump::RegisterContextMinidump_ARM64::Context GetThreadContext_ARM64(RegisterContext *reg_ctx)
uint32_t read_register_u32_raw(RegisterContext *reg_ctx, llvm::StringRef reg_name)
Structure holding data neccessary for minidump file creation.
lldb_private::Status WriteString(const std::string &to_write, lldb_private::DataBufferHeap *buffer)
const void * data() const
llvm::Triple::ArchType m_arch
lldb_private::minidump::MinidumpContext_x86_64 x86_64
lldb_private::minidump::RegisterContextMinidump_ARM64::Context arm64
bool prepareRegisterContext(RegisterContext *reg_ctx)
ArchThreadContexts(llvm::Triple::ArchType arch)
lldb_private::Status AddMemoryList_64(lldb_private::Process::CoreFileMemoryRanges &ranges)
lldb_private::Status AddExceptions()
std::unordered_map< lldb::tid_t, llvm::minidump::LocationDescriptor > m_tid_to_reg_ctx
lldb_private::Status AddThreadList()
lldb_private::Status AddHeaderAndCalculateDirectories()
uint64_t m_saved_data_size
static constexpr size_t DIRECTORY_SIZE
lldb_private::Status AddMemoryList(lldb::SaveCoreStyle core_style)
lldb_private::DataBufferHeap m_data
lldb_private::Status AddSystemInfo()
std::unordered_map< lldb::addr_t, llvm::minidump::Thread > m_thread_by_range_end
lldb_private::Status AddData(const void *data, uint64_t size)
lldb_private::Status DumpFile()
lldb_private::Status FlushBufferToDisk()
size_t m_expected_directories
lldb::offset_t m_thread_list_start
static constexpr size_t MAX_WRITE_CHUNK_SIZE
lldb_private::Status AddDirectory(llvm::minidump::StreamType type, uint64_t stream_size)
lldb_private::Status FixThreadStacks()
lldb::ProcessSP m_process_sp
lldb_private::Status AddMemoryList_32(lldb_private::Process::CoreFileMemoryRanges &ranges)
static constexpr size_t HEADER_SIZE
lldb::offset_t GetCurrentDataEndOffset() const
std::vector< llvm::minidump::Directory > m_directories
lldb_private::Status DumpDirectories() const
lldb_private::Status AddLinuxFileStreams()
lldb_private::Status AddModuleList()
lldb_private::Status AddMiscInfo()
lldb_private::Status DumpHeader() const
A section + offset based address class.
lldb::SectionSP GetSection() const
Get const accessor for the section.
An architecture specification class.
llvm::Triple & GetTriple()
Architecture triple accessor.
llvm::Triple::ArchType GetMachine() const
Returns a machine family for the current architecture.
A subclass of DataBuffer that stores a data buffer on the heap.
lldb::offset_t GetByteSize() const override
Get the number of bytes in the data buffer.
void AppendData(const void *src, uint64_t src_len)
A collection class for Module objects.
lldb::ModuleSP GetModuleAtIndex(size_t idx) const
Get the module shared pointer for the module at index idx.
size_t GetSize() const
Gets the size of the module list.
bool ProcessIDIsValid() const
lldb::pid_t GetProcessID() const
std::vector< CoreFileMemoryRange > CoreFileMemoryRanges
uint64_t GetSP(uint64_t fail_value=LLDB_INVALID_ADDRESS)
const RegisterInfo * GetRegisterInfoByName(llvm::StringRef reg_name, uint32_t start_idx=0)
virtual bool ReadRegister(const RegisterInfo *reg_info, RegisterValue ®_value)=0
uint16_t GetAsUInt16(uint16_t fail_value=UINT16_MAX, bool *success_ptr=nullptr) const
uint32_t GetAsMemoryData(const RegisterInfo ®_info, void *dst, uint32_t dst_len, lldb::ByteOrder dst_byte_order, Status &error) const
uint64_t GetAsUInt64(uint64_t fail_value=UINT64_MAX, bool *success_ptr=nullptr) const
uint32_t GetAsUInt32(uint32_t fail_value=UINT32_MAX, bool *success_ptr=nullptr) const
bool ResolveLoadAddress(lldb::addr_t load_addr, Address &so_addr, uint32_t stop_id=SectionLoadHistory::eStopIDNow)
const ModuleList & GetImages() const
Get accessor for the images for this process.
const ArchSpec & GetArchitecture() const
uint32_t GetSize(bool can_update=true)
lldb::ThreadSP GetThreadAtIndex(uint32_t idx, bool can_update=true)
uint8_t * GetBytes()
Get a pointer to the data.
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.
std::shared_ptr< lldb_private::Thread > ThreadSP
std::shared_ptr< lldb_private::StopInfo > StopInfoSP
std::shared_ptr< lldb_private::Section > SectionSP
StopReason
Thread stop reasons.
std::shared_ptr< lldb_private::RegisterContext > RegisterContextSP
std::shared_ptr< lldb_private::Module > ModuleSP
BaseType GetRangeEnd() const
Every register is described in detail including its name, alternate name (optional),...
llvm::support::ulittle16_t fs
llvm::support::ulittle64_t rdx
llvm::support::ulittle16_t cs
llvm::support::ulittle64_t rsp
llvm::support::ulittle16_t ss
llvm::support::ulittle64_t rbx
llvm::support::ulittle16_t ds
llvm::support::ulittle64_t r8
llvm::support::ulittle16_t gs
llvm::support::ulittle64_t rcx
llvm::support::ulittle64_t r10
llvm::support::ulittle64_t r15
llvm::support::ulittle64_t rbp
llvm::support::ulittle64_t r13
llvm::support::ulittle64_t r12
llvm::support::ulittle64_t rsi
llvm::support::ulittle64_t p1_home
llvm::support::ulittle64_t rax
llvm::support::ulittle32_t context_flags
llvm::support::ulittle64_t rdi
llvm::support::ulittle64_t r14
llvm::support::ulittle32_t eflags
llvm::support::ulittle64_t r9
llvm::support::ulittle64_t rip
llvm::support::ulittle64_t r11
llvm::support::ulittle32_t process_id
llvm::support::ulittle32_t flags1
llvm::support::ulittle32_t size