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