[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 12:59:45 PST 2024


================
@@ -93,25 +94,37 @@ class StackFrameList {
                    bool show_frame_info, uint32_t num_frames_with_source,
                    bool show_unique = false, bool show_hidden = false,
                    const char *frame_marker = nullptr);
+                
+  /// Returns whether we have currently fetched all the frames of a stack.
+  bool WereAllFramesFetched() const;
 
 protected:
   friend class Thread;
   friend class ScriptedThread;
 
+  /// Use this API to build a stack frame list (used for scripted threads, for
+  /// instance.)  This API is not meant for StackFrameLists that have unwinders
+  /// and partake in lazy stack filling (using GetFramesUpTo).  Rather if you
+  /// are building StackFrameLists with this API, you should build the entire
+  /// list before making it available for use.
   bool SetFrameAtIndex(uint32_t idx, lldb::StackFrameSP &frame_sp);
 
-  /// Realizes frames up to (and including) end_idx (which can be greater than  
-  /// the actual number of frames.)  
+  /// Ensures that frames up to (and including) `end_idx` are realized in the
+  /// StackFrameList.  `end_idx` can be larger than the actual number of frames,
+  /// in which case all the frames will be fetched.  Acquires the writer end of
+  /// the list mutex.
   /// Returns true if the function was interrupted, false otherwise.
-  bool GetFramesUpTo(uint32_t end_idx, 
-      InterruptionControl allow_interrupt = AllowInterruption);
-
-  void GetOnlyConcreteFramesUpTo(uint32_t end_idx, Unwind &unwinder);
-
-  void SynthesizeTailCallFrames(StackFrame &next_frame);
-
-  bool GetAllFramesFetched() { return m_concrete_frames_fetched == UINT32_MAX; }
+  /// Callers should first check (under the shared mutex) whether we need to
+  /// fetch frames or not.
----------------
jimingham wrote:

The two uses of GetFramesUpTo figure out whether they can get what they need w/o adding new frames in different ways.  In general, I like that the immediate callers can figure out by their own lights whether they have the frames they need, and then only call GetFramesUpTo if you need to fetch more frames.  That seems clearer to me.

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


More information about the lldb-commits mailing list