================
@@ -771,24 +809,38 @@ void StackFrameList::SelectMostRelevantFrame() {
     LLDB_LOG(log, "No relevant frame!");
 }
 
-uint32_t StackFrameList::GetSelectedFrameIndex(
-    SelectMostRelevant select_most_relevant) {
-  std::lock_guard<std::recursive_mutex> guard(m_mutex);
+uint32_t
+StackFrameList::GetSelectedFrameIndex(SelectMostRelevant select_most_relevant) 
{
   if (!m_selected_frame_idx && select_most_relevant)
     SelectMostRelevantFrame();
-  if (!m_selected_frame_idx) {
-    // If we aren't selecting the most relevant frame, and the selected frame
-    // isn't set, then don't force a selection here, just return 0.
-    if (!select_most_relevant)
-      return 0;
-    // If the inlined stack frame is set, then use that:
-    m_selected_frame_idx = 0;
+  { // Scope for lock guard
+    std::shared_lock<std::shared_mutex> guard(m_list_mutex);
+    if (!m_selected_frame_idx) {
+      // If we aren't selecting the most relevant frame, and the selected frame
+      // isn't set, then don't force a selection here, just return 0.
+      if (!select_most_relevant)
+        return 0;
+      // If the inlined stack frame is set, then use that:
+      m_selected_frame_idx = 0;
+    }
+    return *m_selected_frame_idx;
   }
-  return *m_selected_frame_idx;
 }
 
 uint32_t StackFrameList::SetSelectedFrame(lldb_private::StackFrame *frame) {
-  std::lock_guard<std::recursive_mutex> guard(m_mutex);
+  uint32_t result = 0;
+  {
+    std::shared_lock<std::shared_mutex> guard(m_list_mutex);
+    result = SetSelectedFrameNoLock(frame);
----------------
labath wrote:

A shared lock around a function called "Set" is very suspicious. What is this 
trying to protect?

https://github.com/llvm/llvm-project/pull/117252
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to