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)
72 std::vector<lldb::ThreadSP> threads =
74 for (
const ThreadSP &thread_sp : threads) {
75 StopInfoSP stop_info_sp = thread_sp->GetStopInfo();
77 const StopReason &stop_reason = stop_info_sp->GetStopReason();
89 "Failed to fill in header and directory "
90 "sections. Written / Expected (%" PRIx64
" / %" PRIx64
")",
97 uint64_t stream_size) {
102 "Unable to add directory for stream type "
103 "%x, offset is greater then 32 bit limit.",
110 "Unable to add directory for stream type %x, exceeded expected number "
111 "of directories %zu.",
116 LocationDescriptor loc;
117 loc.DataSize =
static_cast<llvm::support::ulittle32_t
>(stream_size);
122 dir.Type =
static_cast<llvm::support::little_t<StreamType>
>(type);
131 const llvm::Triple &target_triple =
132 m_process_sp->GetTarget().GetArchitecture().GetTriple();
134 AddDirectory(StreamType::SystemInfo,
sizeof(llvm::minidump::SystemInfo));
138 llvm::minidump::ProcessorArchitecture arch;
139 switch (target_triple.getArch()) {
140 case llvm::Triple::ArchType::x86_64:
141 arch = ProcessorArchitecture::AMD64;
143 case llvm::Triple::ArchType::x86:
144 arch = ProcessorArchitecture::X86;
146 case llvm::Triple::ArchType::arm:
147 arch = ProcessorArchitecture::ARM;
149 case llvm::Triple::ArchType::aarch64:
150 arch = ProcessorArchitecture::ARM64;
152 case llvm::Triple::ArchType::mips64:
153 case llvm::Triple::ArchType::mips64el:
154 case llvm::Triple::ArchType::mips:
155 case llvm::Triple::ArchType::mipsel:
156 arch = ProcessorArchitecture::MIPS;
158 case llvm::Triple::ArchType::ppc64:
159 case llvm::Triple::ArchType::ppc:
160 case llvm::Triple::ArchType::ppc64le:
161 arch = ProcessorArchitecture::PPC;
165 "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;
190 "OS %s not supported.", 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;
219 llvm::StringRef to_write_ref(to_write.c_str(), to_write.size() + 1);
220 llvm::SmallVector<llvm::UTF16, 128> to_write_utf16;
222 bool converted = convertUTF8ToUTF16String(to_write_ref, to_write_utf16);
225 "Unable to convert the string to UTF16. Failed to convert %s",
232 llvm::support::ulittle32_t to_write_size(to_write_utf16.size_in_bytes() - 2);
234 buffer->
AppendData(&to_write_size,
sizeof(llvm::support::ulittle32_t));
235 buffer->
AppendData(to_write_utf16.data(), to_write_utf16.size_in_bytes());
243 uint64_t SizeOfImage = 0;
244 if (mod->GetObjectFile()->CalculateType() == ObjectFile::Type::eTypeJIT) {
245 for (
const auto §ion : *mod->GetObjectFile()->GetSectionList()) {
246 SizeOfImage += section->GetByteSize();
250 SectionSP sect_sp = mod->GetObjectFile()->GetBaseAddress().GetSection();
253 return llvm::createStringError(std::errc::operation_not_supported,
254 "Couldn't obtain the section information.");
256 lldb::addr_t sect_addr = sect_sp->GetLoadBaseAddress(&target);
263 mod->GetObjectFile()->GetBaseAddress().GetLoadAddress(&target) -
265 SizeOfImage = sect_size - base_sect_offset;
270 while (next_sect_sp &&
271 next_sect_sp->GetLoadBaseAddress(&target) == next_sect_addr) {
272 sect_size = sect_sp->GetByteSize();
273 SizeOfImage += sect_size;
274 next_sect_addr += sect_size;
288 constexpr size_t minidump_module_size =
sizeof(llvm::minidump::Module);
293 llvm::support::ulittle32_t modules_count =
294 static_cast<llvm::support::ulittle32_t
>(modules.
GetSize());
304 size_t module_stream_size =
305 sizeof(llvm::support::ulittle32_t) + modules_count * minidump_module_size;
319 for (
size_t i = 0; i < modules_count; ++i) {
321 std::string module_name = mod->GetSpecificationDescription();
323 if (!maybe_mod_size) {
324 llvm::Error mod_size_err = maybe_mod_size.takeError();
325 llvm::handleAllErrors(std::move(mod_size_err),
326 [&](
const llvm::ErrorInfoBase &E) {
328 "Unable to get the size of module %s: %s.",
329 module_name.c_str(), E.message().c_str());
334 uint64_t mod_size = std::move(*maybe_mod_size);
336 llvm::support::ulittle32_t signature =
337 static_cast<llvm::support::ulittle32_t
>(
338 static_cast<uint32_t
>(minidump::CvSignature::ElfBuildId));
339 auto uuid = mod->GetUUID().GetBytes();
341 VSFixedFileInfo info;
342 info.Signature =
static_cast<llvm::support::ulittle32_t
>(0u);
343 info.StructVersion =
static_cast<llvm::support::ulittle32_t
>(0u);
344 info.FileVersionHigh =
static_cast<llvm::support::ulittle32_t
>(0u);
345 info.FileVersionLow =
static_cast<llvm::support::ulittle32_t
>(0u);
346 info.ProductVersionHigh =
static_cast<llvm::support::ulittle32_t
>(0u);
347 info.ProductVersionLow =
static_cast<llvm::support::ulittle32_t
>(0u);
348 info.FileFlagsMask =
static_cast<llvm::support::ulittle32_t
>(0u);
349 info.FileFlags =
static_cast<llvm::support::ulittle32_t
>(0u);
350 info.FileOS =
static_cast<llvm::support::ulittle32_t
>(0u);
351 info.FileType =
static_cast<llvm::support::ulittle32_t
>(0u);
352 info.FileSubtype =
static_cast<llvm::support::ulittle32_t
>(0u);
353 info.FileDateHigh =
static_cast<llvm::support::ulittle32_t
>(0u);
354 info.FileDateLow =
static_cast<llvm::support::ulittle32_t
>(0u);
356 LocationDescriptor ld;
357 ld.DataSize =
static_cast<llvm::support::ulittle32_t
>(0u);
358 ld.RVA =
static_cast<llvm::support::ulittle32_t
>(0u);
362 LocationDescriptor ld_cv;
363 ld_cv.DataSize =
static_cast<llvm::support::ulittle32_t
>(
364 sizeof(llvm::support::ulittle32_t) + uuid.size());
365 ld_cv.RVA =
static_cast<llvm::support::ulittle32_t
>(
366 size_before + module_stream_size + helper_data.
GetByteSize());
368 helper_data.
AppendData(&signature,
sizeof(llvm::support::ulittle32_t));
369 helper_data.
AppendData(uuid.begin(), uuid.size());
371 llvm::minidump::Module m;
372 m.BaseOfImage =
static_cast<llvm::support::ulittle64_t
>(
373 mod->GetObjectFile()->GetBaseAddress().GetLoadAddress(&target));
374 m.SizeOfImage =
static_cast<llvm::support::ulittle32_t
>(mod_size);
375 m.Checksum =
static_cast<llvm::support::ulittle32_t
>(0);
377 static_cast<llvm::support::ulittle32_t
>(std::time(
nullptr));
378 m.ModuleNameRVA =
static_cast<llvm::support::ulittle32_t
>(
379 size_before + module_stream_size + helper_data.
GetByteSize());
380 m.VersionInfo = info;
397 llvm::StringRef reg_name) {
402 bool success = reg_ctx->
ReadRegister(reg_info, reg_value);
409 llvm::StringRef reg_name) {
414 bool success = reg_ctx->
ReadRegister(reg_info, reg_value);
421 llvm::StringRef reg_name) {
426 bool success = reg_ctx->
ReadRegister(reg_info, reg_value);
433 llvm::StringRef reg_name) {
434 return static_cast<llvm::support::ulittle16_t
>(
439 llvm::StringRef reg_name) {
440 return static_cast<llvm::support::ulittle32_t
>(
445 llvm::StringRef reg_name) {
446 return static_cast<llvm::support::ulittle64_t
>(
459 if (bytes_copied == 16)
504 return thread_context;
511 minidump::RegisterContextMinidump_ARM64::Flags::ARM64_Flag |
512 minidump::RegisterContextMinidump_ARM64::Flags::Integer |
513 minidump::RegisterContextMinidump_ARM64::Flags::FloatingPoint);
515 for (uint32_t i = 0; i < 31; ++i) {
516 snprintf(reg_name,
sizeof(reg_name),
"x%u", i);
526 for (uint32_t i = 0; i < 32; ++i) {
527 snprintf(reg_name,
sizeof(reg_name),
"v%u", i);
530 return thread_context;
545 case llvm::Triple::ArchType::x86_64:
548 case llvm::Triple::ArchType::aarch64:
561 case llvm::Triple::ArchType::x86_64:
563 case llvm::Triple::ArchType::aarch64:
564 return sizeof(
arm64);
580 const llvm::minidump::Thread &thread = pair.second;
581 size_t bytes_to_write =
sizeof(llvm::minidump::Thread);
582 size_t bytes_written = bytes_to_write;
584 if (
error.Fail() || bytes_to_write != bytes_written) {
586 "Wrote incorrect number of bytes to minidump file. (written %zd/%zd)",
587 bytes_written, bytes_to_write);
596 constexpr size_t minidump_thread_size =
sizeof(llvm::minidump::Thread);
597 std::vector<ThreadSP> thread_list =
602 size_t thread_stream_size =
sizeof(llvm::support::ulittle32_t) +
603 thread_list.size() * minidump_thread_size;
611 llvm::support::ulittle32_t thread_count =
612 static_cast<llvm::support::ulittle32_t
>(thread_list.size());
620 for (
const ThreadSP &thread_sp : thread_list) {
633 "architecture %s not supported.",
634 arch.
GetTriple().getArchName().str().c_str());
638 uint64_t
sp = reg_ctx->
GetSP();
643 MemoryDescriptor stack;
644 LocationDescriptor empty_label;
645 empty_label.DataSize = 0;
647 stack.Memory = empty_label;
648 stack.StartOfMemoryRange = 0;
649 LocationDescriptor thread_context_memory_locator;
650 thread_context_memory_locator.DataSize =
651 static_cast<llvm::support::ulittle32_t
>(thread_context.
size());
652 thread_context_memory_locator.RVA =
static_cast<llvm::support::ulittle32_t
>(
653 size_before + thread_stream_size + helper_data.
GetByteSize());
657 LLDB_LOGF(log,
"AddThreadList for thread %d: thread_context %zu bytes",
658 thread_sp->GetIndexID(), thread_context.
size());
661 llvm::minidump::Thread t;
662 t.ThreadId =
static_cast<llvm::support::ulittle32_t
>(thread_sp->GetID());
663 t.SuspendCount =
static_cast<llvm::support::ulittle32_t
>(
664 (thread_sp->GetState() == StateType::eStateSuspended) ? 1 : 0);
665 t.PriorityClass =
static_cast<llvm::support::ulittle32_t
>(0);
666 t.Priority =
static_cast<llvm::support::ulittle32_t
>(0);
667 t.EnvironmentBlock =
static_cast<llvm::support::ulittle64_t
>(0);
668 t.Stack = stack, t.Context = thread_context_memory_locator;
675 LLDB_LOGF(log,
"AddThreadList(): total helper_data %" PRIx64
" bytes",
682 std::vector<ThreadSP> thread_list =
685 for (
const ThreadSP &thread_sp : thread_list) {
686 StopInfoSP stop_info_sp = thread_sp->GetStopInfo();
692 constexpr size_t minidump_exception_size =
693 sizeof(llvm::minidump::ExceptionStream);
700 exp_record.ExceptionCode =
701 static_cast<llvm::support::ulittle32_t
>(stop_info_sp->GetValue());
702 exp_record.ExceptionFlags =
703 static_cast<llvm::support::ulittle32_t
>(Exception::LLDB_FLAG);
704 exp_record.ExceptionRecord =
static_cast<llvm::support::ulittle64_t
>(0);
705 exp_record.ExceptionAddress = reg_ctx_sp->GetPC();
706 exp_record.NumberParameters =
static_cast<llvm::support::ulittle32_t
>(1);
707 std::string description = stop_info_sp->GetDescription();
710 memcpy(&exp_record.ExceptionInformation, description.c_str(),
711 std::max(description.size(), Exception::MaxParameterBytes));
712 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;
739 misc_info.
size =
static_cast<llvm::support::ulittle32_t
>(
743 misc_info.
flags1 =
static_cast<llvm::support::ulittle32_t
>(0);
750 static_cast<llvm::support::ulittle32_t
>(
static_cast<uint32_t
>(
753 static_cast<llvm::support::ulittle32_t
>(process_info.
GetProcessID());
761std::unique_ptr<llvm::MemoryBuffer>
763 auto maybe_stream = llvm::MemoryBuffer::getFileAsStream(path);
766 return std::move(maybe_stream.get());
772 if (
m_process_sp->GetTarget().GetArchitecture().GetTriple().getOS() !=
776 std::vector<std::pair<StreamType, std::string>> files_with_stream_types = {
777 {StreamType::LinuxCPUInfo,
"/proc/cpuinfo"},
778 {StreamType::LinuxLSBRelease,
"/etc/lsb-release"},
785 std::string pid_str = std::to_string(pid);
786 files_with_stream_types.push_back(
787 {StreamType::LinuxProcStatus,
"/proc/" + pid_str +
"/status"});
788 files_with_stream_types.push_back(
789 {StreamType::LinuxCMDLine,
"/proc/" + pid_str +
"/cmdline"});
790 files_with_stream_types.push_back(
791 {StreamType::LinuxEnviron,
"/proc/" + pid_str +
"/environ"});
792 files_with_stream_types.push_back(
793 {StreamType::LinuxAuxv,
"/proc/" + pid_str +
"/auxv"});
794 files_with_stream_types.push_back(
795 {StreamType::LinuxMaps,
"/proc/" + pid_str +
"/maps"});
796 files_with_stream_types.push_back(
797 {StreamType::LinuxProcStat,
"/proc/" + pid_str +
"/stat"});
798 files_with_stream_types.push_back(
799 {StreamType::LinuxProcFD,
"/proc/" + pid_str +
"/fd"});
802 for (
const auto &entry : files_with_stream_types) {
803 StreamType stream = entry.first;
804 std::string path = entry.second;
808 size_t size = memory_buffer->getBufferSize();
828 std::vector<CoreFileMemoryRange> ranges_32;
829 std::vector<CoreFileMemoryRange> ranges_64;
832 all_core_memory_ranges);
838 all_core_memory_ranges.
GetSize());
839 std::vector<CoreFileMemoryRange> all_core_memory_vec;
842 for (
const auto &core_range : all_core_memory_ranges)
843 all_core_memory_vec.push_back(core_range.data);
848 auto iterator = all_core_memory_vec.begin();
849 while (iterator != all_core_memory_vec.end()) {
852 ranges_32.push_back(*iterator);
854 iterator->range.size() +
sizeof(llvm::minidump::MemoryDescriptor);
855 iterator = all_core_memory_vec.erase(iterator);
863 "Unable to write minidump. Stack memory "
864 "exceeds 32b limit. (Num Stacks %zu)",
875 if (!all_core_memory_vec.empty())
876 total_size += 256 + (all_core_memory_vec.size() *
877 sizeof(llvm::minidump::MemoryDescriptor_64));
879 for (
const auto &core_range : all_core_memory_vec) {
880 const addr_t range_size = core_range.range.size();
884 ranges_32.push_back(core_range);
885 total_size += range_size;
887 ranges_64.push_back(core_range);
896 if (!ranges_64.empty()) {
907 llvm::minidump::Header header;
908 header.Signature =
static_cast<llvm::support::ulittle32_t
>(
909 llvm::minidump::Header::MagicSignature);
910 header.Version =
static_cast<llvm::support::ulittle32_t
>(
911 llvm::minidump::Header::MagicVersion);
912 header.NumberOfStreams =
913 static_cast<llvm::support::ulittle32_t
>(
m_directories.size());
915 header.StreamDirectoryRVA =
916 static_cast<llvm::support::ulittle32_t
>(
HEADER_SIZE);
917 header.Checksum =
static_cast<llvm::support::ulittle32_t
>(
919 header.TimeDateStamp =
920 static_cast<llvm::support::ulittle32_t
>(std::time(
nullptr));
922 static_cast<llvm::support::ulittle64_t
>(0u);
925 size_t bytes_written;
933 "Unable to write the minidump header (written %zd/%zd)",
946 size_t bytes_written;
954 "unable to write the directory (written %zd/%zd)", bytes_written,
965 uint64_t max_size = 0;
966 for (
const auto &core_range : ranges)
967 max_size = std::max(max_size, core_range.range.size());
974 std::vector<MemoryDescriptor> descriptors;
976 if (ranges.size() == 0)
980 size_t region_index = 0;
983 for (
const auto &core_range : ranges) {
986 const addr_t addr = core_range.range.start();
987 const addr_t size = core_range.range.size();
988 const addr_t end = core_range.range.end();
991 "AddMemoryList %zu/%zu reading memory for region "
992 "(%" PRIx64
" bytes) [%" PRIx64
", %" PRIx64
")",
993 region_index, ranges.size(), size, addr, addr + size);
996 progress.
Increment(1,
"Adding Memory Range " + core_range.Dump());
997 const size_t bytes_read =
999 if (
error.Fail() || bytes_read == 0) {
1000 LLDB_LOGF(log,
"Failed to read memory region. Bytes read: %zu, error: %s",
1001 bytes_read,
error.AsCString());
1004 }
else if (bytes_read != size) {
1006 log,
"Memory region at: %" PRIx64
" failed to read %" PRIx64
" bytes",
1010 MemoryDescriptor descriptor;
1011 descriptor.StartOfMemoryRange =
1012 static_cast<llvm::support::ulittle64_t
>(addr);
1013 descriptor.Memory.DataSize =
1014 static_cast<llvm::support::ulittle32_t
>(bytes_read);
1015 descriptor.Memory.RVA =
1016 static_cast<llvm::support::ulittle32_t
>(offset_for_data);
1017 descriptors.push_back(descriptor);
1031 sizeof(llvm::minidump::MemoryListHeader) +
1032 descriptors.size() *
1033 sizeof(llvm::minidump::MemoryDescriptor));
1037 llvm::minidump::MemoryListHeader list_header;
1038 llvm::support::ulittle32_t memory_ranges_num =
1039 static_cast<llvm::support::ulittle32_t
>(descriptors.size());
1040 list_header.NumberOfMemoryRanges = memory_ranges_num;
1045 descriptors.size() *
sizeof(MemoryDescriptor));
1058 (
sizeof(llvm::support::ulittle64_t) * 2) +
1060 sizeof(llvm::minidump::MemoryDescriptor_64));
1064 llvm::minidump::Memory64ListHeader list_header;
1065 llvm::support::ulittle64_t memory_ranges_num =
1066 static_cast<llvm::support::ulittle64_t
>(ranges.size());
1067 list_header.NumberOfMemoryRanges = memory_ranges_num;
1076 (ranges.size() *
sizeof(llvm::minidump::MemoryDescriptor_64));
1077 llvm::support::ulittle64_t memory_ranges_base_rva =
1078 static_cast<llvm::support::ulittle64_t
>(base_rva);
1079 list_header.BaseRVA = memory_ranges_base_rva;
1080 m_data.
AppendData(&list_header,
sizeof(llvm::minidump::Memory64ListHeader));
1082 bool cleanup_required =
false;
1083 std::vector<MemoryDescriptor_64> descriptors;
1086 for (
const auto core_range : ranges) {
1088 MemoryDescriptor_64 memory_desc;
1089 memory_desc.StartOfMemoryRange =
1090 static_cast<llvm::support::ulittle64_t
>(core_range.range.start());
1091 memory_desc.DataSize =
1092 static_cast<llvm::support::ulittle64_t
>(core_range.range.size());
1093 descriptors.push_back(memory_desc);
1099 size_t region_index = 0;
1102 for (
const auto &core_range : ranges) {
1103 const addr_t addr = core_range.range.start();
1104 const addr_t size = core_range.range.size();
1107 "AddMemoryList_64 %zu/%zu reading memory for region "
1108 "(%" PRIx64
"bytes) "
1109 "[%" PRIx64
", %" PRIx64
")",
1110 region_index, ranges.size(), size, addr, addr + size);
1113 progress.
Increment(1,
"Adding Memory Range " + core_range.Dump());
1114 const size_t bytes_read =
1117 LLDB_LOGF(log,
"Failed to read memory region. Bytes read: %zu, error: %s",
1118 bytes_read,
error.AsCString());
1120 cleanup_required =
true;
1121 descriptors[region_index].DataSize = 0;
1123 if (bytes_read != size) {
1125 log,
"Memory region at: %" PRIx64
" failed to read %" PRIx64
" bytes",
1127 cleanup_required =
true;
1128 descriptors[region_index].DataSize = bytes_read;
1138 if (!cleanup_required) {
1145 size_t bytes_written =
sizeof(MemoryDescriptor_64) * descriptors.size();
1148 bytes_written !=
sizeof(MemoryDescriptor_64) * descriptors.size()) {
1150 "unable to write the memory descriptors (written %zd/%zd)",
1151 bytes_written,
sizeof(MemoryDescriptor_64) * descriptors.size());
1177 addr_t remaining_bytes = starting_size;
1180 while (remaining_bytes > 0) {
1181 size_t bytes_written = remaining_bytes;
1187 "Wrote incorrect number of bytes to minidump file. (written %" PRIx64
1189 starting_size - remaining_bytes, starting_size);
1193 offset += bytes_written;
1194 remaining_bytes -= bytes_written;
1228 LLDB_LOGF(log,
"Failed to close minidump file: %s",
error.AsCString());
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)
static uint64_t GetLargestRangeSize(const std::vector< CoreFileMemoryRange > &ranges)
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)
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 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::DataBufferHeap m_data
lldb_private::Status AddSystemInfo()
lldb_private::Status AddMemoryList()
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::SaveCoreOptions m_save_core_options
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()
void DeleteFile() noexcept
lldb::ProcessSP m_process_sp
static constexpr size_t HEADER_SIZE
lldb::offset_t GetCurrentDataEndOffset() const
lldb_private::Status AddMemoryList_32(std::vector< lldb_private::CoreFileMemoryRange > &ranges, lldb_private::Progress &progress)
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
lldb_private::Status AddMemoryList_64(std::vector< lldb_private::CoreFileMemoryRange > &ranges, lldb_private::Progress &progress)
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
A Progress indicator helper class.
void Increment(uint64_t amount=1, std::optional< std::string > updated_detail={})
Increment the progress and send a notification to the installed callback.
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
static Status FromErrorStringWithFormat(const char *format,...) __attribute__((format(printf
static Status FromErrorString(const char *str)
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
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 gs_base
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 fs_base
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