================ @@ -46,8 +48,83 @@ SaveCoreOptions::GetOutputFile() const { return m_file; } +Status SaveCoreOptions::SetProcess(lldb::ProcessSP process_sp) { + Status error; + if (!process_sp) { + ClearProcessSpecificData(); + m_process_sp.reset(); + return error; + } + + if (!process_sp->IsValid()) { + error.SetErrorString("Cannot assign an invalid process."); + return error; + } + + if (m_process_sp == process_sp) + return error; + + ClearProcessSpecificData(); + m_process_sp = process_sp; + return error; +} + +Status SaveCoreOptions::AddThread(lldb::ThreadSP thread_sp) { + Status error; + if (!thread_sp) { + error.SetErrorString("invalid thread"); + return error; + } + + if (m_process_sp) { + if (m_process_sp != thread_sp->GetProcess()) { + error.SetErrorString("Cannot add a thread from a different process."); + return error; + } + } else { + m_process_sp = thread_sp->GetProcess(); + } + + m_threads_to_save[thread_sp->GetID()]; ---------------- clayborg wrote:
This might insert a default constructed ThreadSP. If we need the ThreadSP as the value then this should be: ``` m_threads_to_save[thread_sp->GetID()] = thread_sp; ``` But seeing as you must have a test for this, I am guessing we don't need the thread SP and `m_threads_to_save` can switch to being: ``` std::set<lldb::tid_t> m_tids_to_save; ``` Then the code above becomes: ``` m_threads_to_save.insert(thread_sp->GetID()); ``` https://github.com/llvm/llvm-project/pull/100443 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits