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