StackFrame.h revision e41494a9092e15192012a5e0a8a1ffd66c70b8bb
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    enum ExpressionPathOption
34    {
35        eExpressionPathOptionCheckPtrVsMember   = (1u << 0),
36        eExpressionPathOptionsNoFragileObjcIvar = (1u << 1),
37        eExpressionPathOptionsDynamicValue      = (1u << 2)
38    };
39    //------------------------------------------------------------------
40    // Constructors and Destructors
41    //------------------------------------------------------------------
42    StackFrame (lldb::user_id_t frame_idx,
43                lldb::user_id_t concrete_frame_idx,
44                Thread &thread,
45                lldb::addr_t cfa,
46                lldb::addr_t pc,
47                const SymbolContext *sc_ptr);
48
49    StackFrame (lldb::user_id_t frame_idx,
50                lldb::user_id_t concrete_frame_idx,
51                Thread &thread,
52                const lldb::RegisterContextSP &reg_context_sp,
53                lldb::addr_t cfa,
54                lldb::addr_t pc,
55                const SymbolContext *sc_ptr);
56
57    StackFrame (lldb::user_id_t frame_idx,
58                lldb::user_id_t concrete_frame_idx,
59                Thread &thread,
60                const lldb::RegisterContextSP &reg_context_sp,
61                lldb::addr_t cfa,
62                const Address& pc,
63                const SymbolContext *sc_ptr);
64
65    virtual ~StackFrame ();
66
67    Thread &
68    GetThread()
69    { return m_thread; }
70
71    const Thread &
72    GetThread() const
73    { return m_thread; }
74
75    StackID&
76    GetStackID();
77
78    Address&
79    GetFrameCodeAddress();
80
81    void
82    ChangePC (lldb::addr_t pc);
83
84    const SymbolContext&
85    GetSymbolContext (uint32_t resolve_scope);
86
87    bool
88    GetFrameBaseValue(Scalar &value, Error *error_ptr);
89
90    Block *
91    GetFrameBlock ();
92
93    lldb::RegisterContextSP
94    GetRegisterContext ();
95
96    const lldb::RegisterContextSP &
97    GetRegisterContextSP () const
98    {
99        return m_reg_context_sp;
100    }
101
102    VariableList *
103    GetVariableList (bool get_file_globals);
104
105    // See ExpressionPathOption enumeration for "options" values
106    lldb::ValueObjectSP
107    GetValueForVariableExpressionPath (const char *var_expr, uint32_t options, Error &error);
108
109    bool
110    HasDebugInformation ();
111
112    const char *
113    Disassemble ();
114
115    void
116    DumpUsingSettingsFormat (Stream *strm);
117
118    void
119    Dump (Stream *strm, bool show_frame_index, bool show_fullpaths);
120
121    bool
122    IsInlined ();
123
124    uint32_t
125    GetFrameIndex () const
126    {
127        return m_frame_index;
128    }
129
130    uint32_t
131    GetConcreteFrameIndex () const
132    {
133        return m_concrete_frame_index;
134    }
135
136    lldb::ValueObjectSP
137    GetValueObjectForFrameVariable (const lldb::VariableSP &variable_sp, bool use_dynamic);
138
139    lldb::ValueObjectSP
140    TrackGlobalVariable (const lldb::VariableSP &variable_sp, bool use_dynamic);
141
142    //------------------------------------------------------------------
143    // lldb::ExecutionContextScope pure virtual functions
144    //------------------------------------------------------------------
145    virtual Target *
146    CalculateTarget ();
147
148    virtual Process *
149    CalculateProcess ();
150
151    virtual Thread *
152    CalculateThread ();
153
154    virtual StackFrame *
155    CalculateStackFrame ();
156
157    virtual void
158    CalculateExecutionContext (ExecutionContext &exe_ctx);
159
160    lldb::StackFrameSP
161    GetSP ();
162
163protected:
164    friend class StackFrameList;
165
166    void
167    SetSymbolContextScope (SymbolContextScope *symbol_scope);
168
169    void
170    UpdateCurrentFrameFromPreviousFrame (StackFrame &prev_frame);
171
172    void
173    UpdatePreviousFrameFromCurrentFrame (StackFrame &curr_frame);
174
175    bool
176    HasCachedData () const;
177private:
178    //------------------------------------------------------------------
179    // For StackFrame only
180    //------------------------------------------------------------------
181    Thread &m_thread;
182    uint32_t m_frame_index;
183    uint32_t m_concrete_frame_index;
184    lldb::RegisterContextSP m_reg_context_sp;
185    StackID m_id;
186    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
187    SymbolContext m_sc;
188    Flags m_flags;
189    Scalar m_frame_base;
190    Error m_frame_base_error;
191    lldb::VariableListSP m_variable_list_sp;
192    ValueObjectList m_variable_list_value_objects;  // Value objects for each variable in m_variable_list_sp
193    StreamString m_disassembly;
194    DISALLOW_COPY_AND_ASSIGN (StackFrame);
195};
196
197} // namespace lldb_private
198
199#endif  // liblldb_StackFrame_h_
200