[Lldb-commits] [lldb] Convert the StackFrameList mutex to a shared mutex. (PR #117252)
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Tue Dec 10 07:54:27 PST 2024
================
@@ -578,58 +607,36 @@ void StackFrameList::Dump(Stream *s) {
StackFrameSP StackFrameList::GetFrameAtIndex(uint32_t idx) {
StackFrameSP frame_sp;
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
uint32_t original_idx = idx;
- uint32_t inlined_depth = GetCurrentInlinedDepth();
- if (inlined_depth != UINT32_MAX)
- idx += inlined_depth;
+ // We're going to consult the m_frames.size, but if there are already
+ // enough frames for our request we don't want to block other readers, so
+ // first acquire the shared lock:
+ { // Scope for shared lock:
+ std::shared_lock<std::shared_mutex> guard(m_list_mutex);
+
+ uint32_t inlined_depth = GetCurrentInlinedDepth();
+ if (inlined_depth != UINT32_MAX)
+ idx += inlined_depth;
- if (idx < m_frames.size())
- frame_sp = m_frames[idx];
+ if (idx < m_frames.size())
+ frame_sp = m_frames[idx];
- if (frame_sp)
- return frame_sp;
+ if (frame_sp)
+ return frame_sp;
----------------
labath wrote:
(optional, idea) If `GetFramesUpTo` somehow returned the frame at the given index then there wouldn't be a need for this block here. I'm thinking about this in conjunction with my other suggestion to have a read-locked fastpath in `GetFramesUpTo`.
https://github.com/llvm/llvm-project/pull/117252
More information about the lldb-commits
mailing list