blob: d63fa132bc3f50c6a7076782fbfd2c34ad3defc6 [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,
Greg Claytona32532b2016-04-25 21:54:10 +0000547 [this](Variable* v) { return true; },
Tamas Berghammer72ac8a82016-02-25 12:23:37 +0000548 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
Jim Inghamcef46172016-04-26 00:29:59 +0000574StackFrame::GetInScopeVariableList (bool get_file_globals, bool must_have_valid_location)
Greg Claytond41f0322011-08-02 23:35:43 +0000575{
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,
Jim Inghamcef46172016-04-26 00:29:59 +0000592 [this, must_have_valid_location](Variable* v)
593 {
594 return v->IsInScope(this) && (!must_have_valid_location || v->LocationIsValidForFrame(this));
595 },
Greg Claytond41f0322011-08-02 23:35:43 +0000596 var_list_sp.get());
597 }
598
Siva Chandrab90168f2016-02-02 23:49:41 +0000599 if (m_sc.comp_unit && get_file_globals)
Greg Claytond41f0322011-08-02 23:35:43 +0000600 {
601 VariableListSP global_variable_list_sp (m_sc.comp_unit->GetVariableList(true));
602 if (global_variable_list_sp)
603 var_list_sp->AddVariables (global_variable_list_sp.get());
604 }
605
606 return var_list_sp;
607}
608
Greg Clayton8b2fe6d2010-12-14 02:59:59 +0000609ValueObjectSP
Greg Clayton685c88c2012-07-14 00:53:55 +0000610StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr,
Greg Clayton4d122c42011-09-17 08:33:22 +0000611 DynamicValueType use_dynamic,
Jim Ingham2837b762011-05-04 03:43:18 +0000612 uint32_t options,
Greg Clayton4d122c42011-09-17 08:33:22 +0000613 VariableSP &var_sp,
Jim Ingham2837b762011-05-04 03:43:18 +0000614 Error &error)
Greg Clayton8b2fe6d2010-12-14 02:59:59 +0000615{
Jason Molenda99618472013-11-04 11:02:52 +0000616 // We can't fetch variable information for a history stack frame.
617 if (m_is_history_frame)
618 return ValueObjectSP();
Greg Clayton54979cd2010-12-15 05:08:08 +0000619
620 if (var_expr_cstr && var_expr_cstr[0])
Greg Clayton8b2fe6d2010-12-14 02:59:59 +0000621 {
Greg Clayton6d5e68e2011-01-20 19:27:18 +0000622 const bool check_ptr_vs_member = (options & eExpressionPathOptionCheckPtrVsMember) != 0;
623 const bool no_fragile_ivar = (options & eExpressionPathOptionsNoFragileObjcIvar) != 0;
Enrico Granata27b625e2011-08-09 01:04:56 +0000624 const bool no_synth_child = (options & eExpressionPathOptionsNoSyntheticChildren) != 0;
Enrico Granata58ad3342011-08-19 21:56:10 +0000625 //const bool no_synth_array = (options & eExpressionPathOptionsNoSyntheticArrayRange) != 0;
Greg Clayton54979cd2010-12-15 05:08:08 +0000626 error.Clear();
627 bool deref = false;
628 bool address_of = false;
629 ValueObjectSP valobj_sp;
630 const bool get_file_globals = true;
Greg Claytond41f0322011-08-02 23:35:43 +0000631 // When looking up a variable for an expression, we need only consider the
632 // variables that are in scope.
633 VariableListSP var_list_sp (GetInScopeVariableList (get_file_globals));
634 VariableList *variable_list = var_list_sp.get();
Greg Clayton54979cd2010-12-15 05:08:08 +0000635
636 if (variable_list)
Greg Clayton8b2fe6d2010-12-14 02:59:59 +0000637 {
Greg Clayton54979cd2010-12-15 05:08:08 +0000638 // If first character is a '*', then show pointer contents
639 const char *var_expr = var_expr_cstr;
640 if (var_expr[0] == '*')
Greg Clayton8b2fe6d2010-12-14 02:59:59 +0000641 {
Greg Clayton54979cd2010-12-15 05:08:08 +0000642 deref = true;
643 var_expr++; // Skip the '*'
644 }
645 else if (var_expr[0] == '&')
646 {
647 address_of = true;
648 var_expr++; // Skip the '&'
649 }
650
651 std::string var_path (var_expr);
652 size_t separator_idx = var_path.find_first_of(".-[=+~|&^%#@!/?,<>{}");
653 StreamString var_expr_path_strm;
654
655 ConstString name_const_string;
656 if (separator_idx == std::string::npos)
657 name_const_string.SetCString (var_path.c_str());
658 else
659 name_const_string.SetCStringWithLength (var_path.c_str(), separator_idx);
660
Paul Herman10bc1a42015-08-18 22:46:57 +0000661 var_sp = variable_list->FindVariable(name_const_string, false);
Greg Clayton685c88c2012-07-14 00:53:55 +0000662
663 bool synthetically_added_instance_object = false;
664
665 if (var_sp)
666 {
667 var_path.erase (0, name_const_string.GetLength ());
668 }
Enrico Granata46252392015-11-19 22:28:58 +0000669
670 if (!var_sp && (options & eExpressionPathOptionsAllowDirectIVarAccess))
Greg Clayton685c88c2012-07-14 00:53:55 +0000671 {
672 // Check for direct ivars access which helps us with implicit
673 // access to ivars with the "this->" or "self->"
674 GetSymbolContext(eSymbolContextFunction|eSymbolContextBlock);
675 lldb::LanguageType method_language = eLanguageTypeUnknown;
676 bool is_instance_method = false;
677 ConstString method_object_name;
678 if (m_sc.GetFunctionMethodInfo (method_language, is_instance_method, method_object_name))
679 {
680 if (is_instance_method && method_object_name)
681 {
682 var_sp = variable_list->FindVariable(method_object_name);
683 if (var_sp)
684 {
685 separator_idx = 0;
686 var_path.insert(0, "->");
687 synthetically_added_instance_object = true;
688 }
689 }
690 }
691 }
Enrico Granata46252392015-11-19 22:28:58 +0000692
693 if (!var_sp && (options & eExpressionPathOptionsInspectAnonymousUnions))
694 {
695 // Check if any anonymous unions are there which contain a variable with the name we need
696 for (size_t i = 0;
697 i < variable_list->GetSize();
698 i++)
699 {
700 if (VariableSP variable_sp = variable_list->GetVariableAtIndex(i))
701 {
702 if (variable_sp->GetName().IsEmpty())
703 {
704 if (Type *var_type = variable_sp->GetType())
705 {
706 if (var_type->GetForwardCompilerType().IsAnonymousType())
707 {
708 valobj_sp = GetValueObjectForFrameVariable (variable_sp, use_dynamic);
709 if (!valobj_sp)
710 return valobj_sp;
711 valobj_sp = valobj_sp->GetChildMemberWithName(name_const_string, true);
712 if (valobj_sp)
713 break;
714 }
715 }
716 }
717 }
718 }
719 }
Greg Clayton685c88c2012-07-14 00:53:55 +0000720
Enrico Granata46252392015-11-19 22:28:58 +0000721 if (var_sp && !valobj_sp)
Greg Clayton54979cd2010-12-15 05:08:08 +0000722 {
Jim Ingham2837b762011-05-04 03:43:18 +0000723 valobj_sp = GetValueObjectForFrameVariable (var_sp, use_dynamic);
Jim Ingham78a685a2011-04-16 00:01:13 +0000724 if (!valobj_sp)
725 return valobj_sp;
Enrico Granata46252392015-11-19 22:28:58 +0000726 }
727 if (valobj_sp)
728 {
Greg Clayton54979cd2010-12-15 05:08:08 +0000729 // We are dumping at least one child
730 while (separator_idx != std::string::npos)
Greg Clayton8b2fe6d2010-12-14 02:59:59 +0000731 {
Greg Clayton54979cd2010-12-15 05:08:08 +0000732 // Calculate the next separator index ahead of time
733 ValueObjectSP child_valobj_sp;
734 const char separator_type = var_path[0];
735 switch (separator_type)
Greg Clayton8b2fe6d2010-12-14 02:59:59 +0000736 {
Greg Clayton54979cd2010-12-15 05:08:08 +0000737 case '-':
738 if (var_path.size() >= 2 && var_path[1] != '>')
Greg Clayton8b2fe6d2010-12-14 02:59:59 +0000739 return ValueObjectSP();
Greg Clayton8b2fe6d2010-12-14 02:59:59 +0000740
Greg Clayton6d5e68e2011-01-20 19:27:18 +0000741 if (no_fragile_ivar)
742 {
743 // Make sure we aren't trying to deref an objective
744 // C ivar if this is not allowed
Eugene Zelenkod70a6e72016-02-18 18:52:47 +0000745 const uint32_t pointer_type_flags = valobj_sp->GetCompilerType().GetTypeInfo(nullptr);
Enrico Granata622be232014-10-21 20:52:14 +0000746 if ((pointer_type_flags & eTypeIsObjC) &&
747 (pointer_type_flags & eTypeIsPointer))
Greg Clayton6d5e68e2011-01-20 19:27:18 +0000748 {
749 // This was an objective C object pointer and
750 // it was requested we skip any fragile ivars
751 // so return nothing here
752 return ValueObjectSP();
753 }
754 }
Greg Clayton54979cd2010-12-15 05:08:08 +0000755 var_path.erase (0, 1); // Remove the '-'
Jason Molenda62e06812016-02-16 04:14:33 +0000756 LLVM_FALLTHROUGH;
Greg Clayton54979cd2010-12-15 05:08:08 +0000757 case '.':
Greg Clayton8b2fe6d2010-12-14 02:59:59 +0000758 {
Greg Clayton54979cd2010-12-15 05:08:08 +0000759 const bool expr_is_ptr = var_path[0] == '>';
Greg Clayton8b2fe6d2010-12-14 02:59:59 +0000760
Greg Clayton54979cd2010-12-15 05:08:08 +0000761 var_path.erase (0, 1); // Remove the '.' or '>'
762 separator_idx = var_path.find_first_of(".-[");
763 ConstString child_name;
764 if (separator_idx == std::string::npos)
765 child_name.SetCString (var_path.c_str());
Greg Clayton8b2fe6d2010-12-14 02:59:59 +0000766 else
Greg Clayton54979cd2010-12-15 05:08:08 +0000767 child_name.SetCStringWithLength(var_path.c_str(), separator_idx);
768
769 if (check_ptr_vs_member)
Greg Clayton8b2fe6d2010-12-14 02:59:59 +0000770 {
Greg Clayton54979cd2010-12-15 05:08:08 +0000771 // We either have a pointer type and need to verify
772 // valobj_sp is a pointer, or we have a member of a
773 // class/union/struct being accessed with the . syntax
774 // and need to verify we don't have a pointer.
775 const bool actual_is_ptr = valobj_sp->IsPointerType ();
776
777 if (actual_is_ptr != expr_is_ptr)
778 {
779 // Incorrect use of "." with a pointer, or "->" with
780 // a class/union/struct instance or reference.
Greg Clayton6beaaa62011-01-17 03:46:26 +0000781 valobj_sp->GetExpressionPath (var_expr_path_strm, false);
Greg Clayton54979cd2010-12-15 05:08:08 +0000782 if (actual_is_ptr)
783 error.SetErrorStringWithFormat ("\"%s\" is a pointer and . was used to attempt to access \"%s\". Did you mean \"%s->%s\"?",
784 var_expr_path_strm.GetString().c_str(),
785 child_name.GetCString(),
786 var_expr_path_strm.GetString().c_str(),
787 var_path.c_str());
788 else
789 error.SetErrorStringWithFormat ("\"%s\" is not a pointer and -> was used to attempt to access \"%s\". Did you mean \"%s.%s\"?",
790 var_expr_path_strm.GetString().c_str(),
791 child_name.GetCString(),
792 var_expr_path_strm.GetString().c_str(),
793 var_path.c_str());
794 return ValueObjectSP();
795 }
Greg Clayton8b2fe6d2010-12-14 02:59:59 +0000796 }
Greg Clayton54979cd2010-12-15 05:08:08 +0000797 child_valobj_sp = valobj_sp->GetChildMemberWithName (child_name, true);
Greg Clayton8b2fe6d2010-12-14 02:59:59 +0000798 if (!child_valobj_sp)
799 {
Eugene Zelenkod70a6e72016-02-18 18:52:47 +0000800 if (!no_synth_child)
Enrico Granata86cc9822012-03-19 22:58:49 +0000801 {
802 child_valobj_sp = valobj_sp->GetSyntheticValue();
803 if (child_valobj_sp)
804 child_valobj_sp = child_valobj_sp->GetChildMemberWithName (child_name, true);
805 }
Enrico Granata8c9d3562011-08-11 17:08:01 +0000806
807 if (no_synth_child || !child_valobj_sp)
Greg Clayton54979cd2010-12-15 05:08:08 +0000808 {
Enrico Granata8c9d3562011-08-11 17:08:01 +0000809 // No child member with name "child_name"
Greg Clayton685c88c2012-07-14 00:53:55 +0000810 if (synthetically_added_instance_object)
Enrico Granata8c9d3562011-08-11 17:08:01 +0000811 {
Greg Clayton685c88c2012-07-14 00:53:55 +0000812 // We added a "this->" or "self->" to the beginning of the expression
813 // and this is the first pointer ivar access, so just return the normal
814 // error
815 error.SetErrorStringWithFormat("no variable or instance variable named '%s' found in this frame",
816 name_const_string.GetCString());
Enrico Granata8c9d3562011-08-11 17:08:01 +0000817 }
818 else
819 {
Greg Clayton685c88c2012-07-14 00:53:55 +0000820 valobj_sp->GetExpressionPath (var_expr_path_strm, false);
821 if (child_name)
822 {
823 error.SetErrorStringWithFormat ("\"%s\" is not a member of \"(%s) %s\"",
824 child_name.GetCString(),
825 valobj_sp->GetTypeName().AsCString("<invalid type>"),
826 var_expr_path_strm.GetString().c_str());
827 }
828 else
829 {
830 error.SetErrorStringWithFormat ("incomplete expression path after \"%s\" in \"%s\"",
831 var_expr_path_strm.GetString().c_str(),
832 var_expr_cstr);
833 }
Enrico Granata8c9d3562011-08-11 17:08:01 +0000834 }
835 return ValueObjectSP();
Greg Clayton54979cd2010-12-15 05:08:08 +0000836 }
Greg Clayton8b2fe6d2010-12-14 02:59:59 +0000837 }
Greg Clayton685c88c2012-07-14 00:53:55 +0000838 synthetically_added_instance_object = false;
Greg Clayton54979cd2010-12-15 05:08:08 +0000839 // Remove the child name from the path
840 var_path.erase(0, child_name.GetLength());
Greg Clayton4d122c42011-09-17 08:33:22 +0000841 if (use_dynamic != eNoDynamicValues)
Jim Ingham78a685a2011-04-16 00:01:13 +0000842 {
Jim Ingham2837b762011-05-04 03:43:18 +0000843 ValueObjectSP dynamic_value_sp(child_valobj_sp->GetDynamicValue(use_dynamic));
Jim Ingham78a685a2011-04-16 00:01:13 +0000844 if (dynamic_value_sp)
845 child_valobj_sp = dynamic_value_sp;
846 }
Greg Clayton54979cd2010-12-15 05:08:08 +0000847 }
848 break;
Greg Clayton8b2fe6d2010-12-14 02:59:59 +0000849
Greg Clayton54979cd2010-12-15 05:08:08 +0000850 case '[':
851 // Array member access, or treating pointer as an array
852 if (var_path.size() > 2) // Need at least two brackets and a number
853 {
Eugene Zelenkod70a6e72016-02-18 18:52:47 +0000854 char *end = nullptr;
Greg Clayton1a65ae12011-01-25 23:55:37 +0000855 long child_index = ::strtol (&var_path[1], &end, 0);
Enrico Granata9fc19442011-07-06 02:13:41 +0000856 if (end && *end == ']'
857 && *(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 +0000858 {
Greg Clayton99558cc42015-08-24 23:46:31 +0000859 if (valobj_sp->GetCompilerType().IsPointerToScalarType() && deref)
Enrico Granata9fc19442011-07-06 02:13:41 +0000860 {
861 // what we have is *ptr[low]. the most similar C++ syntax is to deref ptr
862 // and extract bit low out of it. reading array item low
863 // would be done by saying ptr[low], without a deref * sign
864 Error error;
865 ValueObjectSP temp(valobj_sp->Dereference(error));
866 if (error.Fail())
867 {
868 valobj_sp->GetExpressionPath (var_expr_path_strm, false);
869 error.SetErrorStringWithFormat ("could not dereference \"(%s) %s\"",
870 valobj_sp->GetTypeName().AsCString("<invalid type>"),
871 var_expr_path_strm.GetString().c_str());
872 return ValueObjectSP();
873 }
874 valobj_sp = temp;
875 deref = false;
876 }
Greg Clayton99558cc42015-08-24 23:46:31 +0000877 else if (valobj_sp->GetCompilerType().IsArrayOfScalarType() && deref)
Enrico Granata9fc19442011-07-06 02:13:41 +0000878 {
879 // what we have is *arr[low]. the most similar C++ syntax is to get arr[0]
880 // (an operation that is equivalent to deref-ing arr)
881 // and extract bit low out of it. reading array item low
882 // would be done by saying arr[low], without a deref * sign
883 Error error;
884 ValueObjectSP temp(valobj_sp->GetChildAtIndex (0, true));
885 if (error.Fail())
886 {
887 valobj_sp->GetExpressionPath (var_expr_path_strm, false);
888 error.SetErrorStringWithFormat ("could not get item 0 for \"(%s) %s\"",
889 valobj_sp->GetTypeName().AsCString("<invalid type>"),
890 var_expr_path_strm.GetString().c_str());
891 return ValueObjectSP();
892 }
893 valobj_sp = temp;
894 deref = false;
895 }
896
Greg Clayton4ef877f2012-12-06 02:33:54 +0000897 bool is_incomplete_array = false;
Greg Clayton54979cd2010-12-15 05:08:08 +0000898 if (valobj_sp->IsPointerType ())
899 {
Sean Callanan226b70c2012-03-08 02:39:03 +0000900 bool is_objc_pointer = true;
901
Greg Clayton99558cc42015-08-24 23:46:31 +0000902 if (valobj_sp->GetCompilerType().GetMinimumLanguage() != eLanguageTypeObjC)
Sean Callanan226b70c2012-03-08 02:39:03 +0000903 is_objc_pointer = false;
Greg Clayton99558cc42015-08-24 23:46:31 +0000904 else if (!valobj_sp->GetCompilerType().IsPointerType())
Sean Callanan226b70c2012-03-08 02:39:03 +0000905 is_objc_pointer = false;
906
907 if (no_synth_child && is_objc_pointer)
Greg Clayton54979cd2010-12-15 05:08:08 +0000908 {
Sean Callanan226b70c2012-03-08 02:39:03 +0000909 error.SetErrorStringWithFormat("\"(%s) %s\" is an Objective-C pointer, and cannot be subscripted",
910 valobj_sp->GetTypeName().AsCString("<invalid type>"),
911 var_expr_path_strm.GetString().c_str());
912
913 return ValueObjectSP();
914 }
915 else if (is_objc_pointer)
916 {
Enrico Granata27b625e2011-08-09 01:04:56 +0000917 // dereferencing ObjC variables is not valid.. so let's try and recur to synthetic children
Enrico Granata86cc9822012-03-19 22:58:49 +0000918 ValueObjectSP synthetic = valobj_sp->GetSyntheticValue();
Eugene Zelenkod70a6e72016-02-18 18:52:47 +0000919 if (!synthetic /* no synthetic */
Enrico Granata27b625e2011-08-09 01:04:56 +0000920 || synthetic == valobj_sp) /* synthetic is the same as the original object */
921 {
922 valobj_sp->GetExpressionPath (var_expr_path_strm, false);
923 error.SetErrorStringWithFormat ("\"(%s) %s\" is not an array type",
924 valobj_sp->GetTypeName().AsCString("<invalid type>"),
925 var_expr_path_strm.GetString().c_str());
926 }
Saleem Abdulrasool3985c8c2014-04-02 03:51:35 +0000927 else if (static_cast<uint32_t>(child_index) >= synthetic->GetNumChildren() /* synthetic does not have that many values */)
Enrico Granata27b625e2011-08-09 01:04:56 +0000928 {
929 valobj_sp->GetExpressionPath (var_expr_path_strm, false);
Jason Molenda7e589a62011-09-20 00:26:08 +0000930 error.SetErrorStringWithFormat ("array index %ld is not valid for \"(%s) %s\"",
Enrico Granata27b625e2011-08-09 01:04:56 +0000931 child_index,
932 valobj_sp->GetTypeName().AsCString("<invalid type>"),
933 var_expr_path_strm.GetString().c_str());
934 }
935 else
936 {
937 child_valobj_sp = synthetic->GetChildAtIndex(child_index, true);
938 if (!child_valobj_sp)
939 {
940 valobj_sp->GetExpressionPath (var_expr_path_strm, false);
Jason Molenda7e589a62011-09-20 00:26:08 +0000941 error.SetErrorStringWithFormat ("array index %ld is not valid for \"(%s) %s\"",
Enrico Granata27b625e2011-08-09 01:04:56 +0000942 child_index,
943 valobj_sp->GetTypeName().AsCString("<invalid type>"),
944 var_expr_path_strm.GetString().c_str());
945 }
946 }
947 }
948 else
949 {
Bruce Mitchener11d86362015-02-26 23:55:39 +0000950 child_valobj_sp = valobj_sp->GetSyntheticArrayMember (child_index, true);
Enrico Granata27b625e2011-08-09 01:04:56 +0000951 if (!child_valobj_sp)
952 {
953 valobj_sp->GetExpressionPath (var_expr_path_strm, false);
Jason Molenda7e589a62011-09-20 00:26:08 +0000954 error.SetErrorStringWithFormat ("failed to use pointer as array for index %ld for \"(%s) %s\"",
Enrico Granata27b625e2011-08-09 01:04:56 +0000955 child_index,
956 valobj_sp->GetTypeName().AsCString("<invalid type>"),
957 var_expr_path_strm.GetString().c_str());
958 }
Greg Clayton54979cd2010-12-15 05:08:08 +0000959 }
960 }
Eugene Zelenkod70a6e72016-02-18 18:52:47 +0000961 else if (valobj_sp->GetCompilerType().IsArrayType(nullptr, nullptr, &is_incomplete_array))
Greg Clayton54979cd2010-12-15 05:08:08 +0000962 {
Jim Ingham78a685a2011-04-16 00:01:13 +0000963 // Pass false to dynamic_value here so we can tell the difference between
964 // no dynamic value and no member of this type...
Greg Clayton54979cd2010-12-15 05:08:08 +0000965 child_valobj_sp = valobj_sp->GetChildAtIndex (child_index, true);
Eugene Zelenkod70a6e72016-02-18 18:52:47 +0000966 if (!child_valobj_sp && (is_incomplete_array || !no_synth_child))
Greg Clayton4ef877f2012-12-06 02:33:54 +0000967 child_valobj_sp = valobj_sp->GetSyntheticArrayMember (child_index, true);
968
Greg Clayton54979cd2010-12-15 05:08:08 +0000969 if (!child_valobj_sp)
970 {
Greg Clayton6beaaa62011-01-17 03:46:26 +0000971 valobj_sp->GetExpressionPath (var_expr_path_strm, false);
Jason Molenda7e589a62011-09-20 00:26:08 +0000972 error.SetErrorStringWithFormat ("array index %ld is not valid for \"(%s) %s\"",
Greg Clayton54979cd2010-12-15 05:08:08 +0000973 child_index,
974 valobj_sp->GetTypeName().AsCString("<invalid type>"),
975 var_expr_path_strm.GetString().c_str());
976 }
977 }
Greg Clayton99558cc42015-08-24 23:46:31 +0000978 else if (valobj_sp->GetCompilerType().IsScalarType())
Enrico Granata9fc19442011-07-06 02:13:41 +0000979 {
980 // this is a bitfield asking to display just one bit
981 child_valobj_sp = valobj_sp->GetSyntheticBitFieldChild(child_index, child_index, true);
982 if (!child_valobj_sp)
983 {
984 valobj_sp->GetExpressionPath (var_expr_path_strm, false);
Jason Molenda7e589a62011-09-20 00:26:08 +0000985 error.SetErrorStringWithFormat ("bitfield range %ld-%ld is not valid for \"(%s) %s\"",
Enrico Granata9fc19442011-07-06 02:13:41 +0000986 child_index, child_index,
987 valobj_sp->GetTypeName().AsCString("<invalid type>"),
988 var_expr_path_strm.GetString().c_str());
989 }
990 }
Greg Clayton54979cd2010-12-15 05:08:08 +0000991 else
992 {
Enrico Granata86cc9822012-03-19 22:58:49 +0000993 ValueObjectSP synthetic = valobj_sp->GetSyntheticValue();
Enrico Granata27b625e2011-08-09 01:04:56 +0000994 if (no_synth_child /* synthetic is forbidden */ ||
Eugene Zelenkod70a6e72016-02-18 18:52:47 +0000995 !synthetic /* no synthetic */
Enrico Granata27b625e2011-08-09 01:04:56 +0000996 || synthetic == valobj_sp) /* synthetic is the same as the original object */
997 {
998 valobj_sp->GetExpressionPath (var_expr_path_strm, false);
999 error.SetErrorStringWithFormat ("\"(%s) %s\" is not an array type",
1000 valobj_sp->GetTypeName().AsCString("<invalid type>"),
1001 var_expr_path_strm.GetString().c_str());
1002 }
Saleem Abdulrasool3985c8c2014-04-02 03:51:35 +00001003 else if (static_cast<uint32_t>(child_index) >= synthetic->GetNumChildren() /* synthetic does not have that many values */)
Enrico Granata27b625e2011-08-09 01:04:56 +00001004 {
1005 valobj_sp->GetExpressionPath (var_expr_path_strm, false);
Jason Molenda7e589a62011-09-20 00:26:08 +00001006 error.SetErrorStringWithFormat ("array index %ld is not valid for \"(%s) %s\"",
Enrico Granata27b625e2011-08-09 01:04:56 +00001007 child_index,
1008 valobj_sp->GetTypeName().AsCString("<invalid type>"),
1009 var_expr_path_strm.GetString().c_str());
1010 }
1011 else
1012 {
1013 child_valobj_sp = synthetic->GetChildAtIndex(child_index, true);
1014 if (!child_valobj_sp)
1015 {
1016 valobj_sp->GetExpressionPath (var_expr_path_strm, false);
Jason Molenda7e589a62011-09-20 00:26:08 +00001017 error.SetErrorStringWithFormat ("array index %ld is not valid for \"(%s) %s\"",
Enrico Granata27b625e2011-08-09 01:04:56 +00001018 child_index,
1019 valobj_sp->GetTypeName().AsCString("<invalid type>"),
1020 var_expr_path_strm.GetString().c_str());
1021 }
1022 }
Greg Clayton54979cd2010-12-15 05:08:08 +00001023 }
1024
1025 if (!child_valobj_sp)
1026 {
1027 // Invalid array index...
1028 return ValueObjectSP();
1029 }
1030
1031 // Erase the array member specification '[%i]' where
1032 // %i is the array index
1033 var_path.erase(0, (end - var_path.c_str()) + 1);
1034 separator_idx = var_path.find_first_of(".-[");
Greg Clayton4d122c42011-09-17 08:33:22 +00001035 if (use_dynamic != eNoDynamicValues)
Jim Ingham78a685a2011-04-16 00:01:13 +00001036 {
Jim Ingham2837b762011-05-04 03:43:18 +00001037 ValueObjectSP dynamic_value_sp(child_valobj_sp->GetDynamicValue(use_dynamic));
Jim Ingham78a685a2011-04-16 00:01:13 +00001038 if (dynamic_value_sp)
1039 child_valobj_sp = dynamic_value_sp;
1040 }
Greg Clayton54979cd2010-12-15 05:08:08 +00001041 // Break out early from the switch since we were
1042 // able to find the child member
1043 break;
1044 }
Enrico Granata20edcdb2011-07-19 18:03:25 +00001045 else if (end && *end == '-')
Enrico Granata9fc19442011-07-06 02:13:41 +00001046 {
1047 // this is most probably a BitField, let's take a look
Eugene Zelenkod70a6e72016-02-18 18:52:47 +00001048 char *real_end = nullptr;
Enrico Granata9fc19442011-07-06 02:13:41 +00001049 long final_index = ::strtol (end+1, &real_end, 0);
Enrico Granatad64d0bc2011-08-19 21:13:46 +00001050 bool expand_bitfield = true;
Enrico Granata20edcdb2011-07-19 18:03:25 +00001051 if (real_end && *real_end == ']')
Enrico Granata9fc19442011-07-06 02:13:41 +00001052 {
1053 // if the format given is [high-low], swap range
Enrico Granata20edcdb2011-07-19 18:03:25 +00001054 if (child_index > final_index)
Enrico Granata9fc19442011-07-06 02:13:41 +00001055 {
1056 long temp = child_index;
1057 child_index = final_index;
1058 final_index = temp;
1059 }
1060
Greg Clayton99558cc42015-08-24 23:46:31 +00001061 if (valobj_sp->GetCompilerType().IsPointerToScalarType() && deref)
Enrico Granata9fc19442011-07-06 02:13:41 +00001062 {
1063 // what we have is *ptr[low-high]. the most similar C++ syntax is to deref ptr
1064 // and extract bits low thru high out of it. reading array items low thru high
1065 // would be done by saying ptr[low-high], without a deref * sign
1066 Error error;
1067 ValueObjectSP temp(valobj_sp->Dereference(error));
1068 if (error.Fail())
1069 {
1070 valobj_sp->GetExpressionPath (var_expr_path_strm, false);
1071 error.SetErrorStringWithFormat ("could not dereference \"(%s) %s\"",
1072 valobj_sp->GetTypeName().AsCString("<invalid type>"),
1073 var_expr_path_strm.GetString().c_str());
1074 return ValueObjectSP();
1075 }
1076 valobj_sp = temp;
1077 deref = false;
1078 }
Greg Clayton99558cc42015-08-24 23:46:31 +00001079 else if (valobj_sp->GetCompilerType().IsArrayOfScalarType() && deref)
Enrico Granata9fc19442011-07-06 02:13:41 +00001080 {
1081 // what we have is *arr[low-high]. the most similar C++ syntax is to get arr[0]
1082 // (an operation that is equivalent to deref-ing arr)
1083 // and extract bits low thru high out of it. reading array items low thru high
1084 // would be done by saying arr[low-high], without a deref * sign
1085 Error error;
1086 ValueObjectSP temp(valobj_sp->GetChildAtIndex (0, true));
1087 if (error.Fail())
1088 {
1089 valobj_sp->GetExpressionPath (var_expr_path_strm, false);
1090 error.SetErrorStringWithFormat ("could not get item 0 for \"(%s) %s\"",
1091 valobj_sp->GetTypeName().AsCString("<invalid type>"),
1092 var_expr_path_strm.GetString().c_str());
1093 return ValueObjectSP();
1094 }
1095 valobj_sp = temp;
1096 deref = false;
1097 }
Enrico Granatad64d0bc2011-08-19 21:13:46 +00001098 /*else if (valobj_sp->IsArrayType() || valobj_sp->IsPointerType())
Enrico Granata9fc19442011-07-06 02:13:41 +00001099 {
Enrico Granatad64d0bc2011-08-19 21:13:46 +00001100 child_valobj_sp = valobj_sp->GetSyntheticArrayRangeChild(child_index, final_index, true);
1101 expand_bitfield = false;
1102 if (!child_valobj_sp)
1103 {
1104 valobj_sp->GetExpressionPath (var_expr_path_strm, false);
1105 error.SetErrorStringWithFormat ("array range %i-%i is not valid for \"(%s) %s\"",
1106 child_index, final_index,
1107 valobj_sp->GetTypeName().AsCString("<invalid type>"),
1108 var_expr_path_strm.GetString().c_str());
1109 }
1110 }*/
1111
1112 if (expand_bitfield)
1113 {
1114 child_valobj_sp = valobj_sp->GetSyntheticBitFieldChild(child_index, final_index, true);
1115 if (!child_valobj_sp)
1116 {
1117 valobj_sp->GetExpressionPath (var_expr_path_strm, false);
Jason Molenda7e589a62011-09-20 00:26:08 +00001118 error.SetErrorStringWithFormat ("bitfield range %ld-%ld is not valid for \"(%s) %s\"",
Enrico Granatad64d0bc2011-08-19 21:13:46 +00001119 child_index, final_index,
1120 valobj_sp->GetTypeName().AsCString("<invalid type>"),
1121 var_expr_path_strm.GetString().c_str());
1122 }
Enrico Granata9fc19442011-07-06 02:13:41 +00001123 }
1124 }
1125
1126 if (!child_valobj_sp)
1127 {
1128 // Invalid bitfield range...
1129 return ValueObjectSP();
1130 }
1131
1132 // Erase the bitfield member specification '[%i-%i]' where
1133 // %i is the index
1134 var_path.erase(0, (real_end - var_path.c_str()) + 1);
1135 separator_idx = var_path.find_first_of(".-[");
Greg Clayton4d122c42011-09-17 08:33:22 +00001136 if (use_dynamic != eNoDynamicValues)
Enrico Granata9fc19442011-07-06 02:13:41 +00001137 {
1138 ValueObjectSP dynamic_value_sp(child_valobj_sp->GetDynamicValue(use_dynamic));
1139 if (dynamic_value_sp)
1140 child_valobj_sp = dynamic_value_sp;
1141 }
1142 // Break out early from the switch since we were
1143 // able to find the child member
1144 break;
1145
1146 }
1147 }
1148 else
1149 {
1150 error.SetErrorStringWithFormat("invalid square bracket encountered after \"%s\" in \"%s\"",
1151 var_expr_path_strm.GetString().c_str(),
1152 var_path.c_str());
Greg Clayton54979cd2010-12-15 05:08:08 +00001153 }
1154 return ValueObjectSP();
1155
1156 default:
1157 // Failure...
1158 {
Greg Clayton6beaaa62011-01-17 03:46:26 +00001159 valobj_sp->GetExpressionPath (var_expr_path_strm, false);
Greg Clayton54979cd2010-12-15 05:08:08 +00001160 error.SetErrorStringWithFormat ("unexpected char '%c' encountered after \"%s\" in \"%s\"",
1161 separator_type,
1162 var_expr_path_strm.GetString().c_str(),
1163 var_path.c_str());
1164
1165 return ValueObjectSP();
Greg Clayton8b2fe6d2010-12-14 02:59:59 +00001166 }
1167 }
Greg Clayton8b2fe6d2010-12-14 02:59:59 +00001168
Greg Clayton54979cd2010-12-15 05:08:08 +00001169 if (child_valobj_sp)
1170 valobj_sp = child_valobj_sp;
1171
1172 if (var_path.empty())
1173 break;
Greg Clayton8b2fe6d2010-12-14 02:59:59 +00001174 }
Greg Clayton54979cd2010-12-15 05:08:08 +00001175 if (valobj_sp)
1176 {
1177 if (deref)
1178 {
Greg Claytonaf67cec2010-12-20 20:49:23 +00001179 ValueObjectSP deref_valobj_sp (valobj_sp->Dereference(error));
Greg Clayton54979cd2010-12-15 05:08:08 +00001180 valobj_sp = deref_valobj_sp;
1181 }
1182 else if (address_of)
1183 {
1184 ValueObjectSP address_of_valobj_sp (valobj_sp->AddressOf(error));
1185 valobj_sp = address_of_valobj_sp;
1186 }
1187 }
1188 return valobj_sp;
Greg Clayton8b2fe6d2010-12-14 02:59:59 +00001189 }
Greg Clayton54979cd2010-12-15 05:08:08 +00001190 else
Greg Clayton8b2fe6d2010-12-14 02:59:59 +00001191 {
Jim Ingham2837b762011-05-04 03:43:18 +00001192 error.SetErrorStringWithFormat("no variable named '%s' found in this frame",
1193 name_const_string.GetCString());
Greg Clayton8b2fe6d2010-12-14 02:59:59 +00001194 }
Greg Clayton8b2fe6d2010-12-14 02:59:59 +00001195 }
1196 }
Greg Clayton54979cd2010-12-15 05:08:08 +00001197 else
1198 {
1199 error.SetErrorStringWithFormat("invalid variable path '%s'", var_expr_cstr);
1200 }
Greg Clayton8b2fe6d2010-12-14 02:59:59 +00001201 return ValueObjectSP();
1202}
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001203
1204bool
1205StackFrame::GetFrameBaseValue (Scalar &frame_base, Error *error_ptr)
1206{
Jason Molenda6a354702014-10-02 01:08:16 +00001207 Mutex::Locker locker(m_mutex);
Eugene Zelenkod70a6e72016-02-18 18:52:47 +00001208 if (!m_cfa_is_valid)
Jason Molenda99618472013-11-04 11:02:52 +00001209 {
1210 m_frame_base_error.SetErrorString("No frame base available for this historical stack frame.");
1211 return false;
1212 }
1213
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001214 if (m_flags.IsClear(GOT_FRAME_BASE))
1215 {
1216 if (m_sc.function)
1217 {
1218 m_frame_base.Clear();
1219 m_frame_base_error.Clear();
1220
1221 m_flags.Set(GOT_FRAME_BASE);
Greg Claytond9e416c2012-02-18 05:35:26 +00001222 ExecutionContext exe_ctx (shared_from_this());
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001223 Value expr_value;
Greg Clayton016a95e2010-09-14 02:20:48 +00001224 addr_t loclist_base_addr = LLDB_INVALID_ADDRESS;
1225 if (m_sc.function->GetFrameBaseExpression().IsLocationList())
Greg Claytond9e416c2012-02-18 05:35:26 +00001226 loclist_base_addr = m_sc.function->GetAddressRange().GetBaseAddress().GetLoadAddress (exe_ctx.GetTargetPtr());
Greg Clayton016a95e2010-09-14 02:20:48 +00001227
Tamas Berghammer5b42c7a2016-02-26 14:21:10 +00001228 if (m_sc.function->GetFrameBaseExpression().Evaluate(&exe_ctx,
1229 nullptr,
1230 nullptr,
1231 nullptr,
1232 loclist_base_addr,
1233 nullptr,
1234 nullptr,
1235 expr_value,
1236 &m_frame_base_error) == false)
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001237 {
1238 // We should really have an error if evaluate returns, but in case
1239 // we don't, lets set the error to something at least.
1240 if (m_frame_base_error.Success())
1241 m_frame_base_error.SetErrorString("Evaluation of the frame base expression failed.");
1242 }
1243 else
1244 {
Greg Clayton57ee3062013-07-11 22:46:58 +00001245 m_frame_base = expr_value.ResolveValue(&exe_ctx);
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001246 }
1247 }
1248 else
1249 {
1250 m_frame_base_error.SetErrorString ("No function in symbol context.");
1251 }
1252 }
1253
1254 if (m_frame_base_error.Success())
1255 frame_base = m_frame_base;
1256
1257 if (error_ptr)
1258 *error_ptr = m_frame_base_error;
1259 return m_frame_base_error.Success();
1260}
1261
Greg Clayton5ccbd292011-01-06 22:15:06 +00001262RegisterContextSP
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001263StackFrame::GetRegisterContext ()
1264{
Jason Molenda6a354702014-10-02 01:08:16 +00001265 Mutex::Locker locker(m_mutex);
Greg Clayton5ccbd292011-01-06 22:15:06 +00001266 if (!m_reg_context_sp)
Greg Claytond9e416c2012-02-18 05:35:26 +00001267 {
1268 ThreadSP thread_sp (GetThread());
1269 if (thread_sp)
1270 m_reg_context_sp = thread_sp->CreateRegisterContextForFrame (this);
1271 }
Greg Clayton5ccbd292011-01-06 22:15:06 +00001272 return m_reg_context_sp;
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001273}
1274
1275bool
1276StackFrame::HasDebugInformation ()
1277{
Greg Clayton9da7bd02010-08-24 21:05:24 +00001278 GetSymbolContext (eSymbolContextLineEntry);
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001279 return m_sc.line_entry.IsValid();
1280}
1281
Greg Clayton288bdf92010-09-02 02:59:18 +00001282ValueObjectSP
Greg Clayton4d122c42011-09-17 08:33:22 +00001283StackFrame::GetValueObjectForFrameVariable (const VariableSP &variable_sp, DynamicValueType use_dynamic)
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001284{
Jason Molenda6a354702014-10-02 01:08:16 +00001285 Mutex::Locker locker(m_mutex);
Greg Clayton288bdf92010-09-02 02:59:18 +00001286 ValueObjectSP valobj_sp;
Jason Molenda99618472013-11-04 11:02:52 +00001287 if (m_is_history_frame)
1288 {
1289 return valobj_sp;
1290 }
Greg Clayton288bdf92010-09-02 02:59:18 +00001291 VariableList *var_list = GetVariableList (true);
1292 if (var_list)
1293 {
1294 // Make sure the variable is a frame variable
1295 const uint32_t var_idx = var_list->FindIndexForVariable (variable_sp.get());
1296 const uint32_t num_variables = var_list->GetSize();
1297 if (var_idx < num_variables)
1298 {
1299 valobj_sp = m_variable_list_value_objects.GetValueObjectAtIndex (var_idx);
Eugene Zelenkod70a6e72016-02-18 18:52:47 +00001300 if (!valobj_sp)
Greg Clayton288bdf92010-09-02 02:59:18 +00001301 {
1302 if (m_variable_list_value_objects.GetSize() < num_variables)
1303 m_variable_list_value_objects.Resize(num_variables);
Jim Ingham58b59f92011-04-22 23:53:53 +00001304 valobj_sp = ValueObjectVariable::Create (this, variable_sp);
Greg Clayton288bdf92010-09-02 02:59:18 +00001305 m_variable_list_value_objects.SetValueObjectAtIndex (var_idx, valobj_sp);
1306 }
1307 }
1308 }
Greg Clayton4d122c42011-09-17 08:33:22 +00001309 if (use_dynamic != eNoDynamicValues && valobj_sp)
Jim Ingham78a685a2011-04-16 00:01:13 +00001310 {
Jim Ingham2837b762011-05-04 03:43:18 +00001311 ValueObjectSP dynamic_sp = valobj_sp->GetDynamicValue (use_dynamic);
Jim Ingham78a685a2011-04-16 00:01:13 +00001312 if (dynamic_sp)
1313 return dynamic_sp;
1314 }
Greg Clayton288bdf92010-09-02 02:59:18 +00001315 return valobj_sp;
1316}
1317
1318ValueObjectSP
Greg Clayton4d122c42011-09-17 08:33:22 +00001319StackFrame::TrackGlobalVariable (const VariableSP &variable_sp, DynamicValueType use_dynamic)
Greg Clayton288bdf92010-09-02 02:59:18 +00001320{
Jason Molenda6a354702014-10-02 01:08:16 +00001321 Mutex::Locker locker(m_mutex);
Jason Molenda99618472013-11-04 11:02:52 +00001322 if (m_is_history_frame)
1323 return ValueObjectSP();
1324
Greg Clayton288bdf92010-09-02 02:59:18 +00001325 // Check to make sure we aren't already tracking this variable?
Jim Ingham78a685a2011-04-16 00:01:13 +00001326 ValueObjectSP valobj_sp (GetValueObjectForFrameVariable (variable_sp, use_dynamic));
Greg Clayton288bdf92010-09-02 02:59:18 +00001327 if (!valobj_sp)
1328 {
1329 // We aren't already tracking this global
1330 VariableList *var_list = GetVariableList (true);
1331 // If this frame has no variables, create a new list
Eugene Zelenkod70a6e72016-02-18 18:52:47 +00001332 if (var_list == nullptr)
Greg Clayton288bdf92010-09-02 02:59:18 +00001333 m_variable_list_sp.reset (new VariableList());
1334
1335 // Add the global/static variable to this frame
1336 m_variable_list_sp->AddVariable (variable_sp);
1337
1338 // Now make a value object for it so we can track its changes
Jim Ingham78a685a2011-04-16 00:01:13 +00001339 valobj_sp = GetValueObjectForFrameVariable (variable_sp, use_dynamic);
Greg Clayton288bdf92010-09-02 02:59:18 +00001340 }
1341 return valobj_sp;
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001342}
1343
Jim Ingham6b8379c2010-08-26 20:44:45 +00001344bool
1345StackFrame::IsInlined ()
1346{
Eugene Zelenkod70a6e72016-02-18 18:52:47 +00001347 if (m_sc.block == nullptr)
Greg Clayton59e8fc1c2010-08-30 18:11:35 +00001348 GetSymbolContext (eSymbolContextBlock);
1349 if (m_sc.block)
Eugene Zelenkod70a6e72016-02-18 18:52:47 +00001350 return m_sc.block->GetContainingInlinedBlock() != nullptr;
Greg Clayton59e8fc1c2010-08-30 18:11:35 +00001351 return false;
Jim Ingham6b8379c2010-08-26 20:44:45 +00001352}
1353
Dawn Perchik009d1102015-09-04 01:02:30 +00001354lldb::LanguageType
1355StackFrame::GetLanguage ()
1356{
1357 CompileUnit *cu = GetSymbolContext(eSymbolContextCompUnit).comp_unit;
1358 if (cu)
1359 return cu->GetLanguage();
1360 return lldb::eLanguageTypeUnknown;
1361}
1362
Enrico Granata592afe72016-03-15 21:50:51 +00001363lldb::LanguageType
1364StackFrame::GuessLanguage ()
1365{
1366 LanguageType lang_type = GetLanguage();
1367
1368 if (lang_type == eLanguageTypeUnknown)
1369 {
1370 Function *f = GetSymbolContext(eSymbolContextFunction).function;
1371 if (f)
1372 {
1373 lang_type = f->GetMangled().GuessLanguage();
1374 }
1375 }
1376
1377 return lang_type;
1378}
1379
Greg Claytond9e416c2012-02-18 05:35:26 +00001380TargetSP
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001381StackFrame::CalculateTarget ()
1382{
Greg Claytond9e416c2012-02-18 05:35:26 +00001383 TargetSP target_sp;
1384 ThreadSP thread_sp(GetThread());
1385 if (thread_sp)
1386 {
1387 ProcessSP process_sp (thread_sp->CalculateProcess());
1388 if (process_sp)
1389 target_sp = process_sp->CalculateTarget();
1390 }
1391 return target_sp;
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001392}
1393
Greg Claytond9e416c2012-02-18 05:35:26 +00001394ProcessSP
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001395StackFrame::CalculateProcess ()
1396{
Greg Claytond9e416c2012-02-18 05:35:26 +00001397 ProcessSP process_sp;
1398 ThreadSP thread_sp(GetThread());
1399 if (thread_sp)
1400 process_sp = thread_sp->CalculateProcess();
1401 return process_sp;
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001402}
1403
Greg Claytond9e416c2012-02-18 05:35:26 +00001404ThreadSP
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001405StackFrame::CalculateThread ()
1406{
Greg Claytond9e416c2012-02-18 05:35:26 +00001407 return GetThread();
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001408}
1409
Jason Molendab57e4a12013-11-04 09:33:30 +00001410StackFrameSP
1411StackFrame::CalculateStackFrame ()
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001412{
Greg Claytond9e416c2012-02-18 05:35:26 +00001413 return shared_from_this();
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001414}
1415
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001416void
Greg Clayton0603aa92010-10-04 01:05:56 +00001417StackFrame::CalculateExecutionContext (ExecutionContext &exe_ctx)
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001418{
Greg Claytond9e416c2012-02-18 05:35:26 +00001419 exe_ctx.SetContext (shared_from_this());
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001420}
1421
1422void
Jim Ingham8ec10ef2013-10-18 17:38:31 +00001423StackFrame::DumpUsingSettingsFormat (Stream *strm, const char *frame_marker)
Greg Clayton0603aa92010-10-04 01:05:56 +00001424{
Eugene Zelenkod70a6e72016-02-18 18:52:47 +00001425 if (strm == nullptr)
Greg Clayton0603aa92010-10-04 01:05:56 +00001426 return;
1427
1428 GetSymbolContext(eSymbolContextEverything);
Greg Claytond9e416c2012-02-18 05:35:26 +00001429 ExecutionContext exe_ctx (shared_from_this());
Greg Clayton0603aa92010-10-04 01:05:56 +00001430 StreamString s;
Jim Ingham8ec10ef2013-10-18 17:38:31 +00001431
1432 if (frame_marker)
1433 s.PutCString(frame_marker);
1434
Eugene Zelenkod70a6e72016-02-18 18:52:47 +00001435 const FormatEntity::Entry *frame_format = nullptr;
Greg Claytond9e416c2012-02-18 05:35:26 +00001436 Target *target = exe_ctx.GetTargetPtr();
1437 if (target)
1438 frame_format = target->GetDebugger().GetFrameFormat();
Eugene Zelenkod70a6e72016-02-18 18:52:47 +00001439 if (frame_format && FormatEntity::Format(*frame_format, s, &m_sc, &exe_ctx, nullptr, nullptr, false, false))
Greg Clayton0603aa92010-10-04 01:05:56 +00001440 {
1441 strm->Write(s.GetData(), s.GetSize());
1442 }
1443 else
1444 {
1445 Dump (strm, true, false);
1446 strm->EOL();
1447 }
1448}
1449
1450void
Greg Clayton6dadd502010-09-02 21:44:10 +00001451StackFrame::Dump (Stream *strm, bool show_frame_index, bool show_fullpaths)
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001452{
Eugene Zelenkod70a6e72016-02-18 18:52:47 +00001453 if (strm == nullptr)
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001454 return;
1455
1456 if (show_frame_index)
Greg Clayton1b72fcb2010-08-24 00:45:41 +00001457 strm->Printf("frame #%u: ", m_frame_index);
Greg Claytond9e416c2012-02-18 05:35:26 +00001458 ExecutionContext exe_ctx (shared_from_this());
1459 Target *target = exe_ctx.GetTargetPtr();
Daniel Malead01b2952012-11-29 21:49:15 +00001460 strm->Printf("0x%0*" PRIx64 " ",
Greg Claytond9e416c2012-02-18 05:35:26 +00001461 target ? (target->GetArchitecture().GetAddressByteSize() * 2) : 16,
1462 GetFrameCodeAddress().GetLoadAddress(target));
Greg Clayton9da7bd02010-08-24 21:05:24 +00001463 GetSymbolContext(eSymbolContextEverything);
Greg Clayton1b72fcb2010-08-24 00:45:41 +00001464 const bool show_module = true;
1465 const bool show_inline = true;
Jason Molendaaff1b352014-10-10 23:07:36 +00001466 const bool show_function_arguments = true;
Jason Molendac980fa92015-02-13 23:24:21 +00001467 const bool show_function_name = true;
Greg Claytond9e416c2012-02-18 05:35:26 +00001468 m_sc.DumpStopContext (strm,
1469 exe_ctx.GetBestExecutionContextScope(),
1470 GetFrameCodeAddress(),
1471 show_fullpaths,
1472 show_module,
Jason Molendaaff1b352014-10-10 23:07:36 +00001473 show_inline,
Jason Molendac980fa92015-02-13 23:24:21 +00001474 show_function_arguments,
1475 show_function_name);
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001476}
1477
Greg Clayton5082c5f2010-08-27 18:24:16 +00001478void
Jason Molendab57e4a12013-11-04 09:33:30 +00001479StackFrame::UpdateCurrentFrameFromPreviousFrame (StackFrame &prev_frame)
Greg Clayton5082c5f2010-08-27 18:24:16 +00001480{
Jason Molenda6a354702014-10-02 01:08:16 +00001481 Mutex::Locker locker(m_mutex);
Greg Clayton59e8fc1c2010-08-30 18:11:35 +00001482 assert (GetStackID() == prev_frame.GetStackID()); // TODO: remove this after some testing
Jason Molendab57e4a12013-11-04 09:33:30 +00001483 m_variable_list_sp = prev_frame.m_variable_list_sp;
1484 m_variable_list_value_objects.Swap (prev_frame.m_variable_list_value_objects);
1485 if (!m_disassembly.GetString().empty())
1486 m_disassembly.GetString().swap (m_disassembly.GetString());
Greg Clayton5082c5f2010-08-27 18:24:16 +00001487}
Greg Clayton68275d52010-08-27 21:47:54 +00001488
Greg Clayton59e8fc1c2010-08-30 18:11:35 +00001489void
Jason Molendab57e4a12013-11-04 09:33:30 +00001490StackFrame::UpdatePreviousFrameFromCurrentFrame (StackFrame &curr_frame)
Greg Clayton59e8fc1c2010-08-30 18:11:35 +00001491{
Jason Molenda6a354702014-10-02 01:08:16 +00001492 Mutex::Locker locker(m_mutex);
Greg Clayton2cad65a2010-09-03 17:10:42 +00001493 assert (GetStackID() == curr_frame.GetStackID()); // TODO: remove this after some testing
Jason Molendab57e4a12013-11-04 09:33:30 +00001494 m_id.SetPC (curr_frame.m_id.GetPC()); // Update the Stack ID PC value
1495 assert (GetThread() == curr_frame.GetThread());
1496 m_frame_index = curr_frame.m_frame_index;
1497 m_concrete_frame_index = curr_frame.m_concrete_frame_index;
1498 m_reg_context_sp = curr_frame.m_reg_context_sp;
1499 m_frame_code_addr = curr_frame.m_frame_code_addr;
Eugene Zelenkod70a6e72016-02-18 18:52:47 +00001500 assert (!m_sc.target_sp || !curr_frame.m_sc.target_sp || m_sc.target_sp.get() == curr_frame.m_sc.target_sp.get());
1501 assert (!m_sc.module_sp || !curr_frame.m_sc.module_sp || m_sc.module_sp.get() == curr_frame.m_sc.module_sp.get());
1502 assert (m_sc.comp_unit == nullptr || curr_frame.m_sc.comp_unit == nullptr || m_sc.comp_unit == curr_frame.m_sc.comp_unit);
1503 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 +00001504 m_sc = curr_frame.m_sc;
1505 m_flags.Clear(GOT_FRAME_BASE | eSymbolContextEverything);
1506 m_flags.Set (m_sc.GetResolvedMask());
1507 m_frame_base.Clear();
1508 m_frame_base_error.Clear();
Greg Clayton59e8fc1c2010-08-30 18:11:35 +00001509}
1510
Greg Clayton2cad65a2010-09-03 17:10:42 +00001511bool
Jason Molendab57e4a12013-11-04 09:33:30 +00001512StackFrame::HasCachedData () const
1513{
Eugene Zelenkod70a6e72016-02-18 18:52:47 +00001514 if (m_variable_list_sp)
Jason Molendab57e4a12013-11-04 09:33:30 +00001515 return true;
1516 if (m_variable_list_value_objects.GetSize() > 0)
1517 return true;
1518 if (!m_disassembly.GetString().empty())
1519 return true;
1520 return false;
1521}
1522
1523bool
Greg Clayton7260f622011-04-18 08:33:37 +00001524StackFrame::GetStatus (Stream& strm,
1525 bool show_frame_info,
Jim Ingham8ec10ef2013-10-18 17:38:31 +00001526 bool show_source,
1527 const char *frame_marker)
Greg Clayton7260f622011-04-18 08:33:37 +00001528{
Greg Clayton53eb7ad2012-07-11 20:33:48 +00001529
Greg Clayton7260f622011-04-18 08:33:37 +00001530 if (show_frame_info)
1531 {
1532 strm.Indent();
Jim Ingham8ec10ef2013-10-18 17:38:31 +00001533 DumpUsingSettingsFormat (&strm, frame_marker);
Greg Clayton7260f622011-04-18 08:33:37 +00001534 }
1535
1536 if (show_source)
1537 {
Greg Claytond9e416c2012-02-18 05:35:26 +00001538 ExecutionContext exe_ctx (shared_from_this());
Mohit K. Bhakkad8be74992015-12-03 04:56:16 +00001539 bool have_source = false, have_debuginfo = false;
Greg Clayton67cc0632012-08-22 17:17:09 +00001540 Debugger::StopDisassemblyType disasm_display = Debugger::eStopDisassemblyTypeNever;
Greg Claytond9e416c2012-02-18 05:35:26 +00001541 Target *target = exe_ctx.GetTargetPtr();
Greg Clayton53eb7ad2012-07-11 20:33:48 +00001542 if (target)
Greg Clayton7260f622011-04-18 08:33:37 +00001543 {
Greg Clayton53eb7ad2012-07-11 20:33:48 +00001544 Debugger &debugger = target->GetDebugger();
1545 const uint32_t source_lines_before = debugger.GetStopSourceLineCount(true);
1546 const uint32_t source_lines_after = debugger.GetStopSourceLineCount(false);
1547 disasm_display = debugger.GetStopDisassemblyDisplay ();
Greg Claytone372b982011-11-21 21:44:34 +00001548
Todd Fiala6d1fbc92014-07-07 20:47:24 +00001549 GetSymbolContext(eSymbolContextCompUnit | eSymbolContextLineEntry);
1550 if (m_sc.comp_unit && m_sc.line_entry.IsValid())
Greg Claytone372b982011-11-21 21:44:34 +00001551 {
Mohit K. Bhakkad8be74992015-12-03 04:56:16 +00001552 have_debuginfo = true;
Todd Fiala6d1fbc92014-07-07 20:47:24 +00001553 if (source_lines_before > 0 || source_lines_after > 0)
Greg Claytone372b982011-11-21 21:44:34 +00001554 {
Mohit K. Bhakkad8be74992015-12-03 04:56:16 +00001555 size_t num_lines = target->GetSourceManager().DisplaySourceLinesWithLineNumbers (m_sc.line_entry.file,
Greg Clayton53eb7ad2012-07-11 20:33:48 +00001556 m_sc.line_entry.line,
1557 source_lines_before,
1558 source_lines_after,
1559 "->",
Jason Molenda7cd81c52013-04-29 09:59:31 +00001560 &strm);
Mohit K. Bhakkad8be74992015-12-03 04:56:16 +00001561 if (num_lines != 0)
1562 have_source = true;
1563 // TODO: Give here a one time warning if source file is missing.
Greg Claytone372b982011-11-21 21:44:34 +00001564 }
1565 }
Greg Clayton53eb7ad2012-07-11 20:33:48 +00001566 switch (disasm_display)
1567 {
Greg Clayton67cc0632012-08-22 17:17:09 +00001568 case Debugger::eStopDisassemblyTypeNever:
Greg Claytone372b982011-11-21 21:44:34 +00001569 break;
Mohit K. Bhakkad8be74992015-12-03 04:56:16 +00001570
1571 case Debugger::eStopDisassemblyTypeNoDebugInfo:
1572 if (have_debuginfo)
1573 break;
Jason Molenda62e06812016-02-16 04:14:33 +00001574 LLVM_FALLTHROUGH;
Mohit K. Bhakkad8be74992015-12-03 04:56:16 +00001575
Greg Clayton67cc0632012-08-22 17:17:09 +00001576 case Debugger::eStopDisassemblyTypeNoSource:
Greg Clayton53eb7ad2012-07-11 20:33:48 +00001577 if (have_source)
1578 break;
Jason Molenda62e06812016-02-16 04:14:33 +00001579 LLVM_FALLTHROUGH;
Mohit K. Bhakkad8be74992015-12-03 04:56:16 +00001580
Greg Clayton67cc0632012-08-22 17:17:09 +00001581 case Debugger::eStopDisassemblyTypeAlways:
Greg Clayton53eb7ad2012-07-11 20:33:48 +00001582 if (target)
Greg Claytone372b982011-11-21 21:44:34 +00001583 {
Greg Clayton53eb7ad2012-07-11 20:33:48 +00001584 const uint32_t disasm_lines = debugger.GetDisassemblyLineCount();
1585 if (disasm_lines > 0)
1586 {
1587 const ArchSpec &target_arch = target->GetArchitecture();
1588 AddressRange pc_range;
1589 pc_range.GetBaseAddress() = GetFrameCodeAddress();
1590 pc_range.SetByteSize(disasm_lines * target_arch.GetMaximumOpcodeByteSize());
Eugene Zelenkod70a6e72016-02-18 18:52:47 +00001591 const char *plugin_name = nullptr;
1592 const char *flavor = nullptr;
Greg Clayton53eb7ad2012-07-11 20:33:48 +00001593 Disassembler::Disassemble (target->GetDebugger(),
1594 target_arch,
Jim Ingham0f063ba2013-03-02 00:26:47 +00001595 plugin_name,
1596 flavor,
Greg Clayton53eb7ad2012-07-11 20:33:48 +00001597 exe_ctx,
1598 pc_range,
1599 disasm_lines,
1600 0,
1601 Disassembler::eOptionMarkPCAddress,
1602 strm);
1603 }
Greg Claytone372b982011-11-21 21:44:34 +00001604 }
Greg Clayton53eb7ad2012-07-11 20:33:48 +00001605 break;
Greg Claytone372b982011-11-21 21:44:34 +00001606 }
Greg Clayton7260f622011-04-18 08:33:37 +00001607 }
1608 }
1609 return true;
1610}