130fdc8d8SChris Lattner //===-- StackFrame.cpp ------------------------------------------*- C++ -*-===// 230fdc8d8SChris Lattner // 330fdc8d8SChris Lattner // The LLVM Compiler Infrastructure 430fdc8d8SChris Lattner // 530fdc8d8SChris Lattner // This file is distributed under the University of Illinois Open Source 630fdc8d8SChris Lattner // License. See LICENSE.TXT for details. 730fdc8d8SChris Lattner // 830fdc8d8SChris Lattner //===----------------------------------------------------------------------===// 930fdc8d8SChris Lattner 1093a64300SDaniel Malea #include "lldb/lldb-python.h" 1193a64300SDaniel Malea 1230fdc8d8SChris Lattner #include "lldb/Target/StackFrame.h" 1330fdc8d8SChris Lattner 1430fdc8d8SChris Lattner // C Includes 1530fdc8d8SChris Lattner // C++ Includes 1630fdc8d8SChris Lattner // Other libraries and framework includes 1730fdc8d8SChris Lattner // Project includes 1830fdc8d8SChris Lattner #include "lldb/Core/Module.h" 190603aa9dSGreg Clayton #include "lldb/Core/Debugger.h" 2030fdc8d8SChris Lattner #include "lldb/Core/Disassembler.h" 2130fdc8d8SChris Lattner #include "lldb/Core/Value.h" 22288bdf9cSGreg Clayton #include "lldb/Core/ValueObjectVariable.h" 2354979cddSGreg Clayton #include "lldb/Core/ValueObjectConstResult.h" 241f746071SGreg Clayton #include "lldb/Symbol/CompileUnit.h" 2530fdc8d8SChris Lattner #include "lldb/Symbol/Function.h" 261f746071SGreg Clayton #include "lldb/Symbol/Symbol.h" 271f746071SGreg Clayton #include "lldb/Symbol/SymbolContextScope.h" 28288bdf9cSGreg Clayton #include "lldb/Symbol/VariableList.h" 2930fdc8d8SChris Lattner #include "lldb/Target/ExecutionContext.h" 3030fdc8d8SChris Lattner #include "lldb/Target/Process.h" 3130fdc8d8SChris Lattner #include "lldb/Target/RegisterContext.h" 3230fdc8d8SChris Lattner #include "lldb/Target/Target.h" 3330fdc8d8SChris Lattner #include "lldb/Target/Thread.h" 3430fdc8d8SChris Lattner 3530fdc8d8SChris Lattner using namespace lldb; 3630fdc8d8SChris Lattner using namespace lldb_private; 3730fdc8d8SChris Lattner 3830fdc8d8SChris Lattner // The first bits in the flags are reserved for the SymbolContext::Scope bits 3930fdc8d8SChris Lattner // so we know if we have tried to look up information in our internal symbol 4030fdc8d8SChris Lattner // context (m_sc) already. 4159e8fc1cSGreg Clayton #define RESOLVED_FRAME_CODE_ADDR (uint32_t(eSymbolContextEverything + 1)) 426dadd508SGreg Clayton #define RESOLVED_FRAME_ID_SYMBOL_SCOPE (RESOLVED_FRAME_CODE_ADDR << 1) 4359e8fc1cSGreg Clayton #define GOT_FRAME_BASE (RESOLVED_FRAME_ID_SYMBOL_SCOPE << 1) 4459e8fc1cSGreg Clayton #define RESOLVED_VARIABLES (GOT_FRAME_BASE << 1) 457c0962dcSSean Callanan #define RESOLVED_GLOBAL_VARIABLES (RESOLVED_VARIABLES << 1) 4630fdc8d8SChris Lattner 47d9e416c0SGreg Clayton StackFrame::StackFrame (const ThreadSP &thread_sp, 48d9e416c0SGreg Clayton user_id_t frame_idx, 494d122c40SGreg Clayton user_id_t unwind_frame_index, 504d122c40SGreg Clayton addr_t cfa, 5199618476SJason Molenda bool cfa_is_valid, 524d122c40SGreg Clayton addr_t pc, 5399618476SJason Molenda uint32_t stop_id, 5499618476SJason Molenda bool stop_id_is_valid, 5599618476SJason Molenda bool is_history_frame, 568f7180b1SGreg Clayton const SymbolContext *sc_ptr) : 57d9e416c0SGreg Clayton m_thread_wp (thread_sp), 581b72fcb7SGreg Clayton m_frame_index (frame_idx), 595ccbd294SGreg Clayton m_concrete_frame_index (unwind_frame_index), 6030fdc8d8SChris Lattner m_reg_context_sp (), 616dadd508SGreg Clayton m_id (pc, cfa, NULL), 62e72dfb32SGreg Clayton m_frame_code_addr (pc), 6330fdc8d8SChris Lattner m_sc (), 6430fdc8d8SChris Lattner m_flags (), 6530fdc8d8SChris Lattner m_frame_base (), 6630fdc8d8SChris Lattner m_frame_base_error (), 6799618476SJason Molenda m_cfa_is_valid (cfa_is_valid), 6899618476SJason Molenda m_stop_id (stop_id), 6999618476SJason Molenda m_stop_id_is_valid (stop_id_is_valid), 7099618476SJason Molenda m_is_history_frame (is_history_frame), 7130fdc8d8SChris Lattner m_variable_list_sp (), 721a65ae11SGreg Clayton m_variable_list_value_objects (), 731a65ae11SGreg Clayton m_disassembly () 7430fdc8d8SChris Lattner { 7599618476SJason Molenda // If we don't have a CFA value, use the frame index for our StackID so that recursive 7699618476SJason Molenda // functions properly aren't confused with one another on a history stack. 7799618476SJason Molenda if (m_is_history_frame && m_cfa_is_valid == false) 7899618476SJason Molenda { 7999618476SJason Molenda m_id.SetCFA (m_frame_index); 8099618476SJason Molenda } 8199618476SJason Molenda 8230fdc8d8SChris Lattner if (sc_ptr != NULL) 831b72fcb7SGreg Clayton { 8430fdc8d8SChris Lattner m_sc = *sc_ptr; 851b72fcb7SGreg Clayton m_flags.Set(m_sc.GetResolvedMask ()); 861b72fcb7SGreg Clayton } 8730fdc8d8SChris Lattner } 8830fdc8d8SChris Lattner 89d9e416c0SGreg Clayton StackFrame::StackFrame (const ThreadSP &thread_sp, 90d9e416c0SGreg Clayton user_id_t frame_idx, 914d122c40SGreg Clayton user_id_t unwind_frame_index, 921b72fcb7SGreg Clayton const RegisterContextSP ®_context_sp, 934d122c40SGreg Clayton addr_t cfa, 944d122c40SGreg Clayton addr_t pc, 958f7180b1SGreg Clayton const SymbolContext *sc_ptr) : 96d9e416c0SGreg Clayton m_thread_wp (thread_sp), 971b72fcb7SGreg Clayton m_frame_index (frame_idx), 985ccbd294SGreg Clayton m_concrete_frame_index (unwind_frame_index), 9930fdc8d8SChris Lattner m_reg_context_sp (reg_context_sp), 1006dadd508SGreg Clayton m_id (pc, cfa, NULL), 101e72dfb32SGreg Clayton m_frame_code_addr (pc), 10230fdc8d8SChris Lattner m_sc (), 10330fdc8d8SChris Lattner m_flags (), 10430fdc8d8SChris Lattner m_frame_base (), 10530fdc8d8SChris Lattner m_frame_base_error (), 10699618476SJason Molenda m_cfa_is_valid (true), 10799618476SJason Molenda m_stop_id (0), 10899618476SJason Molenda m_stop_id_is_valid (false), 10999618476SJason Molenda m_is_history_frame (false), 11030fdc8d8SChris Lattner m_variable_list_sp (), 1111a65ae11SGreg Clayton m_variable_list_value_objects (), 1121a65ae11SGreg Clayton m_disassembly () 11330fdc8d8SChris Lattner { 11430fdc8d8SChris Lattner if (sc_ptr != NULL) 1151b72fcb7SGreg Clayton { 11630fdc8d8SChris Lattner m_sc = *sc_ptr; 1171b72fcb7SGreg Clayton m_flags.Set(m_sc.GetResolvedMask ()); 1181b72fcb7SGreg Clayton } 1191b72fcb7SGreg Clayton 1201b72fcb7SGreg Clayton if (reg_context_sp && !m_sc.target_sp) 1211b72fcb7SGreg Clayton { 122d9e416c0SGreg Clayton m_sc.target_sp = reg_context_sp->CalculateTarget(); 123d9e416c0SGreg Clayton if (m_sc.target_sp) 1241b72fcb7SGreg Clayton m_flags.Set (eSymbolContextTarget); 1251b72fcb7SGreg Clayton } 1261b72fcb7SGreg Clayton } 1271b72fcb7SGreg Clayton 128d9e416c0SGreg Clayton StackFrame::StackFrame (const ThreadSP &thread_sp, 129d9e416c0SGreg Clayton user_id_t frame_idx, 1304d122c40SGreg Clayton user_id_t unwind_frame_index, 1311b72fcb7SGreg Clayton const RegisterContextSP ®_context_sp, 1324d122c40SGreg Clayton addr_t cfa, 1331b72fcb7SGreg Clayton const Address& pc_addr, 1348f7180b1SGreg Clayton const SymbolContext *sc_ptr) : 135d9e416c0SGreg Clayton m_thread_wp (thread_sp), 1361b72fcb7SGreg Clayton m_frame_index (frame_idx), 1375ccbd294SGreg Clayton m_concrete_frame_index (unwind_frame_index), 1381b72fcb7SGreg Clayton m_reg_context_sp (reg_context_sp), 1391ac04c30SGreg Clayton m_id (pc_addr.GetLoadAddress (thread_sp->CalculateTarget().get()), cfa, NULL), 14012fc3e0fSGreg Clayton m_frame_code_addr (pc_addr), 1411b72fcb7SGreg Clayton m_sc (), 1421b72fcb7SGreg Clayton m_flags (), 1431b72fcb7SGreg Clayton m_frame_base (), 1441b72fcb7SGreg Clayton m_frame_base_error (), 14599618476SJason Molenda m_cfa_is_valid (true), 14699618476SJason Molenda m_stop_id (0), 14799618476SJason Molenda m_stop_id_is_valid (false), 14899618476SJason Molenda m_is_history_frame (false), 1491b72fcb7SGreg Clayton m_variable_list_sp (), 1501a65ae11SGreg Clayton m_variable_list_value_objects (), 1511a65ae11SGreg Clayton m_disassembly () 1521b72fcb7SGreg Clayton { 1531b72fcb7SGreg Clayton if (sc_ptr != NULL) 1541b72fcb7SGreg Clayton { 1551b72fcb7SGreg Clayton m_sc = *sc_ptr; 1561b72fcb7SGreg Clayton m_flags.Set(m_sc.GetResolvedMask ()); 1571b72fcb7SGreg Clayton } 1581b72fcb7SGreg Clayton 1591b72fcb7SGreg Clayton if (m_sc.target_sp.get() == NULL && reg_context_sp) 1601b72fcb7SGreg Clayton { 161d9e416c0SGreg Clayton m_sc.target_sp = reg_context_sp->CalculateTarget(); 162d9e416c0SGreg Clayton if (m_sc.target_sp) 1631b72fcb7SGreg Clayton m_flags.Set (eSymbolContextTarget); 1641b72fcb7SGreg Clayton } 1651b72fcb7SGreg Clayton 166e72dfb32SGreg Clayton ModuleSP pc_module_sp (pc_addr.GetModule()); 167e72dfb32SGreg Clayton if (!m_sc.module_sp || m_sc.module_sp != pc_module_sp) 1681b72fcb7SGreg Clayton { 169e72dfb32SGreg Clayton if (pc_module_sp) 1701b72fcb7SGreg Clayton { 171e72dfb32SGreg Clayton m_sc.module_sp = pc_module_sp; 1721b72fcb7SGreg Clayton m_flags.Set (eSymbolContextModule); 1731b72fcb7SGreg Clayton } 174ffc1d667SGreg Clayton else 175ffc1d667SGreg Clayton { 176ffc1d667SGreg Clayton m_sc.module_sp.reset(); 177ffc1d667SGreg Clayton } 1781b72fcb7SGreg Clayton } 17930fdc8d8SChris Lattner } 18030fdc8d8SChris Lattner 18130fdc8d8SChris Lattner 18230fdc8d8SChris Lattner //---------------------------------------------------------------------- 18330fdc8d8SChris Lattner // Destructor 18430fdc8d8SChris Lattner //---------------------------------------------------------------------- 18530fdc8d8SChris Lattner StackFrame::~StackFrame() 18630fdc8d8SChris Lattner { 18730fdc8d8SChris Lattner } 18830fdc8d8SChris Lattner 18930fdc8d8SChris Lattner StackID& 19030fdc8d8SChris Lattner StackFrame::GetStackID() 19130fdc8d8SChris Lattner { 1926dadd508SGreg Clayton // Make sure we have resolved the StackID object's symbol context scope if 1936dadd508SGreg Clayton // we already haven't looked it up. 19459e8fc1cSGreg Clayton 19559e8fc1cSGreg Clayton if (m_flags.IsClear (RESOLVED_FRAME_ID_SYMBOL_SCOPE)) 19659e8fc1cSGreg Clayton { 1972cad65a5SGreg Clayton if (m_id.GetSymbolContextScope ()) 19859e8fc1cSGreg Clayton { 19995897c6aSGreg Clayton // We already have a symbol context scope, we just don't have our 20095897c6aSGreg Clayton // flag bit set. 20159e8fc1cSGreg Clayton m_flags.Set (RESOLVED_FRAME_ID_SYMBOL_SCOPE); 20259e8fc1cSGreg Clayton } 20359e8fc1cSGreg Clayton else 20459e8fc1cSGreg Clayton { 20595897c6aSGreg Clayton // Calculate the frame block and use this for the stack ID symbol 20695897c6aSGreg Clayton // context scope if we have one. 20795897c6aSGreg Clayton SymbolContextScope *scope = GetFrameBlock (); 20895897c6aSGreg Clayton if (scope == NULL) 20959e8fc1cSGreg Clayton { 21095897c6aSGreg Clayton // We don't have a block, so use the symbol 21195897c6aSGreg Clayton if (m_flags.IsClear (eSymbolContextSymbol)) 21259e8fc1cSGreg Clayton GetSymbolContext (eSymbolContextSymbol); 21395897c6aSGreg Clayton 21495897c6aSGreg Clayton // It is ok if m_sc.symbol is NULL here 21595897c6aSGreg Clayton scope = m_sc.symbol; 21659e8fc1cSGreg Clayton } 21795897c6aSGreg Clayton // Set the symbol context scope (the accessor will set the 21895897c6aSGreg Clayton // RESOLVED_FRAME_ID_SYMBOL_SCOPE bit in m_flags). 21995897c6aSGreg Clayton SetSymbolContextScope (scope); 22059e8fc1cSGreg Clayton } 22159e8fc1cSGreg Clayton } 22230fdc8d8SChris Lattner return m_id; 22330fdc8d8SChris Lattner } 22430fdc8d8SChris Lattner 225513c6bb8SJim Ingham uint32_t 226513c6bb8SJim Ingham StackFrame::GetFrameIndex () const 227513c6bb8SJim Ingham { 228513c6bb8SJim Ingham ThreadSP thread_sp = GetThread(); 229513c6bb8SJim Ingham if (thread_sp) 230b57e4a1bSJason Molenda return thread_sp->GetStackFrameList()->GetVisibleStackFrameIndex(m_frame_index); 231513c6bb8SJim Ingham else 232513c6bb8SJim Ingham return m_frame_index; 233513c6bb8SJim Ingham } 234513c6bb8SJim Ingham 23559e8fc1cSGreg Clayton void 23659e8fc1cSGreg Clayton StackFrame::SetSymbolContextScope (SymbolContextScope *symbol_scope) 23759e8fc1cSGreg Clayton { 23859e8fc1cSGreg Clayton m_flags.Set (RESOLVED_FRAME_ID_SYMBOL_SCOPE); 23959e8fc1cSGreg Clayton m_id.SetSymbolContextScope (symbol_scope); 24059e8fc1cSGreg Clayton } 24159e8fc1cSGreg Clayton 24234132754SGreg Clayton const Address& 2439da7bd07SGreg Clayton StackFrame::GetFrameCodeAddress() 24430fdc8d8SChris Lattner { 24559e8fc1cSGreg Clayton if (m_flags.IsClear(RESOLVED_FRAME_CODE_ADDR) && !m_frame_code_addr.IsSectionOffset()) 24630fdc8d8SChris Lattner { 24759e8fc1cSGreg Clayton m_flags.Set (RESOLVED_FRAME_CODE_ADDR); 24830fdc8d8SChris Lattner 24930fdc8d8SChris Lattner // Resolve the PC into a temporary address because if ResolveLoadAddress 25030fdc8d8SChris Lattner // fails to resolve the address, it will clear the address object... 251d9e416c0SGreg Clayton ThreadSP thread_sp (GetThread()); 252d9e416c0SGreg Clayton if (thread_sp) 253d9e416c0SGreg Clayton { 254d9e416c0SGreg Clayton TargetSP target_sp (thread_sp->CalculateTarget()); 255d9e416c0SGreg Clayton if (target_sp) 256d9e416c0SGreg Clayton { 257d9e416c0SGreg Clayton if (m_frame_code_addr.SetOpcodeLoadAddress (m_frame_code_addr.GetOffset(), target_sp.get())) 25830fdc8d8SChris Lattner { 259e72dfb32SGreg Clayton ModuleSP module_sp (m_frame_code_addr.GetModule()); 260e72dfb32SGreg Clayton if (module_sp) 26130fdc8d8SChris Lattner { 262e72dfb32SGreg Clayton m_sc.module_sp = module_sp; 26330fdc8d8SChris Lattner m_flags.Set(eSymbolContextModule); 26430fdc8d8SChris Lattner } 26530fdc8d8SChris Lattner } 26630fdc8d8SChris Lattner } 26730fdc8d8SChris Lattner } 268d9e416c0SGreg Clayton } 26912fc3e0fSGreg Clayton return m_frame_code_addr; 27030fdc8d8SChris Lattner } 27130fdc8d8SChris Lattner 27299618476SJason Molenda bool 27330fdc8d8SChris Lattner StackFrame::ChangePC (addr_t pc) 27430fdc8d8SChris Lattner { 27599618476SJason Molenda // We can't change the pc value of a history stack frame - it is immutable. 27699618476SJason Molenda if (m_is_history_frame) 27799618476SJason Molenda return false; 278e72dfb32SGreg Clayton m_frame_code_addr.SetRawAddress(pc); 27972310355SGreg Clayton m_sc.Clear(false); 28073b472d4SGreg Clayton m_flags.Reset(0); 281d9e416c0SGreg Clayton ThreadSP thread_sp (GetThread()); 282d9e416c0SGreg Clayton if (thread_sp) 283d9e416c0SGreg Clayton thread_sp->ClearStackFrames (); 28499618476SJason Molenda return true; 28530fdc8d8SChris Lattner } 28630fdc8d8SChris Lattner 28730fdc8d8SChris Lattner const char * 28830fdc8d8SChris Lattner StackFrame::Disassemble () 28930fdc8d8SChris Lattner { 29030fdc8d8SChris Lattner if (m_disassembly.GetSize() == 0) 29130fdc8d8SChris Lattner { 292d9e416c0SGreg Clayton ExecutionContext exe_ctx (shared_from_this()); 293d9e416c0SGreg Clayton Target *target = exe_ctx.GetTargetPtr(); 294d9e416c0SGreg Clayton if (target) 295d9e416c0SGreg Clayton { 2960f063ba6SJim Ingham const char *plugin_name = NULL; 2970f063ba6SJim Ingham const char *flavor = NULL; 298d9e416c0SGreg Clayton Disassembler::Disassemble (target->GetDebugger(), 299d9e416c0SGreg Clayton target->GetArchitecture(), 3000f063ba6SJim Ingham plugin_name, 3010f063ba6SJim Ingham flavor, 30230fdc8d8SChris Lattner exe_ctx, 30330fdc8d8SChris Lattner 0, 30437023b06SJim Ingham 0, 3051da6f9d7SGreg Clayton 0, 30630fdc8d8SChris Lattner m_disassembly); 307d9e416c0SGreg Clayton } 30830fdc8d8SChris Lattner if (m_disassembly.GetSize() == 0) 30930fdc8d8SChris Lattner return NULL; 31030fdc8d8SChris Lattner } 31130fdc8d8SChris Lattner return m_disassembly.GetData(); 31230fdc8d8SChris Lattner } 31330fdc8d8SChris Lattner 31495897c6aSGreg Clayton Block * 31595897c6aSGreg Clayton StackFrame::GetFrameBlock () 31695897c6aSGreg Clayton { 31795897c6aSGreg Clayton if (m_sc.block == NULL && m_flags.IsClear (eSymbolContextBlock)) 31895897c6aSGreg Clayton GetSymbolContext (eSymbolContextBlock); 31995897c6aSGreg Clayton 32095897c6aSGreg Clayton if (m_sc.block) 32195897c6aSGreg Clayton { 32295897c6aSGreg Clayton Block *inline_block = m_sc.block->GetContainingInlinedBlock(); 32395897c6aSGreg Clayton if (inline_block) 32495897c6aSGreg Clayton { 32595897c6aSGreg Clayton // Use the block with the inlined function info 32695897c6aSGreg Clayton // as the frame block we want this frame to have only the variables 32795897c6aSGreg Clayton // for the inlined function and its non-inlined block child blocks. 32895897c6aSGreg Clayton return inline_block; 32995897c6aSGreg Clayton } 33095897c6aSGreg Clayton else 33195897c6aSGreg Clayton { 33295897c6aSGreg Clayton // This block is not contained withing any inlined function blocks 33395897c6aSGreg Clayton // with so we want to use the top most function block. 33495897c6aSGreg Clayton return &m_sc.function->GetBlock (false); 33595897c6aSGreg Clayton } 33695897c6aSGreg Clayton } 33795897c6aSGreg Clayton return NULL; 33895897c6aSGreg Clayton } 33995897c6aSGreg Clayton 34030fdc8d8SChris Lattner //---------------------------------------------------------------------- 34130fdc8d8SChris Lattner // Get the symbol context if we already haven't done so by resolving the 34230fdc8d8SChris Lattner // PC address as much as possible. This way when we pass around a 34330fdc8d8SChris Lattner // StackFrame object, everyone will have as much information as 34430fdc8d8SChris Lattner // possible and no one will ever have to look things up manually. 34530fdc8d8SChris Lattner //---------------------------------------------------------------------- 34630fdc8d8SChris Lattner const SymbolContext& 34730fdc8d8SChris Lattner StackFrame::GetSymbolContext (uint32_t resolve_scope) 34830fdc8d8SChris Lattner { 34930fdc8d8SChris Lattner // Copy our internal symbol context into "sc". 35073b472d4SGreg Clayton if ((m_flags.Get() & resolve_scope) != resolve_scope) 35130fdc8d8SChris Lattner { 35275a0333bSGreg Clayton uint32_t resolved = 0; 35375a0333bSGreg Clayton 35475a0333bSGreg Clayton // If the target was requested add that: 35575a0333bSGreg Clayton if (!m_sc.target_sp) 35675a0333bSGreg Clayton { 35775a0333bSGreg Clayton m_sc.target_sp = CalculateTarget(); 35875a0333bSGreg Clayton if (m_sc.target_sp) 35975a0333bSGreg Clayton resolved |= eSymbolContextTarget; 36075a0333bSGreg Clayton } 36175a0333bSGreg Clayton 36275a0333bSGreg Clayton 363*aaa0ba31SBruce Mitchener // Resolve our PC to section offset if we haven't already done so 36430fdc8d8SChris Lattner // and if we don't have a module. The resolved address section will 36530fdc8d8SChris Lattner // contain the module to which it belongs 36659e8fc1cSGreg Clayton if (!m_sc.module_sp && m_flags.IsClear(RESOLVED_FRAME_CODE_ADDR)) 3679da7bd07SGreg Clayton GetFrameCodeAddress(); 36830fdc8d8SChris Lattner 36930fdc8d8SChris Lattner // If this is not frame zero, then we need to subtract 1 from the PC 37030fdc8d8SChris Lattner // value when doing address lookups since the PC will be on the 37130fdc8d8SChris Lattner // instruction following the function call instruction... 37230fdc8d8SChris Lattner 3739da7bd07SGreg Clayton Address lookup_addr(GetFrameCodeAddress()); 3741b72fcb7SGreg Clayton if (m_frame_index > 0 && lookup_addr.IsValid()) 37530fdc8d8SChris Lattner { 37630fdc8d8SChris Lattner addr_t offset = lookup_addr.GetOffset(); 37730fdc8d8SChris Lattner if (offset > 0) 37830fdc8d8SChris Lattner lookup_addr.SetOffset(offset - 1); 37930fdc8d8SChris Lattner } 38030fdc8d8SChris Lattner 3819da7bd07SGreg Clayton 38230fdc8d8SChris Lattner if (m_sc.module_sp) 38330fdc8d8SChris Lattner { 38430fdc8d8SChris Lattner // We have something in our stack frame symbol context, lets check 38530fdc8d8SChris Lattner // if we haven't already tried to lookup one of those things. If we 38630fdc8d8SChris Lattner // haven't then we will do the query. 3871b72fcb7SGreg Clayton 3881b72fcb7SGreg Clayton uint32_t actual_resolve_scope = 0; 3891b72fcb7SGreg Clayton 3901b72fcb7SGreg Clayton if (resolve_scope & eSymbolContextCompUnit) 3911b72fcb7SGreg Clayton { 3921b72fcb7SGreg Clayton if (m_flags.IsClear (eSymbolContextCompUnit)) 3931b72fcb7SGreg Clayton { 3941b72fcb7SGreg Clayton if (m_sc.comp_unit) 3959da7bd07SGreg Clayton resolved |= eSymbolContextCompUnit; 3961b72fcb7SGreg Clayton else 3971b72fcb7SGreg Clayton actual_resolve_scope |= eSymbolContextCompUnit; 3981b72fcb7SGreg Clayton } 3991b72fcb7SGreg Clayton } 4001b72fcb7SGreg Clayton 4011b72fcb7SGreg Clayton if (resolve_scope & eSymbolContextFunction) 4021b72fcb7SGreg Clayton { 4031b72fcb7SGreg Clayton if (m_flags.IsClear (eSymbolContextFunction)) 4041b72fcb7SGreg Clayton { 4051b72fcb7SGreg Clayton if (m_sc.function) 4069da7bd07SGreg Clayton resolved |= eSymbolContextFunction; 4071b72fcb7SGreg Clayton else 4081b72fcb7SGreg Clayton actual_resolve_scope |= eSymbolContextFunction; 4091b72fcb7SGreg Clayton } 4101b72fcb7SGreg Clayton } 4111b72fcb7SGreg Clayton 4121b72fcb7SGreg Clayton if (resolve_scope & eSymbolContextBlock) 4131b72fcb7SGreg Clayton { 4141b72fcb7SGreg Clayton if (m_flags.IsClear (eSymbolContextBlock)) 4151b72fcb7SGreg Clayton { 4161b72fcb7SGreg Clayton if (m_sc.block) 4179da7bd07SGreg Clayton resolved |= eSymbolContextBlock; 4181b72fcb7SGreg Clayton else 4191b72fcb7SGreg Clayton actual_resolve_scope |= eSymbolContextBlock; 4201b72fcb7SGreg Clayton } 4211b72fcb7SGreg Clayton } 4221b72fcb7SGreg Clayton 4231b72fcb7SGreg Clayton if (resolve_scope & eSymbolContextSymbol) 4241b72fcb7SGreg Clayton { 4251b72fcb7SGreg Clayton if (m_flags.IsClear (eSymbolContextSymbol)) 4261b72fcb7SGreg Clayton { 4271b72fcb7SGreg Clayton if (m_sc.symbol) 4289da7bd07SGreg Clayton resolved |= eSymbolContextSymbol; 4291b72fcb7SGreg Clayton else 4301b72fcb7SGreg Clayton actual_resolve_scope |= eSymbolContextSymbol; 4311b72fcb7SGreg Clayton } 4321b72fcb7SGreg Clayton } 4331b72fcb7SGreg Clayton 4341b72fcb7SGreg Clayton if (resolve_scope & eSymbolContextLineEntry) 4351b72fcb7SGreg Clayton { 4361b72fcb7SGreg Clayton if (m_flags.IsClear (eSymbolContextLineEntry)) 4371b72fcb7SGreg Clayton { 4381b72fcb7SGreg Clayton if (m_sc.line_entry.IsValid()) 4399da7bd07SGreg Clayton resolved |= eSymbolContextLineEntry; 4401b72fcb7SGreg Clayton else 4411b72fcb7SGreg Clayton actual_resolve_scope |= eSymbolContextLineEntry; 4421b72fcb7SGreg Clayton } 4431b72fcb7SGreg Clayton } 4441b72fcb7SGreg Clayton 4451b72fcb7SGreg Clayton if (actual_resolve_scope) 44630fdc8d8SChris Lattner { 44730fdc8d8SChris Lattner // We might be resolving less information than what is already 44830fdc8d8SChris Lattner // in our current symbol context so resolve into a temporary 44930fdc8d8SChris Lattner // symbol context "sc" so we don't clear out data we have 45030fdc8d8SChris Lattner // already found in "m_sc" 45130fdc8d8SChris Lattner SymbolContext sc; 45230fdc8d8SChris Lattner // Set flags that indicate what we have tried to resolve 4539da7bd07SGreg Clayton resolved |= m_sc.module_sp->ResolveSymbolContextForAddress (lookup_addr, actual_resolve_scope, sc); 4541b72fcb7SGreg Clayton // Only replace what we didn't already have as we may have 4551b72fcb7SGreg Clayton // information for an inlined function scope that won't match 4561b72fcb7SGreg Clayton // what a standard lookup by address would match 4579da7bd07SGreg Clayton if ((resolved & eSymbolContextCompUnit) && m_sc.comp_unit == NULL) 4589da7bd07SGreg Clayton m_sc.comp_unit = sc.comp_unit; 4599da7bd07SGreg Clayton if ((resolved & eSymbolContextFunction) && m_sc.function == NULL) 4609da7bd07SGreg Clayton m_sc.function = sc.function; 4619da7bd07SGreg Clayton if ((resolved & eSymbolContextBlock) && m_sc.block == NULL) 4629da7bd07SGreg Clayton m_sc.block = sc.block; 4639da7bd07SGreg Clayton if ((resolved & eSymbolContextSymbol) && m_sc.symbol == NULL) 4649da7bd07SGreg Clayton m_sc.symbol = sc.symbol; 4659da7bd07SGreg Clayton if ((resolved & eSymbolContextLineEntry) && !m_sc.line_entry.IsValid()) 46675a0333bSGreg Clayton { 4679da7bd07SGreg Clayton m_sc.line_entry = sc.line_entry; 46875a0333bSGreg Clayton if (m_sc.target_sp) 46975a0333bSGreg Clayton { 47075a0333bSGreg Clayton // Be sure to apply and file remappings to our file and line 47175a0333bSGreg Clayton // entries when handing out a line entry 47275a0333bSGreg Clayton FileSpec new_file_spec; 47375a0333bSGreg Clayton if (m_sc.target_sp->GetSourcePathMap().FindFile (m_sc.line_entry.file, new_file_spec)) 47475a0333bSGreg Clayton m_sc.line_entry.file = new_file_spec; 47575a0333bSGreg Clayton } 47675a0333bSGreg Clayton } 47730fdc8d8SChris Lattner } 47830fdc8d8SChris Lattner } 47930fdc8d8SChris Lattner else 48030fdc8d8SChris Lattner { 48130fdc8d8SChris Lattner // If we don't have a module, then we can't have the compile unit, 48230fdc8d8SChris Lattner // function, block, line entry or symbol, so we can safely call 48330fdc8d8SChris Lattner // ResolveSymbolContextForAddress with our symbol context member m_sc. 4849da7bd07SGreg Clayton if (m_sc.target_sp) 485f4be227dSSean Callanan { 48675a0333bSGreg Clayton resolved |= m_sc.target_sp->GetImages().ResolveSymbolContextForAddress (lookup_addr, resolve_scope, m_sc); 487f4be227dSSean Callanan } 4889da7bd07SGreg Clayton } 48930fdc8d8SChris Lattner 49030fdc8d8SChris Lattner // Update our internal flags so we remember what we have tried to locate so 49130fdc8d8SChris Lattner // we don't have to keep trying when more calls to this function are made. 4929da7bd07SGreg Clayton // We might have dug up more information that was requested (for example 4939da7bd07SGreg Clayton // if we were asked to only get the block, we will have gotten the 4949da7bd07SGreg Clayton // compile unit, and function) so set any additional bits that we resolved 4959da7bd07SGreg Clayton m_flags.Set (resolve_scope | resolved); 49630fdc8d8SChris Lattner } 49730fdc8d8SChris Lattner 49830fdc8d8SChris Lattner // Return the symbol context with everything that was possible to resolve 49930fdc8d8SChris Lattner // resolved. 50030fdc8d8SChris Lattner return m_sc; 50130fdc8d8SChris Lattner } 50230fdc8d8SChris Lattner 50330fdc8d8SChris Lattner 50430fdc8d8SChris Lattner VariableList * 505288bdf9cSGreg Clayton StackFrame::GetVariableList (bool get_file_globals) 50630fdc8d8SChris Lattner { 50730fdc8d8SChris Lattner if (m_flags.IsClear(RESOLVED_VARIABLES)) 50830fdc8d8SChris Lattner { 50930fdc8d8SChris Lattner m_flags.Set(RESOLVED_VARIABLES); 51030fdc8d8SChris Lattner 51195897c6aSGreg Clayton Block *frame_block = GetFrameBlock(); 512288bdf9cSGreg Clayton 51395897c6aSGreg Clayton if (frame_block) 51430fdc8d8SChris Lattner { 51595897c6aSGreg Clayton const bool get_child_variables = true; 51695897c6aSGreg Clayton const bool can_create = true; 517c662ec8bSGreg Clayton const bool stop_if_child_block_is_inlined_function = true; 518c662ec8bSGreg Clayton m_variable_list_sp.reset(new VariableList()); 519c662ec8bSGreg Clayton frame_block->AppendBlockVariables(can_create, get_child_variables, stop_if_child_block_is_inlined_function, m_variable_list_sp.get()); 52030fdc8d8SChris Lattner } 5217c0962dcSSean Callanan } 522288bdf9cSGreg Clayton 5237c0962dcSSean Callanan if (m_flags.IsClear(RESOLVED_GLOBAL_VARIABLES) && 5247c0962dcSSean Callanan get_file_globals) 52595897c6aSGreg Clayton { 5267c0962dcSSean Callanan m_flags.Set(RESOLVED_GLOBAL_VARIABLES); 5277c0962dcSSean Callanan 52895897c6aSGreg Clayton if (m_flags.IsClear (eSymbolContextCompUnit)) 52995897c6aSGreg Clayton GetSymbolContext (eSymbolContextCompUnit); 53095897c6aSGreg Clayton 53195897c6aSGreg Clayton if (m_sc.comp_unit) 532288bdf9cSGreg Clayton { 533288bdf9cSGreg Clayton VariableListSP global_variable_list_sp (m_sc.comp_unit->GetVariableList(true)); 534288bdf9cSGreg Clayton if (m_variable_list_sp) 535288bdf9cSGreg Clayton m_variable_list_sp->AddVariables (global_variable_list_sp.get()); 536288bdf9cSGreg Clayton else 537288bdf9cSGreg Clayton m_variable_list_sp = global_variable_list_sp; 538288bdf9cSGreg Clayton } 53930fdc8d8SChris Lattner } 5407c0962dcSSean Callanan 54130fdc8d8SChris Lattner return m_variable_list_sp.get(); 54230fdc8d8SChris Lattner } 54330fdc8d8SChris Lattner 544d41f032aSGreg Clayton VariableListSP 545d41f032aSGreg Clayton StackFrame::GetInScopeVariableList (bool get_file_globals) 546d41f032aSGreg Clayton { 54799618476SJason Molenda // We can't fetch variable information for a history stack frame. 54899618476SJason Molenda if (m_is_history_frame) 54999618476SJason Molenda return VariableListSP(); 55099618476SJason Molenda 551d41f032aSGreg Clayton VariableListSP var_list_sp(new VariableList); 552d41f032aSGreg Clayton GetSymbolContext (eSymbolContextCompUnit | eSymbolContextBlock); 553d41f032aSGreg Clayton 554d41f032aSGreg Clayton if (m_sc.block) 555d41f032aSGreg Clayton { 556d41f032aSGreg Clayton const bool can_create = true; 557d41f032aSGreg Clayton const bool get_parent_variables = true; 558d41f032aSGreg Clayton const bool stop_if_block_is_inlined_function = true; 559d41f032aSGreg Clayton m_sc.block->AppendVariables (can_create, 560d41f032aSGreg Clayton get_parent_variables, 561d41f032aSGreg Clayton stop_if_block_is_inlined_function, 562d41f032aSGreg Clayton var_list_sp.get()); 563d41f032aSGreg Clayton } 564d41f032aSGreg Clayton 565d41f032aSGreg Clayton if (m_sc.comp_unit) 566d41f032aSGreg Clayton { 567d41f032aSGreg Clayton VariableListSP global_variable_list_sp (m_sc.comp_unit->GetVariableList(true)); 568d41f032aSGreg Clayton if (global_variable_list_sp) 569d41f032aSGreg Clayton var_list_sp->AddVariables (global_variable_list_sp.get()); 570d41f032aSGreg Clayton } 571d41f032aSGreg Clayton 572d41f032aSGreg Clayton return var_list_sp; 573d41f032aSGreg Clayton } 574d41f032aSGreg Clayton 575d41f032aSGreg Clayton 5768b2fe6dcSGreg Clayton ValueObjectSP 5772837b766SJim Ingham StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr, 5784d122c40SGreg Clayton DynamicValueType use_dynamic, 5792837b766SJim Ingham uint32_t options, 5804d122c40SGreg Clayton VariableSP &var_sp, 5812837b766SJim Ingham Error &error) 5828b2fe6dcSGreg Clayton { 58399618476SJason Molenda // We can't fetch variable information for a history stack frame. 58499618476SJason Molenda if (m_is_history_frame) 58599618476SJason Molenda return ValueObjectSP(); 58654979cddSGreg Clayton 58754979cddSGreg Clayton if (var_expr_cstr && var_expr_cstr[0]) 58854979cddSGreg Clayton { 5896d5e68eaSGreg Clayton const bool check_ptr_vs_member = (options & eExpressionPathOptionCheckPtrVsMember) != 0; 5906d5e68eaSGreg Clayton const bool no_fragile_ivar = (options & eExpressionPathOptionsNoFragileObjcIvar) != 0; 59127b625e1SEnrico Granata const bool no_synth_child = (options & eExpressionPathOptionsNoSyntheticChildren) != 0; 59258ad3344SEnrico Granata //const bool no_synth_array = (options & eExpressionPathOptionsNoSyntheticArrayRange) != 0; 59354979cddSGreg Clayton error.Clear(); 5948b2fe6dcSGreg Clayton bool deref = false; 5958b2fe6dcSGreg Clayton bool address_of = false; 5968b2fe6dcSGreg Clayton ValueObjectSP valobj_sp; 5978b2fe6dcSGreg Clayton const bool get_file_globals = true; 598d41f032aSGreg Clayton // When looking up a variable for an expression, we need only consider the 599d41f032aSGreg Clayton // variables that are in scope. 600d41f032aSGreg Clayton VariableListSP var_list_sp (GetInScopeVariableList (get_file_globals)); 601d41f032aSGreg Clayton VariableList *variable_list = var_list_sp.get(); 6028b2fe6dcSGreg Clayton 6038b2fe6dcSGreg Clayton if (variable_list) 6048b2fe6dcSGreg Clayton { 6058b2fe6dcSGreg Clayton // If first character is a '*', then show pointer contents 60654979cddSGreg Clayton const char *var_expr = var_expr_cstr; 6078b2fe6dcSGreg Clayton if (var_expr[0] == '*') 6088b2fe6dcSGreg Clayton { 6098b2fe6dcSGreg Clayton deref = true; 6108b2fe6dcSGreg Clayton var_expr++; // Skip the '*' 6118b2fe6dcSGreg Clayton } 6128b2fe6dcSGreg Clayton else if (var_expr[0] == '&') 6138b2fe6dcSGreg Clayton { 6148b2fe6dcSGreg Clayton address_of = true; 6158b2fe6dcSGreg Clayton var_expr++; // Skip the '&' 6168b2fe6dcSGreg Clayton } 6178b2fe6dcSGreg Clayton 6188b2fe6dcSGreg Clayton std::string var_path (var_expr); 61954979cddSGreg Clayton size_t separator_idx = var_path.find_first_of(".-[=+~|&^%#@!/?,<>{}"); 62054979cddSGreg Clayton StreamString var_expr_path_strm; 6218b2fe6dcSGreg Clayton 6228b2fe6dcSGreg Clayton ConstString name_const_string; 6238b2fe6dcSGreg Clayton if (separator_idx == std::string::npos) 6248b2fe6dcSGreg Clayton name_const_string.SetCString (var_path.c_str()); 6258b2fe6dcSGreg Clayton else 6268b2fe6dcSGreg Clayton name_const_string.SetCStringWithLength (var_path.c_str(), separator_idx); 6278b2fe6dcSGreg Clayton 6282837b766SJim Ingham var_sp = variable_list->FindVariable(name_const_string); 629685c88c5SGreg Clayton 630685c88c5SGreg Clayton bool synthetically_added_instance_object = false; 631685c88c5SGreg Clayton 632685c88c5SGreg Clayton if (var_sp) 633685c88c5SGreg Clayton { 634685c88c5SGreg Clayton var_path.erase (0, name_const_string.GetLength ()); 635685c88c5SGreg Clayton } 636685c88c5SGreg Clayton else if (options & eExpressionPathOptionsAllowDirectIVarAccess) 637685c88c5SGreg Clayton { 638685c88c5SGreg Clayton // Check for direct ivars access which helps us with implicit 639685c88c5SGreg Clayton // access to ivars with the "this->" or "self->" 640685c88c5SGreg Clayton GetSymbolContext(eSymbolContextFunction|eSymbolContextBlock); 641685c88c5SGreg Clayton lldb::LanguageType method_language = eLanguageTypeUnknown; 642685c88c5SGreg Clayton bool is_instance_method = false; 643685c88c5SGreg Clayton ConstString method_object_name; 644685c88c5SGreg Clayton if (m_sc.GetFunctionMethodInfo (method_language, is_instance_method, method_object_name)) 645685c88c5SGreg Clayton { 646685c88c5SGreg Clayton if (is_instance_method && method_object_name) 647685c88c5SGreg Clayton { 648685c88c5SGreg Clayton var_sp = variable_list->FindVariable(method_object_name); 649685c88c5SGreg Clayton if (var_sp) 650685c88c5SGreg Clayton { 651685c88c5SGreg Clayton separator_idx = 0; 652685c88c5SGreg Clayton var_path.insert(0, "->"); 653685c88c5SGreg Clayton synthetically_added_instance_object = true; 654685c88c5SGreg Clayton } 655685c88c5SGreg Clayton } 656685c88c5SGreg Clayton } 657685c88c5SGreg Clayton } 658685c88c5SGreg Clayton 6598b2fe6dcSGreg Clayton if (var_sp) 6608b2fe6dcSGreg Clayton { 6612837b766SJim Ingham valobj_sp = GetValueObjectForFrameVariable (var_sp, use_dynamic); 66278a685aaSJim Ingham if (!valobj_sp) 66378a685aaSJim Ingham return valobj_sp; 6648b2fe6dcSGreg Clayton 6658b2fe6dcSGreg Clayton // We are dumping at least one child 6668b2fe6dcSGreg Clayton while (separator_idx != std::string::npos) 6678b2fe6dcSGreg Clayton { 6688b2fe6dcSGreg Clayton // Calculate the next separator index ahead of time 6698b2fe6dcSGreg Clayton ValueObjectSP child_valobj_sp; 6708b2fe6dcSGreg Clayton const char separator_type = var_path[0]; 6718b2fe6dcSGreg Clayton switch (separator_type) 6728b2fe6dcSGreg Clayton { 6738b2fe6dcSGreg Clayton 6748b2fe6dcSGreg Clayton case '-': 6758b2fe6dcSGreg Clayton if (var_path.size() >= 2 && var_path[1] != '>') 6768b2fe6dcSGreg Clayton return ValueObjectSP(); 6778b2fe6dcSGreg Clayton 6786d5e68eaSGreg Clayton if (no_fragile_ivar) 6796d5e68eaSGreg Clayton { 6806d5e68eaSGreg Clayton // Make sure we aren't trying to deref an objective 6816d5e68eaSGreg Clayton // C ivar if this is not allowed 68257ee3067SGreg Clayton const uint32_t pointer_type_flags = valobj_sp->GetClangType().GetTypeInfo (NULL); 68357ee3067SGreg Clayton if ((pointer_type_flags & ClangASTType::eTypeIsObjC) && 68457ee3067SGreg Clayton (pointer_type_flags & ClangASTType::eTypeIsPointer)) 6856d5e68eaSGreg Clayton { 6866d5e68eaSGreg Clayton // This was an objective C object pointer and 6876d5e68eaSGreg Clayton // it was requested we skip any fragile ivars 6886d5e68eaSGreg Clayton // so return nothing here 6896d5e68eaSGreg Clayton return ValueObjectSP(); 6906d5e68eaSGreg Clayton } 6916d5e68eaSGreg Clayton } 6928b2fe6dcSGreg Clayton var_path.erase (0, 1); // Remove the '-' 6938b2fe6dcSGreg Clayton // Fall through 6948b2fe6dcSGreg Clayton case '.': 6958b2fe6dcSGreg Clayton { 69654979cddSGreg Clayton const bool expr_is_ptr = var_path[0] == '>'; 6978b2fe6dcSGreg Clayton 6988b2fe6dcSGreg Clayton var_path.erase (0, 1); // Remove the '.' or '>' 6998b2fe6dcSGreg Clayton separator_idx = var_path.find_first_of(".-["); 7008b2fe6dcSGreg Clayton ConstString child_name; 7018b2fe6dcSGreg Clayton if (separator_idx == std::string::npos) 7028b2fe6dcSGreg Clayton child_name.SetCString (var_path.c_str()); 7038b2fe6dcSGreg Clayton else 7048b2fe6dcSGreg Clayton child_name.SetCStringWithLength(var_path.c_str(), separator_idx); 7058b2fe6dcSGreg Clayton 70654979cddSGreg Clayton if (check_ptr_vs_member) 70754979cddSGreg Clayton { 70854979cddSGreg Clayton // We either have a pointer type and need to verify 70954979cddSGreg Clayton // valobj_sp is a pointer, or we have a member of a 71054979cddSGreg Clayton // class/union/struct being accessed with the . syntax 71154979cddSGreg Clayton // and need to verify we don't have a pointer. 71254979cddSGreg Clayton const bool actual_is_ptr = valobj_sp->IsPointerType (); 71354979cddSGreg Clayton 71454979cddSGreg Clayton if (actual_is_ptr != expr_is_ptr) 71554979cddSGreg Clayton { 71654979cddSGreg Clayton // Incorrect use of "." with a pointer, or "->" with 71754979cddSGreg Clayton // a class/union/struct instance or reference. 7186beaaa68SGreg Clayton valobj_sp->GetExpressionPath (var_expr_path_strm, false); 71954979cddSGreg Clayton if (actual_is_ptr) 72054979cddSGreg Clayton error.SetErrorStringWithFormat ("\"%s\" is a pointer and . was used to attempt to access \"%s\". Did you mean \"%s->%s\"?", 72154979cddSGreg Clayton var_expr_path_strm.GetString().c_str(), 72254979cddSGreg Clayton child_name.GetCString(), 72354979cddSGreg Clayton var_expr_path_strm.GetString().c_str(), 72454979cddSGreg Clayton var_path.c_str()); 72554979cddSGreg Clayton else 72654979cddSGreg Clayton error.SetErrorStringWithFormat ("\"%s\" is not a pointer and -> was used to attempt to access \"%s\". Did you mean \"%s.%s\"?", 72754979cddSGreg Clayton var_expr_path_strm.GetString().c_str(), 72854979cddSGreg Clayton child_name.GetCString(), 72954979cddSGreg Clayton var_expr_path_strm.GetString().c_str(), 73054979cddSGreg Clayton var_path.c_str()); 73154979cddSGreg Clayton return ValueObjectSP(); 73254979cddSGreg Clayton } 73354979cddSGreg Clayton } 7348b2fe6dcSGreg Clayton child_valobj_sp = valobj_sp->GetChildMemberWithName (child_name, true); 7358b2fe6dcSGreg Clayton if (!child_valobj_sp) 7368b2fe6dcSGreg Clayton { 7378c9d3560SEnrico Granata if (no_synth_child == false) 73886cc9829SEnrico Granata { 73986cc9829SEnrico Granata child_valobj_sp = valobj_sp->GetSyntheticValue(); 74086cc9829SEnrico Granata if (child_valobj_sp) 74186cc9829SEnrico Granata child_valobj_sp = child_valobj_sp->GetChildMemberWithName (child_name, true); 74286cc9829SEnrico Granata } 7438c9d3560SEnrico Granata 7448c9d3560SEnrico Granata if (no_synth_child || !child_valobj_sp) 7458c9d3560SEnrico Granata { 7468b2fe6dcSGreg Clayton // No child member with name "child_name" 747685c88c5SGreg Clayton if (synthetically_added_instance_object) 748685c88c5SGreg Clayton { 749685c88c5SGreg Clayton // We added a "this->" or "self->" to the beginning of the expression 750685c88c5SGreg Clayton // and this is the first pointer ivar access, so just return the normal 751685c88c5SGreg Clayton // error 752685c88c5SGreg Clayton error.SetErrorStringWithFormat("no variable or instance variable named '%s' found in this frame", 753685c88c5SGreg Clayton name_const_string.GetCString()); 754685c88c5SGreg Clayton } 755685c88c5SGreg Clayton else 756685c88c5SGreg Clayton { 7576beaaa68SGreg Clayton valobj_sp->GetExpressionPath (var_expr_path_strm, false); 75854979cddSGreg Clayton if (child_name) 75954979cddSGreg Clayton { 76054979cddSGreg Clayton error.SetErrorStringWithFormat ("\"%s\" is not a member of \"(%s) %s\"", 76154979cddSGreg Clayton child_name.GetCString(), 76254979cddSGreg Clayton valobj_sp->GetTypeName().AsCString("<invalid type>"), 76354979cddSGreg Clayton var_expr_path_strm.GetString().c_str()); 76454979cddSGreg Clayton } 76554979cddSGreg Clayton else 76654979cddSGreg Clayton { 76754979cddSGreg Clayton error.SetErrorStringWithFormat ("incomplete expression path after \"%s\" in \"%s\"", 76854979cddSGreg Clayton var_expr_path_strm.GetString().c_str(), 76954979cddSGreg Clayton var_expr_cstr); 77054979cddSGreg Clayton } 771685c88c5SGreg Clayton } 7728b2fe6dcSGreg Clayton return ValueObjectSP(); 7738b2fe6dcSGreg Clayton } 7748c9d3560SEnrico Granata } 775685c88c5SGreg Clayton synthetically_added_instance_object = false; 7768b2fe6dcSGreg Clayton // Remove the child name from the path 7778b2fe6dcSGreg Clayton var_path.erase(0, child_name.GetLength()); 7784d122c40SGreg Clayton if (use_dynamic != eNoDynamicValues) 77978a685aaSJim Ingham { 7802837b766SJim Ingham ValueObjectSP dynamic_value_sp(child_valobj_sp->GetDynamicValue(use_dynamic)); 78178a685aaSJim Ingham if (dynamic_value_sp) 78278a685aaSJim Ingham child_valobj_sp = dynamic_value_sp; 78378a685aaSJim Ingham } 7848b2fe6dcSGreg Clayton } 7858b2fe6dcSGreg Clayton break; 7868b2fe6dcSGreg Clayton 7878b2fe6dcSGreg Clayton case '[': 7888b2fe6dcSGreg Clayton // Array member access, or treating pointer as an array 7898b2fe6dcSGreg Clayton if (var_path.size() > 2) // Need at least two brackets and a number 7908b2fe6dcSGreg Clayton { 7918b2fe6dcSGreg Clayton char *end = NULL; 7921a65ae11SGreg Clayton long child_index = ::strtol (&var_path[1], &end, 0); 7939fc1944eSEnrico Granata if (end && *end == ']' 7949fc1944eSEnrico Granata && *(end-1) != '[') // this code forces an error in the case of arr[]. as bitfield[] is not a good syntax we're good to go 7958b2fe6dcSGreg Clayton { 79657ee3067SGreg Clayton if (valobj_sp->GetClangType().IsPointerToScalarType() && deref) 7979fc1944eSEnrico Granata { 7989fc1944eSEnrico Granata // what we have is *ptr[low]. the most similar C++ syntax is to deref ptr 7999fc1944eSEnrico Granata // and extract bit low out of it. reading array item low 8009fc1944eSEnrico Granata // would be done by saying ptr[low], without a deref * sign 8019fc1944eSEnrico Granata Error error; 8029fc1944eSEnrico Granata ValueObjectSP temp(valobj_sp->Dereference(error)); 8039fc1944eSEnrico Granata if (error.Fail()) 8049fc1944eSEnrico Granata { 8059fc1944eSEnrico Granata valobj_sp->GetExpressionPath (var_expr_path_strm, false); 8069fc1944eSEnrico Granata error.SetErrorStringWithFormat ("could not dereference \"(%s) %s\"", 8079fc1944eSEnrico Granata valobj_sp->GetTypeName().AsCString("<invalid type>"), 8089fc1944eSEnrico Granata var_expr_path_strm.GetString().c_str()); 8099fc1944eSEnrico Granata return ValueObjectSP(); 8109fc1944eSEnrico Granata } 8119fc1944eSEnrico Granata valobj_sp = temp; 8129fc1944eSEnrico Granata deref = false; 8139fc1944eSEnrico Granata } 81457ee3067SGreg Clayton else if (valobj_sp->GetClangType().IsArrayOfScalarType() && deref) 8159fc1944eSEnrico Granata { 8169fc1944eSEnrico Granata // what we have is *arr[low]. the most similar C++ syntax is to get arr[0] 8179fc1944eSEnrico Granata // (an operation that is equivalent to deref-ing arr) 8189fc1944eSEnrico Granata // and extract bit low out of it. reading array item low 8199fc1944eSEnrico Granata // would be done by saying arr[low], without a deref * sign 8209fc1944eSEnrico Granata Error error; 8219fc1944eSEnrico Granata ValueObjectSP temp(valobj_sp->GetChildAtIndex (0, true)); 8229fc1944eSEnrico Granata if (error.Fail()) 8239fc1944eSEnrico Granata { 8249fc1944eSEnrico Granata valobj_sp->GetExpressionPath (var_expr_path_strm, false); 8259fc1944eSEnrico Granata error.SetErrorStringWithFormat ("could not get item 0 for \"(%s) %s\"", 8269fc1944eSEnrico Granata valobj_sp->GetTypeName().AsCString("<invalid type>"), 8279fc1944eSEnrico Granata var_expr_path_strm.GetString().c_str()); 8289fc1944eSEnrico Granata return ValueObjectSP(); 8299fc1944eSEnrico Granata } 8309fc1944eSEnrico Granata valobj_sp = temp; 8319fc1944eSEnrico Granata deref = false; 8329fc1944eSEnrico Granata } 8338b2fe6dcSGreg Clayton 8344ef877f5SGreg Clayton bool is_incomplete_array = false; 8358b2fe6dcSGreg Clayton if (valobj_sp->IsPointerType ()) 8368b2fe6dcSGreg Clayton { 837226b70c1SSean Callanan bool is_objc_pointer = true; 838226b70c1SSean Callanan 83957ee3067SGreg Clayton if (valobj_sp->GetClangType().GetMinimumLanguage() != eLanguageTypeObjC) 840226b70c1SSean Callanan is_objc_pointer = false; 84157ee3067SGreg Clayton else if (!valobj_sp->GetClangType().IsPointerType()) 842226b70c1SSean Callanan is_objc_pointer = false; 843226b70c1SSean Callanan 844226b70c1SSean Callanan if (no_synth_child && is_objc_pointer) 845226b70c1SSean Callanan { 846226b70c1SSean Callanan error.SetErrorStringWithFormat("\"(%s) %s\" is an Objective-C pointer, and cannot be subscripted", 847226b70c1SSean Callanan valobj_sp->GetTypeName().AsCString("<invalid type>"), 848226b70c1SSean Callanan var_expr_path_strm.GetString().c_str()); 849226b70c1SSean Callanan 850226b70c1SSean Callanan return ValueObjectSP(); 851226b70c1SSean Callanan } 852226b70c1SSean Callanan else if (is_objc_pointer) 85327b625e1SEnrico Granata { 85427b625e1SEnrico Granata // dereferencing ObjC variables is not valid.. so let's try and recur to synthetic children 85586cc9829SEnrico Granata ValueObjectSP synthetic = valobj_sp->GetSyntheticValue(); 85627b625e1SEnrico Granata if (synthetic.get() == NULL /* no synthetic */ 85727b625e1SEnrico Granata || synthetic == valobj_sp) /* synthetic is the same as the original object */ 85827b625e1SEnrico Granata { 85927b625e1SEnrico Granata valobj_sp->GetExpressionPath (var_expr_path_strm, false); 86027b625e1SEnrico Granata error.SetErrorStringWithFormat ("\"(%s) %s\" is not an array type", 86127b625e1SEnrico Granata valobj_sp->GetTypeName().AsCString("<invalid type>"), 86227b625e1SEnrico Granata var_expr_path_strm.GetString().c_str()); 86327b625e1SEnrico Granata } 8643985c8c6SSaleem Abdulrasool else if (static_cast<uint32_t>(child_index) >= synthetic->GetNumChildren() /* synthetic does not have that many values */) 86527b625e1SEnrico Granata { 86627b625e1SEnrico Granata valobj_sp->GetExpressionPath (var_expr_path_strm, false); 8677e589a60SJason Molenda error.SetErrorStringWithFormat ("array index %ld is not valid for \"(%s) %s\"", 86827b625e1SEnrico Granata child_index, 86927b625e1SEnrico Granata valobj_sp->GetTypeName().AsCString("<invalid type>"), 87027b625e1SEnrico Granata var_expr_path_strm.GetString().c_str()); 87127b625e1SEnrico Granata } 87227b625e1SEnrico Granata else 87327b625e1SEnrico Granata { 87427b625e1SEnrico Granata child_valobj_sp = synthetic->GetChildAtIndex(child_index, true); 87527b625e1SEnrico Granata if (!child_valobj_sp) 87627b625e1SEnrico Granata { 87727b625e1SEnrico Granata valobj_sp->GetExpressionPath (var_expr_path_strm, false); 8787e589a60SJason Molenda error.SetErrorStringWithFormat ("array index %ld is not valid for \"(%s) %s\"", 87927b625e1SEnrico Granata child_index, 88027b625e1SEnrico Granata valobj_sp->GetTypeName().AsCString("<invalid type>"), 88127b625e1SEnrico Granata var_expr_path_strm.GetString().c_str()); 88227b625e1SEnrico Granata } 88327b625e1SEnrico Granata } 88427b625e1SEnrico Granata } 88527b625e1SEnrico Granata else 88627b625e1SEnrico Granata { 8878b2fe6dcSGreg Clayton child_valobj_sp = valobj_sp->GetSyntheticArrayMemberFromPointer (child_index, true); 88854979cddSGreg Clayton if (!child_valobj_sp) 88954979cddSGreg Clayton { 8906beaaa68SGreg Clayton valobj_sp->GetExpressionPath (var_expr_path_strm, false); 8917e589a60SJason Molenda error.SetErrorStringWithFormat ("failed to use pointer as array for index %ld for \"(%s) %s\"", 89254979cddSGreg Clayton child_index, 89354979cddSGreg Clayton valobj_sp->GetTypeName().AsCString("<invalid type>"), 89454979cddSGreg Clayton var_expr_path_strm.GetString().c_str()); 89554979cddSGreg Clayton } 89654979cddSGreg Clayton } 89727b625e1SEnrico Granata } 89857ee3067SGreg Clayton else if (valobj_sp->GetClangType().IsArrayType (NULL, NULL, &is_incomplete_array)) 89954979cddSGreg Clayton { 90078a685aaSJim Ingham // Pass false to dynamic_value here so we can tell the difference between 90178a685aaSJim Ingham // no dynamic value and no member of this type... 90254979cddSGreg Clayton child_valobj_sp = valobj_sp->GetChildAtIndex (child_index, true); 9034ef877f5SGreg Clayton if (!child_valobj_sp && (is_incomplete_array || no_synth_child == false)) 9044ef877f5SGreg Clayton child_valobj_sp = valobj_sp->GetSyntheticArrayMember (child_index, true); 9054ef877f5SGreg Clayton 90654979cddSGreg Clayton if (!child_valobj_sp) 90754979cddSGreg Clayton { 9086beaaa68SGreg Clayton valobj_sp->GetExpressionPath (var_expr_path_strm, false); 9097e589a60SJason Molenda error.SetErrorStringWithFormat ("array index %ld is not valid for \"(%s) %s\"", 91054979cddSGreg Clayton child_index, 91154979cddSGreg Clayton valobj_sp->GetTypeName().AsCString("<invalid type>"), 91254979cddSGreg Clayton var_expr_path_strm.GetString().c_str()); 91354979cddSGreg Clayton } 9148b2fe6dcSGreg Clayton } 91557ee3067SGreg Clayton else if (valobj_sp->GetClangType().IsScalarType()) 9169fc1944eSEnrico Granata { 9179fc1944eSEnrico Granata // this is a bitfield asking to display just one bit 9189fc1944eSEnrico Granata child_valobj_sp = valobj_sp->GetSyntheticBitFieldChild(child_index, child_index, true); 9199fc1944eSEnrico Granata if (!child_valobj_sp) 9209fc1944eSEnrico Granata { 9219fc1944eSEnrico Granata valobj_sp->GetExpressionPath (var_expr_path_strm, false); 9227e589a60SJason Molenda error.SetErrorStringWithFormat ("bitfield range %ld-%ld is not valid for \"(%s) %s\"", 9239fc1944eSEnrico Granata child_index, child_index, 9249fc1944eSEnrico Granata valobj_sp->GetTypeName().AsCString("<invalid type>"), 9259fc1944eSEnrico Granata var_expr_path_strm.GetString().c_str()); 9269fc1944eSEnrico Granata } 9279fc1944eSEnrico Granata } 9288b2fe6dcSGreg Clayton else 9298b2fe6dcSGreg Clayton { 93086cc9829SEnrico Granata ValueObjectSP synthetic = valobj_sp->GetSyntheticValue(); 93127b625e1SEnrico Granata if (no_synth_child /* synthetic is forbidden */ || 93227b625e1SEnrico Granata synthetic.get() == NULL /* no synthetic */ 93327b625e1SEnrico Granata || synthetic == valobj_sp) /* synthetic is the same as the original object */ 93427b625e1SEnrico Granata { 9356beaaa68SGreg Clayton valobj_sp->GetExpressionPath (var_expr_path_strm, false); 93654979cddSGreg Clayton error.SetErrorStringWithFormat ("\"(%s) %s\" is not an array type", 93754979cddSGreg Clayton valobj_sp->GetTypeName().AsCString("<invalid type>"), 93854979cddSGreg Clayton var_expr_path_strm.GetString().c_str()); 9398b2fe6dcSGreg Clayton } 9403985c8c6SSaleem Abdulrasool else if (static_cast<uint32_t>(child_index) >= synthetic->GetNumChildren() /* synthetic does not have that many values */) 94127b625e1SEnrico Granata { 94227b625e1SEnrico Granata valobj_sp->GetExpressionPath (var_expr_path_strm, false); 9437e589a60SJason Molenda error.SetErrorStringWithFormat ("array index %ld is not valid for \"(%s) %s\"", 94427b625e1SEnrico Granata child_index, 94527b625e1SEnrico Granata valobj_sp->GetTypeName().AsCString("<invalid type>"), 94627b625e1SEnrico Granata var_expr_path_strm.GetString().c_str()); 94727b625e1SEnrico Granata } 94827b625e1SEnrico Granata else 94927b625e1SEnrico Granata { 95027b625e1SEnrico Granata child_valobj_sp = synthetic->GetChildAtIndex(child_index, true); 95127b625e1SEnrico Granata if (!child_valobj_sp) 95227b625e1SEnrico Granata { 95327b625e1SEnrico Granata valobj_sp->GetExpressionPath (var_expr_path_strm, false); 9547e589a60SJason Molenda error.SetErrorStringWithFormat ("array index %ld is not valid for \"(%s) %s\"", 95527b625e1SEnrico Granata child_index, 95627b625e1SEnrico Granata valobj_sp->GetTypeName().AsCString("<invalid type>"), 95727b625e1SEnrico Granata var_expr_path_strm.GetString().c_str()); 95827b625e1SEnrico Granata } 95927b625e1SEnrico Granata } 96027b625e1SEnrico Granata } 9618b2fe6dcSGreg Clayton 9628b2fe6dcSGreg Clayton if (!child_valobj_sp) 9638b2fe6dcSGreg Clayton { 9648b2fe6dcSGreg Clayton // Invalid array index... 9658b2fe6dcSGreg Clayton return ValueObjectSP(); 9668b2fe6dcSGreg Clayton } 9678b2fe6dcSGreg Clayton 9688b2fe6dcSGreg Clayton // Erase the array member specification '[%i]' where 9698b2fe6dcSGreg Clayton // %i is the array index 9708b2fe6dcSGreg Clayton var_path.erase(0, (end - var_path.c_str()) + 1); 9718b2fe6dcSGreg Clayton separator_idx = var_path.find_first_of(".-["); 9724d122c40SGreg Clayton if (use_dynamic != eNoDynamicValues) 97378a685aaSJim Ingham { 9742837b766SJim Ingham ValueObjectSP dynamic_value_sp(child_valobj_sp->GetDynamicValue(use_dynamic)); 97578a685aaSJim Ingham if (dynamic_value_sp) 97678a685aaSJim Ingham child_valobj_sp = dynamic_value_sp; 97778a685aaSJim Ingham } 9788b2fe6dcSGreg Clayton // Break out early from the switch since we were 9798b2fe6dcSGreg Clayton // able to find the child member 9808b2fe6dcSGreg Clayton break; 9818b2fe6dcSGreg Clayton } 9829fc1944eSEnrico Granata else if (end && *end == '-') 9839fc1944eSEnrico Granata { 9849fc1944eSEnrico Granata // this is most probably a BitField, let's take a look 9859fc1944eSEnrico Granata char *real_end = NULL; 9869fc1944eSEnrico Granata long final_index = ::strtol (end+1, &real_end, 0); 987d64d0bc0SEnrico Granata bool expand_bitfield = true; 9889fc1944eSEnrico Granata if (real_end && *real_end == ']') 9899fc1944eSEnrico Granata { 9909fc1944eSEnrico Granata // if the format given is [high-low], swap range 9919fc1944eSEnrico Granata if (child_index > final_index) 9929fc1944eSEnrico Granata { 9939fc1944eSEnrico Granata long temp = child_index; 9949fc1944eSEnrico Granata child_index = final_index; 9959fc1944eSEnrico Granata final_index = temp; 9969fc1944eSEnrico Granata } 9979fc1944eSEnrico Granata 99857ee3067SGreg Clayton if (valobj_sp->GetClangType().IsPointerToScalarType() && deref) 9999fc1944eSEnrico Granata { 10009fc1944eSEnrico Granata // what we have is *ptr[low-high]. the most similar C++ syntax is to deref ptr 10019fc1944eSEnrico Granata // and extract bits low thru high out of it. reading array items low thru high 10029fc1944eSEnrico Granata // would be done by saying ptr[low-high], without a deref * sign 10039fc1944eSEnrico Granata Error error; 10049fc1944eSEnrico Granata ValueObjectSP temp(valobj_sp->Dereference(error)); 10059fc1944eSEnrico Granata if (error.Fail()) 10069fc1944eSEnrico Granata { 10079fc1944eSEnrico Granata valobj_sp->GetExpressionPath (var_expr_path_strm, false); 10089fc1944eSEnrico Granata error.SetErrorStringWithFormat ("could not dereference \"(%s) %s\"", 10099fc1944eSEnrico Granata valobj_sp->GetTypeName().AsCString("<invalid type>"), 10109fc1944eSEnrico Granata var_expr_path_strm.GetString().c_str()); 10119fc1944eSEnrico Granata return ValueObjectSP(); 10129fc1944eSEnrico Granata } 10139fc1944eSEnrico Granata valobj_sp = temp; 10149fc1944eSEnrico Granata deref = false; 10159fc1944eSEnrico Granata } 101657ee3067SGreg Clayton else if (valobj_sp->GetClangType().IsArrayOfScalarType() && deref) 10179fc1944eSEnrico Granata { 10189fc1944eSEnrico Granata // what we have is *arr[low-high]. the most similar C++ syntax is to get arr[0] 10199fc1944eSEnrico Granata // (an operation that is equivalent to deref-ing arr) 10209fc1944eSEnrico Granata // and extract bits low thru high out of it. reading array items low thru high 10219fc1944eSEnrico Granata // would be done by saying arr[low-high], without a deref * sign 10229fc1944eSEnrico Granata Error error; 10239fc1944eSEnrico Granata ValueObjectSP temp(valobj_sp->GetChildAtIndex (0, true)); 10249fc1944eSEnrico Granata if (error.Fail()) 10259fc1944eSEnrico Granata { 10269fc1944eSEnrico Granata valobj_sp->GetExpressionPath (var_expr_path_strm, false); 10279fc1944eSEnrico Granata error.SetErrorStringWithFormat ("could not get item 0 for \"(%s) %s\"", 10289fc1944eSEnrico Granata valobj_sp->GetTypeName().AsCString("<invalid type>"), 10299fc1944eSEnrico Granata var_expr_path_strm.GetString().c_str()); 10309fc1944eSEnrico Granata return ValueObjectSP(); 10319fc1944eSEnrico Granata } 10329fc1944eSEnrico Granata valobj_sp = temp; 10339fc1944eSEnrico Granata deref = false; 10349fc1944eSEnrico Granata } 1035d64d0bc0SEnrico Granata /*else if (valobj_sp->IsArrayType() || valobj_sp->IsPointerType()) 1036d64d0bc0SEnrico Granata { 1037d64d0bc0SEnrico Granata child_valobj_sp = valobj_sp->GetSyntheticArrayRangeChild(child_index, final_index, true); 1038d64d0bc0SEnrico Granata expand_bitfield = false; 1039d64d0bc0SEnrico Granata if (!child_valobj_sp) 1040d64d0bc0SEnrico Granata { 1041d64d0bc0SEnrico Granata valobj_sp->GetExpressionPath (var_expr_path_strm, false); 1042d64d0bc0SEnrico Granata error.SetErrorStringWithFormat ("array range %i-%i is not valid for \"(%s) %s\"", 1043d64d0bc0SEnrico Granata child_index, final_index, 1044d64d0bc0SEnrico Granata valobj_sp->GetTypeName().AsCString("<invalid type>"), 1045d64d0bc0SEnrico Granata var_expr_path_strm.GetString().c_str()); 1046d64d0bc0SEnrico Granata } 1047d64d0bc0SEnrico Granata }*/ 10489fc1944eSEnrico Granata 1049d64d0bc0SEnrico Granata if (expand_bitfield) 1050d64d0bc0SEnrico Granata { 10519fc1944eSEnrico Granata child_valobj_sp = valobj_sp->GetSyntheticBitFieldChild(child_index, final_index, true); 10529fc1944eSEnrico Granata if (!child_valobj_sp) 10539fc1944eSEnrico Granata { 10549fc1944eSEnrico Granata valobj_sp->GetExpressionPath (var_expr_path_strm, false); 10557e589a60SJason Molenda error.SetErrorStringWithFormat ("bitfield range %ld-%ld is not valid for \"(%s) %s\"", 10569fc1944eSEnrico Granata child_index, final_index, 10579fc1944eSEnrico Granata valobj_sp->GetTypeName().AsCString("<invalid type>"), 10589fc1944eSEnrico Granata var_expr_path_strm.GetString().c_str()); 10599fc1944eSEnrico Granata } 10609fc1944eSEnrico Granata } 1061d64d0bc0SEnrico Granata } 10629fc1944eSEnrico Granata 10639fc1944eSEnrico Granata if (!child_valobj_sp) 10649fc1944eSEnrico Granata { 10659fc1944eSEnrico Granata // Invalid bitfield range... 10669fc1944eSEnrico Granata return ValueObjectSP(); 10679fc1944eSEnrico Granata } 10689fc1944eSEnrico Granata 10699fc1944eSEnrico Granata // Erase the bitfield member specification '[%i-%i]' where 10709fc1944eSEnrico Granata // %i is the index 10719fc1944eSEnrico Granata var_path.erase(0, (real_end - var_path.c_str()) + 1); 10729fc1944eSEnrico Granata separator_idx = var_path.find_first_of(".-["); 10734d122c40SGreg Clayton if (use_dynamic != eNoDynamicValues) 10749fc1944eSEnrico Granata { 10759fc1944eSEnrico Granata ValueObjectSP dynamic_value_sp(child_valobj_sp->GetDynamicValue(use_dynamic)); 10769fc1944eSEnrico Granata if (dynamic_value_sp) 10779fc1944eSEnrico Granata child_valobj_sp = dynamic_value_sp; 10789fc1944eSEnrico Granata } 10799fc1944eSEnrico Granata // Break out early from the switch since we were 10809fc1944eSEnrico Granata // able to find the child member 10819fc1944eSEnrico Granata break; 10829fc1944eSEnrico Granata 10839fc1944eSEnrico Granata } 10849fc1944eSEnrico Granata } 10859fc1944eSEnrico Granata else 10869fc1944eSEnrico Granata { 10879fc1944eSEnrico Granata error.SetErrorStringWithFormat("invalid square bracket encountered after \"%s\" in \"%s\"", 10889fc1944eSEnrico Granata var_expr_path_strm.GetString().c_str(), 10899fc1944eSEnrico Granata var_path.c_str()); 10908b2fe6dcSGreg Clayton } 10918b2fe6dcSGreg Clayton return ValueObjectSP(); 10928b2fe6dcSGreg Clayton 10938b2fe6dcSGreg Clayton default: 10948b2fe6dcSGreg Clayton // Failure... 109554979cddSGreg Clayton { 10966beaaa68SGreg Clayton valobj_sp->GetExpressionPath (var_expr_path_strm, false); 109754979cddSGreg Clayton error.SetErrorStringWithFormat ("unexpected char '%c' encountered after \"%s\" in \"%s\"", 109854979cddSGreg Clayton separator_type, 109954979cddSGreg Clayton var_expr_path_strm.GetString().c_str(), 110054979cddSGreg Clayton var_path.c_str()); 110154979cddSGreg Clayton 11028b2fe6dcSGreg Clayton return ValueObjectSP(); 11038b2fe6dcSGreg Clayton } 110454979cddSGreg Clayton } 11058b2fe6dcSGreg Clayton 11068b2fe6dcSGreg Clayton if (child_valobj_sp) 11078b2fe6dcSGreg Clayton valobj_sp = child_valobj_sp; 11088b2fe6dcSGreg Clayton 11098b2fe6dcSGreg Clayton if (var_path.empty()) 11108b2fe6dcSGreg Clayton break; 11118b2fe6dcSGreg Clayton 11128b2fe6dcSGreg Clayton } 11138b2fe6dcSGreg Clayton if (valobj_sp) 11148b2fe6dcSGreg Clayton { 11158b2fe6dcSGreg Clayton if (deref) 11168b2fe6dcSGreg Clayton { 1117af67cecdSGreg Clayton ValueObjectSP deref_valobj_sp (valobj_sp->Dereference(error)); 11188b2fe6dcSGreg Clayton valobj_sp = deref_valobj_sp; 11198b2fe6dcSGreg Clayton } 11208b2fe6dcSGreg Clayton else if (address_of) 11218b2fe6dcSGreg Clayton { 112254979cddSGreg Clayton ValueObjectSP address_of_valobj_sp (valobj_sp->AddressOf(error)); 11238b2fe6dcSGreg Clayton valobj_sp = address_of_valobj_sp; 11248b2fe6dcSGreg Clayton } 11258b2fe6dcSGreg Clayton } 11268b2fe6dcSGreg Clayton return valobj_sp; 11278b2fe6dcSGreg Clayton } 112854979cddSGreg Clayton else 112954979cddSGreg Clayton { 11302837b766SJim Ingham error.SetErrorStringWithFormat("no variable named '%s' found in this frame", 11312837b766SJim Ingham name_const_string.GetCString()); 113254979cddSGreg Clayton } 113354979cddSGreg Clayton } 113454979cddSGreg Clayton } 113554979cddSGreg Clayton else 113654979cddSGreg Clayton { 113754979cddSGreg Clayton error.SetErrorStringWithFormat("invalid variable path '%s'", var_expr_cstr); 11388b2fe6dcSGreg Clayton } 11398b2fe6dcSGreg Clayton return ValueObjectSP(); 11408b2fe6dcSGreg Clayton } 114130fdc8d8SChris Lattner 114230fdc8d8SChris Lattner bool 114330fdc8d8SChris Lattner StackFrame::GetFrameBaseValue (Scalar &frame_base, Error *error_ptr) 114430fdc8d8SChris Lattner { 114599618476SJason Molenda if (m_cfa_is_valid == false) 114699618476SJason Molenda { 114799618476SJason Molenda m_frame_base_error.SetErrorString("No frame base available for this historical stack frame."); 114899618476SJason Molenda return false; 114999618476SJason Molenda } 115099618476SJason Molenda 115130fdc8d8SChris Lattner if (m_flags.IsClear(GOT_FRAME_BASE)) 115230fdc8d8SChris Lattner { 115330fdc8d8SChris Lattner if (m_sc.function) 115430fdc8d8SChris Lattner { 115530fdc8d8SChris Lattner m_frame_base.Clear(); 115630fdc8d8SChris Lattner m_frame_base_error.Clear(); 115730fdc8d8SChris Lattner 115830fdc8d8SChris Lattner m_flags.Set(GOT_FRAME_BASE); 1159d9e416c0SGreg Clayton ExecutionContext exe_ctx (shared_from_this()); 116030fdc8d8SChris Lattner Value expr_value; 1161016a95ebSGreg Clayton addr_t loclist_base_addr = LLDB_INVALID_ADDRESS; 1162016a95ebSGreg Clayton if (m_sc.function->GetFrameBaseExpression().IsLocationList()) 1163d9e416c0SGreg Clayton loclist_base_addr = m_sc.function->GetAddressRange().GetBaseAddress().GetLoadAddress (exe_ctx.GetTargetPtr()); 1164016a95ebSGreg Clayton 116557ee3067SGreg Clayton if (m_sc.function->GetFrameBaseExpression().Evaluate(&exe_ctx, NULL, NULL, NULL, loclist_base_addr, NULL, expr_value, &m_frame_base_error) == false) 116630fdc8d8SChris Lattner { 116730fdc8d8SChris Lattner // We should really have an error if evaluate returns, but in case 116830fdc8d8SChris Lattner // we don't, lets set the error to something at least. 116930fdc8d8SChris Lattner if (m_frame_base_error.Success()) 117030fdc8d8SChris Lattner m_frame_base_error.SetErrorString("Evaluation of the frame base expression failed."); 117130fdc8d8SChris Lattner } 117230fdc8d8SChris Lattner else 117330fdc8d8SChris Lattner { 117457ee3067SGreg Clayton m_frame_base = expr_value.ResolveValue(&exe_ctx); 117530fdc8d8SChris Lattner } 117630fdc8d8SChris Lattner } 117730fdc8d8SChris Lattner else 117830fdc8d8SChris Lattner { 117930fdc8d8SChris Lattner m_frame_base_error.SetErrorString ("No function in symbol context."); 118030fdc8d8SChris Lattner } 118130fdc8d8SChris Lattner } 118230fdc8d8SChris Lattner 118330fdc8d8SChris Lattner if (m_frame_base_error.Success()) 118430fdc8d8SChris Lattner frame_base = m_frame_base; 118530fdc8d8SChris Lattner 118630fdc8d8SChris Lattner if (error_ptr) 118730fdc8d8SChris Lattner *error_ptr = m_frame_base_error; 118830fdc8d8SChris Lattner return m_frame_base_error.Success(); 118930fdc8d8SChris Lattner } 119030fdc8d8SChris Lattner 11915ccbd294SGreg Clayton RegisterContextSP 119230fdc8d8SChris Lattner StackFrame::GetRegisterContext () 119330fdc8d8SChris Lattner { 11945ccbd294SGreg Clayton if (!m_reg_context_sp) 1195d9e416c0SGreg Clayton { 1196d9e416c0SGreg Clayton ThreadSP thread_sp (GetThread()); 1197d9e416c0SGreg Clayton if (thread_sp) 1198d9e416c0SGreg Clayton m_reg_context_sp = thread_sp->CreateRegisterContextForFrame (this); 1199d9e416c0SGreg Clayton } 12005ccbd294SGreg Clayton return m_reg_context_sp; 120130fdc8d8SChris Lattner } 120230fdc8d8SChris Lattner 120330fdc8d8SChris Lattner bool 120430fdc8d8SChris Lattner StackFrame::HasDebugInformation () 120530fdc8d8SChris Lattner { 120630fdc8d8SChris Lattner GetSymbolContext (eSymbolContextLineEntry); 120730fdc8d8SChris Lattner return m_sc.line_entry.IsValid(); 120830fdc8d8SChris Lattner } 120930fdc8d8SChris Lattner 1210288bdf9cSGreg Clayton 1211288bdf9cSGreg Clayton ValueObjectSP 12124d122c40SGreg Clayton StackFrame::GetValueObjectForFrameVariable (const VariableSP &variable_sp, DynamicValueType use_dynamic) 121330fdc8d8SChris Lattner { 1214288bdf9cSGreg Clayton ValueObjectSP valobj_sp; 121599618476SJason Molenda if (m_is_history_frame) 121699618476SJason Molenda { 121799618476SJason Molenda return valobj_sp; 121899618476SJason Molenda } 1219288bdf9cSGreg Clayton VariableList *var_list = GetVariableList (true); 1220288bdf9cSGreg Clayton if (var_list) 1221288bdf9cSGreg Clayton { 1222288bdf9cSGreg Clayton // Make sure the variable is a frame variable 1223288bdf9cSGreg Clayton const uint32_t var_idx = var_list->FindIndexForVariable (variable_sp.get()); 1224288bdf9cSGreg Clayton const uint32_t num_variables = var_list->GetSize(); 1225288bdf9cSGreg Clayton if (var_idx < num_variables) 1226288bdf9cSGreg Clayton { 1227288bdf9cSGreg Clayton valobj_sp = m_variable_list_value_objects.GetValueObjectAtIndex (var_idx); 1228288bdf9cSGreg Clayton if (valobj_sp.get() == NULL) 1229288bdf9cSGreg Clayton { 1230288bdf9cSGreg Clayton if (m_variable_list_value_objects.GetSize() < num_variables) 1231288bdf9cSGreg Clayton m_variable_list_value_objects.Resize(num_variables); 123258b59f95SJim Ingham valobj_sp = ValueObjectVariable::Create (this, variable_sp); 1233288bdf9cSGreg Clayton m_variable_list_value_objects.SetValueObjectAtIndex (var_idx, valobj_sp); 1234288bdf9cSGreg Clayton } 1235288bdf9cSGreg Clayton } 1236288bdf9cSGreg Clayton } 12374d122c40SGreg Clayton if (use_dynamic != eNoDynamicValues && valobj_sp) 123878a685aaSJim Ingham { 12392837b766SJim Ingham ValueObjectSP dynamic_sp = valobj_sp->GetDynamicValue (use_dynamic); 124078a685aaSJim Ingham if (dynamic_sp) 124178a685aaSJim Ingham return dynamic_sp; 124278a685aaSJim Ingham } 1243288bdf9cSGreg Clayton return valobj_sp; 1244288bdf9cSGreg Clayton } 1245288bdf9cSGreg Clayton 1246288bdf9cSGreg Clayton ValueObjectSP 12474d122c40SGreg Clayton StackFrame::TrackGlobalVariable (const VariableSP &variable_sp, DynamicValueType use_dynamic) 1248288bdf9cSGreg Clayton { 124999618476SJason Molenda if (m_is_history_frame) 125099618476SJason Molenda return ValueObjectSP(); 125199618476SJason Molenda 1252288bdf9cSGreg Clayton // Check to make sure we aren't already tracking this variable? 125378a685aaSJim Ingham ValueObjectSP valobj_sp (GetValueObjectForFrameVariable (variable_sp, use_dynamic)); 1254288bdf9cSGreg Clayton if (!valobj_sp) 1255288bdf9cSGreg Clayton { 1256288bdf9cSGreg Clayton // We aren't already tracking this global 1257288bdf9cSGreg Clayton VariableList *var_list = GetVariableList (true); 1258288bdf9cSGreg Clayton // If this frame has no variables, create a new list 1259288bdf9cSGreg Clayton if (var_list == NULL) 1260288bdf9cSGreg Clayton m_variable_list_sp.reset (new VariableList()); 1261288bdf9cSGreg Clayton 1262288bdf9cSGreg Clayton // Add the global/static variable to this frame 1263288bdf9cSGreg Clayton m_variable_list_sp->AddVariable (variable_sp); 1264288bdf9cSGreg Clayton 1265288bdf9cSGreg Clayton // Now make a value object for it so we can track its changes 126678a685aaSJim Ingham valobj_sp = GetValueObjectForFrameVariable (variable_sp, use_dynamic); 1267288bdf9cSGreg Clayton } 1268288bdf9cSGreg Clayton return valobj_sp; 126930fdc8d8SChris Lattner } 127030fdc8d8SChris Lattner 12716b8379c4SJim Ingham bool 12726b8379c4SJim Ingham StackFrame::IsInlined () 12736b8379c4SJim Ingham { 127459e8fc1cSGreg Clayton if (m_sc.block == NULL) 127559e8fc1cSGreg Clayton GetSymbolContext (eSymbolContextBlock); 127659e8fc1cSGreg Clayton if (m_sc.block) 127759e8fc1cSGreg Clayton return m_sc.block->GetContainingInlinedBlock() != NULL; 127859e8fc1cSGreg Clayton return false; 12796b8379c4SJim Ingham } 12806b8379c4SJim Ingham 1281d9e416c0SGreg Clayton TargetSP 128230fdc8d8SChris Lattner StackFrame::CalculateTarget () 128330fdc8d8SChris Lattner { 1284d9e416c0SGreg Clayton TargetSP target_sp; 1285d9e416c0SGreg Clayton ThreadSP thread_sp(GetThread()); 1286d9e416c0SGreg Clayton if (thread_sp) 1287d9e416c0SGreg Clayton { 1288d9e416c0SGreg Clayton ProcessSP process_sp (thread_sp->CalculateProcess()); 1289d9e416c0SGreg Clayton if (process_sp) 1290d9e416c0SGreg Clayton target_sp = process_sp->CalculateTarget(); 1291d9e416c0SGreg Clayton } 1292d9e416c0SGreg Clayton return target_sp; 129330fdc8d8SChris Lattner } 129430fdc8d8SChris Lattner 1295d9e416c0SGreg Clayton ProcessSP 129630fdc8d8SChris Lattner StackFrame::CalculateProcess () 129730fdc8d8SChris Lattner { 1298d9e416c0SGreg Clayton ProcessSP process_sp; 1299d9e416c0SGreg Clayton ThreadSP thread_sp(GetThread()); 1300d9e416c0SGreg Clayton if (thread_sp) 1301d9e416c0SGreg Clayton process_sp = thread_sp->CalculateProcess(); 1302d9e416c0SGreg Clayton return process_sp; 130330fdc8d8SChris Lattner } 130430fdc8d8SChris Lattner 1305d9e416c0SGreg Clayton ThreadSP 130630fdc8d8SChris Lattner StackFrame::CalculateThread () 130730fdc8d8SChris Lattner { 1308d9e416c0SGreg Clayton return GetThread(); 130930fdc8d8SChris Lattner } 131030fdc8d8SChris Lattner 1311b57e4a1bSJason Molenda StackFrameSP 1312b57e4a1bSJason Molenda StackFrame::CalculateStackFrame () 131330fdc8d8SChris Lattner { 1314d9e416c0SGreg Clayton return shared_from_this(); 131530fdc8d8SChris Lattner } 131630fdc8d8SChris Lattner 131730fdc8d8SChris Lattner 131830fdc8d8SChris Lattner void 13190603aa9dSGreg Clayton StackFrame::CalculateExecutionContext (ExecutionContext &exe_ctx) 132030fdc8d8SChris Lattner { 1321d9e416c0SGreg Clayton exe_ctx.SetContext (shared_from_this()); 132230fdc8d8SChris Lattner } 132330fdc8d8SChris Lattner 132430fdc8d8SChris Lattner void 13258ec10efcSJim Ingham StackFrame::DumpUsingSettingsFormat (Stream *strm, const char *frame_marker) 13260603aa9dSGreg Clayton { 13270603aa9dSGreg Clayton if (strm == NULL) 13280603aa9dSGreg Clayton return; 13290603aa9dSGreg Clayton 13300603aa9dSGreg Clayton GetSymbolContext(eSymbolContextEverything); 1331d9e416c0SGreg Clayton ExecutionContext exe_ctx (shared_from_this()); 13320603aa9dSGreg Clayton StreamString s; 13338ec10efcSJim Ingham 13348ec10efcSJim Ingham if (frame_marker) 13358ec10efcSJim Ingham s.PutCString(frame_marker); 13368ec10efcSJim Ingham 1337d9e416c0SGreg Clayton const char *frame_format = NULL; 1338d9e416c0SGreg Clayton Target *target = exe_ctx.GetTargetPtr(); 1339d9e416c0SGreg Clayton if (target) 1340d9e416c0SGreg Clayton frame_format = target->GetDebugger().GetFrameFormat(); 1341c3ce7f27SMichael Sartain if (frame_format && Debugger::FormatPrompt (frame_format, &m_sc, &exe_ctx, NULL, s)) 13420603aa9dSGreg Clayton { 13430603aa9dSGreg Clayton strm->Write(s.GetData(), s.GetSize()); 13440603aa9dSGreg Clayton } 13450603aa9dSGreg Clayton else 13460603aa9dSGreg Clayton { 13470603aa9dSGreg Clayton Dump (strm, true, false); 13480603aa9dSGreg Clayton strm->EOL(); 13490603aa9dSGreg Clayton } 13500603aa9dSGreg Clayton } 13510603aa9dSGreg Clayton 13520603aa9dSGreg Clayton void 13536dadd508SGreg Clayton StackFrame::Dump (Stream *strm, bool show_frame_index, bool show_fullpaths) 135430fdc8d8SChris Lattner { 135530fdc8d8SChris Lattner if (strm == NULL) 135630fdc8d8SChris Lattner return; 135730fdc8d8SChris Lattner 135830fdc8d8SChris Lattner if (show_frame_index) 13591b72fcb7SGreg Clayton strm->Printf("frame #%u: ", m_frame_index); 1360d9e416c0SGreg Clayton ExecutionContext exe_ctx (shared_from_this()); 1361d9e416c0SGreg Clayton Target *target = exe_ctx.GetTargetPtr(); 1362d01b2953SDaniel Malea strm->Printf("0x%0*" PRIx64 " ", 1363d9e416c0SGreg Clayton target ? (target->GetArchitecture().GetAddressByteSize() * 2) : 16, 1364d9e416c0SGreg Clayton GetFrameCodeAddress().GetLoadAddress(target)); 13659da7bd07SGreg Clayton GetSymbolContext(eSymbolContextEverything); 13661b72fcb7SGreg Clayton const bool show_module = true; 13671b72fcb7SGreg Clayton const bool show_inline = true; 1368d9e416c0SGreg Clayton m_sc.DumpStopContext (strm, 1369d9e416c0SGreg Clayton exe_ctx.GetBestExecutionContextScope(), 1370d9e416c0SGreg Clayton GetFrameCodeAddress(), 1371d9e416c0SGreg Clayton show_fullpaths, 1372d9e416c0SGreg Clayton show_module, 1373d9e416c0SGreg Clayton show_inline); 137430fdc8d8SChris Lattner } 137530fdc8d8SChris Lattner 13765082c5fdSGreg Clayton void 1377b57e4a1bSJason Molenda StackFrame::UpdateCurrentFrameFromPreviousFrame (StackFrame &prev_frame) 13785082c5fdSGreg Clayton { 137959e8fc1cSGreg Clayton assert (GetStackID() == prev_frame.GetStackID()); // TODO: remove this after some testing 1380b57e4a1bSJason Molenda m_variable_list_sp = prev_frame.m_variable_list_sp; 1381b57e4a1bSJason Molenda m_variable_list_value_objects.Swap (prev_frame.m_variable_list_value_objects); 138268275d5eSGreg Clayton if (!m_disassembly.GetString().empty()) 138368275d5eSGreg Clayton m_disassembly.GetString().swap (m_disassembly.GetString()); 13845082c5fdSGreg Clayton } 138568275d5eSGreg Clayton 138668275d5eSGreg Clayton 138759e8fc1cSGreg Clayton void 1388b57e4a1bSJason Molenda StackFrame::UpdatePreviousFrameFromCurrentFrame (StackFrame &curr_frame) 138959e8fc1cSGreg Clayton { 139059e8fc1cSGreg Clayton assert (GetStackID() == curr_frame.GetStackID()); // TODO: remove this after some testing 1391b57e4a1bSJason Molenda m_id.SetPC (curr_frame.m_id.GetPC()); // Update the Stack ID PC value 1392b57e4a1bSJason Molenda assert (GetThread() == curr_frame.GetThread()); 1393b57e4a1bSJason Molenda m_frame_index = curr_frame.m_frame_index; 1394b57e4a1bSJason Molenda m_concrete_frame_index = curr_frame.m_concrete_frame_index; 1395b57e4a1bSJason Molenda m_reg_context_sp = curr_frame.m_reg_context_sp; 1396b57e4a1bSJason Molenda m_frame_code_addr = curr_frame.m_frame_code_addr; 1397b57e4a1bSJason Molenda assert (m_sc.target_sp.get() == NULL || curr_frame.m_sc.target_sp.get() == NULL || m_sc.target_sp.get() == curr_frame.m_sc.target_sp.get()); 1398b57e4a1bSJason Molenda assert (m_sc.module_sp.get() == NULL || curr_frame.m_sc.module_sp.get() == NULL || m_sc.module_sp.get() == curr_frame.m_sc.module_sp.get()); 1399b57e4a1bSJason Molenda assert (m_sc.comp_unit == NULL || curr_frame.m_sc.comp_unit == NULL || m_sc.comp_unit == curr_frame.m_sc.comp_unit); 1400b57e4a1bSJason Molenda assert (m_sc.function == NULL || curr_frame.m_sc.function == NULL || m_sc.function == curr_frame.m_sc.function); 1401b57e4a1bSJason Molenda m_sc = curr_frame.m_sc; 140259e8fc1cSGreg Clayton m_flags.Clear(GOT_FRAME_BASE | eSymbolContextEverything); 140359e8fc1cSGreg Clayton m_flags.Set (m_sc.GetResolvedMask()); 140459e8fc1cSGreg Clayton m_frame_base.Clear(); 140559e8fc1cSGreg Clayton m_frame_base_error.Clear(); 140659e8fc1cSGreg Clayton } 1407e4284b71SJim Ingham 1408f23bf743SJason Molenda 14097260f620SGreg Clayton bool 1410b57e4a1bSJason Molenda StackFrame::HasCachedData () const 1411b57e4a1bSJason Molenda { 1412b57e4a1bSJason Molenda if (m_variable_list_sp.get()) 1413b57e4a1bSJason Molenda return true; 1414b57e4a1bSJason Molenda if (m_variable_list_value_objects.GetSize() > 0) 1415b57e4a1bSJason Molenda return true; 1416b57e4a1bSJason Molenda if (!m_disassembly.GetString().empty()) 1417b57e4a1bSJason Molenda return true; 1418b57e4a1bSJason Molenda return false; 1419b57e4a1bSJason Molenda } 1420b57e4a1bSJason Molenda 1421b57e4a1bSJason Molenda bool 14227260f620SGreg Clayton StackFrame::GetStatus (Stream& strm, 14237260f620SGreg Clayton bool show_frame_info, 14248ec10efcSJim Ingham bool show_source, 14258ec10efcSJim Ingham const char *frame_marker) 14267260f620SGreg Clayton { 142753eb7ad2SGreg Clayton 14287260f620SGreg Clayton if (show_frame_info) 14297260f620SGreg Clayton { 14307260f620SGreg Clayton strm.Indent(); 14318ec10efcSJim Ingham DumpUsingSettingsFormat (&strm, frame_marker); 14327260f620SGreg Clayton } 14337260f620SGreg Clayton 14347260f620SGreg Clayton if (show_source) 14357260f620SGreg Clayton { 1436d9e416c0SGreg Clayton ExecutionContext exe_ctx (shared_from_this()); 1437e372b98dSGreg Clayton bool have_source = false; 143867cc0636SGreg Clayton Debugger::StopDisassemblyType disasm_display = Debugger::eStopDisassemblyTypeNever; 1439d9e416c0SGreg Clayton Target *target = exe_ctx.GetTargetPtr(); 144053eb7ad2SGreg Clayton if (target) 144153eb7ad2SGreg Clayton { 144253eb7ad2SGreg Clayton Debugger &debugger = target->GetDebugger(); 144353eb7ad2SGreg Clayton const uint32_t source_lines_before = debugger.GetStopSourceLineCount(true); 144453eb7ad2SGreg Clayton const uint32_t source_lines_after = debugger.GetStopSourceLineCount(false); 144553eb7ad2SGreg Clayton disasm_display = debugger.GetStopDisassemblyDisplay (); 144653eb7ad2SGreg Clayton 14477260f620SGreg Clayton GetSymbolContext(eSymbolContextCompUnit | eSymbolContextLineEntry); 14487260f620SGreg Clayton if (m_sc.comp_unit && m_sc.line_entry.IsValid()) 14497260f620SGreg Clayton { 14507cd81c55SJason Molenda have_source = true; 14516d1fbc9cSTodd Fiala if (source_lines_before > 0 || source_lines_after > 0) 14526d1fbc9cSTodd Fiala { 14537cd81c55SJason Molenda target->GetSourceManager().DisplaySourceLinesWithLineNumbers (m_sc.line_entry.file, 14547260f620SGreg Clayton m_sc.line_entry.line, 1455d9e416c0SGreg Clayton source_lines_before, 1456d9e416c0SGreg Clayton source_lines_after, 14577260f620SGreg Clayton "->", 14587cd81c55SJason Molenda &strm); 1459e372b98dSGreg Clayton } 1460e372b98dSGreg Clayton } 1461e372b98dSGreg Clayton switch (disasm_display) 1462e372b98dSGreg Clayton { 146367cc0636SGreg Clayton case Debugger::eStopDisassemblyTypeNever: 1464e372b98dSGreg Clayton break; 1465e372b98dSGreg Clayton 146667cc0636SGreg Clayton case Debugger::eStopDisassemblyTypeNoSource: 1467e372b98dSGreg Clayton if (have_source) 1468e372b98dSGreg Clayton break; 1469e372b98dSGreg Clayton // Fall through to next case 147067cc0636SGreg Clayton case Debugger::eStopDisassemblyTypeAlways: 1471d9e416c0SGreg Clayton if (target) 1472e372b98dSGreg Clayton { 147353eb7ad2SGreg Clayton const uint32_t disasm_lines = debugger.GetDisassemblyLineCount(); 1474e372b98dSGreg Clayton if (disasm_lines > 0) 1475e372b98dSGreg Clayton { 1476d9e416c0SGreg Clayton const ArchSpec &target_arch = target->GetArchitecture(); 1477e372b98dSGreg Clayton AddressRange pc_range; 1478e372b98dSGreg Clayton pc_range.GetBaseAddress() = GetFrameCodeAddress(); 1479e372b98dSGreg Clayton pc_range.SetByteSize(disasm_lines * target_arch.GetMaximumOpcodeByteSize()); 14800f063ba6SJim Ingham const char *plugin_name = NULL; 14810f063ba6SJim Ingham const char *flavor = NULL; 1482d9e416c0SGreg Clayton Disassembler::Disassemble (target->GetDebugger(), 1483e372b98dSGreg Clayton target_arch, 14840f063ba6SJim Ingham plugin_name, 14850f063ba6SJim Ingham flavor, 1486e372b98dSGreg Clayton exe_ctx, 1487e372b98dSGreg Clayton pc_range, 1488e372b98dSGreg Clayton disasm_lines, 1489e372b98dSGreg Clayton 0, 1490e372b98dSGreg Clayton Disassembler::eOptionMarkPCAddress, 1491e372b98dSGreg Clayton strm); 1492e372b98dSGreg Clayton } 1493e372b98dSGreg Clayton } 1494e372b98dSGreg Clayton break; 14957260f620SGreg Clayton } 14967260f620SGreg Clayton } 149753eb7ad2SGreg Clayton } 14987260f620SGreg Clayton return true; 14997260f620SGreg Clayton } 15007260f620SGreg Clayton 1501