]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Target/StackFrameList.h
Import to 0.6.1
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / 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 <vector>
17
18 // Other libraries and framework includes
19 // Project includes
20 #include "lldb/Host/Mutex.h"
21 #include "lldb/Target/StackFrame.h"
22
23 namespace lldb_private {
24
25 class StackFrameList
26 {
27 public:
28     //------------------------------------------------------------------
29     // Constructors and Destructors
30     //------------------------------------------------------------------
31     StackFrameList (Thread &thread, 
32                     const lldb::StackFrameListSP &prev_frames_sp,
33                     bool show_inline_frames);
34
35     ~StackFrameList();
36
37     uint32_t
38     GetNumFrames (bool can_create = true);
39     
40     lldb::StackFrameSP
41     GetFrameAtIndex (uint32_t idx);
42
43     lldb::StackFrameSP
44     GetFrameWithConcreteFrameIndex (uint32_t unwind_idx);
45     
46     lldb::StackFrameSP
47     GetFrameWithStackID (const StackID &stack_id);
48
49     // Mark a stack frame as the current frame
50     uint32_t
51     SetSelectedFrame (lldb_private::StackFrame *frame);
52     
53     uint32_t
54     GetSelectedFrameIndex () const;
55
56     // Mark a stack frame as the current frame using the frame index
57     bool
58     SetSelectedFrameByIndex (uint32_t idx);
59     
60     uint32_t
61     GetVisibleStackFrameIndex(uint32_t idx)
62     {
63         if (m_current_inlined_depth < UINT32_MAX)
64             return idx - m_current_inlined_depth;
65         else
66             return idx;
67     }
68     
69     void
70     CalculateCurrentInlinedDepth ();
71     
72     void
73     SetDefaultFileAndLineToSelectedFrame();
74
75     void
76     Clear ();
77
78     void
79     InvalidateFrames (uint32_t start_idx);
80     
81     void
82     Dump (Stream *s);
83     
84     lldb::StackFrameSP
85     GetStackFrameSPForStackFramePtr (StackFrame *stack_frame_ptr);
86
87     size_t
88     GetStatus(Stream &strm,
89               uint32_t first_frame,
90               uint32_t num_frames,
91               bool show_frame_info,
92               uint32_t num_frames_with_source,
93               const char *frame_marker = nullptr);
94     
95 protected:
96     friend class Thread;
97
98     bool
99     SetFrameAtIndex (uint32_t idx, lldb::StackFrameSP &frame_sp);
100
101     static void
102     Merge (std::unique_ptr<StackFrameList>& curr_ap,
103            lldb::StackFrameListSP& prev_sp);
104
105     void
106     GetFramesUpTo (uint32_t end_idx);
107     
108     bool
109     GetAllFramesFetched()
110     {
111         return m_concrete_frames_fetched == UINT32_MAX;
112     }
113     
114     void
115     SetAllFramesFetched ()
116     {
117         m_concrete_frames_fetched = UINT32_MAX;
118     }
119     
120     bool
121     DecrementCurrentInlinedDepth ();
122     
123     void
124     ResetCurrentInlinedDepth();
125
126     uint32_t
127     GetCurrentInlinedDepth ();
128     
129     void
130     SetCurrentInlinedDepth (uint32_t new_depth);
131     
132     typedef std::vector<lldb::StackFrameSP> collection;
133     typedef collection::iterator iterator;
134     typedef collection::const_iterator const_iterator;
135
136     Thread &m_thread;
137     lldb::StackFrameListSP m_prev_frames_sp;
138     mutable Mutex m_mutex;
139     collection m_frames;
140     uint32_t m_selected_frame_idx;
141     uint32_t m_concrete_frames_fetched;
142     uint32_t m_current_inlined_depth;
143     lldb::addr_t m_current_inlined_pc;
144     bool m_show_inlined_frames;
145
146 private:
147     DISALLOW_COPY_AND_ASSIGN (StackFrameList);
148 };
149
150 } // namespace lldb_private
151
152 #endif // liblldb_StackFrameList_h_