blob: 633d394cf071597bf032106dbace08df87f27a88 [file] [log] [blame]
Chris Lattner24943d22010-06-08 16:52:24 +00001//===-- 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 Claytona830adb2010-10-04 01:05:56 +000017#include "lldb/Core/Debugger.h"
Chris Lattner24943d22010-06-08 16:52:24 +000018#include "lldb/Core/Disassembler.h"
19#include "lldb/Core/Value.h"
Greg Clayton17dae082010-09-02 02:59:18 +000020#include "lldb/Core/ValueObjectVariable.h"
Greg Claytonc3b61d22010-12-15 05:08:08 +000021#include "lldb/Core/ValueObjectConstResult.h"
Chris Lattner24943d22010-06-08 16:52:24 +000022#include "lldb/Symbol/Function.h"
Greg Clayton17dae082010-09-02 02:59:18 +000023#include "lldb/Symbol/VariableList.h"
Chris Lattner24943d22010-06-08 16:52:24 +000024#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
30using namespace lldb;
31using 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 Clayton4fb08152010-08-30 18:11:35 +000036#define RESOLVED_FRAME_CODE_ADDR (uint32_t(eSymbolContextEverything + 1))
Greg Clayton72b71582010-09-02 21:44:10 +000037#define RESOLVED_FRAME_ID_SYMBOL_SCOPE (RESOLVED_FRAME_CODE_ADDR << 1)
Greg Clayton4fb08152010-08-30 18:11:35 +000038#define GOT_FRAME_BASE (RESOLVED_FRAME_ID_SYMBOL_SCOPE << 1)
39#define RESOLVED_VARIABLES (GOT_FRAME_BASE << 1)
Sean Callanan89363592010-11-01 04:38:59 +000040#define RESOLVED_GLOBAL_VARIABLES (RESOLVED_VARIABLES << 1)
Chris Lattner24943d22010-06-08 16:52:24 +000041
Greg Clayton33ed1702010-08-24 00:45:41 +000042StackFrame::StackFrame
43(
44 lldb::user_id_t frame_idx,
Greg Clayton4fb08152010-08-30 18:11:35 +000045 lldb::user_id_t unwind_frame_index,
Greg Clayton33ed1702010-08-24 00:45:41 +000046 Thread &thread,
47 lldb::addr_t cfa,
Greg Clayton33ed1702010-08-24 00:45:41 +000048 lldb::addr_t pc,
49 const SymbolContext *sc_ptr
50) :
51 m_frame_index (frame_idx),
Greg Clayton08d7d3a2011-01-06 22:15:06 +000052 m_concrete_frame_index (unwind_frame_index),
Chris Lattner24943d22010-06-08 16:52:24 +000053 m_thread (thread),
Greg Clayton33ed1702010-08-24 00:45:41 +000054 m_reg_context_sp (),
Greg Clayton72b71582010-09-02 21:44:10 +000055 m_id (pc, cfa, NULL),
Greg Clayton65124ea2010-08-26 22:05:43 +000056 m_frame_code_addr (NULL, pc),
Greg Clayton33ed1702010-08-24 00:45:41 +000057 m_sc (),
58 m_flags (),
59 m_frame_base (),
60 m_frame_base_error (),
Chris Lattner24943d22010-06-08 16:52:24 +000061 m_variable_list_sp (),
Greg Clayton17dae082010-09-02 02:59:18 +000062 m_variable_list_value_objects ()
Chris Lattner24943d22010-06-08 16:52:24 +000063{
64 if (sc_ptr != NULL)
Greg Clayton33ed1702010-08-24 00:45:41 +000065 {
Chris Lattner24943d22010-06-08 16:52:24 +000066 m_sc = *sc_ptr;
Greg Clayton33ed1702010-08-24 00:45:41 +000067 m_flags.Set(m_sc.GetResolvedMask ());
68 }
Chris Lattner24943d22010-06-08 16:52:24 +000069}
70
Greg Clayton33ed1702010-08-24 00:45:41 +000071StackFrame::StackFrame
72(
73 lldb::user_id_t frame_idx,
Greg Clayton4fb08152010-08-30 18:11:35 +000074 lldb::user_id_t unwind_frame_index,
Greg Clayton33ed1702010-08-24 00:45:41 +000075 Thread &thread,
76 const RegisterContextSP &reg_context_sp,
77 lldb::addr_t cfa,
Greg Clayton33ed1702010-08-24 00:45:41 +000078 lldb::addr_t pc,
79 const SymbolContext *sc_ptr
80) :
81 m_frame_index (frame_idx),
Greg Clayton08d7d3a2011-01-06 22:15:06 +000082 m_concrete_frame_index (unwind_frame_index),
Chris Lattner24943d22010-06-08 16:52:24 +000083 m_thread (thread),
Greg Clayton33ed1702010-08-24 00:45:41 +000084 m_reg_context_sp (reg_context_sp),
Greg Clayton72b71582010-09-02 21:44:10 +000085 m_id (pc, cfa, NULL),
Greg Clayton65124ea2010-08-26 22:05:43 +000086 m_frame_code_addr (NULL, pc),
Greg Clayton33ed1702010-08-24 00:45:41 +000087 m_sc (),
88 m_flags (),
89 m_frame_base (),
90 m_frame_base_error (),
Chris Lattner24943d22010-06-08 16:52:24 +000091 m_variable_list_sp (),
Greg Clayton17dae082010-09-02 02:59:18 +000092 m_variable_list_value_objects ()
Chris Lattner24943d22010-06-08 16:52:24 +000093{
94 if (sc_ptr != NULL)
Greg Clayton33ed1702010-08-24 00:45:41 +000095 {
Chris Lattner24943d22010-06-08 16:52:24 +000096 m_sc = *sc_ptr;
Greg Clayton33ed1702010-08-24 00:45:41 +000097 m_flags.Set(m_sc.GetResolvedMask ());
98 }
99
100 if (reg_context_sp && !m_sc.target_sp)
101 {
102 m_sc.target_sp = reg_context_sp->GetThread().GetProcess().GetTarget().GetSP();
103 m_flags.Set (eSymbolContextTarget);
104 }
105}
106
107StackFrame::StackFrame
108(
109 lldb::user_id_t frame_idx,
Greg Clayton4fb08152010-08-30 18:11:35 +0000110 lldb::user_id_t unwind_frame_index,
Greg Clayton33ed1702010-08-24 00:45:41 +0000111 Thread &thread,
112 const RegisterContextSP &reg_context_sp,
113 lldb::addr_t cfa,
Greg Clayton33ed1702010-08-24 00:45:41 +0000114 const Address& pc_addr,
115 const SymbolContext *sc_ptr
116) :
117 m_frame_index (frame_idx),
Greg Clayton08d7d3a2011-01-06 22:15:06 +0000118 m_concrete_frame_index (unwind_frame_index),
Greg Clayton33ed1702010-08-24 00:45:41 +0000119 m_thread (thread),
120 m_reg_context_sp (reg_context_sp),
Greg Claytoneea26402010-09-14 23:36:40 +0000121 m_id (pc_addr.GetLoadAddress (&thread.GetProcess().GetTarget()), cfa, NULL),
Greg Clayton65124ea2010-08-26 22:05:43 +0000122 m_frame_code_addr (pc_addr),
Greg Clayton33ed1702010-08-24 00:45:41 +0000123 m_sc (),
124 m_flags (),
125 m_frame_base (),
126 m_frame_base_error (),
127 m_variable_list_sp (),
Greg Clayton17dae082010-09-02 02:59:18 +0000128 m_variable_list_value_objects ()
Greg Clayton33ed1702010-08-24 00:45:41 +0000129{
130 if (sc_ptr != NULL)
131 {
132 m_sc = *sc_ptr;
133 m_flags.Set(m_sc.GetResolvedMask ());
134 }
135
136 if (m_sc.target_sp.get() == NULL && reg_context_sp)
137 {
138 m_sc.target_sp = reg_context_sp->GetThread().GetProcess().GetTarget().GetSP();
139 m_flags.Set (eSymbolContextTarget);
140 }
141
Greg Claytone2c5e452010-09-13 04:34:30 +0000142 Module *pc_module = pc_addr.GetModule();
143 if (m_sc.module_sp.get() == NULL || m_sc.module_sp.get() != pc_module)
Greg Clayton33ed1702010-08-24 00:45:41 +0000144 {
Greg Clayton33ed1702010-08-24 00:45:41 +0000145 if (pc_module)
146 {
147 m_sc.module_sp = pc_module->GetSP();
148 m_flags.Set (eSymbolContextModule);
149 }
Greg Claytone2c5e452010-09-13 04:34:30 +0000150 else
151 {
152 m_sc.module_sp.reset();
153 }
154
Greg Clayton33ed1702010-08-24 00:45:41 +0000155 }
Chris Lattner24943d22010-06-08 16:52:24 +0000156}
157
158
159//----------------------------------------------------------------------
160// Destructor
161//----------------------------------------------------------------------
162StackFrame::~StackFrame()
163{
164}
165
166StackID&
167StackFrame::GetStackID()
168{
Greg Clayton72b71582010-09-02 21:44:10 +0000169 // Make sure we have resolved the StackID object's symbol context scope if
170 // we already haven't looked it up.
Chris Lattner24943d22010-06-08 16:52:24 +0000171
Greg Clayton4fb08152010-08-30 18:11:35 +0000172 if (m_flags.IsClear (RESOLVED_FRAME_ID_SYMBOL_SCOPE))
173 {
Greg Clayton5205f0b2010-09-03 17:10:42 +0000174 if (m_id.GetSymbolContextScope ())
Greg Clayton4fb08152010-08-30 18:11:35 +0000175 {
Greg Clayton69aa5d92010-09-07 04:20:48 +0000176 // We already have a symbol context scope, we just don't have our
177 // flag bit set.
Greg Clayton4fb08152010-08-30 18:11:35 +0000178 m_flags.Set (RESOLVED_FRAME_ID_SYMBOL_SCOPE);
179 }
180 else
181 {
Greg Clayton69aa5d92010-09-07 04:20:48 +0000182 // Calculate the frame block and use this for the stack ID symbol
183 // context scope if we have one.
184 SymbolContextScope *scope = GetFrameBlock ();
185 if (scope == NULL)
Greg Clayton4fb08152010-08-30 18:11:35 +0000186 {
Greg Clayton69aa5d92010-09-07 04:20:48 +0000187 // We don't have a block, so use the symbol
188 if (m_flags.IsClear (eSymbolContextSymbol))
189 GetSymbolContext (eSymbolContextSymbol);
190
191 // It is ok if m_sc.symbol is NULL here
192 scope = m_sc.symbol;
Greg Clayton4fb08152010-08-30 18:11:35 +0000193 }
Greg Clayton69aa5d92010-09-07 04:20:48 +0000194 // Set the symbol context scope (the accessor will set the
195 // RESOLVED_FRAME_ID_SYMBOL_SCOPE bit in m_flags).
196 SetSymbolContextScope (scope);
Greg Clayton4fb08152010-08-30 18:11:35 +0000197 }
Chris Lattner24943d22010-06-08 16:52:24 +0000198 }
199 return m_id;
200}
201
Greg Clayton4fb08152010-08-30 18:11:35 +0000202void
203StackFrame::SetSymbolContextScope (SymbolContextScope *symbol_scope)
204{
205 m_flags.Set (RESOLVED_FRAME_ID_SYMBOL_SCOPE);
206 m_id.SetSymbolContextScope (symbol_scope);
207}
208
Chris Lattner24943d22010-06-08 16:52:24 +0000209Address&
Greg Claytonb04e7a82010-08-24 21:05:24 +0000210StackFrame::GetFrameCodeAddress()
Chris Lattner24943d22010-06-08 16:52:24 +0000211{
Greg Clayton4fb08152010-08-30 18:11:35 +0000212 if (m_flags.IsClear(RESOLVED_FRAME_CODE_ADDR) && !m_frame_code_addr.IsSectionOffset())
Chris Lattner24943d22010-06-08 16:52:24 +0000213 {
Greg Clayton4fb08152010-08-30 18:11:35 +0000214 m_flags.Set (RESOLVED_FRAME_CODE_ADDR);
Chris Lattner24943d22010-06-08 16:52:24 +0000215
216 // Resolve the PC into a temporary address because if ResolveLoadAddress
217 // fails to resolve the address, it will clear the address object...
218 Address resolved_pc;
Greg Claytoneea26402010-09-14 23:36:40 +0000219 if (m_thread.GetProcess().GetTarget().GetSectionLoadList().ResolveLoadAddress(m_frame_code_addr.GetOffset(), resolved_pc))
Chris Lattner24943d22010-06-08 16:52:24 +0000220 {
Greg Clayton65124ea2010-08-26 22:05:43 +0000221 m_frame_code_addr = resolved_pc;
222 const Section *section = m_frame_code_addr.GetSection();
Chris Lattner24943d22010-06-08 16:52:24 +0000223 if (section)
224 {
225 Module *module = section->GetModule();
226 if (module)
227 {
228 m_sc.module_sp = module->GetSP();
229 if (m_sc.module_sp)
230 m_flags.Set(eSymbolContextModule);
231 }
232 }
233 }
234 }
Greg Clayton65124ea2010-08-26 22:05:43 +0000235 return m_frame_code_addr;
Chris Lattner24943d22010-06-08 16:52:24 +0000236}
237
238void
239StackFrame::ChangePC (addr_t pc)
240{
Greg Clayton65124ea2010-08-26 22:05:43 +0000241 m_frame_code_addr.SetOffset(pc);
242 m_frame_code_addr.SetSection(NULL);
Chris Lattner24943d22010-06-08 16:52:24 +0000243 m_sc.Clear();
Greg Claytonf3d0b0c2010-10-27 03:32:59 +0000244 m_flags.Reset(0);
Chris Lattner24943d22010-06-08 16:52:24 +0000245 m_thread.ClearStackFrames ();
246}
247
248const char *
249StackFrame::Disassemble ()
250{
251 if (m_disassembly.GetSize() == 0)
252 {
253 ExecutionContext exe_ctx;
Greg Claytona830adb2010-10-04 01:05:56 +0000254 CalculateExecutionContext(exe_ctx);
Greg Clayton63094e02010-06-23 01:19:29 +0000255 Target &target = m_thread.GetProcess().GetTarget();
256 Disassembler::Disassemble (target.GetDebugger(),
257 target.GetArchitecture(),
Chris Lattner24943d22010-06-08 16:52:24 +0000258 exe_ctx,
259 0,
Greg Clayton70436352010-06-30 23:03:03 +0000260 false,
Chris Lattner24943d22010-06-08 16:52:24 +0000261 m_disassembly);
262 if (m_disassembly.GetSize() == 0)
263 return NULL;
264 }
265 return m_disassembly.GetData();
266}
267
Greg Clayton69aa5d92010-09-07 04:20:48 +0000268Block *
269StackFrame::GetFrameBlock ()
270{
271 if (m_sc.block == NULL && m_flags.IsClear (eSymbolContextBlock))
272 GetSymbolContext (eSymbolContextBlock);
273
274 if (m_sc.block)
275 {
276 Block *inline_block = m_sc.block->GetContainingInlinedBlock();
277 if (inline_block)
278 {
279 // Use the block with the inlined function info
280 // as the frame block we want this frame to have only the variables
281 // for the inlined function and its non-inlined block child blocks.
282 return inline_block;
283 }
284 else
285 {
286 // This block is not contained withing any inlined function blocks
287 // with so we want to use the top most function block.
288 return &m_sc.function->GetBlock (false);
289 }
290 }
291 return NULL;
292}
293
Chris Lattner24943d22010-06-08 16:52:24 +0000294//----------------------------------------------------------------------
295// Get the symbol context if we already haven't done so by resolving the
296// PC address as much as possible. This way when we pass around a
297// StackFrame object, everyone will have as much information as
298// possible and no one will ever have to look things up manually.
299//----------------------------------------------------------------------
300const SymbolContext&
301StackFrame::GetSymbolContext (uint32_t resolve_scope)
302{
303 // Copy our internal symbol context into "sc".
Greg Claytonf3d0b0c2010-10-27 03:32:59 +0000304 if ((m_flags.Get() & resolve_scope) != resolve_scope)
Chris Lattner24943d22010-06-08 16:52:24 +0000305 {
306 // Resolve our PC to section offset if we haven't alreday done so
307 // and if we don't have a module. The resolved address section will
308 // contain the module to which it belongs
Greg Clayton4fb08152010-08-30 18:11:35 +0000309 if (!m_sc.module_sp && m_flags.IsClear(RESOLVED_FRAME_CODE_ADDR))
Greg Claytonb04e7a82010-08-24 21:05:24 +0000310 GetFrameCodeAddress();
Chris Lattner24943d22010-06-08 16:52:24 +0000311
312 // If this is not frame zero, then we need to subtract 1 from the PC
313 // value when doing address lookups since the PC will be on the
314 // instruction following the function call instruction...
315
Greg Claytonb04e7a82010-08-24 21:05:24 +0000316 Address lookup_addr(GetFrameCodeAddress());
Greg Clayton33ed1702010-08-24 00:45:41 +0000317 if (m_frame_index > 0 && lookup_addr.IsValid())
Chris Lattner24943d22010-06-08 16:52:24 +0000318 {
319 addr_t offset = lookup_addr.GetOffset();
320 if (offset > 0)
321 lookup_addr.SetOffset(offset - 1);
322 }
323
Greg Claytonb04e7a82010-08-24 21:05:24 +0000324
325 uint32_t resolved = 0;
Chris Lattner24943d22010-06-08 16:52:24 +0000326 if (m_sc.module_sp)
327 {
328 // We have something in our stack frame symbol context, lets check
329 // if we haven't already tried to lookup one of those things. If we
330 // haven't then we will do the query.
Greg Clayton33ed1702010-08-24 00:45:41 +0000331
332 uint32_t actual_resolve_scope = 0;
333
334 if (resolve_scope & eSymbolContextCompUnit)
335 {
336 if (m_flags.IsClear (eSymbolContextCompUnit))
337 {
338 if (m_sc.comp_unit)
Greg Claytonb04e7a82010-08-24 21:05:24 +0000339 resolved |= eSymbolContextCompUnit;
Greg Clayton33ed1702010-08-24 00:45:41 +0000340 else
341 actual_resolve_scope |= eSymbolContextCompUnit;
342 }
343 }
344
345 if (resolve_scope & eSymbolContextFunction)
346 {
347 if (m_flags.IsClear (eSymbolContextFunction))
348 {
349 if (m_sc.function)
Greg Claytonb04e7a82010-08-24 21:05:24 +0000350 resolved |= eSymbolContextFunction;
Greg Clayton33ed1702010-08-24 00:45:41 +0000351 else
352 actual_resolve_scope |= eSymbolContextFunction;
353 }
354 }
355
356 if (resolve_scope & eSymbolContextBlock)
357 {
358 if (m_flags.IsClear (eSymbolContextBlock))
359 {
360 if (m_sc.block)
Greg Claytonb04e7a82010-08-24 21:05:24 +0000361 resolved |= eSymbolContextBlock;
Greg Clayton33ed1702010-08-24 00:45:41 +0000362 else
363 actual_resolve_scope |= eSymbolContextBlock;
364 }
365 }
366
367 if (resolve_scope & eSymbolContextSymbol)
368 {
369 if (m_flags.IsClear (eSymbolContextSymbol))
370 {
371 if (m_sc.symbol)
Greg Claytonb04e7a82010-08-24 21:05:24 +0000372 resolved |= eSymbolContextSymbol;
Greg Clayton33ed1702010-08-24 00:45:41 +0000373 else
374 actual_resolve_scope |= eSymbolContextSymbol;
375 }
376 }
377
378 if (resolve_scope & eSymbolContextLineEntry)
379 {
380 if (m_flags.IsClear (eSymbolContextLineEntry))
381 {
382 if (m_sc.line_entry.IsValid())
Greg Claytonb04e7a82010-08-24 21:05:24 +0000383 resolved |= eSymbolContextLineEntry;
Greg Clayton33ed1702010-08-24 00:45:41 +0000384 else
385 actual_resolve_scope |= eSymbolContextLineEntry;
386 }
387 }
388
389 if (actual_resolve_scope)
Chris Lattner24943d22010-06-08 16:52:24 +0000390 {
391 // We might be resolving less information than what is already
392 // in our current symbol context so resolve into a temporary
393 // symbol context "sc" so we don't clear out data we have
394 // already found in "m_sc"
395 SymbolContext sc;
396 // Set flags that indicate what we have tried to resolve
Greg Claytonb04e7a82010-08-24 21:05:24 +0000397 resolved |= m_sc.module_sp->ResolveSymbolContextForAddress (lookup_addr, actual_resolve_scope, sc);
Greg Clayton33ed1702010-08-24 00:45:41 +0000398 // Only replace what we didn't already have as we may have
399 // information for an inlined function scope that won't match
400 // what a standard lookup by address would match
Greg Claytonb04e7a82010-08-24 21:05:24 +0000401 if ((resolved & eSymbolContextCompUnit) && m_sc.comp_unit == NULL)
402 m_sc.comp_unit = sc.comp_unit;
403 if ((resolved & eSymbolContextFunction) && m_sc.function == NULL)
404 m_sc.function = sc.function;
405 if ((resolved & eSymbolContextBlock) && m_sc.block == NULL)
406 m_sc.block = sc.block;
407 if ((resolved & eSymbolContextSymbol) && m_sc.symbol == NULL)
408 m_sc.symbol = sc.symbol;
409 if ((resolved & eSymbolContextLineEntry) && !m_sc.line_entry.IsValid())
410 m_sc.line_entry = sc.line_entry;
411
Chris Lattner24943d22010-06-08 16:52:24 +0000412 }
413 }
414 else
415 {
416 // If we don't have a module, then we can't have the compile unit,
417 // function, block, line entry or symbol, so we can safely call
418 // ResolveSymbolContextForAddress with our symbol context member m_sc.
Greg Claytonb04e7a82010-08-24 21:05:24 +0000419 resolved |= m_thread.GetProcess().GetTarget().GetImages().ResolveSymbolContextForAddress (lookup_addr, resolve_scope, m_sc);
Chris Lattner24943d22010-06-08 16:52:24 +0000420 }
421
422 // If the target was requested add that:
423 if (m_sc.target_sp.get() == NULL)
Greg Claytonb04e7a82010-08-24 21:05:24 +0000424 {
Chris Lattner24943d22010-06-08 16:52:24 +0000425 m_sc.target_sp = CalculateProcess()->GetTarget().GetSP();
Greg Claytonb04e7a82010-08-24 21:05:24 +0000426 if (m_sc.target_sp)
427 resolved |= eSymbolContextTarget;
428 }
Chris Lattner24943d22010-06-08 16:52:24 +0000429
430 // Update our internal flags so we remember what we have tried to locate so
431 // we don't have to keep trying when more calls to this function are made.
Greg Claytonb04e7a82010-08-24 21:05:24 +0000432 // We might have dug up more information that was requested (for example
433 // if we were asked to only get the block, we will have gotten the
434 // compile unit, and function) so set any additional bits that we resolved
435 m_flags.Set (resolve_scope | resolved);
Chris Lattner24943d22010-06-08 16:52:24 +0000436 }
437
438 // Return the symbol context with everything that was possible to resolve
439 // resolved.
440 return m_sc;
441}
442
443
444VariableList *
Greg Clayton17dae082010-09-02 02:59:18 +0000445StackFrame::GetVariableList (bool get_file_globals)
Chris Lattner24943d22010-06-08 16:52:24 +0000446{
447 if (m_flags.IsClear(RESOLVED_VARIABLES))
448 {
449 m_flags.Set(RESOLVED_VARIABLES);
450
Greg Clayton69aa5d92010-09-07 04:20:48 +0000451 Block *frame_block = GetFrameBlock();
452
453 if (frame_block)
Chris Lattner24943d22010-06-08 16:52:24 +0000454 {
Greg Clayton69aa5d92010-09-07 04:20:48 +0000455 const bool get_child_variables = true;
456 const bool can_create = true;
457 m_variable_list_sp = frame_block->GetVariableList (get_child_variables, can_create);
Chris Lattner24943d22010-06-08 16:52:24 +0000458 }
Sean Callanan89363592010-11-01 04:38:59 +0000459 }
460
461 if (m_flags.IsClear(RESOLVED_GLOBAL_VARIABLES) &&
462 get_file_globals)
463 {
464 m_flags.Set(RESOLVED_GLOBAL_VARIABLES);
Greg Clayton17dae082010-09-02 02:59:18 +0000465
Sean Callanan89363592010-11-01 04:38:59 +0000466 if (m_flags.IsClear (eSymbolContextCompUnit))
467 GetSymbolContext (eSymbolContextCompUnit);
468
469 if (m_sc.comp_unit)
Greg Clayton17dae082010-09-02 02:59:18 +0000470 {
Sean Callanan89363592010-11-01 04:38:59 +0000471 VariableListSP global_variable_list_sp (m_sc.comp_unit->GetVariableList(true));
472 if (m_variable_list_sp)
473 m_variable_list_sp->AddVariables (global_variable_list_sp.get());
474 else
475 m_variable_list_sp = global_variable_list_sp;
Greg Clayton17dae082010-09-02 02:59:18 +0000476 }
Chris Lattner24943d22010-06-08 16:52:24 +0000477 }
Sean Callanan89363592010-11-01 04:38:59 +0000478
Chris Lattner24943d22010-06-08 16:52:24 +0000479 return m_variable_list_sp.get();
480}
481
Greg Clayton427f2902010-12-14 02:59:59 +0000482ValueObjectSP
Greg Claytonc67efa42011-01-20 19:27:18 +0000483StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr, uint32_t options, Error &error)
Greg Clayton427f2902010-12-14 02:59:59 +0000484{
Greg Claytonc3b61d22010-12-15 05:08:08 +0000485
486 if (var_expr_cstr && var_expr_cstr[0])
Greg Clayton427f2902010-12-14 02:59:59 +0000487 {
Greg Claytonc67efa42011-01-20 19:27:18 +0000488 const bool check_ptr_vs_member = (options & eExpressionPathOptionCheckPtrVsMember) != 0;
489 const bool no_fragile_ivar = (options & eExpressionPathOptionsNoFragileObjcIvar) != 0;
Greg Claytonc3b61d22010-12-15 05:08:08 +0000490 error.Clear();
491 bool deref = false;
492 bool address_of = false;
493 ValueObjectSP valobj_sp;
494 const bool get_file_globals = true;
495 VariableList *variable_list = GetVariableList (get_file_globals);
496
497 if (variable_list)
Greg Clayton427f2902010-12-14 02:59:59 +0000498 {
Greg Claytonc3b61d22010-12-15 05:08:08 +0000499 // If first character is a '*', then show pointer contents
500 const char *var_expr = var_expr_cstr;
501 if (var_expr[0] == '*')
Greg Clayton427f2902010-12-14 02:59:59 +0000502 {
Greg Claytonc3b61d22010-12-15 05:08:08 +0000503 deref = true;
504 var_expr++; // Skip the '*'
505 }
506 else if (var_expr[0] == '&')
507 {
508 address_of = true;
509 var_expr++; // Skip the '&'
510 }
511
512 std::string var_path (var_expr);
513 size_t separator_idx = var_path.find_first_of(".-[=+~|&^%#@!/?,<>{}");
514 StreamString var_expr_path_strm;
515
516 ConstString name_const_string;
517 if (separator_idx == std::string::npos)
518 name_const_string.SetCString (var_path.c_str());
519 else
520 name_const_string.SetCStringWithLength (var_path.c_str(), separator_idx);
521
522 VariableSP var_sp (variable_list->FindVariable(name_const_string));
523 if (var_sp)
524 {
525 valobj_sp = GetValueObjectForFrameVariable (var_sp);
526
527 var_path.erase (0, name_const_string.GetLength ());
528 // We are dumping at least one child
529 while (separator_idx != std::string::npos)
Greg Clayton427f2902010-12-14 02:59:59 +0000530 {
Greg Claytonc3b61d22010-12-15 05:08:08 +0000531 // Calculate the next separator index ahead of time
532 ValueObjectSP child_valobj_sp;
533 const char separator_type = var_path[0];
534 switch (separator_type)
Greg Clayton427f2902010-12-14 02:59:59 +0000535 {
Greg Claytonc3b61d22010-12-15 05:08:08 +0000536
537 case '-':
538 if (var_path.size() >= 2 && var_path[1] != '>')
Greg Clayton427f2902010-12-14 02:59:59 +0000539 return ValueObjectSP();
Greg Clayton427f2902010-12-14 02:59:59 +0000540
Greg Claytonc67efa42011-01-20 19:27:18 +0000541 if (no_fragile_ivar)
542 {
543 // Make sure we aren't trying to deref an objective
544 // C ivar if this is not allowed
545 const uint32_t pointer_type_flags = ClangASTContext::GetTypeInfo (valobj_sp->GetClangType(), NULL, NULL);
546 if ((pointer_type_flags & ClangASTContext::eTypeIsObjC) &&
547 (pointer_type_flags & ClangASTContext::eTypeIsPointer))
548 {
549 // This was an objective C object pointer and
550 // it was requested we skip any fragile ivars
551 // so return nothing here
552 return ValueObjectSP();
553 }
554 }
Greg Claytonc3b61d22010-12-15 05:08:08 +0000555 var_path.erase (0, 1); // Remove the '-'
556 // Fall through
557 case '.':
Greg Clayton427f2902010-12-14 02:59:59 +0000558 {
Greg Claytonc3b61d22010-12-15 05:08:08 +0000559 const bool expr_is_ptr = var_path[0] == '>';
Greg Clayton427f2902010-12-14 02:59:59 +0000560
Greg Claytonc3b61d22010-12-15 05:08:08 +0000561 var_path.erase (0, 1); // Remove the '.' or '>'
562 separator_idx = var_path.find_first_of(".-[");
563 ConstString child_name;
564 if (separator_idx == std::string::npos)
565 child_name.SetCString (var_path.c_str());
Greg Clayton427f2902010-12-14 02:59:59 +0000566 else
Greg Claytonc3b61d22010-12-15 05:08:08 +0000567 child_name.SetCStringWithLength(var_path.c_str(), separator_idx);
568
569 if (check_ptr_vs_member)
Greg Clayton427f2902010-12-14 02:59:59 +0000570 {
Greg Claytonc3b61d22010-12-15 05:08:08 +0000571 // We either have a pointer type and need to verify
572 // valobj_sp is a pointer, or we have a member of a
573 // class/union/struct being accessed with the . syntax
574 // and need to verify we don't have a pointer.
575 const bool actual_is_ptr = valobj_sp->IsPointerType ();
576
577 if (actual_is_ptr != expr_is_ptr)
578 {
579 // Incorrect use of "." with a pointer, or "->" with
580 // a class/union/struct instance or reference.
Greg Claytonb01000f2011-01-17 03:46:26 +0000581 valobj_sp->GetExpressionPath (var_expr_path_strm, false);
Greg Claytonc3b61d22010-12-15 05:08:08 +0000582 if (actual_is_ptr)
583 error.SetErrorStringWithFormat ("\"%s\" is a pointer and . was used to attempt to access \"%s\". Did you mean \"%s->%s\"?",
584 var_expr_path_strm.GetString().c_str(),
585 child_name.GetCString(),
586 var_expr_path_strm.GetString().c_str(),
587 var_path.c_str());
588 else
589 error.SetErrorStringWithFormat ("\"%s\" is not a pointer and -> was used to attempt to access \"%s\". Did you mean \"%s.%s\"?",
590 var_expr_path_strm.GetString().c_str(),
591 child_name.GetCString(),
592 var_expr_path_strm.GetString().c_str(),
593 var_path.c_str());
594 return ValueObjectSP();
595 }
Greg Clayton427f2902010-12-14 02:59:59 +0000596 }
597
Greg Claytonc3b61d22010-12-15 05:08:08 +0000598 child_valobj_sp = valobj_sp->GetChildMemberWithName (child_name, true);
Greg Clayton427f2902010-12-14 02:59:59 +0000599 if (!child_valobj_sp)
600 {
Greg Claytonc3b61d22010-12-15 05:08:08 +0000601 // No child member with name "child_name"
Greg Claytonb01000f2011-01-17 03:46:26 +0000602 valobj_sp->GetExpressionPath (var_expr_path_strm, false);
Greg Claytonc3b61d22010-12-15 05:08:08 +0000603 if (child_name)
604 {
605 error.SetErrorStringWithFormat ("\"%s\" is not a member of \"(%s) %s\"",
606 child_name.GetCString(),
607 valobj_sp->GetTypeName().AsCString("<invalid type>"),
608 var_expr_path_strm.GetString().c_str());
609 }
610 else
611 {
612 error.SetErrorStringWithFormat ("incomplete expression path after \"%s\" in \"%s\"",
613 var_expr_path_strm.GetString().c_str(),
614 var_expr_cstr);
615 }
616
Greg Clayton427f2902010-12-14 02:59:59 +0000617 return ValueObjectSP();
618 }
Greg Claytonc3b61d22010-12-15 05:08:08 +0000619 // Remove the child name from the path
620 var_path.erase(0, child_name.GetLength());
621 }
622 break;
Greg Clayton427f2902010-12-14 02:59:59 +0000623
Greg Claytonc3b61d22010-12-15 05:08:08 +0000624 case '[':
625 // Array member access, or treating pointer as an array
626 if (var_path.size() > 2) // Need at least two brackets and a number
627 {
628 char *end = NULL;
629 int32_t child_index = ::strtol (&var_path[1], &end, 0);
630 if (end && *end == ']')
631 {
Greg Clayton427f2902010-12-14 02:59:59 +0000632
Greg Claytonc3b61d22010-12-15 05:08:08 +0000633 if (valobj_sp->IsPointerType ())
634 {
635 child_valobj_sp = valobj_sp->GetSyntheticArrayMemberFromPointer (child_index, true);
636 if (!child_valobj_sp)
637 {
Greg Claytonb01000f2011-01-17 03:46:26 +0000638 valobj_sp->GetExpressionPath (var_expr_path_strm, false);
Greg Claytonc3b61d22010-12-15 05:08:08 +0000639 error.SetErrorStringWithFormat ("failed to use pointer as array for index %i for \"(%s) %s\"",
640 child_index,
641 valobj_sp->GetTypeName().AsCString("<invalid type>"),
642 var_expr_path_strm.GetString().c_str());
643 }
644 }
645 else if (ClangASTContext::IsArrayType (valobj_sp->GetClangType(), NULL, NULL))
646 {
647 child_valobj_sp = valobj_sp->GetChildAtIndex (child_index, true);
648 if (!child_valobj_sp)
649 {
Greg Claytonb01000f2011-01-17 03:46:26 +0000650 valobj_sp->GetExpressionPath (var_expr_path_strm, false);
Greg Claytonc3b61d22010-12-15 05:08:08 +0000651 error.SetErrorStringWithFormat ("array index %i is not valid for \"(%s) %s\"",
652 child_index,
653 valobj_sp->GetTypeName().AsCString("<invalid type>"),
654 var_expr_path_strm.GetString().c_str());
655 }
656 }
657 else
658 {
Greg Claytonb01000f2011-01-17 03:46:26 +0000659 valobj_sp->GetExpressionPath (var_expr_path_strm, false);
Greg Claytonc3b61d22010-12-15 05:08:08 +0000660 error.SetErrorStringWithFormat ("\"(%s) %s\" is not an array type",
661 valobj_sp->GetTypeName().AsCString("<invalid type>"),
662 var_expr_path_strm.GetString().c_str());
663 }
664
665 if (!child_valobj_sp)
666 {
667 // Invalid array index...
668 return ValueObjectSP();
669 }
670
671 // Erase the array member specification '[%i]' where
672 // %i is the array index
673 var_path.erase(0, (end - var_path.c_str()) + 1);
674 separator_idx = var_path.find_first_of(".-[");
675
676 // Break out early from the switch since we were
677 // able to find the child member
678 break;
679 }
680 }
681 return ValueObjectSP();
682
683 default:
684 // Failure...
685 {
Greg Claytonb01000f2011-01-17 03:46:26 +0000686 valobj_sp->GetExpressionPath (var_expr_path_strm, false);
Greg Claytonc3b61d22010-12-15 05:08:08 +0000687 error.SetErrorStringWithFormat ("unexpected char '%c' encountered after \"%s\" in \"%s\"",
688 separator_type,
689 var_expr_path_strm.GetString().c_str(),
690 var_path.c_str());
691
692 return ValueObjectSP();
Greg Clayton427f2902010-12-14 02:59:59 +0000693 }
694 }
Greg Clayton427f2902010-12-14 02:59:59 +0000695
Greg Claytonc3b61d22010-12-15 05:08:08 +0000696 if (child_valobj_sp)
697 valobj_sp = child_valobj_sp;
698
699 if (var_path.empty())
700 break;
701
Greg Clayton427f2902010-12-14 02:59:59 +0000702 }
Greg Claytonc3b61d22010-12-15 05:08:08 +0000703 if (valobj_sp)
704 {
705 if (deref)
706 {
Greg Claytonbdcda462010-12-20 20:49:23 +0000707 ValueObjectSP deref_valobj_sp (valobj_sp->Dereference(error));
Greg Claytonc3b61d22010-12-15 05:08:08 +0000708 valobj_sp = deref_valobj_sp;
709 }
710 else if (address_of)
711 {
712 ValueObjectSP address_of_valobj_sp (valobj_sp->AddressOf(error));
713 valobj_sp = address_of_valobj_sp;
714 }
715 }
716 return valobj_sp;
Greg Clayton427f2902010-12-14 02:59:59 +0000717 }
Greg Claytonc3b61d22010-12-15 05:08:08 +0000718 else
Greg Clayton427f2902010-12-14 02:59:59 +0000719 {
Greg Claytonc3b61d22010-12-15 05:08:08 +0000720 error.SetErrorStringWithFormat("no variable named '%s' found in this frame", name_const_string.GetCString());
Greg Clayton427f2902010-12-14 02:59:59 +0000721 }
Greg Clayton427f2902010-12-14 02:59:59 +0000722 }
723 }
Greg Claytonc3b61d22010-12-15 05:08:08 +0000724 else
725 {
726 error.SetErrorStringWithFormat("invalid variable path '%s'", var_expr_cstr);
727 }
Greg Clayton427f2902010-12-14 02:59:59 +0000728 return ValueObjectSP();
729}
Chris Lattner24943d22010-06-08 16:52:24 +0000730
731bool
732StackFrame::GetFrameBaseValue (Scalar &frame_base, Error *error_ptr)
733{
734 if (m_flags.IsClear(GOT_FRAME_BASE))
735 {
736 if (m_sc.function)
737 {
738 m_frame_base.Clear();
739 m_frame_base_error.Clear();
740
741 m_flags.Set(GOT_FRAME_BASE);
742 ExecutionContext exe_ctx (&m_thread.GetProcess(), &m_thread, this);
743 Value expr_value;
Greg Clayton178710c2010-09-14 02:20:48 +0000744 addr_t loclist_base_addr = LLDB_INVALID_ADDRESS;
745 if (m_sc.function->GetFrameBaseExpression().IsLocationList())
Greg Claytoneea26402010-09-14 23:36:40 +0000746 loclist_base_addr = m_sc.function->GetAddressRange().GetBaseAddress().GetLoadAddress (&m_thread.GetProcess().GetTarget());
Greg Clayton178710c2010-09-14 02:20:48 +0000747
Jason Molenda8e69de42010-11-20 01:28:30 +0000748 if (m_sc.function->GetFrameBaseExpression().Evaluate(&exe_ctx, NULL, NULL, loclist_base_addr, NULL, expr_value, &m_frame_base_error) == false)
Chris Lattner24943d22010-06-08 16:52:24 +0000749 {
750 // We should really have an error if evaluate returns, but in case
751 // we don't, lets set the error to something at least.
752 if (m_frame_base_error.Success())
753 m_frame_base_error.SetErrorString("Evaluation of the frame base expression failed.");
754 }
755 else
756 {
757 m_frame_base = expr_value.ResolveValue(&exe_ctx, NULL);
758 }
759 }
760 else
761 {
762 m_frame_base_error.SetErrorString ("No function in symbol context.");
763 }
764 }
765
766 if (m_frame_base_error.Success())
767 frame_base = m_frame_base;
768
769 if (error_ptr)
770 *error_ptr = m_frame_base_error;
771 return m_frame_base_error.Success();
772}
773
Greg Clayton08d7d3a2011-01-06 22:15:06 +0000774RegisterContextSP
Chris Lattner24943d22010-06-08 16:52:24 +0000775StackFrame::GetRegisterContext ()
776{
Greg Clayton08d7d3a2011-01-06 22:15:06 +0000777 if (!m_reg_context_sp)
778 m_reg_context_sp = m_thread.CreateRegisterContextForFrame (this);
779 return m_reg_context_sp;
Chris Lattner24943d22010-06-08 16:52:24 +0000780}
781
782bool
783StackFrame::HasDebugInformation ()
784{
Greg Claytonb04e7a82010-08-24 21:05:24 +0000785 GetSymbolContext (eSymbolContextLineEntry);
Chris Lattner24943d22010-06-08 16:52:24 +0000786 return m_sc.line_entry.IsValid();
787}
788
Greg Clayton17dae082010-09-02 02:59:18 +0000789
790ValueObjectSP
791StackFrame::GetValueObjectForFrameVariable (const VariableSP &variable_sp)
Chris Lattner24943d22010-06-08 16:52:24 +0000792{
Greg Clayton17dae082010-09-02 02:59:18 +0000793 ValueObjectSP valobj_sp;
794 VariableList *var_list = GetVariableList (true);
795 if (var_list)
796 {
797 // Make sure the variable is a frame variable
798 const uint32_t var_idx = var_list->FindIndexForVariable (variable_sp.get());
799 const uint32_t num_variables = var_list->GetSize();
800 if (var_idx < num_variables)
801 {
802 valobj_sp = m_variable_list_value_objects.GetValueObjectAtIndex (var_idx);
803 if (valobj_sp.get() == NULL)
804 {
805 if (m_variable_list_value_objects.GetSize() < num_variables)
806 m_variable_list_value_objects.Resize(num_variables);
807 valobj_sp.reset (new ValueObjectVariable (variable_sp));
808 m_variable_list_value_objects.SetValueObjectAtIndex (var_idx, valobj_sp);
809 }
810 }
811 }
812 return valobj_sp;
813}
814
815ValueObjectSP
816StackFrame::TrackGlobalVariable (const VariableSP &variable_sp)
817{
818 // Check to make sure we aren't already tracking this variable?
819 ValueObjectSP valobj_sp (GetValueObjectForFrameVariable (variable_sp));
820 if (!valobj_sp)
821 {
822 // We aren't already tracking this global
823 VariableList *var_list = GetVariableList (true);
824 // If this frame has no variables, create a new list
825 if (var_list == NULL)
826 m_variable_list_sp.reset (new VariableList());
827
828 // Add the global/static variable to this frame
829 m_variable_list_sp->AddVariable (variable_sp);
830
831 // Now make a value object for it so we can track its changes
832 valobj_sp = GetValueObjectForFrameVariable (variable_sp);
833 }
834 return valobj_sp;
Chris Lattner24943d22010-06-08 16:52:24 +0000835}
836
Jim Ingham2154da42010-08-26 20:44:45 +0000837bool
838StackFrame::IsInlined ()
839{
Greg Clayton4fb08152010-08-30 18:11:35 +0000840 if (m_sc.block == NULL)
841 GetSymbolContext (eSymbolContextBlock);
842 if (m_sc.block)
843 return m_sc.block->GetContainingInlinedBlock() != NULL;
844 return false;
Jim Ingham2154da42010-08-26 20:44:45 +0000845}
846
Chris Lattner24943d22010-06-08 16:52:24 +0000847Target *
848StackFrame::CalculateTarget ()
849{
850 return m_thread.CalculateTarget();
851}
852
853Process *
854StackFrame::CalculateProcess ()
855{
856 return m_thread.CalculateProcess();
857}
858
859Thread *
860StackFrame::CalculateThread ()
861{
862 return &m_thread;
863}
864
865StackFrame *
866StackFrame::CalculateStackFrame ()
867{
868 return this;
869}
870
871
872void
Greg Claytona830adb2010-10-04 01:05:56 +0000873StackFrame::CalculateExecutionContext (ExecutionContext &exe_ctx)
Chris Lattner24943d22010-06-08 16:52:24 +0000874{
Greg Claytona830adb2010-10-04 01:05:56 +0000875 m_thread.CalculateExecutionContext (exe_ctx);
Chris Lattner24943d22010-06-08 16:52:24 +0000876 exe_ctx.frame = this;
877}
878
879void
Greg Claytona830adb2010-10-04 01:05:56 +0000880StackFrame::DumpUsingSettingsFormat (Stream *strm)
881{
882 if (strm == NULL)
883 return;
884
885 GetSymbolContext(eSymbolContextEverything);
886 ExecutionContext exe_ctx;
887 CalculateExecutionContext(exe_ctx);
888 const char *end = NULL;
889 StreamString s;
890 const char *frame_format = m_thread.GetProcess().GetTarget().GetDebugger().GetFrameFormat();
891 if (frame_format && Debugger::FormatPrompt (frame_format, &m_sc, &exe_ctx, NULL, s, &end))
892 {
893 strm->Write(s.GetData(), s.GetSize());
894 }
895 else
896 {
897 Dump (strm, true, false);
898 strm->EOL();
899 }
900}
901
902void
Greg Clayton72b71582010-09-02 21:44:10 +0000903StackFrame::Dump (Stream *strm, bool show_frame_index, bool show_fullpaths)
Chris Lattner24943d22010-06-08 16:52:24 +0000904{
905 if (strm == NULL)
906 return;
907
908 if (show_frame_index)
Greg Clayton33ed1702010-08-24 00:45:41 +0000909 strm->Printf("frame #%u: ", m_frame_index);
Greg Claytoneea26402010-09-14 23:36:40 +0000910 strm->Printf("0x%0*llx ", m_thread.GetProcess().GetAddressByteSize() * 2, GetFrameCodeAddress().GetLoadAddress(&m_thread.GetProcess().GetTarget()));
Greg Claytonb04e7a82010-08-24 21:05:24 +0000911 GetSymbolContext(eSymbolContextEverything);
Greg Clayton33ed1702010-08-24 00:45:41 +0000912 const bool show_module = true;
913 const bool show_inline = true;
Greg Clayton72b71582010-09-02 21:44:10 +0000914 m_sc.DumpStopContext(strm, &m_thread.GetProcess(), GetFrameCodeAddress(), show_fullpaths, show_module, show_inline);
Chris Lattner24943d22010-06-08 16:52:24 +0000915}
916
Greg Clayton1d66ef52010-08-27 18:24:16 +0000917void
Greg Clayton4fb08152010-08-30 18:11:35 +0000918StackFrame::UpdateCurrentFrameFromPreviousFrame (StackFrame &prev_frame)
Greg Clayton1d66ef52010-08-27 18:24:16 +0000919{
Greg Clayton4fb08152010-08-30 18:11:35 +0000920 assert (GetStackID() == prev_frame.GetStackID()); // TODO: remove this after some testing
921 m_variable_list_sp = prev_frame.m_variable_list_sp;
Greg Clayton17dae082010-09-02 02:59:18 +0000922 m_variable_list_value_objects.Swap (prev_frame.m_variable_list_value_objects);
Greg Clayton870a1cd2010-08-27 21:47:54 +0000923 if (!m_disassembly.GetString().empty())
924 m_disassembly.GetString().swap (m_disassembly.GetString());
Greg Clayton1d66ef52010-08-27 18:24:16 +0000925}
Greg Clayton870a1cd2010-08-27 21:47:54 +0000926
927
Greg Clayton4fb08152010-08-30 18:11:35 +0000928void
929StackFrame::UpdatePreviousFrameFromCurrentFrame (StackFrame &curr_frame)
930{
Greg Clayton5205f0b2010-09-03 17:10:42 +0000931 assert (GetStackID() == curr_frame.GetStackID()); // TODO: remove this after some testing
932 m_id.SetPC (curr_frame.m_id.GetPC()); // Update the Stack ID PC value
Greg Clayton4fb08152010-08-30 18:11:35 +0000933 assert (&m_thread == &curr_frame.m_thread);
934 m_frame_index = curr_frame.m_frame_index;
Greg Clayton08d7d3a2011-01-06 22:15:06 +0000935 m_concrete_frame_index = curr_frame.m_concrete_frame_index;
Greg Clayton4fb08152010-08-30 18:11:35 +0000936 m_reg_context_sp = curr_frame.m_reg_context_sp;
937 m_frame_code_addr = curr_frame.m_frame_code_addr;
938 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());
939 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());
940 assert (m_sc.comp_unit == NULL || curr_frame.m_sc.comp_unit == NULL || m_sc.comp_unit == curr_frame.m_sc.comp_unit);
941 assert (m_sc.function == NULL || curr_frame.m_sc.function == NULL || m_sc.function == curr_frame.m_sc.function);
Greg Clayton4fb08152010-08-30 18:11:35 +0000942 m_sc = curr_frame.m_sc;
943 m_flags.Clear(GOT_FRAME_BASE | eSymbolContextEverything);
944 m_flags.Set (m_sc.GetResolvedMask());
945 m_frame_base.Clear();
946 m_frame_base_error.Clear();
947}
948
949
Greg Clayton5205f0b2010-09-03 17:10:42 +0000950bool
951StackFrame::HasCachedData () const
952{
953 if (m_variable_list_sp.get())
954 return true;
955 if (m_variable_list_value_objects.GetSize() > 0)
956 return true;
957 if (!m_disassembly.GetString().empty())
958 return true;
959 return false;
Jim Inghamccd584d2010-09-23 17:40:12 +0000960}
961
962lldb::StackFrameSP
963StackFrame::GetSP ()
964{
965 return m_thread.GetStackFrameSPForStackFramePtr (this);
Greg Clayton5205f0b2010-09-03 17:10:42 +0000966}