Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1 | //===-- StackFrame.cpp ------------------------------------------*- 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 | #include "lldb/Target/StackFrame.h" |
| 11 | |
| 12 | // C Includes |
| 13 | // C++ Includes |
| 14 | // Other libraries and framework includes |
| 15 | // Project includes |
| 16 | #include "lldb/Core/Module.h" |
Greg Clayton | a830adb | 2010-10-04 01:05:56 +0000 | [diff] [blame] | 17 | #include "lldb/Core/Debugger.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 18 | #include "lldb/Core/Disassembler.h" |
| 19 | #include "lldb/Core/Value.h" |
Greg Clayton | 17dae08 | 2010-09-02 02:59:18 +0000 | [diff] [blame] | 20 | #include "lldb/Core/ValueObjectVariable.h" |
Greg Clayton | c3b61d2 | 2010-12-15 05:08:08 +0000 | [diff] [blame] | 21 | #include "lldb/Core/ValueObjectConstResult.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 22 | #include "lldb/Symbol/Function.h" |
Greg Clayton | 17dae08 | 2010-09-02 02:59:18 +0000 | [diff] [blame] | 23 | #include "lldb/Symbol/VariableList.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 24 | #include "lldb/Target/ExecutionContext.h" |
| 25 | #include "lldb/Target/Process.h" |
| 26 | #include "lldb/Target/RegisterContext.h" |
| 27 | #include "lldb/Target/Target.h" |
| 28 | #include "lldb/Target/Thread.h" |
| 29 | |
| 30 | using namespace lldb; |
| 31 | using namespace lldb_private; |
| 32 | |
| 33 | // The first bits in the flags are reserved for the SymbolContext::Scope bits |
| 34 | // so we know if we have tried to look up information in our internal symbol |
| 35 | // context (m_sc) already. |
Greg Clayton | 4fb0815 | 2010-08-30 18:11:35 +0000 | [diff] [blame] | 36 | #define RESOLVED_FRAME_CODE_ADDR (uint32_t(eSymbolContextEverything + 1)) |
Greg Clayton | 72b7158 | 2010-09-02 21:44:10 +0000 | [diff] [blame] | 37 | #define RESOLVED_FRAME_ID_SYMBOL_SCOPE (RESOLVED_FRAME_CODE_ADDR << 1) |
Greg Clayton | 4fb0815 | 2010-08-30 18:11:35 +0000 | [diff] [blame] | 38 | #define GOT_FRAME_BASE (RESOLVED_FRAME_ID_SYMBOL_SCOPE << 1) |
| 39 | #define RESOLVED_VARIABLES (GOT_FRAME_BASE << 1) |
Sean Callanan | 8936359 | 2010-11-01 04:38:59 +0000 | [diff] [blame] | 40 | #define RESOLVED_GLOBAL_VARIABLES (RESOLVED_VARIABLES << 1) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 41 | |
Greg Clayton | 33ed170 | 2010-08-24 00:45:41 +0000 | [diff] [blame] | 42 | StackFrame::StackFrame |
| 43 | ( |
| 44 | lldb::user_id_t frame_idx, |
Greg Clayton | 4fb0815 | 2010-08-30 18:11:35 +0000 | [diff] [blame] | 45 | lldb::user_id_t unwind_frame_index, |
Greg Clayton | 33ed170 | 2010-08-24 00:45:41 +0000 | [diff] [blame] | 46 | Thread &thread, |
| 47 | lldb::addr_t cfa, |
Greg Clayton | 33ed170 | 2010-08-24 00:45:41 +0000 | [diff] [blame] | 48 | lldb::addr_t pc, |
| 49 | const SymbolContext *sc_ptr |
| 50 | ) : |
Greg Clayton | bdcb6ab | 2011-01-25 23:55:37 +0000 | [diff] [blame] | 51 | m_thread (thread), |
Greg Clayton | 33ed170 | 2010-08-24 00:45:41 +0000 | [diff] [blame] | 52 | m_frame_index (frame_idx), |
Greg Clayton | 08d7d3a | 2011-01-06 22:15:06 +0000 | [diff] [blame] | 53 | m_concrete_frame_index (unwind_frame_index), |
Greg Clayton | 33ed170 | 2010-08-24 00:45:41 +0000 | [diff] [blame] | 54 | m_reg_context_sp (), |
Greg Clayton | 72b7158 | 2010-09-02 21:44:10 +0000 | [diff] [blame] | 55 | m_id (pc, cfa, NULL), |
Greg Clayton | 65124ea | 2010-08-26 22:05:43 +0000 | [diff] [blame] | 56 | m_frame_code_addr (NULL, pc), |
Greg Clayton | 33ed170 | 2010-08-24 00:45:41 +0000 | [diff] [blame] | 57 | m_sc (), |
| 58 | m_flags (), |
| 59 | m_frame_base (), |
| 60 | m_frame_base_error (), |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 61 | m_variable_list_sp (), |
Greg Clayton | bdcb6ab | 2011-01-25 23:55:37 +0000 | [diff] [blame] | 62 | m_variable_list_value_objects (), |
| 63 | m_disassembly () |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 64 | { |
| 65 | if (sc_ptr != NULL) |
Greg Clayton | 33ed170 | 2010-08-24 00:45:41 +0000 | [diff] [blame] | 66 | { |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 67 | m_sc = *sc_ptr; |
Greg Clayton | 33ed170 | 2010-08-24 00:45:41 +0000 | [diff] [blame] | 68 | m_flags.Set(m_sc.GetResolvedMask ()); |
| 69 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 70 | } |
| 71 | |
Greg Clayton | 33ed170 | 2010-08-24 00:45:41 +0000 | [diff] [blame] | 72 | StackFrame::StackFrame |
| 73 | ( |
| 74 | lldb::user_id_t frame_idx, |
Greg Clayton | 4fb0815 | 2010-08-30 18:11:35 +0000 | [diff] [blame] | 75 | lldb::user_id_t unwind_frame_index, |
Greg Clayton | 33ed170 | 2010-08-24 00:45:41 +0000 | [diff] [blame] | 76 | Thread &thread, |
| 77 | const RegisterContextSP ®_context_sp, |
| 78 | lldb::addr_t cfa, |
Greg Clayton | 33ed170 | 2010-08-24 00:45:41 +0000 | [diff] [blame] | 79 | lldb::addr_t pc, |
| 80 | const SymbolContext *sc_ptr |
| 81 | ) : |
Greg Clayton | bdcb6ab | 2011-01-25 23:55:37 +0000 | [diff] [blame] | 82 | m_thread (thread), |
Greg Clayton | 33ed170 | 2010-08-24 00:45:41 +0000 | [diff] [blame] | 83 | m_frame_index (frame_idx), |
Greg Clayton | 08d7d3a | 2011-01-06 22:15:06 +0000 | [diff] [blame] | 84 | m_concrete_frame_index (unwind_frame_index), |
Greg Clayton | 33ed170 | 2010-08-24 00:45:41 +0000 | [diff] [blame] | 85 | m_reg_context_sp (reg_context_sp), |
Greg Clayton | 72b7158 | 2010-09-02 21:44:10 +0000 | [diff] [blame] | 86 | m_id (pc, cfa, NULL), |
Greg Clayton | 65124ea | 2010-08-26 22:05:43 +0000 | [diff] [blame] | 87 | m_frame_code_addr (NULL, pc), |
Greg Clayton | 33ed170 | 2010-08-24 00:45:41 +0000 | [diff] [blame] | 88 | m_sc (), |
| 89 | m_flags (), |
| 90 | m_frame_base (), |
| 91 | m_frame_base_error (), |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 92 | m_variable_list_sp (), |
Greg Clayton | bdcb6ab | 2011-01-25 23:55:37 +0000 | [diff] [blame] | 93 | m_variable_list_value_objects (), |
| 94 | m_disassembly () |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 95 | { |
| 96 | if (sc_ptr != NULL) |
Greg Clayton | 33ed170 | 2010-08-24 00:45:41 +0000 | [diff] [blame] | 97 | { |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 98 | m_sc = *sc_ptr; |
Greg Clayton | 33ed170 | 2010-08-24 00:45:41 +0000 | [diff] [blame] | 99 | m_flags.Set(m_sc.GetResolvedMask ()); |
| 100 | } |
| 101 | |
| 102 | if (reg_context_sp && !m_sc.target_sp) |
| 103 | { |
| 104 | m_sc.target_sp = reg_context_sp->GetThread().GetProcess().GetTarget().GetSP(); |
| 105 | m_flags.Set (eSymbolContextTarget); |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | StackFrame::StackFrame |
| 110 | ( |
| 111 | lldb::user_id_t frame_idx, |
Greg Clayton | 4fb0815 | 2010-08-30 18:11:35 +0000 | [diff] [blame] | 112 | lldb::user_id_t unwind_frame_index, |
Greg Clayton | 33ed170 | 2010-08-24 00:45:41 +0000 | [diff] [blame] | 113 | Thread &thread, |
| 114 | const RegisterContextSP ®_context_sp, |
| 115 | lldb::addr_t cfa, |
Greg Clayton | 33ed170 | 2010-08-24 00:45:41 +0000 | [diff] [blame] | 116 | const Address& pc_addr, |
| 117 | const SymbolContext *sc_ptr |
| 118 | ) : |
Greg Clayton | bdcb6ab | 2011-01-25 23:55:37 +0000 | [diff] [blame] | 119 | m_thread (thread), |
Greg Clayton | 33ed170 | 2010-08-24 00:45:41 +0000 | [diff] [blame] | 120 | m_frame_index (frame_idx), |
Greg Clayton | 08d7d3a | 2011-01-06 22:15:06 +0000 | [diff] [blame] | 121 | m_concrete_frame_index (unwind_frame_index), |
Greg Clayton | 33ed170 | 2010-08-24 00:45:41 +0000 | [diff] [blame] | 122 | m_reg_context_sp (reg_context_sp), |
Greg Clayton | eea2640 | 2010-09-14 23:36:40 +0000 | [diff] [blame] | 123 | m_id (pc_addr.GetLoadAddress (&thread.GetProcess().GetTarget()), cfa, NULL), |
Greg Clayton | 65124ea | 2010-08-26 22:05:43 +0000 | [diff] [blame] | 124 | m_frame_code_addr (pc_addr), |
Greg Clayton | 33ed170 | 2010-08-24 00:45:41 +0000 | [diff] [blame] | 125 | m_sc (), |
| 126 | m_flags (), |
| 127 | m_frame_base (), |
| 128 | m_frame_base_error (), |
| 129 | m_variable_list_sp (), |
Greg Clayton | bdcb6ab | 2011-01-25 23:55:37 +0000 | [diff] [blame] | 130 | m_variable_list_value_objects (), |
| 131 | m_disassembly () |
Greg Clayton | 33ed170 | 2010-08-24 00:45:41 +0000 | [diff] [blame] | 132 | { |
| 133 | if (sc_ptr != NULL) |
| 134 | { |
| 135 | m_sc = *sc_ptr; |
| 136 | m_flags.Set(m_sc.GetResolvedMask ()); |
| 137 | } |
| 138 | |
| 139 | if (m_sc.target_sp.get() == NULL && reg_context_sp) |
| 140 | { |
| 141 | m_sc.target_sp = reg_context_sp->GetThread().GetProcess().GetTarget().GetSP(); |
| 142 | m_flags.Set (eSymbolContextTarget); |
| 143 | } |
| 144 | |
Greg Clayton | e2c5e45 | 2010-09-13 04:34:30 +0000 | [diff] [blame] | 145 | Module *pc_module = pc_addr.GetModule(); |
| 146 | if (m_sc.module_sp.get() == NULL || m_sc.module_sp.get() != pc_module) |
Greg Clayton | 33ed170 | 2010-08-24 00:45:41 +0000 | [diff] [blame] | 147 | { |
Greg Clayton | 33ed170 | 2010-08-24 00:45:41 +0000 | [diff] [blame] | 148 | if (pc_module) |
| 149 | { |
| 150 | m_sc.module_sp = pc_module->GetSP(); |
| 151 | m_flags.Set (eSymbolContextModule); |
| 152 | } |
Greg Clayton | e2c5e45 | 2010-09-13 04:34:30 +0000 | [diff] [blame] | 153 | else |
| 154 | { |
| 155 | m_sc.module_sp.reset(); |
| 156 | } |
| 157 | |
Greg Clayton | 33ed170 | 2010-08-24 00:45:41 +0000 | [diff] [blame] | 158 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 159 | } |
| 160 | |
| 161 | |
| 162 | //---------------------------------------------------------------------- |
| 163 | // Destructor |
| 164 | //---------------------------------------------------------------------- |
| 165 | StackFrame::~StackFrame() |
| 166 | { |
| 167 | } |
| 168 | |
| 169 | StackID& |
| 170 | StackFrame::GetStackID() |
| 171 | { |
Greg Clayton | 72b7158 | 2010-09-02 21:44:10 +0000 | [diff] [blame] | 172 | // Make sure we have resolved the StackID object's symbol context scope if |
| 173 | // we already haven't looked it up. |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 174 | |
Greg Clayton | 4fb0815 | 2010-08-30 18:11:35 +0000 | [diff] [blame] | 175 | if (m_flags.IsClear (RESOLVED_FRAME_ID_SYMBOL_SCOPE)) |
| 176 | { |
Greg Clayton | 5205f0b | 2010-09-03 17:10:42 +0000 | [diff] [blame] | 177 | if (m_id.GetSymbolContextScope ()) |
Greg Clayton | 4fb0815 | 2010-08-30 18:11:35 +0000 | [diff] [blame] | 178 | { |
Greg Clayton | 69aa5d9 | 2010-09-07 04:20:48 +0000 | [diff] [blame] | 179 | // We already have a symbol context scope, we just don't have our |
| 180 | // flag bit set. |
Greg Clayton | 4fb0815 | 2010-08-30 18:11:35 +0000 | [diff] [blame] | 181 | m_flags.Set (RESOLVED_FRAME_ID_SYMBOL_SCOPE); |
| 182 | } |
| 183 | else |
| 184 | { |
Greg Clayton | 69aa5d9 | 2010-09-07 04:20:48 +0000 | [diff] [blame] | 185 | // Calculate the frame block and use this for the stack ID symbol |
| 186 | // context scope if we have one. |
| 187 | SymbolContextScope *scope = GetFrameBlock (); |
| 188 | if (scope == NULL) |
Greg Clayton | 4fb0815 | 2010-08-30 18:11:35 +0000 | [diff] [blame] | 189 | { |
Greg Clayton | 69aa5d9 | 2010-09-07 04:20:48 +0000 | [diff] [blame] | 190 | // We don't have a block, so use the symbol |
| 191 | if (m_flags.IsClear (eSymbolContextSymbol)) |
| 192 | GetSymbolContext (eSymbolContextSymbol); |
| 193 | |
| 194 | // It is ok if m_sc.symbol is NULL here |
| 195 | scope = m_sc.symbol; |
Greg Clayton | 4fb0815 | 2010-08-30 18:11:35 +0000 | [diff] [blame] | 196 | } |
Greg Clayton | 69aa5d9 | 2010-09-07 04:20:48 +0000 | [diff] [blame] | 197 | // Set the symbol context scope (the accessor will set the |
| 198 | // RESOLVED_FRAME_ID_SYMBOL_SCOPE bit in m_flags). |
| 199 | SetSymbolContextScope (scope); |
Greg Clayton | 4fb0815 | 2010-08-30 18:11:35 +0000 | [diff] [blame] | 200 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 201 | } |
| 202 | return m_id; |
| 203 | } |
| 204 | |
Greg Clayton | 4fb0815 | 2010-08-30 18:11:35 +0000 | [diff] [blame] | 205 | void |
| 206 | StackFrame::SetSymbolContextScope (SymbolContextScope *symbol_scope) |
| 207 | { |
| 208 | m_flags.Set (RESOLVED_FRAME_ID_SYMBOL_SCOPE); |
| 209 | m_id.SetSymbolContextScope (symbol_scope); |
| 210 | } |
| 211 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 212 | Address& |
Greg Clayton | b04e7a8 | 2010-08-24 21:05:24 +0000 | [diff] [blame] | 213 | StackFrame::GetFrameCodeAddress() |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 214 | { |
Greg Clayton | 4fb0815 | 2010-08-30 18:11:35 +0000 | [diff] [blame] | 215 | if (m_flags.IsClear(RESOLVED_FRAME_CODE_ADDR) && !m_frame_code_addr.IsSectionOffset()) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 216 | { |
Greg Clayton | 4fb0815 | 2010-08-30 18:11:35 +0000 | [diff] [blame] | 217 | m_flags.Set (RESOLVED_FRAME_CODE_ADDR); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 218 | |
| 219 | // Resolve the PC into a temporary address because if ResolveLoadAddress |
| 220 | // fails to resolve the address, it will clear the address object... |
| 221 | Address resolved_pc; |
Greg Clayton | eea2640 | 2010-09-14 23:36:40 +0000 | [diff] [blame] | 222 | if (m_thread.GetProcess().GetTarget().GetSectionLoadList().ResolveLoadAddress(m_frame_code_addr.GetOffset(), resolved_pc)) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 223 | { |
Greg Clayton | 65124ea | 2010-08-26 22:05:43 +0000 | [diff] [blame] | 224 | m_frame_code_addr = resolved_pc; |
| 225 | const Section *section = m_frame_code_addr.GetSection(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 226 | if (section) |
| 227 | { |
| 228 | Module *module = section->GetModule(); |
| 229 | if (module) |
| 230 | { |
| 231 | m_sc.module_sp = module->GetSP(); |
| 232 | if (m_sc.module_sp) |
| 233 | m_flags.Set(eSymbolContextModule); |
| 234 | } |
| 235 | } |
| 236 | } |
| 237 | } |
Greg Clayton | 65124ea | 2010-08-26 22:05:43 +0000 | [diff] [blame] | 238 | return m_frame_code_addr; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 239 | } |
| 240 | |
| 241 | void |
| 242 | StackFrame::ChangePC (addr_t pc) |
| 243 | { |
Greg Clayton | 65124ea | 2010-08-26 22:05:43 +0000 | [diff] [blame] | 244 | m_frame_code_addr.SetOffset(pc); |
| 245 | m_frame_code_addr.SetSection(NULL); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 246 | m_sc.Clear(); |
Greg Clayton | f3d0b0c | 2010-10-27 03:32:59 +0000 | [diff] [blame] | 247 | m_flags.Reset(0); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 248 | m_thread.ClearStackFrames (); |
| 249 | } |
| 250 | |
| 251 | const char * |
| 252 | StackFrame::Disassemble () |
| 253 | { |
| 254 | if (m_disassembly.GetSize() == 0) |
| 255 | { |
| 256 | ExecutionContext exe_ctx; |
Greg Clayton | a830adb | 2010-10-04 01:05:56 +0000 | [diff] [blame] | 257 | CalculateExecutionContext(exe_ctx); |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 258 | Target &target = m_thread.GetProcess().GetTarget(); |
| 259 | Disassembler::Disassemble (target.GetDebugger(), |
| 260 | target.GetArchitecture(), |
Greg Clayton | 149731c | 2011-03-25 18:03:16 +0000 | [diff] [blame] | 261 | NULL, |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 262 | exe_ctx, |
| 263 | 0, |
Jim Ingham | aa3e3e1 | 2011-03-22 01:48:42 +0000 | [diff] [blame] | 264 | 0, |
Greg Clayton | 7043635 | 2010-06-30 23:03:03 +0000 | [diff] [blame] | 265 | false, |
Sean Callanan | a846cc3 | 2011-03-10 23:35:12 +0000 | [diff] [blame] | 266 | false, |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 267 | m_disassembly); |
| 268 | if (m_disassembly.GetSize() == 0) |
| 269 | return NULL; |
| 270 | } |
| 271 | return m_disassembly.GetData(); |
| 272 | } |
| 273 | |
Greg Clayton | 69aa5d9 | 2010-09-07 04:20:48 +0000 | [diff] [blame] | 274 | Block * |
| 275 | StackFrame::GetFrameBlock () |
| 276 | { |
| 277 | if (m_sc.block == NULL && m_flags.IsClear (eSymbolContextBlock)) |
| 278 | GetSymbolContext (eSymbolContextBlock); |
| 279 | |
| 280 | if (m_sc.block) |
| 281 | { |
| 282 | Block *inline_block = m_sc.block->GetContainingInlinedBlock(); |
| 283 | if (inline_block) |
| 284 | { |
| 285 | // Use the block with the inlined function info |
| 286 | // as the frame block we want this frame to have only the variables |
| 287 | // for the inlined function and its non-inlined block child blocks. |
| 288 | return inline_block; |
| 289 | } |
| 290 | else |
| 291 | { |
| 292 | // This block is not contained withing any inlined function blocks |
| 293 | // with so we want to use the top most function block. |
| 294 | return &m_sc.function->GetBlock (false); |
| 295 | } |
| 296 | } |
| 297 | return NULL; |
| 298 | } |
| 299 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 300 | //---------------------------------------------------------------------- |
| 301 | // Get the symbol context if we already haven't done so by resolving the |
| 302 | // PC address as much as possible. This way when we pass around a |
| 303 | // StackFrame object, everyone will have as much information as |
| 304 | // possible and no one will ever have to look things up manually. |
| 305 | //---------------------------------------------------------------------- |
| 306 | const SymbolContext& |
| 307 | StackFrame::GetSymbolContext (uint32_t resolve_scope) |
| 308 | { |
| 309 | // Copy our internal symbol context into "sc". |
Greg Clayton | f3d0b0c | 2010-10-27 03:32:59 +0000 | [diff] [blame] | 310 | if ((m_flags.Get() & resolve_scope) != resolve_scope) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 311 | { |
| 312 | // Resolve our PC to section offset if we haven't alreday done so |
| 313 | // and if we don't have a module. The resolved address section will |
| 314 | // contain the module to which it belongs |
Greg Clayton | 4fb0815 | 2010-08-30 18:11:35 +0000 | [diff] [blame] | 315 | if (!m_sc.module_sp && m_flags.IsClear(RESOLVED_FRAME_CODE_ADDR)) |
Greg Clayton | b04e7a8 | 2010-08-24 21:05:24 +0000 | [diff] [blame] | 316 | GetFrameCodeAddress(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 317 | |
| 318 | // If this is not frame zero, then we need to subtract 1 from the PC |
| 319 | // value when doing address lookups since the PC will be on the |
| 320 | // instruction following the function call instruction... |
| 321 | |
Greg Clayton | b04e7a8 | 2010-08-24 21:05:24 +0000 | [diff] [blame] | 322 | Address lookup_addr(GetFrameCodeAddress()); |
Greg Clayton | 33ed170 | 2010-08-24 00:45:41 +0000 | [diff] [blame] | 323 | if (m_frame_index > 0 && lookup_addr.IsValid()) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 324 | { |
| 325 | addr_t offset = lookup_addr.GetOffset(); |
| 326 | if (offset > 0) |
| 327 | lookup_addr.SetOffset(offset - 1); |
| 328 | } |
| 329 | |
Greg Clayton | b04e7a8 | 2010-08-24 21:05:24 +0000 | [diff] [blame] | 330 | |
| 331 | uint32_t resolved = 0; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 332 | if (m_sc.module_sp) |
| 333 | { |
| 334 | // We have something in our stack frame symbol context, lets check |
| 335 | // if we haven't already tried to lookup one of those things. If we |
| 336 | // haven't then we will do the query. |
Greg Clayton | 33ed170 | 2010-08-24 00:45:41 +0000 | [diff] [blame] | 337 | |
| 338 | uint32_t actual_resolve_scope = 0; |
| 339 | |
| 340 | if (resolve_scope & eSymbolContextCompUnit) |
| 341 | { |
| 342 | if (m_flags.IsClear (eSymbolContextCompUnit)) |
| 343 | { |
| 344 | if (m_sc.comp_unit) |
Greg Clayton | b04e7a8 | 2010-08-24 21:05:24 +0000 | [diff] [blame] | 345 | resolved |= eSymbolContextCompUnit; |
Greg Clayton | 33ed170 | 2010-08-24 00:45:41 +0000 | [diff] [blame] | 346 | else |
| 347 | actual_resolve_scope |= eSymbolContextCompUnit; |
| 348 | } |
| 349 | } |
| 350 | |
| 351 | if (resolve_scope & eSymbolContextFunction) |
| 352 | { |
| 353 | if (m_flags.IsClear (eSymbolContextFunction)) |
| 354 | { |
| 355 | if (m_sc.function) |
Greg Clayton | b04e7a8 | 2010-08-24 21:05:24 +0000 | [diff] [blame] | 356 | resolved |= eSymbolContextFunction; |
Greg Clayton | 33ed170 | 2010-08-24 00:45:41 +0000 | [diff] [blame] | 357 | else |
| 358 | actual_resolve_scope |= eSymbolContextFunction; |
| 359 | } |
| 360 | } |
| 361 | |
| 362 | if (resolve_scope & eSymbolContextBlock) |
| 363 | { |
| 364 | if (m_flags.IsClear (eSymbolContextBlock)) |
| 365 | { |
| 366 | if (m_sc.block) |
Greg Clayton | b04e7a8 | 2010-08-24 21:05:24 +0000 | [diff] [blame] | 367 | resolved |= eSymbolContextBlock; |
Greg Clayton | 33ed170 | 2010-08-24 00:45:41 +0000 | [diff] [blame] | 368 | else |
| 369 | actual_resolve_scope |= eSymbolContextBlock; |
| 370 | } |
| 371 | } |
| 372 | |
| 373 | if (resolve_scope & eSymbolContextSymbol) |
| 374 | { |
| 375 | if (m_flags.IsClear (eSymbolContextSymbol)) |
| 376 | { |
| 377 | if (m_sc.symbol) |
Greg Clayton | b04e7a8 | 2010-08-24 21:05:24 +0000 | [diff] [blame] | 378 | resolved |= eSymbolContextSymbol; |
Greg Clayton | 33ed170 | 2010-08-24 00:45:41 +0000 | [diff] [blame] | 379 | else |
| 380 | actual_resolve_scope |= eSymbolContextSymbol; |
| 381 | } |
| 382 | } |
| 383 | |
| 384 | if (resolve_scope & eSymbolContextLineEntry) |
| 385 | { |
| 386 | if (m_flags.IsClear (eSymbolContextLineEntry)) |
| 387 | { |
| 388 | if (m_sc.line_entry.IsValid()) |
Greg Clayton | b04e7a8 | 2010-08-24 21:05:24 +0000 | [diff] [blame] | 389 | resolved |= eSymbolContextLineEntry; |
Greg Clayton | 33ed170 | 2010-08-24 00:45:41 +0000 | [diff] [blame] | 390 | else |
| 391 | actual_resolve_scope |= eSymbolContextLineEntry; |
| 392 | } |
| 393 | } |
| 394 | |
| 395 | if (actual_resolve_scope) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 396 | { |
| 397 | // We might be resolving less information than what is already |
| 398 | // in our current symbol context so resolve into a temporary |
| 399 | // symbol context "sc" so we don't clear out data we have |
| 400 | // already found in "m_sc" |
| 401 | SymbolContext sc; |
| 402 | // Set flags that indicate what we have tried to resolve |
Greg Clayton | b04e7a8 | 2010-08-24 21:05:24 +0000 | [diff] [blame] | 403 | resolved |= m_sc.module_sp->ResolveSymbolContextForAddress (lookup_addr, actual_resolve_scope, sc); |
Greg Clayton | 33ed170 | 2010-08-24 00:45:41 +0000 | [diff] [blame] | 404 | // Only replace what we didn't already have as we may have |
| 405 | // information for an inlined function scope that won't match |
| 406 | // what a standard lookup by address would match |
Greg Clayton | b04e7a8 | 2010-08-24 21:05:24 +0000 | [diff] [blame] | 407 | if ((resolved & eSymbolContextCompUnit) && m_sc.comp_unit == NULL) |
| 408 | m_sc.comp_unit = sc.comp_unit; |
| 409 | if ((resolved & eSymbolContextFunction) && m_sc.function == NULL) |
| 410 | m_sc.function = sc.function; |
| 411 | if ((resolved & eSymbolContextBlock) && m_sc.block == NULL) |
| 412 | m_sc.block = sc.block; |
| 413 | if ((resolved & eSymbolContextSymbol) && m_sc.symbol == NULL) |
| 414 | m_sc.symbol = sc.symbol; |
| 415 | if ((resolved & eSymbolContextLineEntry) && !m_sc.line_entry.IsValid()) |
| 416 | m_sc.line_entry = sc.line_entry; |
| 417 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 418 | } |
| 419 | } |
| 420 | else |
| 421 | { |
| 422 | // If we don't have a module, then we can't have the compile unit, |
| 423 | // function, block, line entry or symbol, so we can safely call |
| 424 | // ResolveSymbolContextForAddress with our symbol context member m_sc. |
Greg Clayton | b04e7a8 | 2010-08-24 21:05:24 +0000 | [diff] [blame] | 425 | resolved |= m_thread.GetProcess().GetTarget().GetImages().ResolveSymbolContextForAddress (lookup_addr, resolve_scope, m_sc); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 426 | } |
| 427 | |
| 428 | // If the target was requested add that: |
| 429 | if (m_sc.target_sp.get() == NULL) |
Greg Clayton | b04e7a8 | 2010-08-24 21:05:24 +0000 | [diff] [blame] | 430 | { |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 431 | m_sc.target_sp = CalculateProcess()->GetTarget().GetSP(); |
Greg Clayton | b04e7a8 | 2010-08-24 21:05:24 +0000 | [diff] [blame] | 432 | if (m_sc.target_sp) |
| 433 | resolved |= eSymbolContextTarget; |
| 434 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 435 | |
| 436 | // Update our internal flags so we remember what we have tried to locate so |
| 437 | // we don't have to keep trying when more calls to this function are made. |
Greg Clayton | b04e7a8 | 2010-08-24 21:05:24 +0000 | [diff] [blame] | 438 | // We might have dug up more information that was requested (for example |
| 439 | // if we were asked to only get the block, we will have gotten the |
| 440 | // compile unit, and function) so set any additional bits that we resolved |
| 441 | m_flags.Set (resolve_scope | resolved); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 442 | } |
| 443 | |
| 444 | // Return the symbol context with everything that was possible to resolve |
| 445 | // resolved. |
| 446 | return m_sc; |
| 447 | } |
| 448 | |
| 449 | |
| 450 | VariableList * |
Greg Clayton | 17dae08 | 2010-09-02 02:59:18 +0000 | [diff] [blame] | 451 | StackFrame::GetVariableList (bool get_file_globals) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 452 | { |
| 453 | if (m_flags.IsClear(RESOLVED_VARIABLES)) |
| 454 | { |
| 455 | m_flags.Set(RESOLVED_VARIABLES); |
| 456 | |
Greg Clayton | 69aa5d9 | 2010-09-07 04:20:48 +0000 | [diff] [blame] | 457 | Block *frame_block = GetFrameBlock(); |
| 458 | |
| 459 | if (frame_block) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 460 | { |
Greg Clayton | 69aa5d9 | 2010-09-07 04:20:48 +0000 | [diff] [blame] | 461 | const bool get_child_variables = true; |
| 462 | const bool can_create = true; |
| 463 | m_variable_list_sp = frame_block->GetVariableList (get_child_variables, can_create); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 464 | } |
Sean Callanan | 8936359 | 2010-11-01 04:38:59 +0000 | [diff] [blame] | 465 | } |
| 466 | |
| 467 | if (m_flags.IsClear(RESOLVED_GLOBAL_VARIABLES) && |
| 468 | get_file_globals) |
| 469 | { |
| 470 | m_flags.Set(RESOLVED_GLOBAL_VARIABLES); |
Greg Clayton | 17dae08 | 2010-09-02 02:59:18 +0000 | [diff] [blame] | 471 | |
Sean Callanan | 8936359 | 2010-11-01 04:38:59 +0000 | [diff] [blame] | 472 | if (m_flags.IsClear (eSymbolContextCompUnit)) |
| 473 | GetSymbolContext (eSymbolContextCompUnit); |
| 474 | |
| 475 | if (m_sc.comp_unit) |
Greg Clayton | 17dae08 | 2010-09-02 02:59:18 +0000 | [diff] [blame] | 476 | { |
Sean Callanan | 8936359 | 2010-11-01 04:38:59 +0000 | [diff] [blame] | 477 | VariableListSP global_variable_list_sp (m_sc.comp_unit->GetVariableList(true)); |
| 478 | if (m_variable_list_sp) |
| 479 | m_variable_list_sp->AddVariables (global_variable_list_sp.get()); |
| 480 | else |
| 481 | m_variable_list_sp = global_variable_list_sp; |
Greg Clayton | 17dae08 | 2010-09-02 02:59:18 +0000 | [diff] [blame] | 482 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 483 | } |
Sean Callanan | 8936359 | 2010-11-01 04:38:59 +0000 | [diff] [blame] | 484 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 485 | return m_variable_list_sp.get(); |
| 486 | } |
| 487 | |
Greg Clayton | 427f290 | 2010-12-14 02:59:59 +0000 | [diff] [blame] | 488 | ValueObjectSP |
Greg Clayton | c67efa4 | 2011-01-20 19:27:18 +0000 | [diff] [blame] | 489 | StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr, uint32_t options, Error &error) |
Greg Clayton | 427f290 | 2010-12-14 02:59:59 +0000 | [diff] [blame] | 490 | { |
Greg Clayton | c3b61d2 | 2010-12-15 05:08:08 +0000 | [diff] [blame] | 491 | |
| 492 | if (var_expr_cstr && var_expr_cstr[0]) |
Greg Clayton | 427f290 | 2010-12-14 02:59:59 +0000 | [diff] [blame] | 493 | { |
Greg Clayton | c67efa4 | 2011-01-20 19:27:18 +0000 | [diff] [blame] | 494 | const bool check_ptr_vs_member = (options & eExpressionPathOptionCheckPtrVsMember) != 0; |
| 495 | const bool no_fragile_ivar = (options & eExpressionPathOptionsNoFragileObjcIvar) != 0; |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 496 | const bool dynamic_value = (options & eExpressionPathOptionsDynamicValue) != 0; |
Greg Clayton | c3b61d2 | 2010-12-15 05:08:08 +0000 | [diff] [blame] | 497 | error.Clear(); |
| 498 | bool deref = false; |
| 499 | bool address_of = false; |
| 500 | ValueObjectSP valobj_sp; |
| 501 | const bool get_file_globals = true; |
| 502 | VariableList *variable_list = GetVariableList (get_file_globals); |
| 503 | |
| 504 | if (variable_list) |
Greg Clayton | 427f290 | 2010-12-14 02:59:59 +0000 | [diff] [blame] | 505 | { |
Greg Clayton | c3b61d2 | 2010-12-15 05:08:08 +0000 | [diff] [blame] | 506 | // If first character is a '*', then show pointer contents |
| 507 | const char *var_expr = var_expr_cstr; |
| 508 | if (var_expr[0] == '*') |
Greg Clayton | 427f290 | 2010-12-14 02:59:59 +0000 | [diff] [blame] | 509 | { |
Greg Clayton | c3b61d2 | 2010-12-15 05:08:08 +0000 | [diff] [blame] | 510 | deref = true; |
| 511 | var_expr++; // Skip the '*' |
| 512 | } |
| 513 | else if (var_expr[0] == '&') |
| 514 | { |
| 515 | address_of = true; |
| 516 | var_expr++; // Skip the '&' |
| 517 | } |
| 518 | |
| 519 | std::string var_path (var_expr); |
| 520 | size_t separator_idx = var_path.find_first_of(".-[=+~|&^%#@!/?,<>{}"); |
| 521 | StreamString var_expr_path_strm; |
| 522 | |
| 523 | ConstString name_const_string; |
| 524 | if (separator_idx == std::string::npos) |
| 525 | name_const_string.SetCString (var_path.c_str()); |
| 526 | else |
| 527 | name_const_string.SetCStringWithLength (var_path.c_str(), separator_idx); |
| 528 | |
| 529 | VariableSP var_sp (variable_list->FindVariable(name_const_string)); |
| 530 | if (var_sp) |
| 531 | { |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 532 | valobj_sp = GetValueObjectForFrameVariable (var_sp, dynamic_value); |
| 533 | if (!valobj_sp) |
| 534 | return valobj_sp; |
| 535 | |
Greg Clayton | c3b61d2 | 2010-12-15 05:08:08 +0000 | [diff] [blame] | 536 | var_path.erase (0, name_const_string.GetLength ()); |
| 537 | // We are dumping at least one child |
| 538 | while (separator_idx != std::string::npos) |
Greg Clayton | 427f290 | 2010-12-14 02:59:59 +0000 | [diff] [blame] | 539 | { |
Greg Clayton | c3b61d2 | 2010-12-15 05:08:08 +0000 | [diff] [blame] | 540 | // Calculate the next separator index ahead of time |
| 541 | ValueObjectSP child_valobj_sp; |
| 542 | const char separator_type = var_path[0]; |
| 543 | switch (separator_type) |
Greg Clayton | 427f290 | 2010-12-14 02:59:59 +0000 | [diff] [blame] | 544 | { |
Greg Clayton | c3b61d2 | 2010-12-15 05:08:08 +0000 | [diff] [blame] | 545 | |
| 546 | case '-': |
| 547 | if (var_path.size() >= 2 && var_path[1] != '>') |
Greg Clayton | 427f290 | 2010-12-14 02:59:59 +0000 | [diff] [blame] | 548 | return ValueObjectSP(); |
Greg Clayton | 427f290 | 2010-12-14 02:59:59 +0000 | [diff] [blame] | 549 | |
Greg Clayton | c67efa4 | 2011-01-20 19:27:18 +0000 | [diff] [blame] | 550 | if (no_fragile_ivar) |
| 551 | { |
| 552 | // Make sure we aren't trying to deref an objective |
| 553 | // C ivar if this is not allowed |
| 554 | const uint32_t pointer_type_flags = ClangASTContext::GetTypeInfo (valobj_sp->GetClangType(), NULL, NULL); |
| 555 | if ((pointer_type_flags & ClangASTContext::eTypeIsObjC) && |
| 556 | (pointer_type_flags & ClangASTContext::eTypeIsPointer)) |
| 557 | { |
| 558 | // This was an objective C object pointer and |
| 559 | // it was requested we skip any fragile ivars |
| 560 | // so return nothing here |
| 561 | return ValueObjectSP(); |
| 562 | } |
| 563 | } |
Greg Clayton | c3b61d2 | 2010-12-15 05:08:08 +0000 | [diff] [blame] | 564 | var_path.erase (0, 1); // Remove the '-' |
| 565 | // Fall through |
| 566 | case '.': |
Greg Clayton | 427f290 | 2010-12-14 02:59:59 +0000 | [diff] [blame] | 567 | { |
Greg Clayton | c3b61d2 | 2010-12-15 05:08:08 +0000 | [diff] [blame] | 568 | const bool expr_is_ptr = var_path[0] == '>'; |
Greg Clayton | 427f290 | 2010-12-14 02:59:59 +0000 | [diff] [blame] | 569 | |
Greg Clayton | c3b61d2 | 2010-12-15 05:08:08 +0000 | [diff] [blame] | 570 | var_path.erase (0, 1); // Remove the '.' or '>' |
| 571 | separator_idx = var_path.find_first_of(".-["); |
| 572 | ConstString child_name; |
| 573 | if (separator_idx == std::string::npos) |
| 574 | child_name.SetCString (var_path.c_str()); |
Greg Clayton | 427f290 | 2010-12-14 02:59:59 +0000 | [diff] [blame] | 575 | else |
Greg Clayton | c3b61d2 | 2010-12-15 05:08:08 +0000 | [diff] [blame] | 576 | child_name.SetCStringWithLength(var_path.c_str(), separator_idx); |
| 577 | |
| 578 | if (check_ptr_vs_member) |
Greg Clayton | 427f290 | 2010-12-14 02:59:59 +0000 | [diff] [blame] | 579 | { |
Greg Clayton | c3b61d2 | 2010-12-15 05:08:08 +0000 | [diff] [blame] | 580 | // We either have a pointer type and need to verify |
| 581 | // valobj_sp is a pointer, or we have a member of a |
| 582 | // class/union/struct being accessed with the . syntax |
| 583 | // and need to verify we don't have a pointer. |
| 584 | const bool actual_is_ptr = valobj_sp->IsPointerType (); |
| 585 | |
| 586 | if (actual_is_ptr != expr_is_ptr) |
| 587 | { |
| 588 | // Incorrect use of "." with a pointer, or "->" with |
| 589 | // a class/union/struct instance or reference. |
Greg Clayton | b01000f | 2011-01-17 03:46:26 +0000 | [diff] [blame] | 590 | valobj_sp->GetExpressionPath (var_expr_path_strm, false); |
Greg Clayton | c3b61d2 | 2010-12-15 05:08:08 +0000 | [diff] [blame] | 591 | if (actual_is_ptr) |
| 592 | error.SetErrorStringWithFormat ("\"%s\" is a pointer and . was used to attempt to access \"%s\". Did you mean \"%s->%s\"?", |
| 593 | var_expr_path_strm.GetString().c_str(), |
| 594 | child_name.GetCString(), |
| 595 | var_expr_path_strm.GetString().c_str(), |
| 596 | var_path.c_str()); |
| 597 | else |
| 598 | error.SetErrorStringWithFormat ("\"%s\" is not a pointer and -> was used to attempt to access \"%s\". Did you mean \"%s.%s\"?", |
| 599 | var_expr_path_strm.GetString().c_str(), |
| 600 | child_name.GetCString(), |
| 601 | var_expr_path_strm.GetString().c_str(), |
| 602 | var_path.c_str()); |
| 603 | return ValueObjectSP(); |
| 604 | } |
Greg Clayton | 427f290 | 2010-12-14 02:59:59 +0000 | [diff] [blame] | 605 | } |
Greg Clayton | c3b61d2 | 2010-12-15 05:08:08 +0000 | [diff] [blame] | 606 | child_valobj_sp = valobj_sp->GetChildMemberWithName (child_name, true); |
Greg Clayton | 427f290 | 2010-12-14 02:59:59 +0000 | [diff] [blame] | 607 | if (!child_valobj_sp) |
| 608 | { |
Greg Clayton | c3b61d2 | 2010-12-15 05:08:08 +0000 | [diff] [blame] | 609 | // No child member with name "child_name" |
Greg Clayton | b01000f | 2011-01-17 03:46:26 +0000 | [diff] [blame] | 610 | valobj_sp->GetExpressionPath (var_expr_path_strm, false); |
Greg Clayton | c3b61d2 | 2010-12-15 05:08:08 +0000 | [diff] [blame] | 611 | if (child_name) |
| 612 | { |
| 613 | error.SetErrorStringWithFormat ("\"%s\" is not a member of \"(%s) %s\"", |
| 614 | child_name.GetCString(), |
| 615 | valobj_sp->GetTypeName().AsCString("<invalid type>"), |
| 616 | var_expr_path_strm.GetString().c_str()); |
| 617 | } |
| 618 | else |
| 619 | { |
| 620 | error.SetErrorStringWithFormat ("incomplete expression path after \"%s\" in \"%s\"", |
| 621 | var_expr_path_strm.GetString().c_str(), |
| 622 | var_expr_cstr); |
| 623 | } |
| 624 | |
Greg Clayton | 427f290 | 2010-12-14 02:59:59 +0000 | [diff] [blame] | 625 | return ValueObjectSP(); |
| 626 | } |
Greg Clayton | c3b61d2 | 2010-12-15 05:08:08 +0000 | [diff] [blame] | 627 | // Remove the child name from the path |
| 628 | var_path.erase(0, child_name.GetLength()); |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 629 | if (dynamic_value) |
| 630 | { |
| 631 | ValueObjectSP dynamic_value_sp(child_valobj_sp->GetDynamicValue(true, child_valobj_sp)); |
| 632 | if (dynamic_value_sp) |
| 633 | child_valobj_sp = dynamic_value_sp; |
| 634 | } |
Greg Clayton | c3b61d2 | 2010-12-15 05:08:08 +0000 | [diff] [blame] | 635 | } |
| 636 | break; |
Greg Clayton | 427f290 | 2010-12-14 02:59:59 +0000 | [diff] [blame] | 637 | |
Greg Clayton | c3b61d2 | 2010-12-15 05:08:08 +0000 | [diff] [blame] | 638 | case '[': |
| 639 | // Array member access, or treating pointer as an array |
| 640 | if (var_path.size() > 2) // Need at least two brackets and a number |
| 641 | { |
| 642 | char *end = NULL; |
Greg Clayton | bdcb6ab | 2011-01-25 23:55:37 +0000 | [diff] [blame] | 643 | long child_index = ::strtol (&var_path[1], &end, 0); |
Greg Clayton | c3b61d2 | 2010-12-15 05:08:08 +0000 | [diff] [blame] | 644 | if (end && *end == ']') |
| 645 | { |
Greg Clayton | 427f290 | 2010-12-14 02:59:59 +0000 | [diff] [blame] | 646 | |
Greg Clayton | c3b61d2 | 2010-12-15 05:08:08 +0000 | [diff] [blame] | 647 | if (valobj_sp->IsPointerType ()) |
| 648 | { |
| 649 | child_valobj_sp = valobj_sp->GetSyntheticArrayMemberFromPointer (child_index, true); |
| 650 | if (!child_valobj_sp) |
| 651 | { |
Greg Clayton | b01000f | 2011-01-17 03:46:26 +0000 | [diff] [blame] | 652 | valobj_sp->GetExpressionPath (var_expr_path_strm, false); |
Greg Clayton | c3b61d2 | 2010-12-15 05:08:08 +0000 | [diff] [blame] | 653 | error.SetErrorStringWithFormat ("failed to use pointer as array for index %i for \"(%s) %s\"", |
| 654 | child_index, |
| 655 | valobj_sp->GetTypeName().AsCString("<invalid type>"), |
| 656 | var_expr_path_strm.GetString().c_str()); |
| 657 | } |
| 658 | } |
| 659 | else if (ClangASTContext::IsArrayType (valobj_sp->GetClangType(), NULL, NULL)) |
| 660 | { |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 661 | // Pass false to dynamic_value here so we can tell the difference between |
| 662 | // no dynamic value and no member of this type... |
Greg Clayton | c3b61d2 | 2010-12-15 05:08:08 +0000 | [diff] [blame] | 663 | child_valobj_sp = valobj_sp->GetChildAtIndex (child_index, true); |
| 664 | if (!child_valobj_sp) |
| 665 | { |
Greg Clayton | b01000f | 2011-01-17 03:46:26 +0000 | [diff] [blame] | 666 | valobj_sp->GetExpressionPath (var_expr_path_strm, false); |
Greg Clayton | c3b61d2 | 2010-12-15 05:08:08 +0000 | [diff] [blame] | 667 | error.SetErrorStringWithFormat ("array index %i is not valid for \"(%s) %s\"", |
| 668 | child_index, |
| 669 | valobj_sp->GetTypeName().AsCString("<invalid type>"), |
| 670 | var_expr_path_strm.GetString().c_str()); |
| 671 | } |
| 672 | } |
| 673 | else |
| 674 | { |
Greg Clayton | b01000f | 2011-01-17 03:46:26 +0000 | [diff] [blame] | 675 | valobj_sp->GetExpressionPath (var_expr_path_strm, false); |
Greg Clayton | c3b61d2 | 2010-12-15 05:08:08 +0000 | [diff] [blame] | 676 | error.SetErrorStringWithFormat ("\"(%s) %s\" is not an array type", |
| 677 | valobj_sp->GetTypeName().AsCString("<invalid type>"), |
| 678 | var_expr_path_strm.GetString().c_str()); |
| 679 | } |
| 680 | |
| 681 | if (!child_valobj_sp) |
| 682 | { |
| 683 | // Invalid array index... |
| 684 | return ValueObjectSP(); |
| 685 | } |
| 686 | |
| 687 | // Erase the array member specification '[%i]' where |
| 688 | // %i is the array index |
| 689 | var_path.erase(0, (end - var_path.c_str()) + 1); |
| 690 | separator_idx = var_path.find_first_of(".-["); |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 691 | if (dynamic_value) |
| 692 | { |
| 693 | ValueObjectSP dynamic_value_sp(child_valobj_sp->GetDynamicValue(true, child_valobj_sp)); |
| 694 | if (dynamic_value_sp) |
| 695 | child_valobj_sp = dynamic_value_sp; |
| 696 | } |
Greg Clayton | c3b61d2 | 2010-12-15 05:08:08 +0000 | [diff] [blame] | 697 | // Break out early from the switch since we were |
| 698 | // able to find the child member |
| 699 | break; |
| 700 | } |
| 701 | } |
| 702 | return ValueObjectSP(); |
| 703 | |
| 704 | default: |
| 705 | // Failure... |
| 706 | { |
Greg Clayton | b01000f | 2011-01-17 03:46:26 +0000 | [diff] [blame] | 707 | valobj_sp->GetExpressionPath (var_expr_path_strm, false); |
Greg Clayton | c3b61d2 | 2010-12-15 05:08:08 +0000 | [diff] [blame] | 708 | error.SetErrorStringWithFormat ("unexpected char '%c' encountered after \"%s\" in \"%s\"", |
| 709 | separator_type, |
| 710 | var_expr_path_strm.GetString().c_str(), |
| 711 | var_path.c_str()); |
| 712 | |
| 713 | return ValueObjectSP(); |
Greg Clayton | 427f290 | 2010-12-14 02:59:59 +0000 | [diff] [blame] | 714 | } |
| 715 | } |
Greg Clayton | 427f290 | 2010-12-14 02:59:59 +0000 | [diff] [blame] | 716 | |
Greg Clayton | c3b61d2 | 2010-12-15 05:08:08 +0000 | [diff] [blame] | 717 | if (child_valobj_sp) |
| 718 | valobj_sp = child_valobj_sp; |
| 719 | |
| 720 | if (var_path.empty()) |
| 721 | break; |
| 722 | |
Greg Clayton | 427f290 | 2010-12-14 02:59:59 +0000 | [diff] [blame] | 723 | } |
Greg Clayton | c3b61d2 | 2010-12-15 05:08:08 +0000 | [diff] [blame] | 724 | if (valobj_sp) |
| 725 | { |
| 726 | if (deref) |
| 727 | { |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 728 | ValueObjectSP deref_valobj_sp (valobj_sp->Dereference(error)); |
Greg Clayton | c3b61d2 | 2010-12-15 05:08:08 +0000 | [diff] [blame] | 729 | valobj_sp = deref_valobj_sp; |
| 730 | } |
| 731 | else if (address_of) |
| 732 | { |
| 733 | ValueObjectSP address_of_valobj_sp (valobj_sp->AddressOf(error)); |
| 734 | valobj_sp = address_of_valobj_sp; |
| 735 | } |
| 736 | } |
| 737 | return valobj_sp; |
Greg Clayton | 427f290 | 2010-12-14 02:59:59 +0000 | [diff] [blame] | 738 | } |
Greg Clayton | c3b61d2 | 2010-12-15 05:08:08 +0000 | [diff] [blame] | 739 | else |
Greg Clayton | 427f290 | 2010-12-14 02:59:59 +0000 | [diff] [blame] | 740 | { |
Greg Clayton | c3b61d2 | 2010-12-15 05:08:08 +0000 | [diff] [blame] | 741 | error.SetErrorStringWithFormat("no variable named '%s' found in this frame", name_const_string.GetCString()); |
Greg Clayton | 427f290 | 2010-12-14 02:59:59 +0000 | [diff] [blame] | 742 | } |
Greg Clayton | 427f290 | 2010-12-14 02:59:59 +0000 | [diff] [blame] | 743 | } |
| 744 | } |
Greg Clayton | c3b61d2 | 2010-12-15 05:08:08 +0000 | [diff] [blame] | 745 | else |
| 746 | { |
| 747 | error.SetErrorStringWithFormat("invalid variable path '%s'", var_expr_cstr); |
| 748 | } |
Greg Clayton | 427f290 | 2010-12-14 02:59:59 +0000 | [diff] [blame] | 749 | return ValueObjectSP(); |
| 750 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 751 | |
| 752 | bool |
| 753 | StackFrame::GetFrameBaseValue (Scalar &frame_base, Error *error_ptr) |
| 754 | { |
| 755 | if (m_flags.IsClear(GOT_FRAME_BASE)) |
| 756 | { |
| 757 | if (m_sc.function) |
| 758 | { |
| 759 | m_frame_base.Clear(); |
| 760 | m_frame_base_error.Clear(); |
| 761 | |
| 762 | m_flags.Set(GOT_FRAME_BASE); |
| 763 | ExecutionContext exe_ctx (&m_thread.GetProcess(), &m_thread, this); |
| 764 | Value expr_value; |
Greg Clayton | 178710c | 2010-09-14 02:20:48 +0000 | [diff] [blame] | 765 | addr_t loclist_base_addr = LLDB_INVALID_ADDRESS; |
| 766 | if (m_sc.function->GetFrameBaseExpression().IsLocationList()) |
Greg Clayton | eea2640 | 2010-09-14 23:36:40 +0000 | [diff] [blame] | 767 | loclist_base_addr = m_sc.function->GetAddressRange().GetBaseAddress().GetLoadAddress (&m_thread.GetProcess().GetTarget()); |
Greg Clayton | 178710c | 2010-09-14 02:20:48 +0000 | [diff] [blame] | 768 | |
Greg Clayton | bdcb6ab | 2011-01-25 23:55:37 +0000 | [diff] [blame] | 769 | if (m_sc.function->GetFrameBaseExpression().Evaluate(&exe_ctx, NULL, NULL, NULL, NULL, loclist_base_addr, NULL, expr_value, &m_frame_base_error) == false) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 770 | { |
| 771 | // We should really have an error if evaluate returns, but in case |
| 772 | // we don't, lets set the error to something at least. |
| 773 | if (m_frame_base_error.Success()) |
| 774 | m_frame_base_error.SetErrorString("Evaluation of the frame base expression failed."); |
| 775 | } |
| 776 | else |
| 777 | { |
| 778 | m_frame_base = expr_value.ResolveValue(&exe_ctx, NULL); |
| 779 | } |
| 780 | } |
| 781 | else |
| 782 | { |
| 783 | m_frame_base_error.SetErrorString ("No function in symbol context."); |
| 784 | } |
| 785 | } |
| 786 | |
| 787 | if (m_frame_base_error.Success()) |
| 788 | frame_base = m_frame_base; |
| 789 | |
| 790 | if (error_ptr) |
| 791 | *error_ptr = m_frame_base_error; |
| 792 | return m_frame_base_error.Success(); |
| 793 | } |
| 794 | |
Greg Clayton | 08d7d3a | 2011-01-06 22:15:06 +0000 | [diff] [blame] | 795 | RegisterContextSP |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 796 | StackFrame::GetRegisterContext () |
| 797 | { |
Greg Clayton | 08d7d3a | 2011-01-06 22:15:06 +0000 | [diff] [blame] | 798 | if (!m_reg_context_sp) |
| 799 | m_reg_context_sp = m_thread.CreateRegisterContextForFrame (this); |
| 800 | return m_reg_context_sp; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 801 | } |
| 802 | |
| 803 | bool |
| 804 | StackFrame::HasDebugInformation () |
| 805 | { |
Greg Clayton | b04e7a8 | 2010-08-24 21:05:24 +0000 | [diff] [blame] | 806 | GetSymbolContext (eSymbolContextLineEntry); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 807 | return m_sc.line_entry.IsValid(); |
| 808 | } |
| 809 | |
Greg Clayton | 17dae08 | 2010-09-02 02:59:18 +0000 | [diff] [blame] | 810 | |
| 811 | ValueObjectSP |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 812 | StackFrame::GetValueObjectForFrameVariable (const VariableSP &variable_sp, bool use_dynamic) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 813 | { |
Greg Clayton | 17dae08 | 2010-09-02 02:59:18 +0000 | [diff] [blame] | 814 | ValueObjectSP valobj_sp; |
| 815 | VariableList *var_list = GetVariableList (true); |
| 816 | if (var_list) |
| 817 | { |
| 818 | // Make sure the variable is a frame variable |
| 819 | const uint32_t var_idx = var_list->FindIndexForVariable (variable_sp.get()); |
| 820 | const uint32_t num_variables = var_list->GetSize(); |
| 821 | if (var_idx < num_variables) |
| 822 | { |
| 823 | valobj_sp = m_variable_list_value_objects.GetValueObjectAtIndex (var_idx); |
| 824 | if (valobj_sp.get() == NULL) |
| 825 | { |
| 826 | if (m_variable_list_value_objects.GetSize() < num_variables) |
| 827 | m_variable_list_value_objects.Resize(num_variables); |
Jim Ingham | fa3a16a | 2011-03-31 00:19:25 +0000 | [diff] [blame] | 828 | valobj_sp.reset (new ValueObjectVariable (this, variable_sp)); |
Greg Clayton | 17dae08 | 2010-09-02 02:59:18 +0000 | [diff] [blame] | 829 | m_variable_list_value_objects.SetValueObjectAtIndex (var_idx, valobj_sp); |
| 830 | } |
| 831 | } |
| 832 | } |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 833 | if (use_dynamic && valobj_sp) |
| 834 | { |
| 835 | ValueObjectSP dynamic_sp = valobj_sp->GetDynamicValue (true, valobj_sp); |
| 836 | if (dynamic_sp) |
| 837 | return dynamic_sp; |
| 838 | } |
Greg Clayton | 17dae08 | 2010-09-02 02:59:18 +0000 | [diff] [blame] | 839 | return valobj_sp; |
| 840 | } |
| 841 | |
| 842 | ValueObjectSP |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 843 | StackFrame::TrackGlobalVariable (const VariableSP &variable_sp, bool use_dynamic) |
Greg Clayton | 17dae08 | 2010-09-02 02:59:18 +0000 | [diff] [blame] | 844 | { |
| 845 | // Check to make sure we aren't already tracking this variable? |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 846 | ValueObjectSP valobj_sp (GetValueObjectForFrameVariable (variable_sp, use_dynamic)); |
Greg Clayton | 17dae08 | 2010-09-02 02:59:18 +0000 | [diff] [blame] | 847 | if (!valobj_sp) |
| 848 | { |
| 849 | // We aren't already tracking this global |
| 850 | VariableList *var_list = GetVariableList (true); |
| 851 | // If this frame has no variables, create a new list |
| 852 | if (var_list == NULL) |
| 853 | m_variable_list_sp.reset (new VariableList()); |
| 854 | |
| 855 | // Add the global/static variable to this frame |
| 856 | m_variable_list_sp->AddVariable (variable_sp); |
| 857 | |
| 858 | // Now make a value object for it so we can track its changes |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 859 | valobj_sp = GetValueObjectForFrameVariable (variable_sp, use_dynamic); |
Greg Clayton | 17dae08 | 2010-09-02 02:59:18 +0000 | [diff] [blame] | 860 | } |
| 861 | return valobj_sp; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 862 | } |
| 863 | |
Jim Ingham | 2154da4 | 2010-08-26 20:44:45 +0000 | [diff] [blame] | 864 | bool |
| 865 | StackFrame::IsInlined () |
| 866 | { |
Greg Clayton | 4fb0815 | 2010-08-30 18:11:35 +0000 | [diff] [blame] | 867 | if (m_sc.block == NULL) |
| 868 | GetSymbolContext (eSymbolContextBlock); |
| 869 | if (m_sc.block) |
| 870 | return m_sc.block->GetContainingInlinedBlock() != NULL; |
| 871 | return false; |
Jim Ingham | 2154da4 | 2010-08-26 20:44:45 +0000 | [diff] [blame] | 872 | } |
| 873 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 874 | Target * |
| 875 | StackFrame::CalculateTarget () |
| 876 | { |
| 877 | return m_thread.CalculateTarget(); |
| 878 | } |
| 879 | |
| 880 | Process * |
| 881 | StackFrame::CalculateProcess () |
| 882 | { |
| 883 | return m_thread.CalculateProcess(); |
| 884 | } |
| 885 | |
| 886 | Thread * |
| 887 | StackFrame::CalculateThread () |
| 888 | { |
| 889 | return &m_thread; |
| 890 | } |
| 891 | |
| 892 | StackFrame * |
| 893 | StackFrame::CalculateStackFrame () |
| 894 | { |
| 895 | return this; |
| 896 | } |
| 897 | |
| 898 | |
| 899 | void |
Greg Clayton | a830adb | 2010-10-04 01:05:56 +0000 | [diff] [blame] | 900 | StackFrame::CalculateExecutionContext (ExecutionContext &exe_ctx) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 901 | { |
Greg Clayton | a830adb | 2010-10-04 01:05:56 +0000 | [diff] [blame] | 902 | m_thread.CalculateExecutionContext (exe_ctx); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 903 | exe_ctx.frame = this; |
| 904 | } |
| 905 | |
| 906 | void |
Greg Clayton | a830adb | 2010-10-04 01:05:56 +0000 | [diff] [blame] | 907 | StackFrame::DumpUsingSettingsFormat (Stream *strm) |
| 908 | { |
| 909 | if (strm == NULL) |
| 910 | return; |
| 911 | |
| 912 | GetSymbolContext(eSymbolContextEverything); |
| 913 | ExecutionContext exe_ctx; |
| 914 | CalculateExecutionContext(exe_ctx); |
| 915 | const char *end = NULL; |
| 916 | StreamString s; |
| 917 | const char *frame_format = m_thread.GetProcess().GetTarget().GetDebugger().GetFrameFormat(); |
| 918 | if (frame_format && Debugger::FormatPrompt (frame_format, &m_sc, &exe_ctx, NULL, s, &end)) |
| 919 | { |
| 920 | strm->Write(s.GetData(), s.GetSize()); |
| 921 | } |
| 922 | else |
| 923 | { |
| 924 | Dump (strm, true, false); |
| 925 | strm->EOL(); |
| 926 | } |
| 927 | } |
| 928 | |
| 929 | void |
Greg Clayton | 72b7158 | 2010-09-02 21:44:10 +0000 | [diff] [blame] | 930 | StackFrame::Dump (Stream *strm, bool show_frame_index, bool show_fullpaths) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 931 | { |
| 932 | if (strm == NULL) |
| 933 | return; |
| 934 | |
| 935 | if (show_frame_index) |
Greg Clayton | 33ed170 | 2010-08-24 00:45:41 +0000 | [diff] [blame] | 936 | strm->Printf("frame #%u: ", m_frame_index); |
Greg Clayton | 395fc33 | 2011-02-15 21:59:32 +0000 | [diff] [blame] | 937 | strm->Printf("0x%0*llx ", m_thread.GetProcess().GetTarget().GetArchitecture().GetAddressByteSize() * 2, GetFrameCodeAddress().GetLoadAddress(&m_thread.GetProcess().GetTarget())); |
Greg Clayton | b04e7a8 | 2010-08-24 21:05:24 +0000 | [diff] [blame] | 938 | GetSymbolContext(eSymbolContextEverything); |
Greg Clayton | 33ed170 | 2010-08-24 00:45:41 +0000 | [diff] [blame] | 939 | const bool show_module = true; |
| 940 | const bool show_inline = true; |
Greg Clayton | 72b7158 | 2010-09-02 21:44:10 +0000 | [diff] [blame] | 941 | m_sc.DumpStopContext(strm, &m_thread.GetProcess(), GetFrameCodeAddress(), show_fullpaths, show_module, show_inline); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 942 | } |
| 943 | |
Greg Clayton | 1d66ef5 | 2010-08-27 18:24:16 +0000 | [diff] [blame] | 944 | void |
Greg Clayton | 4fb0815 | 2010-08-30 18:11:35 +0000 | [diff] [blame] | 945 | StackFrame::UpdateCurrentFrameFromPreviousFrame (StackFrame &prev_frame) |
Greg Clayton | 1d66ef5 | 2010-08-27 18:24:16 +0000 | [diff] [blame] | 946 | { |
Greg Clayton | 4fb0815 | 2010-08-30 18:11:35 +0000 | [diff] [blame] | 947 | assert (GetStackID() == prev_frame.GetStackID()); // TODO: remove this after some testing |
| 948 | m_variable_list_sp = prev_frame.m_variable_list_sp; |
Greg Clayton | 17dae08 | 2010-09-02 02:59:18 +0000 | [diff] [blame] | 949 | m_variable_list_value_objects.Swap (prev_frame.m_variable_list_value_objects); |
Greg Clayton | 870a1cd | 2010-08-27 21:47:54 +0000 | [diff] [blame] | 950 | if (!m_disassembly.GetString().empty()) |
| 951 | m_disassembly.GetString().swap (m_disassembly.GetString()); |
Greg Clayton | 1d66ef5 | 2010-08-27 18:24:16 +0000 | [diff] [blame] | 952 | } |
Greg Clayton | 870a1cd | 2010-08-27 21:47:54 +0000 | [diff] [blame] | 953 | |
| 954 | |
Greg Clayton | 4fb0815 | 2010-08-30 18:11:35 +0000 | [diff] [blame] | 955 | void |
| 956 | StackFrame::UpdatePreviousFrameFromCurrentFrame (StackFrame &curr_frame) |
| 957 | { |
Greg Clayton | 5205f0b | 2010-09-03 17:10:42 +0000 | [diff] [blame] | 958 | assert (GetStackID() == curr_frame.GetStackID()); // TODO: remove this after some testing |
| 959 | m_id.SetPC (curr_frame.m_id.GetPC()); // Update the Stack ID PC value |
Greg Clayton | 4fb0815 | 2010-08-30 18:11:35 +0000 | [diff] [blame] | 960 | assert (&m_thread == &curr_frame.m_thread); |
| 961 | m_frame_index = curr_frame.m_frame_index; |
Greg Clayton | 08d7d3a | 2011-01-06 22:15:06 +0000 | [diff] [blame] | 962 | m_concrete_frame_index = curr_frame.m_concrete_frame_index; |
Greg Clayton | 4fb0815 | 2010-08-30 18:11:35 +0000 | [diff] [blame] | 963 | m_reg_context_sp = curr_frame.m_reg_context_sp; |
| 964 | m_frame_code_addr = curr_frame.m_frame_code_addr; |
| 965 | assert (m_sc.target_sp.get() == NULL || curr_frame.m_sc.target_sp.get() == NULL || m_sc.target_sp.get() == curr_frame.m_sc.target_sp.get()); |
| 966 | assert (m_sc.module_sp.get() == NULL || curr_frame.m_sc.module_sp.get() == NULL || m_sc.module_sp.get() == curr_frame.m_sc.module_sp.get()); |
| 967 | assert (m_sc.comp_unit == NULL || curr_frame.m_sc.comp_unit == NULL || m_sc.comp_unit == curr_frame.m_sc.comp_unit); |
| 968 | assert (m_sc.function == NULL || curr_frame.m_sc.function == NULL || m_sc.function == curr_frame.m_sc.function); |
Greg Clayton | 4fb0815 | 2010-08-30 18:11:35 +0000 | [diff] [blame] | 969 | m_sc = curr_frame.m_sc; |
| 970 | m_flags.Clear(GOT_FRAME_BASE | eSymbolContextEverything); |
| 971 | m_flags.Set (m_sc.GetResolvedMask()); |
| 972 | m_frame_base.Clear(); |
| 973 | m_frame_base_error.Clear(); |
| 974 | } |
| 975 | |
| 976 | |
Greg Clayton | 5205f0b | 2010-09-03 17:10:42 +0000 | [diff] [blame] | 977 | bool |
| 978 | StackFrame::HasCachedData () const |
| 979 | { |
| 980 | if (m_variable_list_sp.get()) |
| 981 | return true; |
| 982 | if (m_variable_list_value_objects.GetSize() > 0) |
| 983 | return true; |
| 984 | if (!m_disassembly.GetString().empty()) |
| 985 | return true; |
| 986 | return false; |
Jim Ingham | ccd584d | 2010-09-23 17:40:12 +0000 | [diff] [blame] | 987 | } |
| 988 | |
| 989 | lldb::StackFrameSP |
| 990 | StackFrame::GetSP () |
| 991 | { |
| 992 | return m_thread.GetStackFrameSPForStackFramePtr (this); |
Greg Clayton | bdcb6ab | 2011-01-25 23:55:37 +0000 | [diff] [blame] | 993 | } |
Greg Clayton | abe0fed | 2011-04-18 08:33:37 +0000 | [diff] [blame^] | 994 | |
| 995 | |
| 996 | |
| 997 | bool |
| 998 | StackFrame::GetStatus (Stream& strm, |
| 999 | bool show_frame_info, |
| 1000 | bool show_source, |
| 1001 | uint32_t source_lines_before, |
| 1002 | uint32_t source_lines_after) |
| 1003 | { |
| 1004 | if (show_frame_info) |
| 1005 | { |
| 1006 | strm.Indent(); |
| 1007 | DumpUsingSettingsFormat (&strm); |
| 1008 | } |
| 1009 | |
| 1010 | if (show_source) |
| 1011 | { |
| 1012 | GetSymbolContext(eSymbolContextCompUnit | eSymbolContextLineEntry); |
| 1013 | |
| 1014 | if (m_sc.comp_unit && m_sc.line_entry.IsValid()) |
| 1015 | { |
| 1016 | GetThread().GetProcess().GetTarget().GetDebugger().GetSourceManager().DisplaySourceLinesWithLineNumbers ( |
| 1017 | m_sc.line_entry.file, |
| 1018 | m_sc.line_entry.line, |
| 1019 | 3, |
| 1020 | 3, |
| 1021 | "->", |
| 1022 | &strm); |
| 1023 | |
| 1024 | } |
| 1025 | } |
| 1026 | return true; |
| 1027 | } |
| 1028 | |