diff options
Diffstat (limited to 'lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp')
-rw-r--r-- | lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp index ce095bc..22ece4f 100644 --- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp +++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp @@ -6347,22 +6347,24 @@ struct segment_vmaddr { // are some multiple passes over the image list while calculating // everything. -static offset_t CreateAllImageInfosPayload( - const lldb::ProcessSP &process_sp, offset_t initial_file_offset, - StreamString &all_image_infos_payload, SaveCoreStyle core_style) { +static offset_t +CreateAllImageInfosPayload(const lldb::ProcessSP &process_sp, + offset_t initial_file_offset, + StreamString &all_image_infos_payload, + lldb_private::SaveCoreOptions &options) { Target &target = process_sp->GetTarget(); ModuleList modules = target.GetImages(); // stack-only corefiles have no reason to include binaries that // are not executing; we're trying to make the smallest corefile // we can, so leave the rest out. - if (core_style == SaveCoreStyle::eSaveCoreStackOnly) + if (options.GetStyle() == SaveCoreStyle::eSaveCoreStackOnly) modules.Clear(); std::set<std::string> executing_uuids; - ThreadList &thread_list(process_sp->GetThreadList()); - for (uint32_t i = 0; i < thread_list.GetSize(); i++) { - ThreadSP thread_sp = thread_list.GetThreadAtIndex(i); + std::vector<ThreadSP> thread_list = + process_sp->CalculateCoreFileThreadList(options); + for (const ThreadSP &thread_sp : thread_list) { uint32_t stack_frame_count = thread_sp->GetStackFrameCount(); for (uint32_t j = 0; j < stack_frame_count; j++) { StackFrameSP stack_frame_sp = thread_sp->GetStackFrameAtIndex(j); @@ -6520,16 +6522,17 @@ struct page_object { }; bool ObjectFileMachO::SaveCore(const lldb::ProcessSP &process_sp, - const lldb_private::SaveCoreOptions &options, + lldb_private::SaveCoreOptions &options, Status &error) { - auto core_style = options.GetStyle(); - if (core_style == SaveCoreStyle::eSaveCoreUnspecified) - core_style = SaveCoreStyle::eSaveCoreDirtyOnly; // The FileSpec and Process are already checked in PluginManager::SaveCore. assert(options.GetOutputFile().has_value()); assert(process_sp); const FileSpec outfile = options.GetOutputFile().value(); + // MachO defaults to dirty pages + if (options.GetStyle() == SaveCoreStyle::eSaveCoreUnspecified) + options.SetStyle(eSaveCoreDirtyOnly); + Target &target = process_sp->GetTarget(); const ArchSpec target_arch = target.GetArchitecture(); const llvm::Triple &target_triple = target_arch.GetTriple(); @@ -6559,7 +6562,7 @@ bool ObjectFileMachO::SaveCore(const lldb::ProcessSP &process_sp, if (make_core) { Process::CoreFileMemoryRanges core_ranges; - error = process_sp->CalculateCoreFileSaveRanges(core_style, core_ranges); + error = process_sp->CalculateCoreFileSaveRanges(options, core_ranges); if (error.Success()) { const uint32_t addr_byte_size = target_arch.GetAddressByteSize(); const ByteOrder byte_order = target_arch.GetByteOrder(); @@ -6730,8 +6733,8 @@ bool ObjectFileMachO::SaveCore(const lldb::ProcessSP &process_sp, std::make_shared<StructuredData::Dictionary>()); StructuredData::ArraySP threads( std::make_shared<StructuredData::Array>()); - for (uint32_t thread_idx = 0; thread_idx < num_threads; ++thread_idx) { - ThreadSP thread_sp(thread_list.GetThreadAtIndex(thread_idx)); + for (const ThreadSP &thread_sp : + process_sp->CalculateCoreFileThreadList(options)) { StructuredData::DictionarySP thread( std::make_shared<StructuredData::Dictionary>()); thread->AddIntegerItem("thread_id", thread_sp->GetID()); @@ -6754,7 +6757,7 @@ bool ObjectFileMachO::SaveCore(const lldb::ProcessSP &process_sp, all_image_infos_lcnote_up->payload_file_offset = file_offset; file_offset = CreateAllImageInfosPayload( process_sp, file_offset, all_image_infos_lcnote_up->payload, - core_style); + options); lc_notes.push_back(std::move(all_image_infos_lcnote_up)); // Add LC_NOTE load commands |