aboutsummaryrefslogtreecommitdiff
path: root/include/lldb/Target/StackFrameList.h
blob: b2689d0391e9fd194456dc31e1162c799279c24a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
//===-- StackFrameList.h ----------------------------------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#ifndef liblldb_StackFrameList_h_
#define liblldb_StackFrameList_h_

// C Includes
// C++ Includes
#include <vector>

// Other libraries and framework includes
// Project includes
#include "lldb/Host/Mutex.h"
#include "lldb/Target/StackFrame.h"

namespace lldb_private {

class StackFrameList
{
public:
    //------------------------------------------------------------------
    // Constructors and Destructors
    //------------------------------------------------------------------
    StackFrameList (Thread &thread, 
                    const lldb::StackFrameListSP &prev_frames_sp,
                    bool show_inline_frames);

    ~StackFrameList();

    uint32_t
    GetNumFrames (bool can_create = true);
    
    lldb::StackFrameSP
    GetFrameAtIndex (uint32_t idx);

    lldb::StackFrameSP
    GetFrameWithConcreteFrameIndex (uint32_t unwind_idx);
    
    lldb::StackFrameSP
    GetFrameWithStackID (const StackID &stack_id);

    // Mark a stack frame as the current frame
    uint32_t
    SetSelectedFrame (lldb_private::StackFrame *frame);
    
    uint32_t
    GetSelectedFrameIndex () const;

    // Mark a stack frame as the current frame using the frame index
    bool
    SetSelectedFrameByIndex (uint32_t idx);
    
    uint32_t
    GetVisibleStackFrameIndex(uint32_t idx)
    {
        if (m_current_inlined_depth < UINT32_MAX)
            return idx - m_current_inlined_depth;
        else
            return idx;
    }
    
    void
    CalculateCurrentInlinedDepth ();
    
    void
    SetDefaultFileAndLineToSelectedFrame();

    void
    Clear ();

    void
    InvalidateFrames (uint32_t start_idx);
    
    void
    Dump (Stream *s);
    
    lldb::StackFrameSP
    GetStackFrameSPForStackFramePtr (StackFrame *stack_frame_ptr);

    size_t
    GetStatus (Stream &strm,
               uint32_t first_frame,
               uint32_t num_frames,
               bool show_frame_info,
               uint32_t num_frames_with_source);
    
protected:

    friend class Thread;

    bool
    SetFrameAtIndex (uint32_t idx, lldb::StackFrameSP &frame_sp);

    static void
    Merge (std::unique_ptr<StackFrameList>& curr_ap,
           lldb::StackFrameListSP& prev_sp);

    void
    GetFramesUpTo (uint32_t end_idx);
    
    bool
    GetAllFramesFetched()
    {
        return m_concrete_frames_fetched == UINT32_MAX;
    }
    
    void
    SetAllFramesFetched ()
    {
        m_concrete_frames_fetched = UINT32_MAX;
    }
    
    bool
    DecrementCurrentInlinedDepth ();
    
    void
    ResetCurrentInlinedDepth();

    uint32_t
    GetCurrentInlinedDepth ();
    
    void
    SetCurrentInlinedDepth (uint32_t new_depth);
    
    //------------------------------------------------------------------
    // Classes that inherit from StackFrameList can see and modify these
    //------------------------------------------------------------------
    typedef std::vector<lldb::StackFrameSP> collection;
    typedef collection::iterator iterator;
    typedef collection::const_iterator const_iterator;

    Thread &m_thread;
    lldb::StackFrameListSP m_prev_frames_sp;
    mutable Mutex m_mutex;
    collection m_frames;
    uint32_t m_selected_frame_idx;
    uint32_t m_concrete_frames_fetched;
    uint32_t m_current_inlined_depth;
    lldb::addr_t m_current_inlined_pc;
    bool m_show_inlined_frames;

private:
    //------------------------------------------------------------------
    // For StackFrameList only
    //------------------------------------------------------------------
    DISALLOW_COPY_AND_ASSIGN (StackFrameList);
};

} // namespace lldb_private

#endif  // liblldb_StackFrameList_h_