]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - include/lldb/Target/StackFrameList.h
Vendor import of lldb trunk r290819:
[FreeBSD/FreeBSD.git] / include / lldb / Target / StackFrameList.h
1 //===-- StackFrameList.h ----------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef liblldb_StackFrameList_h_
11 #define liblldb_StackFrameList_h_
12
13 // C Includes
14 // C++ Includes
15 #include <memory>
16 #include <mutex>
17 #include <vector>
18
19 // Other libraries and framework includes
20 // Project includes
21 #include "lldb/Target/StackFrame.h"
22
23 namespace lldb_private {
24
25 class StackFrameList {
26 public:
27   //------------------------------------------------------------------
28   // Constructors and Destructors
29   //------------------------------------------------------------------
30   StackFrameList(Thread &thread, const lldb::StackFrameListSP &prev_frames_sp,
31                  bool show_inline_frames);
32
33   ~StackFrameList();
34
35   uint32_t GetNumFrames(bool can_create = true);
36
37   lldb::StackFrameSP GetFrameAtIndex(uint32_t idx);
38
39   lldb::StackFrameSP GetFrameWithConcreteFrameIndex(uint32_t unwind_idx);
40
41   lldb::StackFrameSP GetFrameWithStackID(const StackID &stack_id);
42
43   // Mark a stack frame as the current frame
44   uint32_t SetSelectedFrame(lldb_private::StackFrame *frame);
45
46   uint32_t GetSelectedFrameIndex() const;
47
48   // Mark a stack frame as the current frame using the frame index
49   bool SetSelectedFrameByIndex(uint32_t idx);
50
51   uint32_t GetVisibleStackFrameIndex(uint32_t idx) {
52     if (m_current_inlined_depth < UINT32_MAX)
53       return idx - m_current_inlined_depth;
54     else
55       return idx;
56   }
57
58   void CalculateCurrentInlinedDepth();
59
60   void SetDefaultFileAndLineToSelectedFrame();
61
62   void Clear();
63
64   void InvalidateFrames(uint32_t start_idx);
65
66   void Dump(Stream *s);
67
68   lldb::StackFrameSP
69   GetStackFrameSPForStackFramePtr(StackFrame *stack_frame_ptr);
70
71   size_t GetStatus(Stream &strm, uint32_t first_frame, uint32_t num_frames,
72                    bool show_frame_info, uint32_t num_frames_with_source,
73                    const char *frame_marker = nullptr);
74
75 protected:
76   friend class Thread;
77
78   bool SetFrameAtIndex(uint32_t idx, lldb::StackFrameSP &frame_sp);
79
80   static void Merge(std::unique_ptr<StackFrameList> &curr_ap,
81                     lldb::StackFrameListSP &prev_sp);
82
83   void GetFramesUpTo(uint32_t end_idx);
84
85   bool GetAllFramesFetched() { return m_concrete_frames_fetched == UINT32_MAX; }
86
87   void SetAllFramesFetched() { m_concrete_frames_fetched = UINT32_MAX; }
88
89   bool DecrementCurrentInlinedDepth();
90
91   void ResetCurrentInlinedDepth();
92
93   uint32_t GetCurrentInlinedDepth();
94
95   void SetCurrentInlinedDepth(uint32_t new_depth);
96
97   typedef std::vector<lldb::StackFrameSP> collection;
98   typedef collection::iterator iterator;
99   typedef collection::const_iterator const_iterator;
100
101   Thread &m_thread;
102   lldb::StackFrameListSP m_prev_frames_sp;
103   mutable std::recursive_mutex m_mutex;
104   collection m_frames;
105   uint32_t m_selected_frame_idx;
106   uint32_t m_concrete_frames_fetched;
107   uint32_t m_current_inlined_depth;
108   lldb::addr_t m_current_inlined_pc;
109   bool m_show_inlined_frames;
110
111 private:
112   DISALLOW_COPY_AND_ASSIGN(StackFrameList);
113 };
114
115 } // namespace lldb_private
116
117 #endif // liblldb_StackFrameList_h_