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