1//===-- SBFrame.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 LLDB_SBFrame_h_
11#define LLDB_SBFrame_h_
12
13#include "lldb/API/SBDefines.h"
14#include "lldb/API/SBValueList.h"
15
16namespace lldb {
17
18class SBFrame
19{
20public:
21    SBFrame ();
22
23    SBFrame (const lldb::SBFrame &rhs);
24
25    const lldb::SBFrame &
26    operator =(const lldb::SBFrame &rhs);
27
28   ~SBFrame();
29
30    bool
31    IsEqual (const lldb::SBFrame &that) const;
32
33    bool
34    IsValid() const;
35
36    uint32_t
37    GetFrameID () const;
38
39    lldb::addr_t
40    GetPC () const;
41
42    bool
43    SetPC (lldb::addr_t new_pc);
44
45    lldb::addr_t
46    GetSP () const;
47
48    lldb::addr_t
49    GetFP () const;
50
51    lldb::SBAddress
52    GetPCAddress () const;
53
54    lldb::SBSymbolContext
55    GetSymbolContext (uint32_t resolve_scope) const;
56
57    lldb::SBModule
58    GetModule () const;
59
60    lldb::SBCompileUnit
61    GetCompileUnit () const;
62
63    lldb::SBFunction
64    GetFunction () const;
65
66    lldb::SBSymbol
67    GetSymbol () const;
68
69    /// Gets the deepest block that contains the frame PC.
70    ///
71    /// See also GetFrameBlock().
72    lldb::SBBlock
73    GetBlock () const;
74
75    /// Get the appropriate function name for this frame. Inlined functions in
76    /// LLDB are represented by Blocks that have inlined function information, so
77    /// just looking at the SBFunction or SBSymbol for a frame isn't enough.
78    /// This function will return the appriopriate function, symbol or inlined
79    /// function name for the frame.
80    ///
81    /// This function returns:
82    /// - the name of the inlined function (if there is one)
83    /// - the name of the concrete function (if there is one)
84    /// - the name of the symbol (if there is one)
85    /// - NULL
86    ///
87    /// See also IsInlined().
88    const char *
89    GetFunctionName();
90
91    /// Return true if this frame represents an inlined function.
92    ///
93    /// See also GetFunctionName().
94    bool
95    IsInlined();
96
97    /// The version that doesn't supply a 'use_dynamic' value will use the
98    /// target's default.
99    lldb::SBValue
100    EvaluateExpression (const char *expr);
101
102    lldb::SBValue
103    EvaluateExpression (const char *expr, lldb::DynamicValueType use_dynamic);
104
105    lldb::SBValue
106    EvaluateExpression (const char *expr, lldb::DynamicValueType use_dynamic, bool unwind_on_error);
107
108    lldb::SBValue
109    EvaluateExpression (const char *expr, const SBExpressionOptions &options);
110
111    /// Gets the lexical block that defines the stack frame. Another way to think
112    /// of this is it will return the block that contains all of the variables
113    /// for a stack frame. Inlined functions are represented as SBBlock objects
114    /// that have inlined function information: the name of the inlined function,
115    /// where it was called from. The block that is returned will be the first
116    /// block at or above the block for the PC (SBFrame::GetBlock()) that defines
117    /// the scope of the frame. When a function contains no inlined functions,
118    /// this will be the top most lexical block that defines the function.
119    /// When a function has inlined functions and the PC is currently
120    /// in one of those inlined functions, this method will return the inlined
121    /// block that defines this frame. If the PC isn't currently in an inlined
122    /// function, the lexical block that defines the function is returned.
123    lldb::SBBlock
124    GetFrameBlock () const;
125
126    lldb::SBLineEntry
127    GetLineEntry () const;
128
129    lldb::SBThread
130    GetThread () const;
131
132    const char *
133    Disassemble () const;
134
135    void
136    Clear();
137
138    bool
139    operator == (const lldb::SBFrame &rhs) const;
140
141    bool
142    operator != (const lldb::SBFrame &rhs) const;
143
144    /// The version that doesn't supply a 'use_dynamic' value will use the
145    /// target's default.
146    lldb::SBValueList
147    GetVariables (bool arguments,
148                  bool locals,
149                  bool statics,
150                  bool in_scope_only);
151
152    lldb::SBValueList
153    GetVariables (bool arguments,
154                  bool locals,
155                  bool statics,
156                  bool in_scope_only,
157                  lldb::DynamicValueType  use_dynamic);
158
159    lldb::SBValueList
160    GetRegisters ();
161
162    lldb::SBValue
163    FindRegister (const char *name);
164
165    /// The version that doesn't supply a 'use_dynamic' value will use the
166    /// target's default.
167    lldb::SBValue
168    FindVariable (const char *var_name);
169
170    lldb::SBValue
171    FindVariable (const char *var_name, lldb::DynamicValueType use_dynamic);
172
173    // Find a value for a variable expression path like "rect.origin.x" or
174    // "pt_ptr->x", "*self", "*this->obj_ptr". The returned value is _not_
175    // and expression result and is not a constant object like
176    // SBFrame::EvaluateExpression(...) returns, but a child object of
177    // the variable value.
178    lldb::SBValue
179    GetValueForVariablePath (const char *var_expr_cstr,
180                             DynamicValueType use_dynamic);
181
182    /// The version that doesn't supply a 'use_dynamic' value will use the
183    /// target's default.
184    lldb::SBValue
185    GetValueForVariablePath (const char *var_path);
186
187    /// Find variables, register sets, registers, or persistent variables using
188    /// the frame as the scope.
189    ///
190    /// NB. This function does not look up ivars in the function object pointer.
191    /// To do that use GetValueForVariablePath.
192    ///
193    /// The version that doesn't supply a 'use_dynamic' value will use the
194    /// target's default.
195    lldb::SBValue
196    FindValue (const char *name, ValueType value_type);
197
198    lldb::SBValue
199    FindValue (const char *name, ValueType value_type, lldb::DynamicValueType use_dynamic);
200
201    /// Find and watch a variable using the frame as the scope.
202    /// It returns an SBValue, similar to FindValue() method, if find-and-watch
203    /// operation succeeds.  Otherwise, an invalid SBValue is returned.
204    /// You can use LLDB_WATCH_TYPE_READ | LLDB_WATCH_TYPE_WRITE for 'rw' watch.
205    lldb::SBValue
206    WatchValue (const char *name, ValueType value_type, uint32_t watch_type);
207
208    /// Find and watch the location pointed to by a variable using the frame as
209    /// the scope.
210    /// It returns an SBValue, similar to FindValue() method, if find-and-watch
211    /// operation succeeds.  Otherwise, an invalid SBValue is returned.
212    /// You can use LLDB_WATCH_TYPE_READ | LLDB_WATCH_TYPE_WRITE for 'rw' watch.
213    lldb::SBValue
214    WatchLocation (const char *name, ValueType value_type, uint32_t watch_type, size_t size);
215
216    bool
217    GetDescription (lldb::SBStream &description);
218
219    SBFrame (const lldb::StackFrameSP &lldb_object_sp);
220
221protected:
222
223    friend class SBBlock;
224    friend class SBInstruction;
225    friend class SBThread;
226    friend class SBValue;
227#ifndef LLDB_DISABLE_PYTHON
228    friend class lldb_private::ScriptInterpreterPython;
229#endif
230
231    lldb::StackFrameSP
232    GetFrameSP() const;
233
234    void
235    SetFrameSP (const lldb::StackFrameSP &lldb_object_sp);
236
237    lldb::ExecutionContextRefSP m_opaque_sp;
238};
239
240} // namespace lldb
241
242#endif  // LLDB_SBFrame_h_
243