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

Greg Clayton via lldb-commits lldb-commits at lists.llvm.org
Thu Aug 1 23:03:51 PDT 2024


================
@@ -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


More information about the lldb-commits mailing list