[Lldb-commits] [lldb] Convert the StackFrameList mutex to a shared mutex. (PR #117252)
via lldb-commits
lldb-commits at lists.llvm.org
Tue Dec 10 13:08:17 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;
----------------
jimingham wrote:
I don't think that helps much. Of the current two uses, GetNumFrames doesn't return the frame of the index passed in, and GetFrameAtIndex has a fallback that would still require the shared lock.
https://github.com/llvm/llvm-project/pull/117252
More information about the lldb-commits
mailing list