StackFrame.h revision a830adbcd63d1995a01e6e18da79893c1426ca43
1//===-- StackFrame.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_StackFrame_h_
11#define liblldb_StackFrame_h_
12
13// C Includes
14// C++ Includes
15// Other libraries and framework includes
16// Project includes
17#include "lldb/Core/Error.h"
18#include "lldb/Core/Flags.h"
19#include "lldb/Core/Scalar.h"
20#include "lldb/Core/StreamString.h"
21#include "lldb/Core/UserID.h"
22#include "lldb/Core/ValueObjectList.h"
23#include "lldb/Symbol/SymbolContext.h"
24#include "lldb/Target/ExecutionContextScope.h"
25#include "lldb/Target/StackID.h"
26
27namespace lldb_private {
28
29class StackFrame :
30    public ExecutionContextScope
31{
32public:
33    //------------------------------------------------------------------
34    // Constructors and Destructors
35    //------------------------------------------------------------------
36    StackFrame (lldb::user_id_t frame_idx,
37                lldb::user_id_t unwind_frame_idx,
38                Thread &thread,
39                lldb::addr_t cfa,
40                lldb::addr_t pc,
41                const SymbolContext *sc_ptr);
42
43    StackFrame (lldb::user_id_t frame_idx,
44                lldb::user_id_t unwind_frame_idx,
45                Thread &thread,
46                const lldb::RegisterContextSP &reg_context_sp,
47                lldb::addr_t cfa,
48                lldb::addr_t pc,
49                const SymbolContext *sc_ptr);
50
51    StackFrame (lldb::user_id_t frame_idx,
52                lldb::user_id_t unwind_frame_idx,
53                Thread &thread,
54                const lldb::RegisterContextSP &reg_context_sp,
55                lldb::addr_t cfa,
56                const Address& pc,
57                const SymbolContext *sc_ptr);
58
59    virtual ~StackFrame ();
60
61    Thread &
62    GetThread()
63    { return m_thread; }
64
65    const Thread &
66    GetThread() const
67    { return m_thread; }
68
69    StackID&
70    GetStackID();
71
72    Address&
73    GetFrameCodeAddress();
74
75    void
76    ChangePC (lldb::addr_t pc);
77
78    const SymbolContext&
79    GetSymbolContext (uint32_t resolve_scope);
80
81    bool
82    GetFrameBaseValue(Scalar &value, Error *error_ptr);
83
84    Block *
85    GetFrameBlock ();
86
87    RegisterContext *
88    GetRegisterContext ();
89
90    const lldb::RegisterContextSP &
91    GetRegisterContextSP () const
92    {
93        return m_reg_context_sp;
94    }
95
96    VariableList *
97    GetVariableList (bool get_file_globals);
98
99    bool
100    HasDebugInformation ();
101
102    const char *
103    Disassemble ();
104
105    void
106    DumpUsingSettingsFormat (Stream *strm);
107
108    void
109    Dump (Stream *strm, bool show_frame_index, bool show_fullpaths);
110
111    bool
112    IsInlined ();
113
114    uint32_t
115    GetFrameIndex () const
116    {
117        return m_frame_index;
118    }
119
120    uint32_t
121    GetUnwindFrameIndex () const
122    {
123        return m_unwind_frame_index;
124    }
125
126    lldb::ValueObjectSP
127    GetValueObjectForFrameVariable (const lldb::VariableSP &variable_sp);
128
129    lldb::ValueObjectSP
130    TrackGlobalVariable (const lldb::VariableSP &variable_sp);
131
132    //------------------------------------------------------------------
133    // lldb::ExecutionContextScope pure virtual functions
134    //------------------------------------------------------------------
135    virtual Target *
136    CalculateTarget ();
137
138    virtual Process *
139    CalculateProcess ();
140
141    virtual Thread *
142    CalculateThread ();
143
144    virtual StackFrame *
145    CalculateStackFrame ();
146
147    virtual void
148    CalculateExecutionContext (ExecutionContext &exe_ctx);
149
150    lldb::StackFrameSP
151    GetSP ();
152
153protected:
154    friend class StackFrameList;
155
156    void
157    SetSymbolContextScope (SymbolContextScope *symbol_scope);
158
159    void
160    UpdateCurrentFrameFromPreviousFrame (StackFrame &prev_frame);
161
162    void
163    UpdatePreviousFrameFromCurrentFrame (StackFrame &curr_frame);
164
165    bool
166    HasCachedData () const;
167private:
168    //------------------------------------------------------------------
169    // For StackFrame only
170    //------------------------------------------------------------------
171    Thread &m_thread;
172    uint32_t m_frame_index;
173    uint32_t m_unwind_frame_index;
174    lldb::RegisterContextSP m_reg_context_sp;
175    StackID m_id;
176    Address m_frame_code_addr;   // The frame code address (might not be the same as the actual PC for inlined frames) as a section/offset address
177    SymbolContext m_sc;
178    Flags m_flags;
179    Scalar m_frame_base;
180    Error m_frame_base_error;
181    lldb::VariableListSP m_variable_list_sp;
182    ValueObjectList m_variable_list_value_objects;  // Value objects for each variable in m_variable_list_sp
183    StreamString m_disassembly;
184    DISALLOW_COPY_AND_ASSIGN (StackFrame);
185};
186
187} // namespace lldb_private
188
189#endif  // liblldb_StackFrame_h_
190