[Lldb-commits] [lldb] [LLDB][SBSaveCore] Implement a selectable threadlist for Core Options. (PR #100443)

Jacob Lalonde via lldb-commits lldb-commits at lists.llvm.org
Thu Jul 25 16:40:46 PDT 2024


================
@@ -46,8 +48,79 @@ SaveCoreOptions::GetOutputFile() const {
   return m_file;
 }
 
+Status SaveCoreOptions::SetProcess(lldb::ProcessSP process_sp) {
+  Status error;
+  if (!process_sp) {
+    ClearProcessSpecificData();
+    m_process_sp = std::nullopt;
+    return error;
+  }
+
+  if (!process_sp->IsValid()) {
+    error.SetErrorString("Cannot assign an invalid process.");
+    return error;
+  }
+
+  if (m_process_sp.has_value())
+    ClearProcessSpecificData();
+
+  m_process_sp = process_sp;
+  return error;
+}
+
+Status SaveCoreOptions::AddThread(lldb_private::Thread *thread) {
+  Status error;
+  if (!thread) {
+    error.SetErrorString("Thread is null");
+  }
+
+  if (!m_process_sp.has_value())
+    m_process_sp = thread->GetProcess();
+
+  if (m_process_sp.value() != thread->GetProcess()) {
+    error.SetErrorString("Cannot add thread from a different process.");
+    return error;
+  }
+
+  std::pair<lldb::tid_t, lldb::ThreadSP> tid_pair(thread->GetID(),
+                                                  thread->GetBackingThread());
+  m_threads_to_save.insert(tid_pair);
+  return error;
+}
+
+bool SaveCoreOptions::RemoveThread(lldb_private::Thread *thread) {
+  return thread && m_threads_to_save.erase(thread->GetID()) > 0;
+}
+
+bool SaveCoreOptions::ShouldSaveThread(lldb::tid_t tid) const {
----------------
Jlalond wrote:

I didn't call it `ThreadShouldBeSaved` I worded it more like a predicate `ShouldThreadBeSaved`. I like this more personally, but I'm not an expert in the codebase convention so please let me know if `ThreadShouldBeSaved` is more fitting

https://github.com/llvm/llvm-project/pull/100443


More information about the lldb-commits mailing list