blob: 37dc67bed0cacb1b276b545aceb4d58e9fdd78f1 [file] [log] [blame]
Chris Lattner30fdc8d2010-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
Chris Lattner30fdc8d2010-06-08 16:52:24 +000010// C Includes
11// C++ Includes
12// Other libraries and framework includes
13// Project includes
Eugene Zelenkod70a6e72016-02-18 18:52:47 +000014#include "lldb/Target/StackFrame.h"
Greg Clayton0603aa92010-10-04 01:05:56 +000015#include "lldb/Core/Debugger.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000016#include "lldb/Core/Disassembler.h"
Greg Clayton554f68d2015-02-04 22:00:53 +000017#include "lldb/Core/FormatEntity.h"
Enrico Granata592afe72016-03-15 21:50:51 +000018#include "lldb/Core/Mangled.h"
19#include "lldb/Core/Module.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000020#include "lldb/Core/Value.h"
Greg Clayton288bdf92010-09-02 02:59:18 +000021#include "lldb/Core/ValueObjectVariable.h"
Greg Clayton54979cd2010-12-15 05:08:08 +000022#include "lldb/Core/ValueObjectConstResult.h"
Greg Clayton1f746072012-08-29 21:13:06 +000023#include "lldb/Symbol/CompileUnit.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000024#include "lldb/Symbol/Function.h"
Greg Clayton1f746072012-08-29 21:13:06 +000025#include "lldb/Symbol/Symbol.h"
26#include "lldb/Symbol/SymbolContextScope.h"
Enrico Granata46252392015-11-19 22:28:58 +000027#include "lldb/Symbol/Type.h"
Greg Clayton288bdf92010-09-02 02:59:18 +000028#include "lldb/Symbol/VariableList.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000029#include "lldb/Target/ExecutionContext.h"
30#include "lldb/Target/Process.h"
31#include "lldb/Target/RegisterContext.h"
32#include "lldb/Target/Target.h"
33#include "lldb/Target/Thread.h"
34
35using namespace lldb;
36using namespace lldb_private;
37
38// The first bits in the flags are reserved for the SymbolContext::Scope bits
39// so we know if we have tried to look up information in our internal symbol
40// context (m_sc) already.
Greg Clayton59e8fc1c2010-08-30 18:11:35 +000041#define RESOLVED_FRAME_CODE_ADDR (uint32_t(eSymbolContextEverything + 1))
Greg Clayton6dadd502010-09-02 21:44:10 +000042#define RESOLVED_FRAME_ID_SYMBOL_SCOPE (RESOLVED_FRAME_CODE_ADDR << 1)
Greg Clayton59e8fc1c2010-08-30 18:11:35 +000043#define GOT_FRAME_BASE (RESOLVED_FRAME_ID_SYMBOL_SCOPE << 1)
44#define RESOLVED_VARIABLES (GOT_FRAME_BASE << 1)
Sean Callanan7c0962d2010-11-01 04:38:59 +000045#define RESOLVED_GLOBAL_VARIABLES (RESOLVED_VARIABLES << 1)
Chris Lattner30fdc8d2010-06-08 16:52:24 +000046
Greg Claytond9e416c2012-02-18 05:35:26 +000047StackFrame::StackFrame (const ThreadSP &thread_sp,
48 user_id_t frame_idx,
Greg Clayton8f7180b2011-09-26 07:11:27 +000049 user_id_t unwind_frame_index,
Greg Clayton8f7180b2011-09-26 07:11:27 +000050 addr_t cfa,
Jason Molenda99618472013-11-04 11:02:52 +000051 bool cfa_is_valid,
Greg Clayton8f7180b2011-09-26 07:11:27 +000052 addr_t pc,
Jason Molenda99618472013-11-04 11:02:52 +000053 uint32_t stop_id,
54 bool stop_id_is_valid,
55 bool is_history_frame,
Greg Clayton8f7180b2011-09-26 07:11:27 +000056 const SymbolContext *sc_ptr) :
Greg Claytond9e416c2012-02-18 05:35:26 +000057 m_thread_wp (thread_sp),
Greg Clayton1b72fcb2010-08-24 00:45:41 +000058 m_frame_index (frame_idx),
Greg Clayton5ccbd292011-01-06 22:15:06 +000059 m_concrete_frame_index (unwind_frame_index),
Greg Clayton1b72fcb2010-08-24 00:45:41 +000060 m_reg_context_sp (),
Eugene Zelenkod70a6e72016-02-18 18:52:47 +000061 m_id(pc, cfa, nullptr),
Greg Claytone72dfb32012-02-24 01:59:29 +000062 m_frame_code_addr (pc),
Greg Clayton1b72fcb2010-08-24 00:45:41 +000063 m_sc (),
64 m_flags (),
65 m_frame_base (),
66 m_frame_base_error (),
Jason Molenda99618472013-11-04 11:02:52 +000067 m_cfa_is_valid (cfa_is_valid),
68 m_stop_id (stop_id),
69 m_stop_id_is_valid (stop_id_is_valid),
70 m_is_history_frame (is_history_frame),
Chris Lattner30fdc8d2010-06-08 16:52:24 +000071 m_variable_list_sp (),
Greg Clayton1a65ae12011-01-25 23:55:37 +000072 m_variable_list_value_objects (),
Jason Molenda6a354702014-10-02 01:08:16 +000073 m_disassembly (),
74 m_mutex (Mutex::eMutexTypeRecursive)
Chris Lattner30fdc8d2010-06-08 16:52:24 +000075{
Jason Molenda99618472013-11-04 11:02:52 +000076 // If we don't have a CFA value, use the frame index for our StackID so that recursive
77 // functions properly aren't confused with one another on a history stack.
Eugene Zelenkod70a6e72016-02-18 18:52:47 +000078 if (m_is_history_frame && !m_cfa_is_valid)
Jason Molenda99618472013-11-04 11:02:52 +000079 {
80 m_id.SetCFA (m_frame_index);
81 }
82
Eugene Zelenkod70a6e72016-02-18 18:52:47 +000083 if (sc_ptr != nullptr)
Greg Clayton1b72fcb2010-08-24 00:45:41 +000084 {
Chris Lattner30fdc8d2010-06-08 16:52:24 +000085 m_sc = *sc_ptr;
Greg Clayton1b72fcb2010-08-24 00:45:41 +000086 m_flags.Set(m_sc.GetResolvedMask ());
87 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +000088}
89
Greg Claytond9e416c2012-02-18 05:35:26 +000090StackFrame::StackFrame (const ThreadSP &thread_sp,
91 user_id_t frame_idx,
Greg Clayton8f7180b2011-09-26 07:11:27 +000092 user_id_t unwind_frame_index,
Greg Clayton8f7180b2011-09-26 07:11:27 +000093 const RegisterContextSP &reg_context_sp,
94 addr_t cfa,
95 addr_t pc,
96 const SymbolContext *sc_ptr) :
Greg Claytond9e416c2012-02-18 05:35:26 +000097 m_thread_wp (thread_sp),
Greg Clayton1b72fcb2010-08-24 00:45:41 +000098 m_frame_index (frame_idx),
Greg Clayton5ccbd292011-01-06 22:15:06 +000099 m_concrete_frame_index (unwind_frame_index),
Greg Clayton1b72fcb2010-08-24 00:45:41 +0000100 m_reg_context_sp (reg_context_sp),
Eugene Zelenkod70a6e72016-02-18 18:52:47 +0000101 m_id(pc, cfa, nullptr),
Greg Claytone72dfb32012-02-24 01:59:29 +0000102 m_frame_code_addr (pc),
Greg Clayton1b72fcb2010-08-24 00:45:41 +0000103 m_sc (),
104 m_flags (),
105 m_frame_base (),
106 m_frame_base_error (),
Jason Molenda99618472013-11-04 11:02:52 +0000107 m_cfa_is_valid (true),
108 m_stop_id (0),
109 m_stop_id_is_valid (false),
110 m_is_history_frame (false),
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000111 m_variable_list_sp (),
Greg Clayton1a65ae12011-01-25 23:55:37 +0000112 m_variable_list_value_objects (),
Jason Molenda6a354702014-10-02 01:08:16 +0000113 m_disassembly (),
114 m_mutex (Mutex::eMutexTypeRecursive)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000115{
Eugene Zelenkod70a6e72016-02-18 18:52:47 +0000116 if (sc_ptr != nullptr)
Greg Clayton1b72fcb2010-08-24 00:45:41 +0000117 {
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000118 m_sc = *sc_ptr;
Greg Clayton1b72fcb2010-08-24 00:45:41 +0000119 m_flags.Set(m_sc.GetResolvedMask ());
120 }
121
122 if (reg_context_sp && !m_sc.target_sp)
123 {
Greg Claytond9e416c2012-02-18 05:35:26 +0000124 m_sc.target_sp = reg_context_sp->CalculateTarget();
125 if (m_sc.target_sp)
126 m_flags.Set (eSymbolContextTarget);
Greg Clayton1b72fcb2010-08-24 00:45:41 +0000127 }
128}
129
Greg Claytond9e416c2012-02-18 05:35:26 +0000130StackFrame::StackFrame (const ThreadSP &thread_sp,
131 user_id_t frame_idx,
Greg Clayton8f7180b2011-09-26 07:11:27 +0000132 user_id_t unwind_frame_index,
Greg Clayton8f7180b2011-09-26 07:11:27 +0000133 const RegisterContextSP &reg_context_sp,
134 addr_t cfa,
135 const Address& pc_addr,
136 const SymbolContext *sc_ptr) :
Greg Claytond9e416c2012-02-18 05:35:26 +0000137 m_thread_wp (thread_sp),
Greg Clayton1b72fcb2010-08-24 00:45:41 +0000138 m_frame_index (frame_idx),
Greg Clayton5ccbd292011-01-06 22:15:06 +0000139 m_concrete_frame_index (unwind_frame_index),
Greg Clayton1b72fcb2010-08-24 00:45:41 +0000140 m_reg_context_sp (reg_context_sp),
Eugene Zelenkod70a6e72016-02-18 18:52:47 +0000141 m_id(pc_addr.GetLoadAddress(thread_sp->CalculateTarget().get()), cfa, nullptr),
Greg Clayton12fc3e02010-08-26 22:05:43 +0000142 m_frame_code_addr (pc_addr),
Greg Clayton1b72fcb2010-08-24 00:45:41 +0000143 m_sc (),
144 m_flags (),
145 m_frame_base (),
146 m_frame_base_error (),
Jason Molenda99618472013-11-04 11:02:52 +0000147 m_cfa_is_valid (true),
148 m_stop_id (0),
149 m_stop_id_is_valid (false),
150 m_is_history_frame (false),
Greg Clayton1b72fcb2010-08-24 00:45:41 +0000151 m_variable_list_sp (),
Greg Clayton1a65ae12011-01-25 23:55:37 +0000152 m_variable_list_value_objects (),
Jason Molenda6a354702014-10-02 01:08:16 +0000153 m_disassembly (),
154 m_mutex (Mutex::eMutexTypeRecursive)
Greg Clayton1b72fcb2010-08-24 00:45:41 +0000155{
Eugene Zelenkod70a6e72016-02-18 18:52:47 +0000156 if (sc_ptr != nullptr)
Greg Clayton1b72fcb2010-08-24 00:45:41 +0000157 {
158 m_sc = *sc_ptr;
159 m_flags.Set(m_sc.GetResolvedMask ());
160 }
161
Eugene Zelenkod70a6e72016-02-18 18:52:47 +0000162 if (!m_sc.target_sp && reg_context_sp)
Greg Clayton1b72fcb2010-08-24 00:45:41 +0000163 {
Greg Claytond9e416c2012-02-18 05:35:26 +0000164 m_sc.target_sp = reg_context_sp->CalculateTarget();
165 if (m_sc.target_sp)
166 m_flags.Set (eSymbolContextTarget);
Greg Clayton1b72fcb2010-08-24 00:45:41 +0000167 }
168
Greg Claytone72dfb32012-02-24 01:59:29 +0000169 ModuleSP pc_module_sp (pc_addr.GetModule());
170 if (!m_sc.module_sp || m_sc.module_sp != pc_module_sp)
Greg Clayton1b72fcb2010-08-24 00:45:41 +0000171 {
Greg Claytone72dfb32012-02-24 01:59:29 +0000172 if (pc_module_sp)
Greg Clayton1b72fcb2010-08-24 00:45:41 +0000173 {
Greg Claytone72dfb32012-02-24 01:59:29 +0000174 m_sc.module_sp = pc_module_sp;
Greg Clayton1b72fcb2010-08-24 00:45:41 +0000175 m_flags.Set (eSymbolContextModule);
176 }
Greg Claytonffc1d662010-09-13 04:34:30 +0000177 else
178 {
179 m_sc.module_sp.reset();
180 }
Greg Clayton1b72fcb2010-08-24 00:45:41 +0000181 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000182}
183
Eugene Zelenkod70a6e72016-02-18 18:52:47 +0000184StackFrame::~StackFrame() = default;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000185
186StackID&
187StackFrame::GetStackID()
188{
Jason Molenda6a354702014-10-02 01:08:16 +0000189 Mutex::Locker locker(m_mutex);
Greg Clayton6dadd502010-09-02 21:44:10 +0000190 // Make sure we have resolved the StackID object's symbol context scope if
191 // we already haven't looked it up.
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000192
Greg Clayton59e8fc1c2010-08-30 18:11:35 +0000193 if (m_flags.IsClear (RESOLVED_FRAME_ID_SYMBOL_SCOPE))
194 {
Greg Clayton2cad65a2010-09-03 17:10:42 +0000195 if (m_id.GetSymbolContextScope ())
Greg Clayton59e8fc1c2010-08-30 18:11:35 +0000196 {
Greg Clayton95897c62010-09-07 04:20:48 +0000197 // We already have a symbol context scope, we just don't have our
198 // flag bit set.
Greg Clayton59e8fc1c2010-08-30 18:11:35 +0000199 m_flags.Set (RESOLVED_FRAME_ID_SYMBOL_SCOPE);
200 }
201 else
202 {
Greg Clayton95897c62010-09-07 04:20:48 +0000203 // Calculate the frame block and use this for the stack ID symbol
204 // context scope if we have one.
205 SymbolContextScope *scope = GetFrameBlock ();
Eugene Zelenkod70a6e72016-02-18 18:52:47 +0000206 if (scope == nullptr)
Greg Clayton59e8fc1c2010-08-30 18:11:35 +0000207 {
Greg Clayton95897c62010-09-07 04:20:48 +0000208 // We don't have a block, so use the symbol
209 if (m_flags.IsClear (eSymbolContextSymbol))
210 GetSymbolContext (eSymbolContextSymbol);
211
Eugene Zelenkod70a6e72016-02-18 18:52:47 +0000212 // It is ok if m_sc.symbol is nullptr here
Greg Clayton95897c62010-09-07 04:20:48 +0000213 scope = m_sc.symbol;
Greg Clayton59e8fc1c2010-08-30 18:11:35 +0000214 }
Greg Clayton95897c62010-09-07 04:20:48 +0000215 // Set the symbol context scope (the accessor will set the
216 // RESOLVED_FRAME_ID_SYMBOL_SCOPE bit in m_flags).
217 SetSymbolContextScope (scope);
Greg Clayton59e8fc1c2010-08-30 18:11:35 +0000218 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000219 }
220 return m_id;
221}
222
Jim Ingham513c6bb2012-09-01 01:02:41 +0000223uint32_t
224StackFrame::GetFrameIndex () const
225{
226 ThreadSP thread_sp = GetThread();
227 if (thread_sp)
Jason Molendab57e4a12013-11-04 09:33:30 +0000228 return thread_sp->GetStackFrameList()->GetVisibleStackFrameIndex(m_frame_index);
Jim Ingham513c6bb2012-09-01 01:02:41 +0000229 else
230 return m_frame_index;
231}
232
Greg Clayton59e8fc1c2010-08-30 18:11:35 +0000233void
234StackFrame::SetSymbolContextScope (SymbolContextScope *symbol_scope)
235{
Jason Molenda6a354702014-10-02 01:08:16 +0000236 Mutex::Locker locker(m_mutex);
Greg Clayton59e8fc1c2010-08-30 18:11:35 +0000237 m_flags.Set (RESOLVED_FRAME_ID_SYMBOL_SCOPE);
238 m_id.SetSymbolContextScope (symbol_scope);
239}
240
Greg Clayton34132752011-07-06 04:07:21 +0000241const Address&
Greg Clayton9da7bd02010-08-24 21:05:24 +0000242StackFrame::GetFrameCodeAddress()
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000243{
Jason Molenda6a354702014-10-02 01:08:16 +0000244 Mutex::Locker locker(m_mutex);
Greg Clayton59e8fc1c2010-08-30 18:11:35 +0000245 if (m_flags.IsClear(RESOLVED_FRAME_CODE_ADDR) && !m_frame_code_addr.IsSectionOffset())
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000246 {
Greg Clayton59e8fc1c2010-08-30 18:11:35 +0000247 m_flags.Set (RESOLVED_FRAME_CODE_ADDR);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000248
249 // Resolve the PC into a temporary address because if ResolveLoadAddress
250 // fails to resolve the address, it will clear the address object...
Greg Claytond9e416c2012-02-18 05:35:26 +0000251 ThreadSP thread_sp (GetThread());
252 if (thread_sp)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000253 {
Greg Claytond9e416c2012-02-18 05:35:26 +0000254 TargetSP target_sp (thread_sp->CalculateTarget());
255 if (target_sp)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000256 {
Tamas Berghammer25b9f7e2015-09-07 09:58:09 +0000257 if (m_frame_code_addr.SetOpcodeLoadAddress (m_frame_code_addr.GetOffset(), target_sp.get(), eAddressClassCode))
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000258 {
Greg Claytone72dfb32012-02-24 01:59:29 +0000259 ModuleSP module_sp (m_frame_code_addr.GetModule());
260 if (module_sp)
Greg Claytond9e416c2012-02-18 05:35:26 +0000261 {
Greg Claytone72dfb32012-02-24 01:59:29 +0000262 m_sc.module_sp = module_sp;
263 m_flags.Set(eSymbolContextModule);
Greg Claytond9e416c2012-02-18 05:35:26 +0000264 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000265 }
266 }
267 }
268 }
Greg Clayton12fc3e02010-08-26 22:05:43 +0000269 return m_frame_code_addr;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000270}
271
Jason Molenda99618472013-11-04 11:02:52 +0000272bool
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000273StackFrame::ChangePC (addr_t pc)
274{
Jason Molenda6a354702014-10-02 01:08:16 +0000275 Mutex::Locker locker(m_mutex);
Jason Molenda99618472013-11-04 11:02:52 +0000276 // We can't change the pc value of a history stack frame - it is immutable.
277 if (m_is_history_frame)
278 return false;
Greg Claytone72dfb32012-02-24 01:59:29 +0000279 m_frame_code_addr.SetRawAddress(pc);
Greg Clayton72310352013-02-23 04:12:47 +0000280 m_sc.Clear(false);
Greg Clayton73b472d2010-10-27 03:32:59 +0000281 m_flags.Reset(0);
Greg Claytond9e416c2012-02-18 05:35:26 +0000282 ThreadSP thread_sp (GetThread());
283 if (thread_sp)
284 thread_sp->ClearStackFrames ();
Jason Molenda99618472013-11-04 11:02:52 +0000285 return true;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000286}
287
288const char *
289StackFrame::Disassemble ()
290{
Jason Molenda6a354702014-10-02 01:08:16 +0000291 Mutex::Locker locker(m_mutex);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000292 if (m_disassembly.GetSize() == 0)
293 {
Greg Claytond9e416c2012-02-18 05:35:26 +0000294 ExecutionContext exe_ctx (shared_from_this());
295 Target *target = exe_ctx.GetTargetPtr();
296 if (target)
297 {
Eugene Zelenkod70a6e72016-02-18 18:52:47 +0000298 const char *plugin_name = nullptr;
299 const char *flavor = nullptr;
Greg Claytond9e416c2012-02-18 05:35:26 +0000300 Disassembler::Disassemble (target->GetDebugger(),
301 target->GetArchitecture(),
Jim Ingham0f063ba2013-03-02 00:26:47 +0000302 plugin_name,
303 flavor,
Greg Claytond9e416c2012-02-18 05:35:26 +0000304 exe_ctx,
305 0,
306 0,
307 0,
308 m_disassembly);
309 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000310 if (m_disassembly.GetSize() == 0)
Eugene Zelenkod70a6e72016-02-18 18:52:47 +0000311 return nullptr;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000312 }
313 return m_disassembly.GetData();
314}
315
Greg Clayton95897c62010-09-07 04:20:48 +0000316Block *
317StackFrame::GetFrameBlock ()
318{
Eugene Zelenkod70a6e72016-02-18 18:52:47 +0000319 if (m_sc.block == nullptr && m_flags.IsClear(eSymbolContextBlock))
Greg Clayton95897c62010-09-07 04:20:48 +0000320 GetSymbolContext (eSymbolContextBlock);
321
322 if (m_sc.block)
323 {
324 Block *inline_block = m_sc.block->GetContainingInlinedBlock();
325 if (inline_block)
326 {
327 // Use the block with the inlined function info
328 // as the frame block we want this frame to have only the variables
329 // for the inlined function and its non-inlined block child blocks.
330 return inline_block;
331 }
332 else
333 {
334 // This block is not contained withing any inlined function blocks
335 // with so we want to use the top most function block.
336 return &m_sc.function->GetBlock (false);
337 }
338 }
Eugene Zelenkod70a6e72016-02-18 18:52:47 +0000339 return nullptr;
Greg Clayton95897c62010-09-07 04:20:48 +0000340}
341
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000342//----------------------------------------------------------------------
343// Get the symbol context if we already haven't done so by resolving the
344// PC address as much as possible. This way when we pass around a
345// StackFrame object, everyone will have as much information as
346// possible and no one will ever have to look things up manually.
347//----------------------------------------------------------------------
348const SymbolContext&
349StackFrame::GetSymbolContext (uint32_t resolve_scope)
350{
Jason Molenda6a354702014-10-02 01:08:16 +0000351 Mutex::Locker locker(m_mutex);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000352 // Copy our internal symbol context into "sc".
Greg Clayton73b472d2010-10-27 03:32:59 +0000353 if ((m_flags.Get() & resolve_scope) != resolve_scope)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000354 {
Greg Clayton75a03332012-11-29 00:53:06 +0000355 uint32_t resolved = 0;
356
357 // If the target was requested add that:
358 if (!m_sc.target_sp)
359 {
360 m_sc.target_sp = CalculateTarget();
361 if (m_sc.target_sp)
362 resolved |= eSymbolContextTarget;
363 }
364
Bruce Mitcheneraaa0ba32014-07-08 18:05:41 +0000365 // Resolve our PC to section offset if we haven't already done so
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000366 // and if we don't have a module. The resolved address section will
367 // contain the module to which it belongs
Greg Clayton59e8fc1c2010-08-30 18:11:35 +0000368 if (!m_sc.module_sp && m_flags.IsClear(RESOLVED_FRAME_CODE_ADDR))
Greg Clayton9da7bd02010-08-24 21:05:24 +0000369 GetFrameCodeAddress();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000370
371 // If this is not frame zero, then we need to subtract 1 from the PC
372 // value when doing address lookups since the PC will be on the
373 // instruction following the function call instruction...
374
Greg Clayton9da7bd02010-08-24 21:05:24 +0000375 Address lookup_addr(GetFrameCodeAddress());
Greg Clayton1b72fcb2010-08-24 00:45:41 +0000376 if (m_frame_index > 0 && lookup_addr.IsValid())
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000377 {
378 addr_t offset = lookup_addr.GetOffset();
379 if (offset > 0)
Jason Molendacf296752014-11-08 05:38:17 +0000380 {
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000381 lookup_addr.SetOffset(offset - 1);
Jason Molendacf296752014-11-08 05:38:17 +0000382
383 }
384 else
385 {
386 // lookup_addr is the start of a section. We need
387 // do the math on the actual load address and re-compute
388 // the section. We're working with a 'noreturn' function
389 // at the end of a section.
390 ThreadSP thread_sp (GetThread());
391 if (thread_sp)
392 {
393 TargetSP target_sp (thread_sp->CalculateTarget());
394 if (target_sp)
395 {
396 addr_t addr_minus_one = lookup_addr.GetLoadAddress(target_sp.get()) - 1;
397 lookup_addr.SetLoadAddress (addr_minus_one, target_sp.get());
398 }
399 else
400 {
401 lookup_addr.SetOffset(offset - 1);
402 }
403 }
404 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000405 }
406
407 if (m_sc.module_sp)
408 {
409 // We have something in our stack frame symbol context, lets check
410 // if we haven't already tried to lookup one of those things. If we
411 // haven't then we will do the query.
Greg Clayton1b72fcb2010-08-24 00:45:41 +0000412
413 uint32_t actual_resolve_scope = 0;
414
415 if (resolve_scope & eSymbolContextCompUnit)
416 {
417 if (m_flags.IsClear (eSymbolContextCompUnit))
418 {
419 if (m_sc.comp_unit)
Greg Clayton9da7bd02010-08-24 21:05:24 +0000420 resolved |= eSymbolContextCompUnit;
Greg Clayton1b72fcb2010-08-24 00:45:41 +0000421 else
422 actual_resolve_scope |= eSymbolContextCompUnit;
423 }
424 }
425
426 if (resolve_scope & eSymbolContextFunction)
427 {
428 if (m_flags.IsClear (eSymbolContextFunction))
429 {
430 if (m_sc.function)
Greg Clayton9da7bd02010-08-24 21:05:24 +0000431 resolved |= eSymbolContextFunction;
Greg Clayton1b72fcb2010-08-24 00:45:41 +0000432 else
433 actual_resolve_scope |= eSymbolContextFunction;
434 }
435 }
436
437 if (resolve_scope & eSymbolContextBlock)
438 {
439 if (m_flags.IsClear (eSymbolContextBlock))
440 {
441 if (m_sc.block)
Greg Clayton9da7bd02010-08-24 21:05:24 +0000442 resolved |= eSymbolContextBlock;
Greg Clayton1b72fcb2010-08-24 00:45:41 +0000443 else
444 actual_resolve_scope |= eSymbolContextBlock;
445 }
446 }
447
448 if (resolve_scope & eSymbolContextSymbol)
449 {
450 if (m_flags.IsClear (eSymbolContextSymbol))
451 {
452 if (m_sc.symbol)
Greg Clayton9da7bd02010-08-24 21:05:24 +0000453 resolved |= eSymbolContextSymbol;
Greg Clayton1b72fcb2010-08-24 00:45:41 +0000454 else
455 actual_resolve_scope |= eSymbolContextSymbol;
456 }
457 }
458
459 if (resolve_scope & eSymbolContextLineEntry)
460 {
461 if (m_flags.IsClear (eSymbolContextLineEntry))
462 {
463 if (m_sc.line_entry.IsValid())
Greg Clayton9da7bd02010-08-24 21:05:24 +0000464 resolved |= eSymbolContextLineEntry;
Greg Clayton1b72fcb2010-08-24 00:45:41 +0000465 else
466 actual_resolve_scope |= eSymbolContextLineEntry;
467 }
468 }
469
470 if (actual_resolve_scope)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000471 {
472 // We might be resolving less information than what is already
473 // in our current symbol context so resolve into a temporary
474 // symbol context "sc" so we don't clear out data we have
475 // already found in "m_sc"
476 SymbolContext sc;
477 // Set flags that indicate what we have tried to resolve
Greg Clayton9da7bd02010-08-24 21:05:24 +0000478 resolved |= m_sc.module_sp->ResolveSymbolContextForAddress (lookup_addr, actual_resolve_scope, sc);
Greg Clayton1b72fcb2010-08-24 00:45:41 +0000479 // Only replace what we didn't already have as we may have
480 // information for an inlined function scope that won't match
481 // what a standard lookup by address would match
Eugene Zelenkod70a6e72016-02-18 18:52:47 +0000482 if ((resolved & eSymbolContextCompUnit) && m_sc.comp_unit == nullptr)
Greg Clayton9da7bd02010-08-24 21:05:24 +0000483 m_sc.comp_unit = sc.comp_unit;
Eugene Zelenkod70a6e72016-02-18 18:52:47 +0000484 if ((resolved & eSymbolContextFunction) && m_sc.function == nullptr)
Greg Clayton9da7bd02010-08-24 21:05:24 +0000485 m_sc.function = sc.function;
Eugene Zelenkod70a6e72016-02-18 18:52:47 +0000486 if ((resolved & eSymbolContextBlock) && m_sc.block == nullptr)
Greg Clayton9da7bd02010-08-24 21:05:24 +0000487 m_sc.block = sc.block;
Eugene Zelenkod70a6e72016-02-18 18:52:47 +0000488 if ((resolved & eSymbolContextSymbol) && m_sc.symbol == nullptr)
Greg Clayton9da7bd02010-08-24 21:05:24 +0000489 m_sc.symbol = sc.symbol;
Greg Clayton75a03332012-11-29 00:53:06 +0000490 if ((resolved & eSymbolContextLineEntry) && !m_sc.line_entry.IsValid())
491 {
Greg Clayton9da7bd02010-08-24 21:05:24 +0000492 m_sc.line_entry = sc.line_entry;
Greg Clayton75a03332012-11-29 00:53:06 +0000493 if (m_sc.target_sp)
494 {
495 // Be sure to apply and file remappings to our file and line
496 // entries when handing out a line entry
497 FileSpec new_file_spec;
498 if (m_sc.target_sp->GetSourcePathMap().FindFile (m_sc.line_entry.file, new_file_spec))
499 m_sc.line_entry.file = new_file_spec;
500 }
501 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000502 }
503 }
504 else
505 {
506 // If we don't have a module, then we can't have the compile unit,
507 // function, block, line entry or symbol, so we can safely call
508 // ResolveSymbolContextForAddress with our symbol context member m_sc.
Greg Clayton9da7bd02010-08-24 21:05:24 +0000509 if (m_sc.target_sp)
Sean Callananf4be2272013-02-21 20:54:33 +0000510 {
Greg Clayton75a03332012-11-29 00:53:06 +0000511 resolved |= m_sc.target_sp->GetImages().ResolveSymbolContextForAddress (lookup_addr, resolve_scope, m_sc);
Sean Callananf4be2272013-02-21 20:54:33 +0000512 }
Greg Clayton9da7bd02010-08-24 21:05:24 +0000513 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000514
515 // Update our internal flags so we remember what we have tried to locate so
516 // we don't have to keep trying when more calls to this function are made.
Greg Clayton9da7bd02010-08-24 21:05:24 +0000517 // We might have dug up more information that was requested (for example
518 // if we were asked to only get the block, we will have gotten the
519 // compile unit, and function) so set any additional bits that we resolved
520 m_flags.Set (resolve_scope | resolved);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000521 }
522
523 // Return the symbol context with everything that was possible to resolve
524 // resolved.
525 return m_sc;
526}
527
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000528VariableList *
Greg Clayton288bdf92010-09-02 02:59:18 +0000529StackFrame::GetVariableList (bool get_file_globals)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000530{
Jason Molenda6a354702014-10-02 01:08:16 +0000531 Mutex::Locker locker(m_mutex);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000532 if (m_flags.IsClear(RESOLVED_VARIABLES))
533 {
534 m_flags.Set(RESOLVED_VARIABLES);
535
Greg Clayton95897c62010-09-07 04:20:48 +0000536 Block *frame_block = GetFrameBlock();
537
538 if (frame_block)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000539 {
Greg Clayton95897c62010-09-07 04:20:48 +0000540 const bool get_child_variables = true;
541 const bool can_create = true;
Greg Claytonc662ec82011-06-17 22:10:16 +0000542 const bool stop_if_child_block_is_inlined_function = true;
543 m_variable_list_sp.reset(new VariableList());
Tamas Berghammer72ac8a82016-02-25 12:23:37 +0000544 frame_block->AppendBlockVariables(can_create,
545 get_child_variables,
546 stop_if_child_block_is_inlined_function,
547 [this](Variable* v) { return v->IsInScope(this); },
548 m_variable_list_sp.get());
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000549 }
Sean Callanan7c0962d2010-11-01 04:38:59 +0000550 }
551
552 if (m_flags.IsClear(RESOLVED_GLOBAL_VARIABLES) &&
553 get_file_globals)
554 {
555 m_flags.Set(RESOLVED_GLOBAL_VARIABLES);
Greg Clayton288bdf92010-09-02 02:59:18 +0000556
Sean Callanan7c0962d2010-11-01 04:38:59 +0000557 if (m_flags.IsClear (eSymbolContextCompUnit))
558 GetSymbolContext (eSymbolContextCompUnit);
559
560 if (m_sc.comp_unit)
Greg Clayton288bdf92010-09-02 02:59:18 +0000561 {
Sean Callanan7c0962d2010-11-01 04:38:59 +0000562 VariableListSP global_variable_list_sp (m_sc.comp_unit->GetVariableList(true));
563 if (m_variable_list_sp)
564 m_variable_list_sp->AddVariables (global_variable_list_sp.get());
565 else
566 m_variable_list_sp = global_variable_list_sp;
Greg Clayton288bdf92010-09-02 02:59:18 +0000567 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000568 }
Sean Callanan7c0962d2010-11-01 04:38:59 +0000569
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000570 return m_variable_list_sp.get();
571}
572
Greg Claytond41f0322011-08-02 23:35:43 +0000573VariableListSP
574StackFrame::GetInScopeVariableList (bool get_file_globals)
575{
Jason Molenda6a354702014-10-02 01:08:16 +0000576 Mutex::Locker locker(m_mutex);
Jason Molenda99618472013-11-04 11:02:52 +0000577 // We can't fetch variable information for a history stack frame.
578 if (m_is_history_frame)
579 return VariableListSP();
580
Greg Claytond41f0322011-08-02 23:35:43 +0000581 VariableListSP var_list_sp(new VariableList);
582 GetSymbolContext (eSymbolContextCompUnit | eSymbolContextBlock);
583
584 if (m_sc.block)
585 {
586 const bool can_create = true;
587 const bool get_parent_variables = true;
588 const bool stop_if_block_is_inlined_function = true;
589 m_sc.block->AppendVariables (can_create,
590 get_parent_variables,
591 stop_if_block_is_inlined_function,
Tamas Berghammer72ac8a82016-02-25 12:23:37 +0000592 [this](Variable* v) { return v->IsInScope(this); },
Greg Claytond41f0322011-08-02 23:35:43 +0000593 var_list_sp.get());
594 }
595
Siva Chandrab90168f2016-02-02 23:49:41 +0000596 if (m_sc.comp_unit && get_file_globals)
Greg Claytond41f0322011-08-02 23:35:43 +0000597 {
598 VariableListSP global_variable_list_sp (m_sc.comp_unit->GetVariableList(true));
599 if (global_variable_list_sp)
600 var_list_sp->AddVariables (global_variable_list_sp.get());
601 }
602
603 return var_list_sp;
604}
605
Greg Clayton8b2fe6d2010-12-14 02:59:59 +0000606ValueObjectSP
Greg Clayton685c88c2012-07-14 00:53:55 +0000607StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr,
Greg Clayton4d122c42011-09-17 08:33:22 +0000608 DynamicValueType use_dynamic,
Jim Ingham2837b762011-05-04 03:43:18 +0000609 uint32_t options,
Greg Clayton4d122c42011-09-17 08:33:22 +0000610 VariableSP &var_sp,
Jim Ingham2837b762011-05-04 03:43:18 +0000611 Error &error)
Greg Clayton8b2fe6d2010-12-14 02:59:59 +0000612{
Jason Molenda99618472013-11-04 11:02:52 +0000613 // We can't fetch variable information for a history stack frame.
614 if (m_is_history_frame)
615 return ValueObjectSP();
Greg Clayton54979cd2010-12-15 05:08:08 +0000616
617 if (var_expr_cstr && var_expr_cstr[0])
Greg Clayton8b2fe6d2010-12-14 02:59:59 +0000618 {
Greg Clayton6d5e68e2011-01-20 19:27:18 +0000619 const bool check_ptr_vs_member = (options & eExpressionPathOptionCheckPtrVsMember) != 0;
620 const bool no_fragile_ivar = (options & eExpressionPathOptionsNoFragileObjcIvar) != 0;
Enrico Granata27b625e2011-08-09 01:04:56 +0000621 const bool no_synth_child = (options & eExpressionPathOptionsNoSyntheticChildren) != 0;
Enrico Granata58ad3342011-08-19 21:56:10 +0000622 //const bool no_synth_array = (options & eExpressionPathOptionsNoSyntheticArrayRange) != 0;
Greg Clayton54979cd2010-12-15 05:08:08 +0000623 error.Clear();
624 bool deref = false;
625 bool address_of = false;
626 ValueObjectSP valobj_sp;
627 const bool get_file_globals = true;
Greg Claytond41f0322011-08-02 23:35:43 +0000628 // When looking up a variable for an expression, we need only consider the
629 // variables that are in scope.
630 VariableListSP var_list_sp (GetInScopeVariableList (get_file_globals));
631 VariableList *variable_list = var_list_sp.get();
Greg Clayton54979cd2010-12-15 05:08:08 +0000632
633 if (variable_list)
Greg Clayton8b2fe6d2010-12-14 02:59:59 +0000634 {
Greg Clayton54979cd2010-12-15 05:08:08 +0000635 // If first character is a '*', then show pointer contents
636 const char *var_expr = var_expr_cstr;
637 if (var_expr[0] == '*')
Greg Clayton8b2fe6d2010-12-14 02:59:59 +0000638 {
Greg Clayton54979cd2010-12-15 05:08:08 +0000639 deref = true;
640 var_expr++; // Skip the '*'
641 }
642 else if (var_expr[0] == '&')
643 {
644 address_of = true;
645 var_expr++; // Skip the '&'
646 }
647
648 std::string var_path (var_expr);
649 size_t separator_idx = var_path.find_first_of(".-[=+~|&^%#@!/?,<>{}");
650 StreamString var_expr_path_strm;
651
652 ConstString name_const_string;
653 if (separator_idx == std::string::npos)
654 name_const_string.SetCString (var_path.c_str());
655 else
656 name_const_string.SetCStringWithLength (var_path.c_str(), separator_idx);
657
Paul Herman10bc1a42015-08-18 22:46:57 +0000658 var_sp = variable_list->FindVariable(name_const_string, false);
Greg Clayton685c88c2012-07-14 00:53:55 +0000659
660 bool synthetically_added_instance_object = false;
661
662 if (var_sp)
663 {
664 var_path.erase (0, name_const_string.GetLength ());
665 }
Enrico Granata46252392015-11-19 22:28:58 +0000666
667 if (!var_sp && (options & eExpressionPathOptionsAllowDirectIVarAccess))
Greg Clayton685c88c2012-07-14 00:53:55 +0000668 {
669 // Check for direct ivars access which helps us with implicit
670 // access to ivars with the "this->" or "self->"
671 GetSymbolContext(eSymbolContextFunction|eSymbolContextBlock);
672 lldb::LanguageType method_language = eLanguageTypeUnknown;
673 bool is_instance_method = false;
674 ConstString method_object_name;
675 if (m_sc.GetFunctionMethodInfo (method_language, is_instance_method, method_object_name))
676 {
677 if (is_instance_method && method_object_name)
678 {
679 var_sp = variable_list->FindVariable(method_object_name);
680 if (var_sp)
681 {
682 separator_idx = 0;
683 var_path.insert(0, "->");
684 synthetically_added_instance_object = true;
685 }
686 }
687 }
688 }
Enrico Granata46252392015-11-19 22:28:58 +0000689
690 if (!var_sp && (options & eExpressionPathOptionsInspectAnonymousUnions))
691 {
692 // Check if any anonymous unions are there which contain a variable with the name we need
693 for (size_t i = 0;
694 i < variable_list->GetSize();
695 i++)
696 {
697 if (VariableSP variable_sp = variable_list->GetVariableAtIndex(i))
698 {
699 if (variable_sp->GetName().IsEmpty())
700 {
701 if (Type *var_type = variable_sp->GetType())
702 {
703 if (var_type->GetForwardCompilerType().IsAnonymousType())
704 {
705 valobj_sp = GetValueObjectForFrameVariable (variable_sp, use_dynamic);
706 if (!valobj_sp)
707 return valobj_sp;
708 valobj_sp = valobj_sp->GetChildMemberWithName(name_const_string, true);
709 if (valobj_sp)
710 break;
711 }
712 }
713 }
714 }
715 }
716 }
Greg Clayton685c88c2012-07-14 00:53:55 +0000717
Enrico Granata46252392015-11-19 22:28:58 +0000718 if (var_sp && !valobj_sp)
Greg Clayton54979cd2010-12-15 05:08:08 +0000719 {
Jim Ingham2837b762011-05-04 03:43:18 +0000720 valobj_sp = GetValueObjectForFrameVariable (var_sp, use_dynamic);
Jim Ingham78a685a2011-04-16 00:01:13 +0000721 if (!valobj_sp)
722 return valobj_sp;
Enrico Granata46252392015-11-19 22:28:58 +0000723 }
724 if (valobj_sp)
725 {
Greg Clayton54979cd2010-12-15 05:08:08 +0000726 // We are dumping at least one child
727 while (separator_idx != std::string::npos)
Greg Clayton8b2fe6d2010-12-14 02:59:59 +0000728 {
Greg Clayton54979cd2010-12-15 05:08:08 +0000729 // Calculate the next separator index ahead of time
730 ValueObjectSP child_valobj_sp;
731 const char separator_type = var_path[0];
732 switch (separator_type)
Greg Clayton8b2fe6d2010-12-14 02:59:59 +0000733 {
Greg Clayton54979cd2010-12-15 05:08:08 +0000734 case '-':
735 if (var_path.size() >= 2 && var_path[1] != '>')
Greg Clayton8b2fe6d2010-12-14 02:59:59 +0000736 return ValueObjectSP();
Greg Clayton8b2fe6d2010-12-14 02:59:59 +0000737
Greg Clayton6d5e68e2011-01-20 19:27:18 +0000738 if (no_fragile_ivar)
739 {
740 // Make sure we aren't trying to deref an objective
741 // C ivar if this is not allowed
Eugene Zelenkod70a6e72016-02-18 18:52:47 +0000742 const uint32_t pointer_type_flags = valobj_sp->GetCompilerType().GetTypeInfo(nullptr);
Enrico Granata622be232014-10-21 20:52:14 +0000743 if ((pointer_type_flags & eTypeIsObjC) &&
744 (pointer_type_flags & eTypeIsPointer))
Greg Clayton6d5e68e2011-01-20 19:27:18 +0000745 {
746 // This was an objective C object pointer and
747 // it was requested we skip any fragile ivars
748 // so return nothing here
749 return ValueObjectSP();
750 }
751 }
Greg Clayton54979cd2010-12-15 05:08:08 +0000752 var_path.erase (0, 1); // Remove the '-'
Jason Molenda62e06812016-02-16 04:14:33 +0000753 LLVM_FALLTHROUGH;
Greg Clayton54979cd2010-12-15 05:08:08 +0000754 case '.':
Greg Clayton8b2fe6d2010-12-14 02:59:59 +0000755 {
Greg Clayton54979cd2010-12-15 05:08:08 +0000756 const bool expr_is_ptr = var_path[0] == '>';
Greg Clayton8b2fe6d2010-12-14 02:59:59 +0000757
Greg Clayton54979cd2010-12-15 05:08:08 +0000758 var_path.erase (0, 1); // Remove the '.' or '>'
759 separator_idx = var_path.find_first_of(".-[");
760 ConstString child_name;
761 if (separator_idx == std::string::npos)
762 child_name.SetCString (var_path.c_str());
Greg Clayton8b2fe6d2010-12-14 02:59:59 +0000763 else
Greg Clayton54979cd2010-12-15 05:08:08 +0000764 child_name.SetCStringWithLength(var_path.c_str(), separator_idx);
765
766 if (check_ptr_vs_member)
Greg Clayton8b2fe6d2010-12-14 02:59:59 +0000767 {
Greg Clayton54979cd2010-12-15 05:08:08 +0000768 // We either have a pointer type and need to verify
769 // valobj_sp is a pointer, or we have a member of a
770 // class/union/struct being accessed with the . syntax
771 // and need to verify we don't have a pointer.
772 const bool actual_is_ptr = valobj_sp->IsPointerType ();
773
774 if (actual_is_ptr != expr_is_ptr)
775 {
776 // Incorrect use of "." with a pointer, or "->" with
777 // a class/union/struct instance or reference.
Greg Clayton6beaaa62011-01-17 03:46:26 +0000778 valobj_sp->GetExpressionPath (var_expr_path_strm, false);
Greg Clayton54979cd2010-12-15 05:08:08 +0000779 if (actual_is_ptr)
780 error.SetErrorStringWithFormat ("\"%s\" is a pointer and . was used to attempt to access \"%s\". Did you mean \"%s->%s\"?",
781 var_expr_path_strm.GetString().c_str(),
782 child_name.GetCString(),
783 var_expr_path_strm.GetString().c_str(),
784 var_path.c_str());
785 else
786 error.SetErrorStringWithFormat ("\"%s\" is not a pointer and -> was used to attempt to access \"%s\". Did you mean \"%s.%s\"?",
787 var_expr_path_strm.GetString().c_str(),
788 child_name.GetCString(),
789 var_expr_path_strm.GetString().c_str(),
790 var_path.c_str());
791 return ValueObjectSP();
792 }
Greg Clayton8b2fe6d2010-12-14 02:59:59 +0000793 }
Greg Clayton54979cd2010-12-15 05:08:08 +0000794 child_valobj_sp = valobj_sp->GetChildMemberWithName (child_name, true);
Greg Clayton8b2fe6d2010-12-14 02:59:59 +0000795 if (!child_valobj_sp)
796 {
Eugene Zelenkod70a6e72016-02-18 18:52:47 +0000797 if (!no_synth_child)
Enrico Granata86cc9822012-03-19 22:58:49 +0000798 {
799 child_valobj_sp = valobj_sp->GetSyntheticValue();
800 if (child_valobj_sp)
801 child_valobj_sp = child_valobj_sp->GetChildMemberWithName (child_name, true);
802 }
Enrico Granata8c9d3562011-08-11 17:08:01 +0000803
804 if (no_synth_child || !child_valobj_sp)
Greg Clayton54979cd2010-12-15 05:08:08 +0000805 {
Enrico Granata8c9d3562011-08-11 17:08:01 +0000806 // No child member with name "child_name"
Greg Clayton685c88c2012-07-14 00:53:55 +0000807 if (synthetically_added_instance_object)
Enrico Granata8c9d3562011-08-11 17:08:01 +0000808 {
Greg Clayton685c88c2012-07-14 00:53:55 +0000809 // We added a "this->" or "self->" to the beginning of the expression
810 // and this is the first pointer ivar access, so just return the normal
811 // error
812 error.SetErrorStringWithFormat("no variable or instance variable named '%s' found in this frame",
813 name_const_string.GetCString());
Enrico Granata8c9d3562011-08-11 17:08:01 +0000814 }
815 else
816 {
Greg Clayton685c88c2012-07-14 00:53:55 +0000817 valobj_sp->GetExpressionPath (var_expr_path_strm, false);
818 if (child_name)
819 {
820 error.SetErrorStringWithFormat ("\"%s\" is not a member of \"(%s) %s\"",
821 child_name.GetCString(),
822 valobj_sp->GetTypeName().AsCString("<invalid type>"),
823 var_expr_path_strm.GetString().c_str());
824 }
825 else
826 {
827 error.SetErrorStringWithFormat ("incomplete expression path after \"%s\" in \"%s\"",
828 var_expr_path_strm.GetString().c_str(),
829 var_expr_cstr);
830 }
Enrico Granata8c9d3562011-08-11 17:08:01 +0000831 }
832 return ValueObjectSP();
Greg Clayton54979cd2010-12-15 05:08:08 +0000833 }
Greg Clayton8b2fe6d2010-12-14 02:59:59 +0000834 }
Greg Clayton685c88c2012-07-14 00:53:55 +0000835 synthetically_added_instance_object = false;
Greg Clayton54979cd2010-12-15 05:08:08 +0000836 // Remove the child name from the path
837 var_path.erase(0, child_name.GetLength());
Greg Clayton4d122c42011-09-17 08:33:22 +0000838 if (use_dynamic != eNoDynamicValues)
Jim Ingham78a685a2011-04-16 00:01:13 +0000839 {
Jim Ingham2837b762011-05-04 03:43:18 +0000840 ValueObjectSP dynamic_value_sp(child_valobj_sp->GetDynamicValue(use_dynamic));
Jim Ingham78a685a2011-04-16 00:01:13 +0000841 if (dynamic_value_sp)
842 child_valobj_sp = dynamic_value_sp;
843 }
Greg Clayton54979cd2010-12-15 05:08:08 +0000844 }
845 break;
Greg Clayton8b2fe6d2010-12-14 02:59:59 +0000846
Greg Clayton54979cd2010-12-15 05:08:08 +0000847 case '[':
848 // Array member access, or treating pointer as an array
849 if (var_path.size() > 2) // Need at least two brackets and a number
850 {
Eugene Zelenkod70a6e72016-02-18 18:52:47 +0000851 char *end = nullptr;
Greg Clayton1a65ae12011-01-25 23:55:37 +0000852 long child_index = ::strtol (&var_path[1], &end, 0);
Enrico Granata9fc19442011-07-06 02:13:41 +0000853 if (end && *end == ']'
854 && *(end-1) != '[') // this code forces an error in the case of arr[]. as bitfield[] is not a good syntax we're good to go
Greg Clayton54979cd2010-12-15 05:08:08 +0000855 {
Greg Clayton99558cc42015-08-24 23:46:31 +0000856 if (valobj_sp->GetCompilerType().IsPointerToScalarType() && deref)
Enrico Granata9fc19442011-07-06 02:13:41 +0000857 {
858 // what we have is *ptr[low]. the most similar C++ syntax is to deref ptr
859 // and extract bit low out of it. reading array item low
860 // would be done by saying ptr[low], without a deref * sign
861 Error error;
862 ValueObjectSP temp(valobj_sp->Dereference(error));
863 if (error.Fail())
864 {
865 valobj_sp->GetExpressionPath (var_expr_path_strm, false);
866 error.SetErrorStringWithFormat ("could not dereference \"(%s) %s\"",
867 valobj_sp->GetTypeName().AsCString("<invalid type>"),
868 var_expr_path_strm.GetString().c_str());
869 return ValueObjectSP();
870 }
871 valobj_sp = temp;
872 deref = false;
873 }
Greg Clayton99558cc42015-08-24 23:46:31 +0000874 else if (valobj_sp->GetCompilerType().IsArrayOfScalarType() && deref)
Enrico Granata9fc19442011-07-06 02:13:41 +0000875 {
876 // what we have is *arr[low]. the most similar C++ syntax is to get arr[0]
877 // (an operation that is equivalent to deref-ing arr)
878 // and extract bit low out of it. reading array item low
879 // would be done by saying arr[low], without a deref * sign
880 Error error;
881 ValueObjectSP temp(valobj_sp->GetChildAtIndex (0, true));
882 if (error.Fail())
883 {
884 valobj_sp->GetExpressionPath (var_expr_path_strm, false);
885 error.SetErrorStringWithFormat ("could not get item 0 for \"(%s) %s\"",
886 valobj_sp->GetTypeName().AsCString("<invalid type>"),
887 var_expr_path_strm.GetString().c_str());
888 return ValueObjectSP();
889 }
890 valobj_sp = temp;
891 deref = false;
892 }
893
Greg Clayton4ef877f2012-12-06 02:33:54 +0000894 bool is_incomplete_array = false;
Greg Clayton54979cd2010-12-15 05:08:08 +0000895 if (valobj_sp->IsPointerType ())
896 {
Sean Callanan226b70c2012-03-08 02:39:03 +0000897 bool is_objc_pointer = true;
898
Greg Clayton99558cc42015-08-24 23:46:31 +0000899 if (valobj_sp->GetCompilerType().GetMinimumLanguage() != eLanguageTypeObjC)
Sean Callanan226b70c2012-03-08 02:39:03 +0000900 is_objc_pointer = false;
Greg Clayton99558cc42015-08-24 23:46:31 +0000901 else if (!valobj_sp->GetCompilerType().IsPointerType())
Sean Callanan226b70c2012-03-08 02:39:03 +0000902 is_objc_pointer = false;
903
904 if (no_synth_child && is_objc_pointer)
Greg Clayton54979cd2010-12-15 05:08:08 +0000905 {
Sean Callanan226b70c2012-03-08 02:39:03 +0000906 error.SetErrorStringWithFormat("\"(%s) %s\" is an Objective-C pointer, and cannot be subscripted",
907 valobj_sp->GetTypeName().AsCString("<invalid type>"),
908 var_expr_path_strm.GetString().c_str());
909
910 return ValueObjectSP();
911 }
912 else if (is_objc_pointer)
913 {
Enrico Granata27b625e2011-08-09 01:04:56 +0000914 // dereferencing ObjC variables is not valid.. so let's try and recur to synthetic children
Enrico Granata86cc9822012-03-19 22:58:49 +0000915 ValueObjectSP synthetic = valobj_sp->GetSyntheticValue();
Eugene Zelenkod70a6e72016-02-18 18:52:47 +0000916 if (!synthetic /* no synthetic */
Enrico Granata27b625e2011-08-09 01:04:56 +0000917 || synthetic == valobj_sp) /* synthetic is the same as the original object */
918 {
919 valobj_sp->GetExpressionPath (var_expr_path_strm, false);
920 error.SetErrorStringWithFormat ("\"(%s) %s\" is not an array type",
921 valobj_sp->GetTypeName().AsCString("<invalid type>"),
922 var_expr_path_strm.GetString().c_str());
923 }
Saleem Abdulrasool3985c8c2014-04-02 03:51:35 +0000924 else if (static_cast<uint32_t>(child_index) >= synthetic->GetNumChildren() /* synthetic does not have that many values */)
Enrico Granata27b625e2011-08-09 01:04:56 +0000925 {
926 valobj_sp->GetExpressionPath (var_expr_path_strm, false);
Jason Molenda7e589a62011-09-20 00:26:08 +0000927 error.SetErrorStringWithFormat ("array index %ld is not valid for \"(%s) %s\"",
Enrico Granata27b625e2011-08-09 01:04:56 +0000928 child_index,
929 valobj_sp->GetTypeName().AsCString("<invalid type>"),
930 var_expr_path_strm.GetString().c_str());
931 }
932 else
933 {
934 child_valobj_sp = synthetic->GetChildAtIndex(child_index, true);
935 if (!child_valobj_sp)
936 {
937 valobj_sp->GetExpressionPath (var_expr_path_strm, false);
Jason Molenda7e589a62011-09-20 00:26:08 +0000938 error.SetErrorStringWithFormat ("array index %ld is not valid for \"(%s) %s\"",
Enrico Granata27b625e2011-08-09 01:04:56 +0000939 child_index,
940 valobj_sp->GetTypeName().AsCString("<invalid type>"),
941 var_expr_path_strm.GetString().c_str());
942 }
943 }
944 }
945 else
946 {
Bruce Mitchener11d86362015-02-26 23:55:39 +0000947 child_valobj_sp = valobj_sp->GetSyntheticArrayMember (child_index, true);
Enrico Granata27b625e2011-08-09 01:04:56 +0000948 if (!child_valobj_sp)
949 {
950 valobj_sp->GetExpressionPath (var_expr_path_strm, false);
Jason Molenda7e589a62011-09-20 00:26:08 +0000951 error.SetErrorStringWithFormat ("failed to use pointer as array for index %ld for \"(%s) %s\"",
Enrico Granata27b625e2011-08-09 01:04:56 +0000952 child_index,
953 valobj_sp->GetTypeName().AsCString("<invalid type>"),
954 var_expr_path_strm.GetString().c_str());
955 }
Greg Clayton54979cd2010-12-15 05:08:08 +0000956 }
957 }
Eugene Zelenkod70a6e72016-02-18 18:52:47 +0000958 else if (valobj_sp->GetCompilerType().IsArrayType(nullptr, nullptr, &is_incomplete_array))
Greg Clayton54979cd2010-12-15 05:08:08 +0000959 {
Jim Ingham78a685a2011-04-16 00:01:13 +0000960 // Pass false to dynamic_value here so we can tell the difference between
961 // no dynamic value and no member of this type...
Greg Clayton54979cd2010-12-15 05:08:08 +0000962 child_valobj_sp = valobj_sp->GetChildAtIndex (child_index, true);
Eugene Zelenkod70a6e72016-02-18 18:52:47 +0000963 if (!child_valobj_sp && (is_incomplete_array || !no_synth_child))
Greg Clayton4ef877f2012-12-06 02:33:54 +0000964 child_valobj_sp = valobj_sp->GetSyntheticArrayMember (child_index, true);
965
Greg Clayton54979cd2010-12-15 05:08:08 +0000966 if (!child_valobj_sp)
967 {
Greg Clayton6beaaa62011-01-17 03:46:26 +0000968 valobj_sp->GetExpressionPath (var_expr_path_strm, false);
Jason Molenda7e589a62011-09-20 00:26:08 +0000969 error.SetErrorStringWithFormat ("array index %ld is not valid for \"(%s) %s\"",
Greg Clayton54979cd2010-12-15 05:08:08 +0000970 child_index,
971 valobj_sp->GetTypeName().AsCString("<invalid type>"),
972 var_expr_path_strm.GetString().c_str());
973 }
974 }
Greg Clayton99558cc42015-08-24 23:46:31 +0000975 else if (valobj_sp->GetCompilerType().IsScalarType())
Enrico Granata9fc19442011-07-06 02:13:41 +0000976 {
977 // this is a bitfield asking to display just one bit
978 child_valobj_sp = valobj_sp->GetSyntheticBitFieldChild(child_index, child_index, true);
979 if (!child_valobj_sp)
980 {
981 valobj_sp->GetExpressionPath (var_expr_path_strm, false);
Jason Molenda7e589a62011-09-20 00:26:08 +0000982 error.SetErrorStringWithFormat ("bitfield range %ld-%ld is not valid for \"(%s) %s\"",
Enrico Granata9fc19442011-07-06 02:13:41 +0000983 child_index, child_index,
984 valobj_sp->GetTypeName().AsCString("<invalid type>"),
985 var_expr_path_strm.GetString().c_str());
986 }
987 }
Greg Clayton54979cd2010-12-15 05:08:08 +0000988 else
989 {
Enrico Granata86cc9822012-03-19 22:58:49 +0000990 ValueObjectSP synthetic = valobj_sp->GetSyntheticValue();
Enrico Granata27b625e2011-08-09 01:04:56 +0000991 if (no_synth_child /* synthetic is forbidden */ ||
Eugene Zelenkod70a6e72016-02-18 18:52:47 +0000992 !synthetic /* no synthetic */
Enrico Granata27b625e2011-08-09 01:04:56 +0000993 || synthetic == valobj_sp) /* synthetic is the same as the original object */
994 {
995 valobj_sp->GetExpressionPath (var_expr_path_strm, false);
996 error.SetErrorStringWithFormat ("\"(%s) %s\" is not an array type",
997 valobj_sp->GetTypeName().AsCString("<invalid type>"),
998 var_expr_path_strm.GetString().c_str());
999 }
Saleem Abdulrasool3985c8c2014-04-02 03:51:35 +00001000 else if (static_cast<uint32_t>(child_index) >= synthetic->GetNumChildren() /* synthetic does not have that many values */)
Enrico Granata27b625e2011-08-09 01:04:56 +00001001 {
1002 valobj_sp->GetExpressionPath (var_expr_path_strm, false);
Jason Molenda7e589a62011-09-20 00:26:08 +00001003 error.SetErrorStringWithFormat ("array index %ld is not valid for \"(%s) %s\"",
Enrico Granata27b625e2011-08-09 01:04:56 +00001004 child_index,
1005 valobj_sp->GetTypeName().AsCString("<invalid type>"),
1006 var_expr_path_strm.GetString().c_str());
1007 }
1008 else
1009 {
1010 child_valobj_sp = synthetic->GetChildAtIndex(child_index, true);
1011 if (!child_valobj_sp)
1012 {
1013 valobj_sp->GetExpressionPath (var_expr_path_strm, false);
Jason Molenda7e589a62011-09-20 00:26:08 +00001014 error.SetErrorStringWithFormat ("array index %ld is not valid for \"(%s) %s\"",
Enrico Granata27b625e2011-08-09 01:04:56 +00001015 child_index,
1016 valobj_sp->GetTypeName().AsCString("<invalid type>"),
1017 var_expr_path_strm.GetString().c_str());
1018 }
1019 }
Greg Clayton54979cd2010-12-15 05:08:08 +00001020 }
1021
1022 if (!child_valobj_sp)
1023 {
1024 // Invalid array index...
1025 return ValueObjectSP();
1026 }
1027
1028 // Erase the array member specification '[%i]' where
1029 // %i is the array index
1030 var_path.erase(0, (end - var_path.c_str()) + 1);
1031 separator_idx = var_path.find_first_of(".-[");
Greg Clayton4d122c42011-09-17 08:33:22 +00001032 if (use_dynamic != eNoDynamicValues)
Jim Ingham78a685a2011-04-16 00:01:13 +00001033 {
Jim Ingham2837b762011-05-04 03:43:18 +00001034 ValueObjectSP dynamic_value_sp(child_valobj_sp->GetDynamicValue(use_dynamic));
Jim Ingham78a685a2011-04-16 00:01:13 +00001035 if (dynamic_value_sp)
1036 child_valobj_sp = dynamic_value_sp;
1037 }
Greg Clayton54979cd2010-12-15 05:08:08 +00001038 // Break out early from the switch since we were
1039 // able to find the child member
1040 break;
1041 }
Enrico Granata20edcdb2011-07-19 18:03:25 +00001042 else if (end && *end == '-')
Enrico Granata9fc19442011-07-06 02:13:41 +00001043 {
1044 // this is most probably a BitField, let's take a look
Eugene Zelenkod70a6e72016-02-18 18:52:47 +00001045 char *real_end = nullptr;
Enrico Granata9fc19442011-07-06 02:13:41 +00001046 long final_index = ::strtol (end+1, &real_end, 0);
Enrico Granatad64d0bc2011-08-19 21:13:46 +00001047 bool expand_bitfield = true;
Enrico Granata20edcdb2011-07-19 18:03:25 +00001048 if (real_end && *real_end == ']')
Enrico Granata9fc19442011-07-06 02:13:41 +00001049 {
1050 // if the format given is [high-low], swap range
Enrico Granata20edcdb2011-07-19 18:03:25 +00001051 if (child_index > final_index)
Enrico Granata9fc19442011-07-06 02:13:41 +00001052 {
1053 long temp = child_index;
1054 child_index = final_index;
1055 final_index = temp;
1056 }
1057
Greg Clayton99558cc42015-08-24 23:46:31 +00001058 if (valobj_sp->GetCompilerType().IsPointerToScalarType() && deref)
Enrico Granata9fc19442011-07-06 02:13:41 +00001059 {
1060 // what we have is *ptr[low-high]. the most similar C++ syntax is to deref ptr
1061 // and extract bits low thru high out of it. reading array items low thru high
1062 // would be done by saying ptr[low-high], without a deref * sign
1063 Error error;
1064 ValueObjectSP temp(valobj_sp->Dereference(error));
1065 if (error.Fail())
1066 {
1067 valobj_sp->GetExpressionPath (var_expr_path_strm, false);
1068 error.SetErrorStringWithFormat ("could not dereference \"(%s) %s\"",
1069 valobj_sp->GetTypeName().AsCString("<invalid type>"),
1070 var_expr_path_strm.GetString().c_str());
1071 return ValueObjectSP();
1072 }
1073 valobj_sp = temp;
1074 deref = false;
1075 }
Greg Clayton99558cc42015-08-24 23:46:31 +00001076 else if (valobj_sp->GetCompilerType().IsArrayOfScalarType() && deref)
Enrico Granata9fc19442011-07-06 02:13:41 +00001077 {
1078 // what we have is *arr[low-high]. the most similar C++ syntax is to get arr[0]
1079 // (an operation that is equivalent to deref-ing arr)
1080 // and extract bits low thru high out of it. reading array items low thru high
1081 // would be done by saying arr[low-high], without a deref * sign
1082 Error error;
1083 ValueObjectSP temp(valobj_sp->GetChildAtIndex (0, true));
1084 if (error.Fail())
1085 {
1086 valobj_sp->GetExpressionPath (var_expr_path_strm, false);
1087 error.SetErrorStringWithFormat ("could not get item 0 for \"(%s) %s\"",
1088 valobj_sp->GetTypeName().AsCString("<invalid type>"),
1089 var_expr_path_strm.GetString().c_str());
1090 return ValueObjectSP();
1091 }
1092 valobj_sp = temp;
1093 deref = false;
1094 }
Enrico Granatad64d0bc2011-08-19 21:13:46 +00001095 /*else if (valobj_sp->IsArrayType() || valobj_sp->IsPointerType())
Enrico Granata9fc19442011-07-06 02:13:41 +00001096 {
Enrico Granatad64d0bc2011-08-19 21:13:46 +00001097 child_valobj_sp = valobj_sp->GetSyntheticArrayRangeChild(child_index, final_index, true);
1098 expand_bitfield = false;
1099 if (!child_valobj_sp)
1100 {
1101 valobj_sp->GetExpressionPath (var_expr_path_strm, false);
1102 error.SetErrorStringWithFormat ("array range %i-%i is not valid for \"(%s) %s\"",
1103 child_index, final_index,
1104 valobj_sp->GetTypeName().AsCString("<invalid type>"),
1105 var_expr_path_strm.GetString().c_str());
1106 }
1107 }*/
1108
1109 if (expand_bitfield)
1110 {
1111 child_valobj_sp = valobj_sp->GetSyntheticBitFieldChild(child_index, final_index, true);
1112 if (!child_valobj_sp)
1113 {
1114 valobj_sp->GetExpressionPath (var_expr_path_strm, false);
Jason Molenda7e589a62011-09-20 00:26:08 +00001115 error.SetErrorStringWithFormat ("bitfield range %ld-%ld is not valid for \"(%s) %s\"",
Enrico Granatad64d0bc2011-08-19 21:13:46 +00001116 child_index, final_index,
1117 valobj_sp->GetTypeName().AsCString("<invalid type>"),
1118 var_expr_path_strm.GetString().c_str());
1119 }
Enrico Granata9fc19442011-07-06 02:13:41 +00001120 }
1121 }
1122
1123 if (!child_valobj_sp)
1124 {
1125 // Invalid bitfield range...
1126 return ValueObjectSP();
1127 }
1128
1129 // Erase the bitfield member specification '[%i-%i]' where
1130 // %i is the index
1131 var_path.erase(0, (real_end - var_path.c_str()) + 1);
1132 separator_idx = var_path.find_first_of(".-[");
Greg Clayton4d122c42011-09-17 08:33:22 +00001133 if (use_dynamic != eNoDynamicValues)
Enrico Granata9fc19442011-07-06 02:13:41 +00001134 {
1135 ValueObjectSP dynamic_value_sp(child_valobj_sp->GetDynamicValue(use_dynamic));
1136 if (dynamic_value_sp)
1137 child_valobj_sp = dynamic_value_sp;
1138 }
1139 // Break out early from the switch since we were
1140 // able to find the child member
1141 break;
1142
1143 }
1144 }
1145 else
1146 {
1147 error.SetErrorStringWithFormat("invalid square bracket encountered after \"%s\" in \"%s\"",
1148 var_expr_path_strm.GetString().c_str(),
1149 var_path.c_str());
Greg Clayton54979cd2010-12-15 05:08:08 +00001150 }
1151 return ValueObjectSP();
1152
1153 default:
1154 // Failure...
1155 {
Greg Clayton6beaaa62011-01-17 03:46:26 +00001156 valobj_sp->GetExpressionPath (var_expr_path_strm, false);
Greg Clayton54979cd2010-12-15 05:08:08 +00001157 error.SetErrorStringWithFormat ("unexpected char '%c' encountered after \"%s\" in \"%s\"",
1158 separator_type,
1159 var_expr_path_strm.GetString().c_str(),
1160 var_path.c_str());
1161
1162 return ValueObjectSP();
Greg Clayton8b2fe6d2010-12-14 02:59:59 +00001163 }
1164 }
Greg Clayton8b2fe6d2010-12-14 02:59:59 +00001165
Greg Clayton54979cd2010-12-15 05:08:08 +00001166 if (child_valobj_sp)
1167 valobj_sp = child_valobj_sp;
1168
1169 if (var_path.empty())
1170 break;
Greg Clayton8b2fe6d2010-12-14 02:59:59 +00001171 }
Greg Clayton54979cd2010-12-15 05:08:08 +00001172 if (valobj_sp)
1173 {
1174 if (deref)
1175 {
Greg Claytonaf67cec2010-12-20 20:49:23 +00001176 ValueObjectSP deref_valobj_sp (valobj_sp->Dereference(error));
Greg Clayton54979cd2010-12-15 05:08:08 +00001177 valobj_sp = deref_valobj_sp;
1178 }
1179 else if (address_of)
1180 {
1181 ValueObjectSP address_of_valobj_sp (valobj_sp->AddressOf(error));
1182 valobj_sp = address_of_valobj_sp;
1183 }
1184 }
1185 return valobj_sp;
Greg Clayton8b2fe6d2010-12-14 02:59:59 +00001186 }
Greg Clayton54979cd2010-12-15 05:08:08 +00001187 else
Greg Clayton8b2fe6d2010-12-14 02:59:59 +00001188 {
Jim Ingham2837b762011-05-04 03:43:18 +00001189 error.SetErrorStringWithFormat("no variable named '%s' found in this frame",
1190 name_const_string.GetCString());
Greg Clayton8b2fe6d2010-12-14 02:59:59 +00001191 }
Greg Clayton8b2fe6d2010-12-14 02:59:59 +00001192 }
1193 }
Greg Clayton54979cd2010-12-15 05:08:08 +00001194 else
1195 {
1196 error.SetErrorStringWithFormat("invalid variable path '%s'", var_expr_cstr);
1197 }
Greg Clayton8b2fe6d2010-12-14 02:59:59 +00001198 return ValueObjectSP();
1199}
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001200
1201bool
1202StackFrame::GetFrameBaseValue (Scalar &frame_base, Error *error_ptr)
1203{
Jason Molenda6a354702014-10-02 01:08:16 +00001204 Mutex::Locker locker(m_mutex);
Eugene Zelenkod70a6e72016-02-18 18:52:47 +00001205 if (!m_cfa_is_valid)
Jason Molenda99618472013-11-04 11:02:52 +00001206 {
1207 m_frame_base_error.SetErrorString("No frame base available for this historical stack frame.");
1208 return false;
1209 }
1210
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001211 if (m_flags.IsClear(GOT_FRAME_BASE))
1212 {
1213 if (m_sc.function)
1214 {
1215 m_frame_base.Clear();
1216 m_frame_base_error.Clear();
1217
1218 m_flags.Set(GOT_FRAME_BASE);
Greg Claytond9e416c2012-02-18 05:35:26 +00001219 ExecutionContext exe_ctx (shared_from_this());
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001220 Value expr_value;
Greg Clayton016a95e2010-09-14 02:20:48 +00001221 addr_t loclist_base_addr = LLDB_INVALID_ADDRESS;
1222 if (m_sc.function->GetFrameBaseExpression().IsLocationList())
Greg Claytond9e416c2012-02-18 05:35:26 +00001223 loclist_base_addr = m_sc.function->GetAddressRange().GetBaseAddress().GetLoadAddress (exe_ctx.GetTargetPtr());
Greg Clayton016a95e2010-09-14 02:20:48 +00001224
Tamas Berghammer5b42c7a2016-02-26 14:21:10 +00001225 if (m_sc.function->GetFrameBaseExpression().Evaluate(&exe_ctx,
1226 nullptr,
1227 nullptr,
1228 nullptr,
1229 loclist_base_addr,
1230 nullptr,
1231 nullptr,
1232 expr_value,
1233 &m_frame_base_error) == false)
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001234 {
1235 // We should really have an error if evaluate returns, but in case
1236 // we don't, lets set the error to something at least.
1237 if (m_frame_base_error.Success())
1238 m_frame_base_error.SetErrorString("Evaluation of the frame base expression failed.");
1239 }
1240 else
1241 {
Greg Clayton57ee3062013-07-11 22:46:58 +00001242 m_frame_base = expr_value.ResolveValue(&exe_ctx);
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001243 }
1244 }
1245 else
1246 {
1247 m_frame_base_error.SetErrorString ("No function in symbol context.");
1248 }
1249 }
1250
1251 if (m_frame_base_error.Success())
1252 frame_base = m_frame_base;
1253
1254 if (error_ptr)
1255 *error_ptr = m_frame_base_error;
1256 return m_frame_base_error.Success();
1257}
1258
Greg Clayton5ccbd292011-01-06 22:15:06 +00001259RegisterContextSP
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001260StackFrame::GetRegisterContext ()
1261{
Jason Molenda6a354702014-10-02 01:08:16 +00001262 Mutex::Locker locker(m_mutex);
Greg Clayton5ccbd292011-01-06 22:15:06 +00001263 if (!m_reg_context_sp)
Greg Claytond9e416c2012-02-18 05:35:26 +00001264 {
1265 ThreadSP thread_sp (GetThread());
1266 if (thread_sp)
1267 m_reg_context_sp = thread_sp->CreateRegisterContextForFrame (this);
1268 }
Greg Clayton5ccbd292011-01-06 22:15:06 +00001269 return m_reg_context_sp;
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001270}
1271
1272bool
1273StackFrame::HasDebugInformation ()
1274{
Greg Clayton9da7bd02010-08-24 21:05:24 +00001275 GetSymbolContext (eSymbolContextLineEntry);
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001276 return m_sc.line_entry.IsValid();
1277}
1278
Greg Clayton288bdf92010-09-02 02:59:18 +00001279ValueObjectSP
Greg Clayton4d122c42011-09-17 08:33:22 +00001280StackFrame::GetValueObjectForFrameVariable (const VariableSP &variable_sp, DynamicValueType use_dynamic)
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001281{
Jason Molenda6a354702014-10-02 01:08:16 +00001282 Mutex::Locker locker(m_mutex);
Greg Clayton288bdf92010-09-02 02:59:18 +00001283 ValueObjectSP valobj_sp;
Jason Molenda99618472013-11-04 11:02:52 +00001284 if (m_is_history_frame)
1285 {
1286 return valobj_sp;
1287 }
Greg Clayton288bdf92010-09-02 02:59:18 +00001288 VariableList *var_list = GetVariableList (true);
1289 if (var_list)
1290 {
1291 // Make sure the variable is a frame variable
1292 const uint32_t var_idx = var_list->FindIndexForVariable (variable_sp.get());
1293 const uint32_t num_variables = var_list->GetSize();
1294 if (var_idx < num_variables)
1295 {
1296 valobj_sp = m_variable_list_value_objects.GetValueObjectAtIndex (var_idx);
Eugene Zelenkod70a6e72016-02-18 18:52:47 +00001297 if (!valobj_sp)
Greg Clayton288bdf92010-09-02 02:59:18 +00001298 {
1299 if (m_variable_list_value_objects.GetSize() < num_variables)
1300 m_variable_list_value_objects.Resize(num_variables);
Jim Ingham58b59f92011-04-22 23:53:53 +00001301 valobj_sp = ValueObjectVariable::Create (this, variable_sp);
Greg Clayton288bdf92010-09-02 02:59:18 +00001302 m_variable_list_value_objects.SetValueObjectAtIndex (var_idx, valobj_sp);
1303 }
1304 }
1305 }
Greg Clayton4d122c42011-09-17 08:33:22 +00001306 if (use_dynamic != eNoDynamicValues && valobj_sp)
Jim Ingham78a685a2011-04-16 00:01:13 +00001307 {
Jim Ingham2837b762011-05-04 03:43:18 +00001308 ValueObjectSP dynamic_sp = valobj_sp->GetDynamicValue (use_dynamic);
Jim Ingham78a685a2011-04-16 00:01:13 +00001309 if (dynamic_sp)
1310 return dynamic_sp;
1311 }
Greg Clayton288bdf92010-09-02 02:59:18 +00001312 return valobj_sp;
1313}
1314
1315ValueObjectSP
Greg Clayton4d122c42011-09-17 08:33:22 +00001316StackFrame::TrackGlobalVariable (const VariableSP &variable_sp, DynamicValueType use_dynamic)
Greg Clayton288bdf92010-09-02 02:59:18 +00001317{
Jason Molenda6a354702014-10-02 01:08:16 +00001318 Mutex::Locker locker(m_mutex);
Jason Molenda99618472013-11-04 11:02:52 +00001319 if (m_is_history_frame)
1320 return ValueObjectSP();
1321
Greg Clayton288bdf92010-09-02 02:59:18 +00001322 // Check to make sure we aren't already tracking this variable?
Jim Ingham78a685a2011-04-16 00:01:13 +00001323 ValueObjectSP valobj_sp (GetValueObjectForFrameVariable (variable_sp, use_dynamic));
Greg Clayton288bdf92010-09-02 02:59:18 +00001324 if (!valobj_sp)
1325 {
1326 // We aren't already tracking this global
1327 VariableList *var_list = GetVariableList (true);
1328 // If this frame has no variables, create a new list
Eugene Zelenkod70a6e72016-02-18 18:52:47 +00001329 if (var_list == nullptr)
Greg Clayton288bdf92010-09-02 02:59:18 +00001330 m_variable_list_sp.reset (new VariableList());
1331
1332 // Add the global/static variable to this frame
1333 m_variable_list_sp->AddVariable (variable_sp);
1334
1335 // Now make a value object for it so we can track its changes
Jim Ingham78a685a2011-04-16 00:01:13 +00001336 valobj_sp = GetValueObjectForFrameVariable (variable_sp, use_dynamic);
Greg Clayton288bdf92010-09-02 02:59:18 +00001337 }
1338 return valobj_sp;
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001339}
1340
Jim Ingham6b8379c2010-08-26 20:44:45 +00001341bool
1342StackFrame::IsInlined ()
1343{
Eugene Zelenkod70a6e72016-02-18 18:52:47 +00001344 if (m_sc.block == nullptr)
Greg Clayton59e8fc1c2010-08-30 18:11:35 +00001345 GetSymbolContext (eSymbolContextBlock);
1346 if (m_sc.block)
Eugene Zelenkod70a6e72016-02-18 18:52:47 +00001347 return m_sc.block->GetContainingInlinedBlock() != nullptr;
Greg Clayton59e8fc1c2010-08-30 18:11:35 +00001348 return false;
Jim Ingham6b8379c2010-08-26 20:44:45 +00001349}
1350
Dawn Perchik009d1102015-09-04 01:02:30 +00001351lldb::LanguageType
1352StackFrame::GetLanguage ()
1353{
1354 CompileUnit *cu = GetSymbolContext(eSymbolContextCompUnit).comp_unit;
1355 if (cu)
1356 return cu->GetLanguage();
1357 return lldb::eLanguageTypeUnknown;
1358}
1359
Enrico Granata592afe72016-03-15 21:50:51 +00001360lldb::LanguageType
1361StackFrame::GuessLanguage ()
1362{
1363 LanguageType lang_type = GetLanguage();
1364
1365 if (lang_type == eLanguageTypeUnknown)
1366 {
1367 Function *f = GetSymbolContext(eSymbolContextFunction).function;
1368 if (f)
1369 {
1370 lang_type = f->GetMangled().GuessLanguage();
1371 }
1372 }
1373
1374 return lang_type;
1375}
1376
Greg Claytond9e416c2012-02-18 05:35:26 +00001377TargetSP
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001378StackFrame::CalculateTarget ()
1379{
Greg Claytond9e416c2012-02-18 05:35:26 +00001380 TargetSP target_sp;
1381 ThreadSP thread_sp(GetThread());
1382 if (thread_sp)
1383 {
1384 ProcessSP process_sp (thread_sp->CalculateProcess());
1385 if (process_sp)
1386 target_sp = process_sp->CalculateTarget();
1387 }
1388 return target_sp;
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001389}
1390
Greg Claytond9e416c2012-02-18 05:35:26 +00001391ProcessSP
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001392StackFrame::CalculateProcess ()
1393{
Greg Claytond9e416c2012-02-18 05:35:26 +00001394 ProcessSP process_sp;
1395 ThreadSP thread_sp(GetThread());
1396 if (thread_sp)
1397 process_sp = thread_sp->CalculateProcess();
1398 return process_sp;
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001399}
1400
Greg Claytond9e416c2012-02-18 05:35:26 +00001401ThreadSP
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001402StackFrame::CalculateThread ()
1403{
Greg Claytond9e416c2012-02-18 05:35:26 +00001404 return GetThread();
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001405}
1406
Jason Molendab57e4a12013-11-04 09:33:30 +00001407StackFrameSP
1408StackFrame::CalculateStackFrame ()
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001409{
Greg Claytond9e416c2012-02-18 05:35:26 +00001410 return shared_from_this();
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001411}
1412
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001413void
Greg Clayton0603aa92010-10-04 01:05:56 +00001414StackFrame::CalculateExecutionContext (ExecutionContext &exe_ctx)
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001415{
Greg Claytond9e416c2012-02-18 05:35:26 +00001416 exe_ctx.SetContext (shared_from_this());
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001417}
1418
1419void
Jim Ingham8ec10ef2013-10-18 17:38:31 +00001420StackFrame::DumpUsingSettingsFormat (Stream *strm, const char *frame_marker)
Greg Clayton0603aa92010-10-04 01:05:56 +00001421{
Eugene Zelenkod70a6e72016-02-18 18:52:47 +00001422 if (strm == nullptr)
Greg Clayton0603aa92010-10-04 01:05:56 +00001423 return;
1424
1425 GetSymbolContext(eSymbolContextEverything);
Greg Claytond9e416c2012-02-18 05:35:26 +00001426 ExecutionContext exe_ctx (shared_from_this());
Greg Clayton0603aa92010-10-04 01:05:56 +00001427 StreamString s;
Jim Ingham8ec10ef2013-10-18 17:38:31 +00001428
1429 if (frame_marker)
1430 s.PutCString(frame_marker);
1431
Eugene Zelenkod70a6e72016-02-18 18:52:47 +00001432 const FormatEntity::Entry *frame_format = nullptr;
Greg Claytond9e416c2012-02-18 05:35:26 +00001433 Target *target = exe_ctx.GetTargetPtr();
1434 if (target)
1435 frame_format = target->GetDebugger().GetFrameFormat();
Eugene Zelenkod70a6e72016-02-18 18:52:47 +00001436 if (frame_format && FormatEntity::Format(*frame_format, s, &m_sc, &exe_ctx, nullptr, nullptr, false, false))
Greg Clayton0603aa92010-10-04 01:05:56 +00001437 {
1438 strm->Write(s.GetData(), s.GetSize());
1439 }
1440 else
1441 {
1442 Dump (strm, true, false);
1443 strm->EOL();
1444 }
1445}
1446
1447void
Greg Clayton6dadd502010-09-02 21:44:10 +00001448StackFrame::Dump (Stream *strm, bool show_frame_index, bool show_fullpaths)
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001449{
Eugene Zelenkod70a6e72016-02-18 18:52:47 +00001450 if (strm == nullptr)
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001451 return;
1452
1453 if (show_frame_index)
Greg Clayton1b72fcb2010-08-24 00:45:41 +00001454 strm->Printf("frame #%u: ", m_frame_index);
Greg Claytond9e416c2012-02-18 05:35:26 +00001455 ExecutionContext exe_ctx (shared_from_this());
1456 Target *target = exe_ctx.GetTargetPtr();
Daniel Malead01b2952012-11-29 21:49:15 +00001457 strm->Printf("0x%0*" PRIx64 " ",
Greg Claytond9e416c2012-02-18 05:35:26 +00001458 target ? (target->GetArchitecture().GetAddressByteSize() * 2) : 16,
1459 GetFrameCodeAddress().GetLoadAddress(target));
Greg Clayton9da7bd02010-08-24 21:05:24 +00001460 GetSymbolContext(eSymbolContextEverything);
Greg Clayton1b72fcb2010-08-24 00:45:41 +00001461 const bool show_module = true;
1462 const bool show_inline = true;
Jason Molendaaff1b352014-10-10 23:07:36 +00001463 const bool show_function_arguments = true;
Jason Molendac980fa92015-02-13 23:24:21 +00001464 const bool show_function_name = true;
Greg Claytond9e416c2012-02-18 05:35:26 +00001465 m_sc.DumpStopContext (strm,
1466 exe_ctx.GetBestExecutionContextScope(),
1467 GetFrameCodeAddress(),
1468 show_fullpaths,
1469 show_module,
Jason Molendaaff1b352014-10-10 23:07:36 +00001470 show_inline,
Jason Molendac980fa92015-02-13 23:24:21 +00001471 show_function_arguments,
1472 show_function_name);
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001473}
1474
Greg Clayton5082c5f2010-08-27 18:24:16 +00001475void
Jason Molendab57e4a12013-11-04 09:33:30 +00001476StackFrame::UpdateCurrentFrameFromPreviousFrame (StackFrame &prev_frame)
Greg Clayton5082c5f2010-08-27 18:24:16 +00001477{
Jason Molenda6a354702014-10-02 01:08:16 +00001478 Mutex::Locker locker(m_mutex);
Greg Clayton59e8fc1c2010-08-30 18:11:35 +00001479 assert (GetStackID() == prev_frame.GetStackID()); // TODO: remove this after some testing
Jason Molendab57e4a12013-11-04 09:33:30 +00001480 m_variable_list_sp = prev_frame.m_variable_list_sp;
1481 m_variable_list_value_objects.Swap (prev_frame.m_variable_list_value_objects);
1482 if (!m_disassembly.GetString().empty())
1483 m_disassembly.GetString().swap (m_disassembly.GetString());
Greg Clayton5082c5f2010-08-27 18:24:16 +00001484}
Greg Clayton68275d52010-08-27 21:47:54 +00001485
Greg Clayton59e8fc1c2010-08-30 18:11:35 +00001486void
Jason Molendab57e4a12013-11-04 09:33:30 +00001487StackFrame::UpdatePreviousFrameFromCurrentFrame (StackFrame &curr_frame)
Greg Clayton59e8fc1c2010-08-30 18:11:35 +00001488{
Jason Molenda6a354702014-10-02 01:08:16 +00001489 Mutex::Locker locker(m_mutex);
Greg Clayton2cad65a2010-09-03 17:10:42 +00001490 assert (GetStackID() == curr_frame.GetStackID()); // TODO: remove this after some testing
Jason Molendab57e4a12013-11-04 09:33:30 +00001491 m_id.SetPC (curr_frame.m_id.GetPC()); // Update the Stack ID PC value
1492 assert (GetThread() == curr_frame.GetThread());
1493 m_frame_index = curr_frame.m_frame_index;
1494 m_concrete_frame_index = curr_frame.m_concrete_frame_index;
1495 m_reg_context_sp = curr_frame.m_reg_context_sp;
1496 m_frame_code_addr = curr_frame.m_frame_code_addr;
Eugene Zelenkod70a6e72016-02-18 18:52:47 +00001497 assert (!m_sc.target_sp || !curr_frame.m_sc.target_sp || m_sc.target_sp.get() == curr_frame.m_sc.target_sp.get());
1498 assert (!m_sc.module_sp || !curr_frame.m_sc.module_sp || m_sc.module_sp.get() == curr_frame.m_sc.module_sp.get());
1499 assert (m_sc.comp_unit == nullptr || curr_frame.m_sc.comp_unit == nullptr || m_sc.comp_unit == curr_frame.m_sc.comp_unit);
1500 assert (m_sc.function == nullptr || curr_frame.m_sc.function == nullptr || m_sc.function == curr_frame.m_sc.function);
Jason Molendab57e4a12013-11-04 09:33:30 +00001501 m_sc = curr_frame.m_sc;
1502 m_flags.Clear(GOT_FRAME_BASE | eSymbolContextEverything);
1503 m_flags.Set (m_sc.GetResolvedMask());
1504 m_frame_base.Clear();
1505 m_frame_base_error.Clear();
Greg Clayton59e8fc1c2010-08-30 18:11:35 +00001506}
1507
Greg Clayton2cad65a2010-09-03 17:10:42 +00001508bool
Jason Molendab57e4a12013-11-04 09:33:30 +00001509StackFrame::HasCachedData () const
1510{
Eugene Zelenkod70a6e72016-02-18 18:52:47 +00001511 if (m_variable_list_sp)
Jason Molendab57e4a12013-11-04 09:33:30 +00001512 return true;
1513 if (m_variable_list_value_objects.GetSize() > 0)
1514 return true;
1515 if (!m_disassembly.GetString().empty())
1516 return true;
1517 return false;
1518}
1519
1520bool
Greg Clayton7260f622011-04-18 08:33:37 +00001521StackFrame::GetStatus (Stream& strm,
1522 bool show_frame_info,
Jim Ingham8ec10ef2013-10-18 17:38:31 +00001523 bool show_source,
1524 const char *frame_marker)
Greg Clayton7260f622011-04-18 08:33:37 +00001525{
Greg Clayton53eb7ad2012-07-11 20:33:48 +00001526
Greg Clayton7260f622011-04-18 08:33:37 +00001527 if (show_frame_info)
1528 {
1529 strm.Indent();
Jim Ingham8ec10ef2013-10-18 17:38:31 +00001530 DumpUsingSettingsFormat (&strm, frame_marker);
Greg Clayton7260f622011-04-18 08:33:37 +00001531 }
1532
1533 if (show_source)
1534 {
Greg Claytond9e416c2012-02-18 05:35:26 +00001535 ExecutionContext exe_ctx (shared_from_this());
Mohit K. Bhakkad8be74992015-12-03 04:56:16 +00001536 bool have_source = false, have_debuginfo = false;
Greg Clayton67cc0632012-08-22 17:17:09 +00001537 Debugger::StopDisassemblyType disasm_display = Debugger::eStopDisassemblyTypeNever;
Greg Claytond9e416c2012-02-18 05:35:26 +00001538 Target *target = exe_ctx.GetTargetPtr();
Greg Clayton53eb7ad2012-07-11 20:33:48 +00001539 if (target)
Greg Clayton7260f622011-04-18 08:33:37 +00001540 {
Greg Clayton53eb7ad2012-07-11 20:33:48 +00001541 Debugger &debugger = target->GetDebugger();
1542 const uint32_t source_lines_before = debugger.GetStopSourceLineCount(true);
1543 const uint32_t source_lines_after = debugger.GetStopSourceLineCount(false);
1544 disasm_display = debugger.GetStopDisassemblyDisplay ();
Greg Claytone372b982011-11-21 21:44:34 +00001545
Todd Fiala6d1fbc92014-07-07 20:47:24 +00001546 GetSymbolContext(eSymbolContextCompUnit | eSymbolContextLineEntry);
1547 if (m_sc.comp_unit && m_sc.line_entry.IsValid())
Greg Claytone372b982011-11-21 21:44:34 +00001548 {
Mohit K. Bhakkad8be74992015-12-03 04:56:16 +00001549 have_debuginfo = true;
Todd Fiala6d1fbc92014-07-07 20:47:24 +00001550 if (source_lines_before > 0 || source_lines_after > 0)
Greg Claytone372b982011-11-21 21:44:34 +00001551 {
Mohit K. Bhakkad8be74992015-12-03 04:56:16 +00001552 size_t num_lines = target->GetSourceManager().DisplaySourceLinesWithLineNumbers (m_sc.line_entry.file,
Greg Clayton53eb7ad2012-07-11 20:33:48 +00001553 m_sc.line_entry.line,
1554 source_lines_before,
1555 source_lines_after,
1556 "->",
Jason Molenda7cd81c52013-04-29 09:59:31 +00001557 &strm);
Mohit K. Bhakkad8be74992015-12-03 04:56:16 +00001558 if (num_lines != 0)
1559 have_source = true;
1560 // TODO: Give here a one time warning if source file is missing.
Greg Claytone372b982011-11-21 21:44:34 +00001561 }
1562 }
Greg Clayton53eb7ad2012-07-11 20:33:48 +00001563 switch (disasm_display)
1564 {
Greg Clayton67cc0632012-08-22 17:17:09 +00001565 case Debugger::eStopDisassemblyTypeNever:
Greg Claytone372b982011-11-21 21:44:34 +00001566 break;
Mohit K. Bhakkad8be74992015-12-03 04:56:16 +00001567
1568 case Debugger::eStopDisassemblyTypeNoDebugInfo:
1569 if (have_debuginfo)
1570 break;
Jason Molenda62e06812016-02-16 04:14:33 +00001571 LLVM_FALLTHROUGH;
Mohit K. Bhakkad8be74992015-12-03 04:56:16 +00001572
Greg Clayton67cc0632012-08-22 17:17:09 +00001573 case Debugger::eStopDisassemblyTypeNoSource:
Greg Clayton53eb7ad2012-07-11 20:33:48 +00001574 if (have_source)
1575 break;
Jason Molenda62e06812016-02-16 04:14:33 +00001576 LLVM_FALLTHROUGH;
Mohit K. Bhakkad8be74992015-12-03 04:56:16 +00001577
Greg Clayton67cc0632012-08-22 17:17:09 +00001578 case Debugger::eStopDisassemblyTypeAlways:
Greg Clayton53eb7ad2012-07-11 20:33:48 +00001579 if (target)
Greg Claytone372b982011-11-21 21:44:34 +00001580 {
Greg Clayton53eb7ad2012-07-11 20:33:48 +00001581 const uint32_t disasm_lines = debugger.GetDisassemblyLineCount();
1582 if (disasm_lines > 0)
1583 {
1584 const ArchSpec &target_arch = target->GetArchitecture();
1585 AddressRange pc_range;
1586 pc_range.GetBaseAddress() = GetFrameCodeAddress();
1587 pc_range.SetByteSize(disasm_lines * target_arch.GetMaximumOpcodeByteSize());
Eugene Zelenkod70a6e72016-02-18 18:52:47 +00001588 const char *plugin_name = nullptr;
1589 const char *flavor = nullptr;
Greg Clayton53eb7ad2012-07-11 20:33:48 +00001590 Disassembler::Disassemble (target->GetDebugger(),
1591 target_arch,
Jim Ingham0f063ba2013-03-02 00:26:47 +00001592 plugin_name,
1593 flavor,
Greg Clayton53eb7ad2012-07-11 20:33:48 +00001594 exe_ctx,
1595 pc_range,
1596 disasm_lines,
1597 0,
1598 Disassembler::eOptionMarkPCAddress,
1599 strm);
1600 }
Greg Claytone372b982011-11-21 21:44:34 +00001601 }
Greg Clayton53eb7ad2012-07-11 20:33:48 +00001602 break;
Greg Claytone372b982011-11-21 21:44:34 +00001603 }
Greg Clayton7260f622011-04-18 08:33:37 +00001604 }
1605 }
1606 return true;
1607}