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 
1030fdc8d8SChris Lattner #include "lldb/Target/StackFrame.h"
1130fdc8d8SChris Lattner 
1230fdc8d8SChris Lattner // C Includes
1330fdc8d8SChris Lattner // C++ Includes
1430fdc8d8SChris Lattner // Other libraries and framework includes
1530fdc8d8SChris Lattner // Project includes
1630fdc8d8SChris Lattner #include "lldb/Core/Module.h"
170603aa9dSGreg Clayton #include "lldb/Core/Debugger.h"
1830fdc8d8SChris Lattner #include "lldb/Core/Disassembler.h"
1930fdc8d8SChris Lattner #include "lldb/Core/Value.h"
20288bdf9cSGreg Clayton #include "lldb/Core/ValueObjectVariable.h"
2154979cddSGreg Clayton #include "lldb/Core/ValueObjectConstResult.h"
2230fdc8d8SChris Lattner #include "lldb/Symbol/Function.h"
23288bdf9cSGreg Clayton #include "lldb/Symbol/VariableList.h"
2430fdc8d8SChris Lattner #include "lldb/Target/ExecutionContext.h"
2530fdc8d8SChris Lattner #include "lldb/Target/Process.h"
2630fdc8d8SChris Lattner #include "lldb/Target/RegisterContext.h"
2730fdc8d8SChris Lattner #include "lldb/Target/Target.h"
2830fdc8d8SChris Lattner #include "lldb/Target/Thread.h"
2930fdc8d8SChris Lattner 
3030fdc8d8SChris Lattner using namespace lldb;
3130fdc8d8SChris Lattner using namespace lldb_private;
3230fdc8d8SChris Lattner 
3330fdc8d8SChris Lattner // The first bits in the flags are reserved for the SymbolContext::Scope bits
3430fdc8d8SChris Lattner // so we know if we have tried to look up information in our internal symbol
3530fdc8d8SChris Lattner // context (m_sc) already.
3659e8fc1cSGreg Clayton #define RESOLVED_FRAME_CODE_ADDR        (uint32_t(eSymbolContextEverything + 1))
376dadd508SGreg Clayton #define RESOLVED_FRAME_ID_SYMBOL_SCOPE  (RESOLVED_FRAME_CODE_ADDR << 1)
3859e8fc1cSGreg Clayton #define GOT_FRAME_BASE                  (RESOLVED_FRAME_ID_SYMBOL_SCOPE << 1)
3959e8fc1cSGreg Clayton #define RESOLVED_VARIABLES              (GOT_FRAME_BASE << 1)
407c0962dcSSean Callanan #define RESOLVED_GLOBAL_VARIABLES       (RESOLVED_VARIABLES << 1)
4130fdc8d8SChris Lattner 
42d9e416c0SGreg Clayton StackFrame::StackFrame (const ThreadSP &thread_sp,
43d9e416c0SGreg Clayton                         user_id_t frame_idx,
444d122c40SGreg Clayton                         user_id_t unwind_frame_index,
454d122c40SGreg Clayton                         addr_t cfa,
464d122c40SGreg Clayton                         addr_t pc,
478f7180b1SGreg Clayton                         const SymbolContext *sc_ptr) :
48d9e416c0SGreg Clayton     m_thread_wp (thread_sp),
491b72fcb7SGreg Clayton     m_frame_index (frame_idx),
505ccbd294SGreg Clayton     m_concrete_frame_index (unwind_frame_index),
5130fdc8d8SChris Lattner     m_reg_context_sp (),
526dadd508SGreg Clayton     m_id (pc, cfa, NULL),
53e72dfb32SGreg Clayton     m_frame_code_addr (pc),
5430fdc8d8SChris Lattner     m_sc (),
5530fdc8d8SChris Lattner     m_flags (),
5630fdc8d8SChris Lattner     m_frame_base (),
5730fdc8d8SChris Lattner     m_frame_base_error (),
5830fdc8d8SChris Lattner     m_variable_list_sp (),
591a65ae11SGreg Clayton     m_variable_list_value_objects (),
601a65ae11SGreg Clayton     m_disassembly ()
6130fdc8d8SChris Lattner {
6230fdc8d8SChris Lattner     if (sc_ptr != NULL)
631b72fcb7SGreg Clayton     {
6430fdc8d8SChris Lattner         m_sc = *sc_ptr;
651b72fcb7SGreg Clayton         m_flags.Set(m_sc.GetResolvedMask ());
661b72fcb7SGreg Clayton     }
6730fdc8d8SChris Lattner }
6830fdc8d8SChris Lattner 
69d9e416c0SGreg Clayton StackFrame::StackFrame (const ThreadSP &thread_sp,
70d9e416c0SGreg Clayton                         user_id_t frame_idx,
714d122c40SGreg Clayton                         user_id_t unwind_frame_index,
721b72fcb7SGreg Clayton                         const RegisterContextSP &reg_context_sp,
734d122c40SGreg Clayton                         addr_t cfa,
744d122c40SGreg Clayton                         addr_t pc,
758f7180b1SGreg Clayton                         const SymbolContext *sc_ptr) :
76d9e416c0SGreg Clayton     m_thread_wp (thread_sp),
771b72fcb7SGreg Clayton     m_frame_index (frame_idx),
785ccbd294SGreg Clayton     m_concrete_frame_index (unwind_frame_index),
7930fdc8d8SChris Lattner     m_reg_context_sp (reg_context_sp),
806dadd508SGreg Clayton     m_id (pc, cfa, NULL),
81e72dfb32SGreg Clayton     m_frame_code_addr (pc),
8230fdc8d8SChris Lattner     m_sc (),
8330fdc8d8SChris Lattner     m_flags (),
8430fdc8d8SChris Lattner     m_frame_base (),
8530fdc8d8SChris Lattner     m_frame_base_error (),
8630fdc8d8SChris Lattner     m_variable_list_sp (),
871a65ae11SGreg Clayton     m_variable_list_value_objects (),
881a65ae11SGreg Clayton     m_disassembly ()
8930fdc8d8SChris Lattner {
9030fdc8d8SChris Lattner     if (sc_ptr != NULL)
911b72fcb7SGreg Clayton     {
9230fdc8d8SChris Lattner         m_sc = *sc_ptr;
931b72fcb7SGreg Clayton         m_flags.Set(m_sc.GetResolvedMask ());
941b72fcb7SGreg Clayton     }
951b72fcb7SGreg Clayton 
961b72fcb7SGreg Clayton     if (reg_context_sp && !m_sc.target_sp)
971b72fcb7SGreg Clayton     {
98d9e416c0SGreg Clayton         m_sc.target_sp = reg_context_sp->CalculateTarget();
99d9e416c0SGreg Clayton         if (m_sc.target_sp)
1001b72fcb7SGreg Clayton             m_flags.Set (eSymbolContextTarget);
1011b72fcb7SGreg Clayton     }
1021b72fcb7SGreg Clayton }
1031b72fcb7SGreg Clayton 
104d9e416c0SGreg Clayton StackFrame::StackFrame (const ThreadSP &thread_sp,
105d9e416c0SGreg Clayton                         user_id_t frame_idx,
1064d122c40SGreg Clayton                         user_id_t unwind_frame_index,
1071b72fcb7SGreg Clayton                         const RegisterContextSP &reg_context_sp,
1084d122c40SGreg Clayton                         addr_t cfa,
1091b72fcb7SGreg Clayton                         const Address& pc_addr,
1108f7180b1SGreg Clayton                         const SymbolContext *sc_ptr) :
111d9e416c0SGreg Clayton     m_thread_wp (thread_sp),
1121b72fcb7SGreg Clayton     m_frame_index (frame_idx),
1135ccbd294SGreg Clayton     m_concrete_frame_index (unwind_frame_index),
1141b72fcb7SGreg Clayton     m_reg_context_sp (reg_context_sp),
1151ac04c30SGreg Clayton     m_id (pc_addr.GetLoadAddress (thread_sp->CalculateTarget().get()), cfa, NULL),
11612fc3e0fSGreg Clayton     m_frame_code_addr (pc_addr),
1171b72fcb7SGreg Clayton     m_sc (),
1181b72fcb7SGreg Clayton     m_flags (),
1191b72fcb7SGreg Clayton     m_frame_base (),
1201b72fcb7SGreg Clayton     m_frame_base_error (),
1211b72fcb7SGreg Clayton     m_variable_list_sp (),
1221a65ae11SGreg Clayton     m_variable_list_value_objects (),
1231a65ae11SGreg Clayton     m_disassembly ()
1241b72fcb7SGreg Clayton {
1251b72fcb7SGreg Clayton     if (sc_ptr != NULL)
1261b72fcb7SGreg Clayton     {
1271b72fcb7SGreg Clayton         m_sc = *sc_ptr;
1281b72fcb7SGreg Clayton         m_flags.Set(m_sc.GetResolvedMask ());
1291b72fcb7SGreg Clayton     }
1301b72fcb7SGreg Clayton 
1311b72fcb7SGreg Clayton     if (m_sc.target_sp.get() == NULL && reg_context_sp)
1321b72fcb7SGreg Clayton     {
133d9e416c0SGreg Clayton         m_sc.target_sp = reg_context_sp->CalculateTarget();
134d9e416c0SGreg Clayton         if (m_sc.target_sp)
1351b72fcb7SGreg Clayton             m_flags.Set (eSymbolContextTarget);
1361b72fcb7SGreg Clayton     }
1371b72fcb7SGreg Clayton 
138e72dfb32SGreg Clayton     ModuleSP pc_module_sp (pc_addr.GetModule());
139e72dfb32SGreg Clayton     if (!m_sc.module_sp || m_sc.module_sp != pc_module_sp)
1401b72fcb7SGreg Clayton     {
141e72dfb32SGreg Clayton         if (pc_module_sp)
1421b72fcb7SGreg Clayton         {
143e72dfb32SGreg Clayton             m_sc.module_sp = pc_module_sp;
1441b72fcb7SGreg Clayton             m_flags.Set (eSymbolContextModule);
1451b72fcb7SGreg Clayton         }
146ffc1d667SGreg Clayton         else
147ffc1d667SGreg Clayton         {
148ffc1d667SGreg Clayton             m_sc.module_sp.reset();
149ffc1d667SGreg Clayton         }
1501b72fcb7SGreg Clayton     }
15130fdc8d8SChris Lattner }
15230fdc8d8SChris Lattner 
15330fdc8d8SChris Lattner 
15430fdc8d8SChris Lattner //----------------------------------------------------------------------
15530fdc8d8SChris Lattner // Destructor
15630fdc8d8SChris Lattner //----------------------------------------------------------------------
15730fdc8d8SChris Lattner StackFrame::~StackFrame()
15830fdc8d8SChris Lattner {
15930fdc8d8SChris Lattner }
16030fdc8d8SChris Lattner 
16130fdc8d8SChris Lattner StackID&
16230fdc8d8SChris Lattner StackFrame::GetStackID()
16330fdc8d8SChris Lattner {
1646dadd508SGreg Clayton     // Make sure we have resolved the StackID object's symbol context scope if
1656dadd508SGreg Clayton     // we already haven't looked it up.
16659e8fc1cSGreg Clayton 
16759e8fc1cSGreg Clayton     if (m_flags.IsClear (RESOLVED_FRAME_ID_SYMBOL_SCOPE))
16859e8fc1cSGreg Clayton     {
1692cad65a5SGreg Clayton         if (m_id.GetSymbolContextScope ())
17059e8fc1cSGreg Clayton         {
17195897c6aSGreg Clayton             // We already have a symbol context scope, we just don't have our
17295897c6aSGreg Clayton             // flag bit set.
17359e8fc1cSGreg Clayton             m_flags.Set (RESOLVED_FRAME_ID_SYMBOL_SCOPE);
17459e8fc1cSGreg Clayton         }
17559e8fc1cSGreg Clayton         else
17659e8fc1cSGreg Clayton         {
17795897c6aSGreg Clayton             // Calculate the frame block and use this for the stack ID symbol
17895897c6aSGreg Clayton             // context scope if we have one.
17995897c6aSGreg Clayton             SymbolContextScope *scope = GetFrameBlock ();
18095897c6aSGreg Clayton             if (scope == NULL)
18159e8fc1cSGreg Clayton             {
18295897c6aSGreg Clayton                 // We don't have a block, so use the symbol
18395897c6aSGreg Clayton                 if (m_flags.IsClear (eSymbolContextSymbol))
18459e8fc1cSGreg Clayton                     GetSymbolContext (eSymbolContextSymbol);
18595897c6aSGreg Clayton 
18695897c6aSGreg Clayton                 // It is ok if m_sc.symbol is NULL here
18795897c6aSGreg Clayton                 scope = m_sc.symbol;
18859e8fc1cSGreg Clayton             }
18995897c6aSGreg Clayton             // Set the symbol context scope (the accessor will set the
19095897c6aSGreg Clayton             // RESOLVED_FRAME_ID_SYMBOL_SCOPE bit in m_flags).
19195897c6aSGreg Clayton             SetSymbolContextScope (scope);
19259e8fc1cSGreg Clayton         }
19359e8fc1cSGreg Clayton     }
19430fdc8d8SChris Lattner     return m_id;
19530fdc8d8SChris Lattner }
19630fdc8d8SChris Lattner 
19759e8fc1cSGreg Clayton void
19859e8fc1cSGreg Clayton StackFrame::SetSymbolContextScope (SymbolContextScope *symbol_scope)
19959e8fc1cSGreg Clayton {
20059e8fc1cSGreg Clayton     m_flags.Set (RESOLVED_FRAME_ID_SYMBOL_SCOPE);
20159e8fc1cSGreg Clayton     m_id.SetSymbolContextScope (symbol_scope);
20259e8fc1cSGreg Clayton }
20359e8fc1cSGreg Clayton 
20434132754SGreg Clayton const Address&
2059da7bd07SGreg Clayton StackFrame::GetFrameCodeAddress()
20630fdc8d8SChris Lattner {
20759e8fc1cSGreg Clayton     if (m_flags.IsClear(RESOLVED_FRAME_CODE_ADDR) && !m_frame_code_addr.IsSectionOffset())
20830fdc8d8SChris Lattner     {
20959e8fc1cSGreg Clayton         m_flags.Set (RESOLVED_FRAME_CODE_ADDR);
21030fdc8d8SChris Lattner 
21130fdc8d8SChris Lattner         // Resolve the PC into a temporary address because if ResolveLoadAddress
21230fdc8d8SChris Lattner         // fails to resolve the address, it will clear the address object...
213d9e416c0SGreg Clayton         ThreadSP thread_sp (GetThread());
214d9e416c0SGreg Clayton         if (thread_sp)
215d9e416c0SGreg Clayton         {
216d9e416c0SGreg Clayton             TargetSP target_sp (thread_sp->CalculateTarget());
217d9e416c0SGreg Clayton             if (target_sp)
218d9e416c0SGreg Clayton             {
219d9e416c0SGreg Clayton                 if (m_frame_code_addr.SetOpcodeLoadAddress (m_frame_code_addr.GetOffset(), target_sp.get()))
22030fdc8d8SChris Lattner                 {
221e72dfb32SGreg Clayton                     ModuleSP module_sp (m_frame_code_addr.GetModule());
222e72dfb32SGreg Clayton                     if (module_sp)
22330fdc8d8SChris Lattner                     {
224e72dfb32SGreg Clayton                         m_sc.module_sp = module_sp;
22530fdc8d8SChris Lattner                         m_flags.Set(eSymbolContextModule);
22630fdc8d8SChris Lattner                     }
22730fdc8d8SChris Lattner                 }
22830fdc8d8SChris Lattner             }
22930fdc8d8SChris Lattner         }
230d9e416c0SGreg Clayton     }
23112fc3e0fSGreg Clayton     return m_frame_code_addr;
23230fdc8d8SChris Lattner }
23330fdc8d8SChris Lattner 
23430fdc8d8SChris Lattner void
23530fdc8d8SChris Lattner StackFrame::ChangePC (addr_t pc)
23630fdc8d8SChris Lattner {
237e72dfb32SGreg Clayton     m_frame_code_addr.SetRawAddress(pc);
23830fdc8d8SChris Lattner     m_sc.Clear();
23973b472d4SGreg Clayton     m_flags.Reset(0);
240d9e416c0SGreg Clayton     ThreadSP thread_sp (GetThread());
241d9e416c0SGreg Clayton     if (thread_sp)
242d9e416c0SGreg Clayton         thread_sp->ClearStackFrames ();
24330fdc8d8SChris Lattner }
24430fdc8d8SChris Lattner 
24530fdc8d8SChris Lattner const char *
24630fdc8d8SChris Lattner StackFrame::Disassemble ()
24730fdc8d8SChris Lattner {
24830fdc8d8SChris Lattner     if (m_disassembly.GetSize() == 0)
24930fdc8d8SChris Lattner     {
250d9e416c0SGreg Clayton         ExecutionContext exe_ctx (shared_from_this());
251d9e416c0SGreg Clayton         Target *target = exe_ctx.GetTargetPtr();
252d9e416c0SGreg Clayton         if (target)
253d9e416c0SGreg Clayton         {
254d9e416c0SGreg Clayton             Disassembler::Disassemble (target->GetDebugger(),
255d9e416c0SGreg Clayton                                        target->GetArchitecture(),
2561080edbcSGreg Clayton                                        NULL,
25730fdc8d8SChris Lattner                                        exe_ctx,
25830fdc8d8SChris Lattner                                        0,
25937023b06SJim Ingham                                        0,
2601da6f9d7SGreg Clayton                                        0,
26130fdc8d8SChris Lattner                                        m_disassembly);
262d9e416c0SGreg Clayton         }
26330fdc8d8SChris Lattner         if (m_disassembly.GetSize() == 0)
26430fdc8d8SChris Lattner             return NULL;
26530fdc8d8SChris Lattner     }
26630fdc8d8SChris Lattner     return m_disassembly.GetData();
26730fdc8d8SChris Lattner }
26830fdc8d8SChris Lattner 
26995897c6aSGreg Clayton Block *
27095897c6aSGreg Clayton StackFrame::GetFrameBlock ()
27195897c6aSGreg Clayton {
27295897c6aSGreg Clayton     if (m_sc.block == NULL && m_flags.IsClear (eSymbolContextBlock))
27395897c6aSGreg Clayton         GetSymbolContext (eSymbolContextBlock);
27495897c6aSGreg Clayton 
27595897c6aSGreg Clayton     if (m_sc.block)
27695897c6aSGreg Clayton     {
27795897c6aSGreg Clayton         Block *inline_block = m_sc.block->GetContainingInlinedBlock();
27895897c6aSGreg Clayton         if (inline_block)
27995897c6aSGreg Clayton         {
28095897c6aSGreg Clayton             // Use the block with the inlined function info
28195897c6aSGreg Clayton             // as the frame block we want this frame to have only the variables
28295897c6aSGreg Clayton             // for the inlined function and its non-inlined block child blocks.
28395897c6aSGreg Clayton             return inline_block;
28495897c6aSGreg Clayton         }
28595897c6aSGreg Clayton         else
28695897c6aSGreg Clayton         {
28795897c6aSGreg Clayton             // This block is not contained withing any inlined function blocks
28895897c6aSGreg Clayton             // with so we want to use the top most function block.
28995897c6aSGreg Clayton             return &m_sc.function->GetBlock (false);
29095897c6aSGreg Clayton         }
29195897c6aSGreg Clayton     }
29295897c6aSGreg Clayton     return NULL;
29395897c6aSGreg Clayton }
29495897c6aSGreg Clayton 
29530fdc8d8SChris Lattner //----------------------------------------------------------------------
29630fdc8d8SChris Lattner // Get the symbol context if we already haven't done so by resolving the
29730fdc8d8SChris Lattner // PC address as much as possible. This way when we pass around a
29830fdc8d8SChris Lattner // StackFrame object, everyone will have as much information as
29930fdc8d8SChris Lattner // possible and no one will ever have to look things up manually.
30030fdc8d8SChris Lattner //----------------------------------------------------------------------
30130fdc8d8SChris Lattner const SymbolContext&
30230fdc8d8SChris Lattner StackFrame::GetSymbolContext (uint32_t resolve_scope)
30330fdc8d8SChris Lattner {
30430fdc8d8SChris Lattner     // Copy our internal symbol context into "sc".
30573b472d4SGreg Clayton     if ((m_flags.Get() & resolve_scope) != resolve_scope)
30630fdc8d8SChris Lattner     {
30730fdc8d8SChris Lattner         // Resolve our PC to section offset if we haven't alreday done so
30830fdc8d8SChris Lattner         // and if we don't have a module. The resolved address section will
30930fdc8d8SChris Lattner         // contain the module to which it belongs
31059e8fc1cSGreg Clayton         if (!m_sc.module_sp && m_flags.IsClear(RESOLVED_FRAME_CODE_ADDR))
3119da7bd07SGreg Clayton             GetFrameCodeAddress();
31230fdc8d8SChris Lattner 
31330fdc8d8SChris Lattner         // If this is not frame zero, then we need to subtract 1 from the PC
31430fdc8d8SChris Lattner         // value when doing address lookups since the PC will be on the
31530fdc8d8SChris Lattner         // instruction following the function call instruction...
31630fdc8d8SChris Lattner 
3179da7bd07SGreg Clayton         Address lookup_addr(GetFrameCodeAddress());
3181b72fcb7SGreg Clayton         if (m_frame_index > 0 && lookup_addr.IsValid())
31930fdc8d8SChris Lattner         {
32030fdc8d8SChris Lattner             addr_t offset = lookup_addr.GetOffset();
32130fdc8d8SChris Lattner             if (offset > 0)
32230fdc8d8SChris Lattner                 lookup_addr.SetOffset(offset - 1);
32330fdc8d8SChris Lattner         }
32430fdc8d8SChris Lattner 
3259da7bd07SGreg Clayton 
3269da7bd07SGreg Clayton         uint32_t resolved = 0;
32730fdc8d8SChris Lattner         if (m_sc.module_sp)
32830fdc8d8SChris Lattner         {
32930fdc8d8SChris Lattner             // We have something in our stack frame symbol context, lets check
33030fdc8d8SChris Lattner             // if we haven't already tried to lookup one of those things. If we
33130fdc8d8SChris Lattner             // haven't then we will do the query.
3321b72fcb7SGreg Clayton 
3331b72fcb7SGreg Clayton             uint32_t actual_resolve_scope = 0;
3341b72fcb7SGreg Clayton 
3351b72fcb7SGreg Clayton             if (resolve_scope & eSymbolContextCompUnit)
3361b72fcb7SGreg Clayton             {
3371b72fcb7SGreg Clayton                 if (m_flags.IsClear (eSymbolContextCompUnit))
3381b72fcb7SGreg Clayton                 {
3391b72fcb7SGreg Clayton                     if (m_sc.comp_unit)
3409da7bd07SGreg Clayton                         resolved |= eSymbolContextCompUnit;
3411b72fcb7SGreg Clayton                     else
3421b72fcb7SGreg Clayton                         actual_resolve_scope |= eSymbolContextCompUnit;
3431b72fcb7SGreg Clayton                 }
3441b72fcb7SGreg Clayton             }
3451b72fcb7SGreg Clayton 
3461b72fcb7SGreg Clayton             if (resolve_scope & eSymbolContextFunction)
3471b72fcb7SGreg Clayton             {
3481b72fcb7SGreg Clayton                 if (m_flags.IsClear (eSymbolContextFunction))
3491b72fcb7SGreg Clayton                 {
3501b72fcb7SGreg Clayton                     if (m_sc.function)
3519da7bd07SGreg Clayton                         resolved |= eSymbolContextFunction;
3521b72fcb7SGreg Clayton                     else
3531b72fcb7SGreg Clayton                         actual_resolve_scope |= eSymbolContextFunction;
3541b72fcb7SGreg Clayton                 }
3551b72fcb7SGreg Clayton             }
3561b72fcb7SGreg Clayton 
3571b72fcb7SGreg Clayton             if (resolve_scope & eSymbolContextBlock)
3581b72fcb7SGreg Clayton             {
3591b72fcb7SGreg Clayton                 if (m_flags.IsClear (eSymbolContextBlock))
3601b72fcb7SGreg Clayton                 {
3611b72fcb7SGreg Clayton                     if (m_sc.block)
3629da7bd07SGreg Clayton                         resolved |= eSymbolContextBlock;
3631b72fcb7SGreg Clayton                     else
3641b72fcb7SGreg Clayton                         actual_resolve_scope |= eSymbolContextBlock;
3651b72fcb7SGreg Clayton                 }
3661b72fcb7SGreg Clayton             }
3671b72fcb7SGreg Clayton 
3681b72fcb7SGreg Clayton             if (resolve_scope & eSymbolContextSymbol)
3691b72fcb7SGreg Clayton             {
3701b72fcb7SGreg Clayton                 if (m_flags.IsClear (eSymbolContextSymbol))
3711b72fcb7SGreg Clayton                 {
3721b72fcb7SGreg Clayton                     if (m_sc.symbol)
3739da7bd07SGreg Clayton                         resolved |= eSymbolContextSymbol;
3741b72fcb7SGreg Clayton                     else
3751b72fcb7SGreg Clayton                         actual_resolve_scope |= eSymbolContextSymbol;
3761b72fcb7SGreg Clayton                 }
3771b72fcb7SGreg Clayton             }
3781b72fcb7SGreg Clayton 
3791b72fcb7SGreg Clayton             if (resolve_scope & eSymbolContextLineEntry)
3801b72fcb7SGreg Clayton             {
3811b72fcb7SGreg Clayton                 if (m_flags.IsClear (eSymbolContextLineEntry))
3821b72fcb7SGreg Clayton                 {
3831b72fcb7SGreg Clayton                     if (m_sc.line_entry.IsValid())
3849da7bd07SGreg Clayton                         resolved |= eSymbolContextLineEntry;
3851b72fcb7SGreg Clayton                     else
3861b72fcb7SGreg Clayton                         actual_resolve_scope |= eSymbolContextLineEntry;
3871b72fcb7SGreg Clayton                 }
3881b72fcb7SGreg Clayton             }
3891b72fcb7SGreg Clayton 
3901b72fcb7SGreg Clayton             if (actual_resolve_scope)
39130fdc8d8SChris Lattner             {
39230fdc8d8SChris Lattner                 // We might be resolving less information than what is already
39330fdc8d8SChris Lattner                 // in our current symbol context so resolve into a temporary
39430fdc8d8SChris Lattner                 // symbol context "sc" so we don't clear out data we have
39530fdc8d8SChris Lattner                 // already found in "m_sc"
39630fdc8d8SChris Lattner                 SymbolContext sc;
39730fdc8d8SChris Lattner                 // Set flags that indicate what we have tried to resolve
3989da7bd07SGreg Clayton                 resolved |= m_sc.module_sp->ResolveSymbolContextForAddress (lookup_addr, actual_resolve_scope, sc);
3991b72fcb7SGreg Clayton                 // Only replace what we didn't already have as we may have
4001b72fcb7SGreg Clayton                 // information for an inlined function scope that won't match
4011b72fcb7SGreg Clayton                 // what a standard lookup by address would match
4029da7bd07SGreg Clayton                 if ((resolved & eSymbolContextCompUnit)  && m_sc.comp_unit == NULL)
4039da7bd07SGreg Clayton                     m_sc.comp_unit = sc.comp_unit;
4049da7bd07SGreg Clayton                 if ((resolved & eSymbolContextFunction)  && m_sc.function == NULL)
4059da7bd07SGreg Clayton                     m_sc.function = sc.function;
4069da7bd07SGreg Clayton                 if ((resolved & eSymbolContextBlock)     && m_sc.block == NULL)
4079da7bd07SGreg Clayton                     m_sc.block = sc.block;
4089da7bd07SGreg Clayton                 if ((resolved & eSymbolContextSymbol)    && m_sc.symbol == NULL)
4099da7bd07SGreg Clayton                     m_sc.symbol = sc.symbol;
4109da7bd07SGreg Clayton                 if ((resolved & eSymbolContextLineEntry) && !m_sc.line_entry.IsValid())
4119da7bd07SGreg Clayton                     m_sc.line_entry = sc.line_entry;
4129da7bd07SGreg Clayton 
41330fdc8d8SChris Lattner             }
41430fdc8d8SChris Lattner         }
41530fdc8d8SChris Lattner         else
41630fdc8d8SChris Lattner         {
41730fdc8d8SChris Lattner             // If we don't have a module, then we can't have the compile unit,
41830fdc8d8SChris Lattner             // function, block, line entry or symbol, so we can safely call
41930fdc8d8SChris Lattner             // ResolveSymbolContextForAddress with our symbol context member m_sc.
420d9e416c0SGreg Clayton             TargetSP target_sp (CalculateTarget());
421d9e416c0SGreg Clayton             if (target_sp)
422d9e416c0SGreg Clayton                 resolved |= target_sp->GetImages().ResolveSymbolContextForAddress (lookup_addr, resolve_scope, m_sc);
42330fdc8d8SChris Lattner         }
42430fdc8d8SChris Lattner 
42530fdc8d8SChris Lattner         // If the target was requested add that:
426d9e416c0SGreg Clayton         if (!m_sc.target_sp)
4279da7bd07SGreg Clayton         {
428d9e416c0SGreg Clayton             m_sc.target_sp = CalculateTarget();
4299da7bd07SGreg Clayton             if (m_sc.target_sp)
4309da7bd07SGreg Clayton                 resolved |= eSymbolContextTarget;
4319da7bd07SGreg Clayton         }
43230fdc8d8SChris Lattner 
43330fdc8d8SChris Lattner         // Update our internal flags so we remember what we have tried to locate so
43430fdc8d8SChris Lattner         // we don't have to keep trying when more calls to this function are made.
4359da7bd07SGreg Clayton         // We might have dug up more information that was requested (for example
4369da7bd07SGreg Clayton         // if we were asked to only get the block, we will have gotten the
4379da7bd07SGreg Clayton         // compile unit, and function) so set any additional bits that we resolved
4389da7bd07SGreg Clayton         m_flags.Set (resolve_scope | resolved);
43930fdc8d8SChris Lattner     }
44030fdc8d8SChris Lattner 
44130fdc8d8SChris Lattner     // Return the symbol context with everything that was possible to resolve
44230fdc8d8SChris Lattner     // resolved.
44330fdc8d8SChris Lattner     return m_sc;
44430fdc8d8SChris Lattner }
44530fdc8d8SChris Lattner 
44630fdc8d8SChris Lattner 
44730fdc8d8SChris Lattner VariableList *
448288bdf9cSGreg Clayton StackFrame::GetVariableList (bool get_file_globals)
44930fdc8d8SChris Lattner {
45030fdc8d8SChris Lattner     if (m_flags.IsClear(RESOLVED_VARIABLES))
45130fdc8d8SChris Lattner     {
45230fdc8d8SChris Lattner         m_flags.Set(RESOLVED_VARIABLES);
45330fdc8d8SChris Lattner 
45495897c6aSGreg Clayton         Block *frame_block = GetFrameBlock();
455288bdf9cSGreg Clayton 
45695897c6aSGreg Clayton         if (frame_block)
45730fdc8d8SChris Lattner         {
45895897c6aSGreg Clayton             const bool get_child_variables = true;
45995897c6aSGreg Clayton             const bool can_create = true;
460c662ec8bSGreg Clayton             const bool stop_if_child_block_is_inlined_function = true;
461c662ec8bSGreg Clayton             m_variable_list_sp.reset(new VariableList());
462c662ec8bSGreg Clayton             frame_block->AppendBlockVariables(can_create, get_child_variables, stop_if_child_block_is_inlined_function, m_variable_list_sp.get());
46330fdc8d8SChris Lattner         }
4647c0962dcSSean Callanan     }
465288bdf9cSGreg Clayton 
4667c0962dcSSean Callanan     if (m_flags.IsClear(RESOLVED_GLOBAL_VARIABLES) &&
4677c0962dcSSean Callanan         get_file_globals)
46895897c6aSGreg Clayton     {
4697c0962dcSSean Callanan         m_flags.Set(RESOLVED_GLOBAL_VARIABLES);
4707c0962dcSSean Callanan 
47195897c6aSGreg Clayton         if (m_flags.IsClear (eSymbolContextCompUnit))
47295897c6aSGreg Clayton             GetSymbolContext (eSymbolContextCompUnit);
47395897c6aSGreg Clayton 
47495897c6aSGreg Clayton         if (m_sc.comp_unit)
475288bdf9cSGreg Clayton         {
476288bdf9cSGreg Clayton             VariableListSP global_variable_list_sp (m_sc.comp_unit->GetVariableList(true));
477288bdf9cSGreg Clayton             if (m_variable_list_sp)
478288bdf9cSGreg Clayton                 m_variable_list_sp->AddVariables (global_variable_list_sp.get());
479288bdf9cSGreg Clayton             else
480288bdf9cSGreg Clayton                 m_variable_list_sp = global_variable_list_sp;
481288bdf9cSGreg Clayton         }
48230fdc8d8SChris Lattner     }
4837c0962dcSSean Callanan 
48430fdc8d8SChris Lattner     return m_variable_list_sp.get();
48530fdc8d8SChris Lattner }
48630fdc8d8SChris Lattner 
487d41f032aSGreg Clayton VariableListSP
488d41f032aSGreg Clayton StackFrame::GetInScopeVariableList (bool get_file_globals)
489d41f032aSGreg Clayton {
490d41f032aSGreg Clayton     VariableListSP var_list_sp(new VariableList);
491d41f032aSGreg Clayton     GetSymbolContext (eSymbolContextCompUnit | eSymbolContextBlock);
492d41f032aSGreg Clayton 
493d41f032aSGreg Clayton     if (m_sc.block)
494d41f032aSGreg Clayton     {
495d41f032aSGreg Clayton         const bool can_create = true;
496d41f032aSGreg Clayton         const bool get_parent_variables = true;
497d41f032aSGreg Clayton         const bool stop_if_block_is_inlined_function = true;
498d41f032aSGreg Clayton         m_sc.block->AppendVariables (can_create,
499d41f032aSGreg Clayton                                      get_parent_variables,
500d41f032aSGreg Clayton                                      stop_if_block_is_inlined_function,
501d41f032aSGreg Clayton                                      var_list_sp.get());
502d41f032aSGreg Clayton     }
503d41f032aSGreg Clayton 
504d41f032aSGreg Clayton     if (m_sc.comp_unit)
505d41f032aSGreg Clayton     {
506d41f032aSGreg Clayton         VariableListSP global_variable_list_sp (m_sc.comp_unit->GetVariableList(true));
507d41f032aSGreg Clayton         if (global_variable_list_sp)
508d41f032aSGreg Clayton             var_list_sp->AddVariables (global_variable_list_sp.get());
509d41f032aSGreg Clayton     }
510d41f032aSGreg Clayton 
511d41f032aSGreg Clayton     return var_list_sp;
512d41f032aSGreg Clayton }
513d41f032aSGreg Clayton 
514d41f032aSGreg Clayton 
5158b2fe6dcSGreg Clayton ValueObjectSP
5162837b766SJim Ingham StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr,
5174d122c40SGreg Clayton                                                DynamicValueType use_dynamic,
5182837b766SJim Ingham                                                uint32_t options,
5194d122c40SGreg Clayton                                                VariableSP &var_sp,
5202837b766SJim Ingham                                                Error &error)
5218b2fe6dcSGreg Clayton {
52254979cddSGreg Clayton 
52354979cddSGreg Clayton     if (var_expr_cstr && var_expr_cstr[0])
52454979cddSGreg Clayton     {
5256d5e68eaSGreg Clayton         const bool check_ptr_vs_member = (options & eExpressionPathOptionCheckPtrVsMember) != 0;
5266d5e68eaSGreg Clayton         const bool no_fragile_ivar = (options & eExpressionPathOptionsNoFragileObjcIvar) != 0;
52727b625e1SEnrico Granata         const bool no_synth_child = (options & eExpressionPathOptionsNoSyntheticChildren) != 0;
52858ad3344SEnrico Granata         //const bool no_synth_array = (options & eExpressionPathOptionsNoSyntheticArrayRange) != 0;
52954979cddSGreg Clayton         error.Clear();
5308b2fe6dcSGreg Clayton         bool deref = false;
5318b2fe6dcSGreg Clayton         bool address_of = false;
5328b2fe6dcSGreg Clayton         ValueObjectSP valobj_sp;
5338b2fe6dcSGreg Clayton         const bool get_file_globals = true;
534d41f032aSGreg Clayton         // When looking up a variable for an expression, we need only consider the
535d41f032aSGreg Clayton         // variables that are in scope.
536d41f032aSGreg Clayton         VariableListSP var_list_sp (GetInScopeVariableList (get_file_globals));
537d41f032aSGreg Clayton         VariableList *variable_list = var_list_sp.get();
5388b2fe6dcSGreg Clayton 
5398b2fe6dcSGreg Clayton         if (variable_list)
5408b2fe6dcSGreg Clayton         {
5418b2fe6dcSGreg Clayton             // If first character is a '*', then show pointer contents
54254979cddSGreg Clayton             const char *var_expr = var_expr_cstr;
5438b2fe6dcSGreg Clayton             if (var_expr[0] == '*')
5448b2fe6dcSGreg Clayton             {
5458b2fe6dcSGreg Clayton                 deref = true;
5468b2fe6dcSGreg Clayton                 var_expr++; // Skip the '*'
5478b2fe6dcSGreg Clayton             }
5488b2fe6dcSGreg Clayton             else if (var_expr[0] == '&')
5498b2fe6dcSGreg Clayton             {
5508b2fe6dcSGreg Clayton                 address_of = true;
5518b2fe6dcSGreg Clayton                 var_expr++; // Skip the '&'
5528b2fe6dcSGreg Clayton             }
5538b2fe6dcSGreg Clayton 
5548b2fe6dcSGreg Clayton             std::string var_path (var_expr);
55554979cddSGreg Clayton             size_t separator_idx = var_path.find_first_of(".-[=+~|&^%#@!/?,<>{}");
55654979cddSGreg Clayton             StreamString var_expr_path_strm;
5578b2fe6dcSGreg Clayton 
5588b2fe6dcSGreg Clayton             ConstString name_const_string;
5598b2fe6dcSGreg Clayton             if (separator_idx == std::string::npos)
5608b2fe6dcSGreg Clayton                 name_const_string.SetCString (var_path.c_str());
5618b2fe6dcSGreg Clayton             else
5628b2fe6dcSGreg Clayton                 name_const_string.SetCStringWithLength (var_path.c_str(), separator_idx);
5638b2fe6dcSGreg Clayton 
5642837b766SJim Ingham             var_sp = variable_list->FindVariable(name_const_string);
5658b2fe6dcSGreg Clayton             if (var_sp)
5668b2fe6dcSGreg Clayton             {
5672837b766SJim Ingham                 valobj_sp = GetValueObjectForFrameVariable (var_sp, use_dynamic);
56878a685aaSJim Ingham                 if (!valobj_sp)
56978a685aaSJim Ingham                     return valobj_sp;
5708b2fe6dcSGreg Clayton 
5718b2fe6dcSGreg Clayton                 var_path.erase (0, name_const_string.GetLength ());
5728b2fe6dcSGreg Clayton                 // We are dumping at least one child
5738b2fe6dcSGreg Clayton                 while (separator_idx != std::string::npos)
5748b2fe6dcSGreg Clayton                 {
5758b2fe6dcSGreg Clayton                     // Calculate the next separator index ahead of time
5768b2fe6dcSGreg Clayton                     ValueObjectSP child_valobj_sp;
5778b2fe6dcSGreg Clayton                     const char separator_type = var_path[0];
5788b2fe6dcSGreg Clayton                     switch (separator_type)
5798b2fe6dcSGreg Clayton                     {
5808b2fe6dcSGreg Clayton 
5818b2fe6dcSGreg Clayton                     case '-':
5828b2fe6dcSGreg Clayton                         if (var_path.size() >= 2 && var_path[1] != '>')
5838b2fe6dcSGreg Clayton                             return ValueObjectSP();
5848b2fe6dcSGreg Clayton 
5856d5e68eaSGreg Clayton                         if (no_fragile_ivar)
5866d5e68eaSGreg Clayton                         {
5876d5e68eaSGreg Clayton                             // Make sure we aren't trying to deref an objective
5886d5e68eaSGreg Clayton                             // C ivar if this is not allowed
5896d5e68eaSGreg Clayton                             const uint32_t pointer_type_flags = ClangASTContext::GetTypeInfo (valobj_sp->GetClangType(), NULL, NULL);
5906d5e68eaSGreg Clayton                             if ((pointer_type_flags & ClangASTContext::eTypeIsObjC) &&
5916d5e68eaSGreg Clayton                                 (pointer_type_flags & ClangASTContext::eTypeIsPointer))
5926d5e68eaSGreg Clayton                             {
5936d5e68eaSGreg Clayton                                 // This was an objective C object pointer and
5946d5e68eaSGreg Clayton                                 // it was requested we skip any fragile ivars
5956d5e68eaSGreg Clayton                                 // so return nothing here
5966d5e68eaSGreg Clayton                                 return ValueObjectSP();
5976d5e68eaSGreg Clayton                             }
5986d5e68eaSGreg Clayton                         }
5998b2fe6dcSGreg Clayton                         var_path.erase (0, 1); // Remove the '-'
6008b2fe6dcSGreg Clayton                         // Fall through
6018b2fe6dcSGreg Clayton                     case '.':
6028b2fe6dcSGreg Clayton                         {
60354979cddSGreg Clayton                             const bool expr_is_ptr = var_path[0] == '>';
6048b2fe6dcSGreg Clayton 
6058b2fe6dcSGreg Clayton                             var_path.erase (0, 1); // Remove the '.' or '>'
6068b2fe6dcSGreg Clayton                             separator_idx = var_path.find_first_of(".-[");
6078b2fe6dcSGreg Clayton                             ConstString child_name;
6088b2fe6dcSGreg Clayton                             if (separator_idx == std::string::npos)
6098b2fe6dcSGreg Clayton                                 child_name.SetCString (var_path.c_str());
6108b2fe6dcSGreg Clayton                             else
6118b2fe6dcSGreg Clayton                                 child_name.SetCStringWithLength(var_path.c_str(), separator_idx);
6128b2fe6dcSGreg Clayton 
61354979cddSGreg Clayton                             if (check_ptr_vs_member)
61454979cddSGreg Clayton                             {
61554979cddSGreg Clayton                                 // We either have a pointer type and need to verify
61654979cddSGreg Clayton                                 // valobj_sp is a pointer, or we have a member of a
61754979cddSGreg Clayton                                 // class/union/struct being accessed with the . syntax
61854979cddSGreg Clayton                                 // and need to verify we don't have a pointer.
61954979cddSGreg Clayton                                 const bool actual_is_ptr = valobj_sp->IsPointerType ();
62054979cddSGreg Clayton 
62154979cddSGreg Clayton                                 if (actual_is_ptr != expr_is_ptr)
62254979cddSGreg Clayton                                 {
62354979cddSGreg Clayton                                     // Incorrect use of "." with a pointer, or "->" with
62454979cddSGreg Clayton                                     // a class/union/struct instance or reference.
6256beaaa68SGreg Clayton                                     valobj_sp->GetExpressionPath (var_expr_path_strm, false);
62654979cddSGreg Clayton                                     if (actual_is_ptr)
62754979cddSGreg Clayton                                         error.SetErrorStringWithFormat ("\"%s\" is a pointer and . was used to attempt to access \"%s\". Did you mean \"%s->%s\"?",
62854979cddSGreg Clayton                                                                         var_expr_path_strm.GetString().c_str(),
62954979cddSGreg Clayton                                                                         child_name.GetCString(),
63054979cddSGreg Clayton                                                                         var_expr_path_strm.GetString().c_str(),
63154979cddSGreg Clayton                                                                         var_path.c_str());
63254979cddSGreg Clayton                                     else
63354979cddSGreg Clayton                                         error.SetErrorStringWithFormat ("\"%s\" is not a pointer and -> was used to attempt to access \"%s\". Did you mean \"%s.%s\"?",
63454979cddSGreg Clayton                                                                         var_expr_path_strm.GetString().c_str(),
63554979cddSGreg Clayton                                                                         child_name.GetCString(),
63654979cddSGreg Clayton                                                                         var_expr_path_strm.GetString().c_str(),
63754979cddSGreg Clayton                                                                         var_path.c_str());
63854979cddSGreg Clayton                                     return ValueObjectSP();
63954979cddSGreg Clayton                                 }
64054979cddSGreg Clayton                             }
6418b2fe6dcSGreg Clayton                             child_valobj_sp = valobj_sp->GetChildMemberWithName (child_name, true);
6428b2fe6dcSGreg Clayton                             if (!child_valobj_sp)
6438b2fe6dcSGreg Clayton                             {
6448c9d3560SEnrico Granata                                 if (no_synth_child == false)
64586cc9829SEnrico Granata                                 {
64686cc9829SEnrico Granata                                     child_valobj_sp = valobj_sp->GetSyntheticValue();
64786cc9829SEnrico Granata                                     if (child_valobj_sp)
64886cc9829SEnrico Granata                                         child_valobj_sp = child_valobj_sp->GetChildMemberWithName (child_name, true);
64986cc9829SEnrico Granata                                 }
6508c9d3560SEnrico Granata 
6518c9d3560SEnrico Granata                                 if (no_synth_child || !child_valobj_sp)
6528c9d3560SEnrico Granata                                 {
6538b2fe6dcSGreg Clayton                                     // No child member with name "child_name"
6546beaaa68SGreg Clayton                                     valobj_sp->GetExpressionPath (var_expr_path_strm, false);
65554979cddSGreg Clayton                                     if (child_name)
65654979cddSGreg Clayton                                     {
65754979cddSGreg Clayton                                         error.SetErrorStringWithFormat ("\"%s\" is not a member of \"(%s) %s\"",
65854979cddSGreg Clayton                                                                         child_name.GetCString(),
65954979cddSGreg Clayton                                                                         valobj_sp->GetTypeName().AsCString("<invalid type>"),
66054979cddSGreg Clayton                                                                         var_expr_path_strm.GetString().c_str());
66154979cddSGreg Clayton                                     }
66254979cddSGreg Clayton                                     else
66354979cddSGreg Clayton                                     {
66454979cddSGreg Clayton                                         error.SetErrorStringWithFormat ("incomplete expression path after \"%s\" in \"%s\"",
66554979cddSGreg Clayton                                                                         var_expr_path_strm.GetString().c_str(),
66654979cddSGreg Clayton                                                                         var_expr_cstr);
66754979cddSGreg Clayton                                     }
6688b2fe6dcSGreg Clayton                                     return ValueObjectSP();
6698b2fe6dcSGreg Clayton                                 }
6708c9d3560SEnrico Granata                             }
6718b2fe6dcSGreg Clayton                             // Remove the child name from the path
6728b2fe6dcSGreg Clayton                             var_path.erase(0, child_name.GetLength());
6734d122c40SGreg Clayton                             if (use_dynamic != eNoDynamicValues)
67478a685aaSJim Ingham                             {
6752837b766SJim Ingham                                 ValueObjectSP dynamic_value_sp(child_valobj_sp->GetDynamicValue(use_dynamic));
67678a685aaSJim Ingham                                 if (dynamic_value_sp)
67778a685aaSJim Ingham                                     child_valobj_sp = dynamic_value_sp;
67878a685aaSJim Ingham                             }
6798b2fe6dcSGreg Clayton                         }
6808b2fe6dcSGreg Clayton                         break;
6818b2fe6dcSGreg Clayton 
6828b2fe6dcSGreg Clayton                     case '[':
6838b2fe6dcSGreg Clayton                         // Array member access, or treating pointer as an array
6848b2fe6dcSGreg Clayton                         if (var_path.size() > 2) // Need at least two brackets and a number
6858b2fe6dcSGreg Clayton                         {
6868b2fe6dcSGreg Clayton                             char *end = NULL;
6871a65ae11SGreg Clayton                             long child_index = ::strtol (&var_path[1], &end, 0);
6889fc1944eSEnrico Granata                             if (end && *end == ']'
6899fc1944eSEnrico 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
6908b2fe6dcSGreg Clayton                             {
6919fc1944eSEnrico Granata                                 if (ClangASTContext::IsPointerToScalarType(valobj_sp->GetClangType()) && deref)
6929fc1944eSEnrico Granata                                 {
6939fc1944eSEnrico Granata                                     // what we have is *ptr[low]. the most similar C++ syntax is to deref ptr
6949fc1944eSEnrico Granata                                     // and extract bit low out of it. reading array item low
6959fc1944eSEnrico Granata                                     // would be done by saying ptr[low], without a deref * sign
6969fc1944eSEnrico Granata                                     Error error;
6979fc1944eSEnrico Granata                                     ValueObjectSP temp(valobj_sp->Dereference(error));
6989fc1944eSEnrico Granata                                     if (error.Fail())
6999fc1944eSEnrico Granata                                     {
7009fc1944eSEnrico Granata                                         valobj_sp->GetExpressionPath (var_expr_path_strm, false);
7019fc1944eSEnrico Granata                                         error.SetErrorStringWithFormat ("could not dereference \"(%s) %s\"",
7029fc1944eSEnrico Granata                                                                         valobj_sp->GetTypeName().AsCString("<invalid type>"),
7039fc1944eSEnrico Granata                                                                         var_expr_path_strm.GetString().c_str());
7049fc1944eSEnrico Granata                                         return ValueObjectSP();
7059fc1944eSEnrico Granata                                     }
7069fc1944eSEnrico Granata                                     valobj_sp = temp;
7079fc1944eSEnrico Granata                                     deref = false;
7089fc1944eSEnrico Granata                                 }
7099fc1944eSEnrico Granata                                 else if (ClangASTContext::IsArrayOfScalarType(valobj_sp->GetClangType()) && deref)
7109fc1944eSEnrico Granata                                 {
7119fc1944eSEnrico Granata                                     // what we have is *arr[low]. the most similar C++ syntax is to get arr[0]
7129fc1944eSEnrico Granata                                     // (an operation that is equivalent to deref-ing arr)
7139fc1944eSEnrico Granata                                     // and extract bit low out of it. reading array item low
7149fc1944eSEnrico Granata                                     // would be done by saying arr[low], without a deref * sign
7159fc1944eSEnrico Granata                                     Error error;
7169fc1944eSEnrico Granata                                     ValueObjectSP temp(valobj_sp->GetChildAtIndex (0, true));
7179fc1944eSEnrico Granata                                     if (error.Fail())
7189fc1944eSEnrico Granata                                     {
7199fc1944eSEnrico Granata                                         valobj_sp->GetExpressionPath (var_expr_path_strm, false);
7209fc1944eSEnrico Granata                                         error.SetErrorStringWithFormat ("could not get item 0 for \"(%s) %s\"",
7219fc1944eSEnrico Granata                                                                         valobj_sp->GetTypeName().AsCString("<invalid type>"),
7229fc1944eSEnrico Granata                                                                         var_expr_path_strm.GetString().c_str());
7239fc1944eSEnrico Granata                                         return ValueObjectSP();
7249fc1944eSEnrico Granata                                     }
7259fc1944eSEnrico Granata                                     valobj_sp = temp;
7269fc1944eSEnrico Granata                                     deref = false;
7279fc1944eSEnrico Granata                                 }
7288b2fe6dcSGreg Clayton 
7298b2fe6dcSGreg Clayton                                 if (valobj_sp->IsPointerType ())
7308b2fe6dcSGreg Clayton                                 {
731226b70c1SSean Callanan                                     bool is_objc_pointer = true;
732226b70c1SSean Callanan 
733226b70c1SSean Callanan                                     if (ClangASTType::GetMinimumLanguage(valobj_sp->GetClangAST(), valobj_sp->GetClangType()) != eLanguageTypeObjC)
734226b70c1SSean Callanan                                         is_objc_pointer = false;
735226b70c1SSean Callanan                                     else if (!ClangASTContext::IsPointerType(valobj_sp->GetClangType()))
736226b70c1SSean Callanan                                         is_objc_pointer = false;
737226b70c1SSean Callanan 
738226b70c1SSean Callanan                                     if (no_synth_child && is_objc_pointer)
739226b70c1SSean Callanan                                     {
740226b70c1SSean Callanan                                         error.SetErrorStringWithFormat("\"(%s) %s\" is an Objective-C pointer, and cannot be subscripted",
741226b70c1SSean Callanan                                                                        valobj_sp->GetTypeName().AsCString("<invalid type>"),
742226b70c1SSean Callanan                                                                        var_expr_path_strm.GetString().c_str());
743226b70c1SSean Callanan 
744226b70c1SSean Callanan                                         return ValueObjectSP();
745226b70c1SSean Callanan                                     }
746226b70c1SSean Callanan                                     else if (is_objc_pointer)
74727b625e1SEnrico Granata                                     {
74827b625e1SEnrico Granata                                         // dereferencing ObjC variables is not valid.. so let's try and recur to synthetic children
74986cc9829SEnrico Granata                                         ValueObjectSP synthetic = valobj_sp->GetSyntheticValue();
75027b625e1SEnrico Granata                                         if (synthetic.get() == NULL /* no synthetic */
75127b625e1SEnrico Granata                                             || synthetic == valobj_sp) /* synthetic is the same as the original object */
75227b625e1SEnrico Granata                                         {
75327b625e1SEnrico Granata                                             valobj_sp->GetExpressionPath (var_expr_path_strm, false);
75427b625e1SEnrico Granata                                             error.SetErrorStringWithFormat ("\"(%s) %s\" is not an array type",
75527b625e1SEnrico Granata                                                                             valobj_sp->GetTypeName().AsCString("<invalid type>"),
75627b625e1SEnrico Granata                                                                             var_expr_path_strm.GetString().c_str());
75727b625e1SEnrico Granata                                         }
75827b625e1SEnrico Granata                                         else if (child_index >= synthetic->GetNumChildren() /* synthetic does not have that many values */)
75927b625e1SEnrico Granata                                         {
76027b625e1SEnrico Granata                                             valobj_sp->GetExpressionPath (var_expr_path_strm, false);
7617e589a60SJason Molenda                                             error.SetErrorStringWithFormat ("array index %ld is not valid for \"(%s) %s\"",
76227b625e1SEnrico Granata                                                                             child_index,
76327b625e1SEnrico Granata                                                                             valobj_sp->GetTypeName().AsCString("<invalid type>"),
76427b625e1SEnrico Granata                                                                             var_expr_path_strm.GetString().c_str());
76527b625e1SEnrico Granata                                         }
76627b625e1SEnrico Granata                                         else
76727b625e1SEnrico Granata                                         {
76827b625e1SEnrico Granata                                             child_valobj_sp = synthetic->GetChildAtIndex(child_index, true);
76927b625e1SEnrico Granata                                             if (!child_valobj_sp)
77027b625e1SEnrico Granata                                             {
77127b625e1SEnrico Granata                                                 valobj_sp->GetExpressionPath (var_expr_path_strm, false);
7727e589a60SJason Molenda                                                 error.SetErrorStringWithFormat ("array index %ld is not valid for \"(%s) %s\"",
77327b625e1SEnrico Granata                                                                                 child_index,
77427b625e1SEnrico Granata                                                                                 valobj_sp->GetTypeName().AsCString("<invalid type>"),
77527b625e1SEnrico Granata                                                                                 var_expr_path_strm.GetString().c_str());
77627b625e1SEnrico Granata                                             }
77727b625e1SEnrico Granata                                         }
77827b625e1SEnrico Granata                                     }
77927b625e1SEnrico Granata                                     else
78027b625e1SEnrico Granata                                     {
7818b2fe6dcSGreg Clayton                                         child_valobj_sp = valobj_sp->GetSyntheticArrayMemberFromPointer (child_index, true);
78254979cddSGreg Clayton                                         if (!child_valobj_sp)
78354979cddSGreg Clayton                                         {
7846beaaa68SGreg Clayton                                             valobj_sp->GetExpressionPath (var_expr_path_strm, false);
7857e589a60SJason Molenda                                             error.SetErrorStringWithFormat ("failed to use pointer as array for index %ld for \"(%s) %s\"",
78654979cddSGreg Clayton                                                                             child_index,
78754979cddSGreg Clayton                                                                             valobj_sp->GetTypeName().AsCString("<invalid type>"),
78854979cddSGreg Clayton                                                                             var_expr_path_strm.GetString().c_str());
78954979cddSGreg Clayton                                         }
79054979cddSGreg Clayton                                     }
79127b625e1SEnrico Granata                                 }
79254979cddSGreg Clayton                                 else if (ClangASTContext::IsArrayType (valobj_sp->GetClangType(), NULL, NULL))
79354979cddSGreg Clayton                                 {
79478a685aaSJim Ingham                                     // Pass false to dynamic_value here so we can tell the difference between
79578a685aaSJim Ingham                                     // no dynamic value and no member of this type...
79654979cddSGreg Clayton                                     child_valobj_sp = valobj_sp->GetChildAtIndex (child_index, true);
79754979cddSGreg Clayton                                     if (!child_valobj_sp)
79854979cddSGreg Clayton                                     {
7996beaaa68SGreg Clayton                                         valobj_sp->GetExpressionPath (var_expr_path_strm, false);
8007e589a60SJason Molenda                                         error.SetErrorStringWithFormat ("array index %ld is not valid for \"(%s) %s\"",
80154979cddSGreg Clayton                                                                         child_index,
80254979cddSGreg Clayton                                                                         valobj_sp->GetTypeName().AsCString("<invalid type>"),
80354979cddSGreg Clayton                                                                         var_expr_path_strm.GetString().c_str());
80454979cddSGreg Clayton                                     }
8058b2fe6dcSGreg Clayton                                 }
8069fc1944eSEnrico Granata                                 else if (ClangASTContext::IsScalarType(valobj_sp->GetClangType()))
8079fc1944eSEnrico Granata                                 {
8089fc1944eSEnrico Granata                                     // this is a bitfield asking to display just one bit
8099fc1944eSEnrico Granata                                     child_valobj_sp = valobj_sp->GetSyntheticBitFieldChild(child_index, child_index, true);
8109fc1944eSEnrico Granata                                     if (!child_valobj_sp)
8119fc1944eSEnrico Granata                                     {
8129fc1944eSEnrico Granata                                         valobj_sp->GetExpressionPath (var_expr_path_strm, false);
8137e589a60SJason Molenda                                         error.SetErrorStringWithFormat ("bitfield range %ld-%ld is not valid for \"(%s) %s\"",
8149fc1944eSEnrico Granata                                                                         child_index, child_index,
8159fc1944eSEnrico Granata                                                                         valobj_sp->GetTypeName().AsCString("<invalid type>"),
8169fc1944eSEnrico Granata                                                                         var_expr_path_strm.GetString().c_str());
8179fc1944eSEnrico Granata                                     }
8189fc1944eSEnrico Granata                                 }
8198b2fe6dcSGreg Clayton                                 else
8208b2fe6dcSGreg Clayton                                 {
82186cc9829SEnrico Granata                                     ValueObjectSP synthetic = valobj_sp->GetSyntheticValue();
82227b625e1SEnrico Granata                                     if (no_synth_child /* synthetic is forbidden */ ||
82327b625e1SEnrico Granata                                         synthetic.get() == NULL /* no synthetic */
82427b625e1SEnrico Granata                                         || synthetic == valobj_sp) /* synthetic is the same as the original object */
82527b625e1SEnrico Granata                                     {
8266beaaa68SGreg Clayton                                         valobj_sp->GetExpressionPath (var_expr_path_strm, false);
82754979cddSGreg Clayton                                         error.SetErrorStringWithFormat ("\"(%s) %s\" is not an array type",
82854979cddSGreg Clayton                                                                         valobj_sp->GetTypeName().AsCString("<invalid type>"),
82954979cddSGreg Clayton                                                                         var_expr_path_strm.GetString().c_str());
8308b2fe6dcSGreg Clayton                                     }
83127b625e1SEnrico Granata                                     else if (child_index >= synthetic->GetNumChildren() /* synthetic does not have that many values */)
83227b625e1SEnrico Granata                                     {
83327b625e1SEnrico Granata                                         valobj_sp->GetExpressionPath (var_expr_path_strm, false);
8347e589a60SJason Molenda                                         error.SetErrorStringWithFormat ("array index %ld is not valid for \"(%s) %s\"",
83527b625e1SEnrico Granata                                                                         child_index,
83627b625e1SEnrico Granata                                                                         valobj_sp->GetTypeName().AsCString("<invalid type>"),
83727b625e1SEnrico Granata                                                                         var_expr_path_strm.GetString().c_str());
83827b625e1SEnrico Granata                                     }
83927b625e1SEnrico Granata                                     else
84027b625e1SEnrico Granata                                     {
84127b625e1SEnrico Granata                                         child_valobj_sp = synthetic->GetChildAtIndex(child_index, true);
84227b625e1SEnrico Granata                                         if (!child_valobj_sp)
84327b625e1SEnrico Granata                                         {
84427b625e1SEnrico Granata                                             valobj_sp->GetExpressionPath (var_expr_path_strm, false);
8457e589a60SJason Molenda                                             error.SetErrorStringWithFormat ("array index %ld is not valid for \"(%s) %s\"",
84627b625e1SEnrico Granata                                                                             child_index,
84727b625e1SEnrico Granata                                                                             valobj_sp->GetTypeName().AsCString("<invalid type>"),
84827b625e1SEnrico Granata                                                                             var_expr_path_strm.GetString().c_str());
84927b625e1SEnrico Granata                                         }
85027b625e1SEnrico Granata                                     }
85127b625e1SEnrico Granata                                 }
8528b2fe6dcSGreg Clayton 
8538b2fe6dcSGreg Clayton                                 if (!child_valobj_sp)
8548b2fe6dcSGreg Clayton                                 {
8558b2fe6dcSGreg Clayton                                     // Invalid array index...
8568b2fe6dcSGreg Clayton                                     return ValueObjectSP();
8578b2fe6dcSGreg Clayton                                 }
8588b2fe6dcSGreg Clayton 
8598b2fe6dcSGreg Clayton                                 // Erase the array member specification '[%i]' where
8608b2fe6dcSGreg Clayton                                 // %i is the array index
8618b2fe6dcSGreg Clayton                                 var_path.erase(0, (end - var_path.c_str()) + 1);
8628b2fe6dcSGreg Clayton                                 separator_idx = var_path.find_first_of(".-[");
8634d122c40SGreg Clayton                                 if (use_dynamic != eNoDynamicValues)
86478a685aaSJim Ingham                                 {
8652837b766SJim Ingham                                     ValueObjectSP dynamic_value_sp(child_valobj_sp->GetDynamicValue(use_dynamic));
86678a685aaSJim Ingham                                     if (dynamic_value_sp)
86778a685aaSJim Ingham                                         child_valobj_sp = dynamic_value_sp;
86878a685aaSJim Ingham                                 }
8698b2fe6dcSGreg Clayton                                 // Break out early from the switch since we were
8708b2fe6dcSGreg Clayton                                 // able to find the child member
8718b2fe6dcSGreg Clayton                                 break;
8728b2fe6dcSGreg Clayton                             }
8739fc1944eSEnrico Granata                             else if (end && *end == '-')
8749fc1944eSEnrico Granata                             {
8759fc1944eSEnrico Granata                                 // this is most probably a BitField, let's take a look
8769fc1944eSEnrico Granata                                 char *real_end = NULL;
8779fc1944eSEnrico Granata                                 long final_index = ::strtol (end+1, &real_end, 0);
878d64d0bc0SEnrico Granata                                 bool expand_bitfield = true;
8799fc1944eSEnrico Granata                                 if (real_end && *real_end == ']')
8809fc1944eSEnrico Granata                                 {
8819fc1944eSEnrico Granata                                     // if the format given is [high-low], swap range
8829fc1944eSEnrico Granata                                     if (child_index > final_index)
8839fc1944eSEnrico Granata                                     {
8849fc1944eSEnrico Granata                                         long temp = child_index;
8859fc1944eSEnrico Granata                                         child_index = final_index;
8869fc1944eSEnrico Granata                                         final_index = temp;
8879fc1944eSEnrico Granata                                     }
8889fc1944eSEnrico Granata 
8899fc1944eSEnrico Granata                                     if (ClangASTContext::IsPointerToScalarType(valobj_sp->GetClangType()) && deref)
8909fc1944eSEnrico Granata                                     {
8919fc1944eSEnrico Granata                                         // what we have is *ptr[low-high]. the most similar C++ syntax is to deref ptr
8929fc1944eSEnrico Granata                                         // and extract bits low thru high out of it. reading array items low thru high
8939fc1944eSEnrico Granata                                         // would be done by saying ptr[low-high], without a deref * sign
8949fc1944eSEnrico Granata                                         Error error;
8959fc1944eSEnrico Granata                                         ValueObjectSP temp(valobj_sp->Dereference(error));
8969fc1944eSEnrico Granata                                         if (error.Fail())
8979fc1944eSEnrico Granata                                         {
8989fc1944eSEnrico Granata                                             valobj_sp->GetExpressionPath (var_expr_path_strm, false);
8999fc1944eSEnrico Granata                                             error.SetErrorStringWithFormat ("could not dereference \"(%s) %s\"",
9009fc1944eSEnrico Granata                                                                             valobj_sp->GetTypeName().AsCString("<invalid type>"),
9019fc1944eSEnrico Granata                                                                             var_expr_path_strm.GetString().c_str());
9029fc1944eSEnrico Granata                                             return ValueObjectSP();
9039fc1944eSEnrico Granata                                         }
9049fc1944eSEnrico Granata                                         valobj_sp = temp;
9059fc1944eSEnrico Granata                                         deref = false;
9069fc1944eSEnrico Granata                                     }
9079fc1944eSEnrico Granata                                     else if (ClangASTContext::IsArrayOfScalarType(valobj_sp->GetClangType()) && deref)
9089fc1944eSEnrico Granata                                     {
9099fc1944eSEnrico Granata                                         // what we have is *arr[low-high]. the most similar C++ syntax is to get arr[0]
9109fc1944eSEnrico Granata                                         // (an operation that is equivalent to deref-ing arr)
9119fc1944eSEnrico Granata                                         // and extract bits low thru high out of it. reading array items low thru high
9129fc1944eSEnrico Granata                                         // would be done by saying arr[low-high], without a deref * sign
9139fc1944eSEnrico Granata                                         Error error;
9149fc1944eSEnrico Granata                                         ValueObjectSP temp(valobj_sp->GetChildAtIndex (0, true));
9159fc1944eSEnrico Granata                                         if (error.Fail())
9169fc1944eSEnrico Granata                                         {
9179fc1944eSEnrico Granata                                             valobj_sp->GetExpressionPath (var_expr_path_strm, false);
9189fc1944eSEnrico Granata                                             error.SetErrorStringWithFormat ("could not get item 0 for \"(%s) %s\"",
9199fc1944eSEnrico Granata                                                                             valobj_sp->GetTypeName().AsCString("<invalid type>"),
9209fc1944eSEnrico Granata                                                                             var_expr_path_strm.GetString().c_str());
9219fc1944eSEnrico Granata                                             return ValueObjectSP();
9229fc1944eSEnrico Granata                                         }
9239fc1944eSEnrico Granata                                         valobj_sp = temp;
9249fc1944eSEnrico Granata                                         deref = false;
9259fc1944eSEnrico Granata                                     }
926d64d0bc0SEnrico Granata                                     /*else if (valobj_sp->IsArrayType() || valobj_sp->IsPointerType())
927d64d0bc0SEnrico Granata                                     {
928d64d0bc0SEnrico Granata                                         child_valobj_sp = valobj_sp->GetSyntheticArrayRangeChild(child_index, final_index, true);
929d64d0bc0SEnrico Granata                                         expand_bitfield = false;
930d64d0bc0SEnrico Granata                                         if (!child_valobj_sp)
931d64d0bc0SEnrico Granata                                         {
932d64d0bc0SEnrico Granata                                             valobj_sp->GetExpressionPath (var_expr_path_strm, false);
933d64d0bc0SEnrico Granata                                             error.SetErrorStringWithFormat ("array range %i-%i is not valid for \"(%s) %s\"",
934d64d0bc0SEnrico Granata                                                                             child_index, final_index,
935d64d0bc0SEnrico Granata                                                                             valobj_sp->GetTypeName().AsCString("<invalid type>"),
936d64d0bc0SEnrico Granata                                                                             var_expr_path_strm.GetString().c_str());
937d64d0bc0SEnrico Granata                                         }
938d64d0bc0SEnrico Granata                                     }*/
9399fc1944eSEnrico Granata 
940d64d0bc0SEnrico Granata                                     if (expand_bitfield)
941d64d0bc0SEnrico Granata                                     {
9429fc1944eSEnrico Granata                                         child_valobj_sp = valobj_sp->GetSyntheticBitFieldChild(child_index, final_index, true);
9439fc1944eSEnrico Granata                                         if (!child_valobj_sp)
9449fc1944eSEnrico Granata                                         {
9459fc1944eSEnrico Granata                                             valobj_sp->GetExpressionPath (var_expr_path_strm, false);
9467e589a60SJason Molenda                                             error.SetErrorStringWithFormat ("bitfield range %ld-%ld is not valid for \"(%s) %s\"",
9479fc1944eSEnrico Granata                                                                             child_index, final_index,
9489fc1944eSEnrico Granata                                                                             valobj_sp->GetTypeName().AsCString("<invalid type>"),
9499fc1944eSEnrico Granata                                                                             var_expr_path_strm.GetString().c_str());
9509fc1944eSEnrico Granata                                         }
9519fc1944eSEnrico Granata                                     }
952d64d0bc0SEnrico Granata                                 }
9539fc1944eSEnrico Granata 
9549fc1944eSEnrico Granata                                 if (!child_valobj_sp)
9559fc1944eSEnrico Granata                                 {
9569fc1944eSEnrico Granata                                     // Invalid bitfield range...
9579fc1944eSEnrico Granata                                     return ValueObjectSP();
9589fc1944eSEnrico Granata                                 }
9599fc1944eSEnrico Granata 
9609fc1944eSEnrico Granata                                 // Erase the bitfield member specification '[%i-%i]' where
9619fc1944eSEnrico Granata                                 // %i is the index
9629fc1944eSEnrico Granata                                 var_path.erase(0, (real_end - var_path.c_str()) + 1);
9639fc1944eSEnrico Granata                                 separator_idx = var_path.find_first_of(".-[");
9644d122c40SGreg Clayton                                 if (use_dynamic != eNoDynamicValues)
9659fc1944eSEnrico Granata                                 {
9669fc1944eSEnrico Granata                                     ValueObjectSP dynamic_value_sp(child_valobj_sp->GetDynamicValue(use_dynamic));
9679fc1944eSEnrico Granata                                     if (dynamic_value_sp)
9689fc1944eSEnrico Granata                                         child_valobj_sp = dynamic_value_sp;
9699fc1944eSEnrico Granata                                 }
9709fc1944eSEnrico Granata                                 // Break out early from the switch since we were
9719fc1944eSEnrico Granata                                 // able to find the child member
9729fc1944eSEnrico Granata                                 break;
9739fc1944eSEnrico Granata 
9749fc1944eSEnrico Granata                             }
9759fc1944eSEnrico Granata                         }
9769fc1944eSEnrico Granata                         else
9779fc1944eSEnrico Granata                         {
9789fc1944eSEnrico Granata                             error.SetErrorStringWithFormat("invalid square bracket encountered after \"%s\" in \"%s\"",
9799fc1944eSEnrico Granata                                                            var_expr_path_strm.GetString().c_str(),
9809fc1944eSEnrico Granata                                                            var_path.c_str());
9818b2fe6dcSGreg Clayton                         }
9828b2fe6dcSGreg Clayton                         return ValueObjectSP();
9838b2fe6dcSGreg Clayton 
9848b2fe6dcSGreg Clayton                     default:
9858b2fe6dcSGreg Clayton                         // Failure...
98654979cddSGreg Clayton                         {
9876beaaa68SGreg Clayton                             valobj_sp->GetExpressionPath (var_expr_path_strm, false);
98854979cddSGreg Clayton                             error.SetErrorStringWithFormat ("unexpected char '%c' encountered after \"%s\" in \"%s\"",
98954979cddSGreg Clayton                                                             separator_type,
99054979cddSGreg Clayton                                                             var_expr_path_strm.GetString().c_str(),
99154979cddSGreg Clayton                                                             var_path.c_str());
99254979cddSGreg Clayton 
9938b2fe6dcSGreg Clayton                             return ValueObjectSP();
9948b2fe6dcSGreg Clayton                         }
99554979cddSGreg Clayton                     }
9968b2fe6dcSGreg Clayton 
9978b2fe6dcSGreg Clayton                     if (child_valobj_sp)
9988b2fe6dcSGreg Clayton                         valobj_sp = child_valobj_sp;
9998b2fe6dcSGreg Clayton 
10008b2fe6dcSGreg Clayton                     if (var_path.empty())
10018b2fe6dcSGreg Clayton                         break;
10028b2fe6dcSGreg Clayton 
10038b2fe6dcSGreg Clayton                 }
10048b2fe6dcSGreg Clayton                 if (valobj_sp)
10058b2fe6dcSGreg Clayton                 {
10068b2fe6dcSGreg Clayton                     if (deref)
10078b2fe6dcSGreg Clayton                     {
1008af67cecdSGreg Clayton                         ValueObjectSP deref_valobj_sp (valobj_sp->Dereference(error));
10098b2fe6dcSGreg Clayton                         valobj_sp = deref_valobj_sp;
10108b2fe6dcSGreg Clayton                     }
10118b2fe6dcSGreg Clayton                     else if (address_of)
10128b2fe6dcSGreg Clayton                     {
101354979cddSGreg Clayton                         ValueObjectSP address_of_valobj_sp (valobj_sp->AddressOf(error));
10148b2fe6dcSGreg Clayton                         valobj_sp = address_of_valobj_sp;
10158b2fe6dcSGreg Clayton                     }
10168b2fe6dcSGreg Clayton                 }
10178b2fe6dcSGreg Clayton                 return valobj_sp;
10188b2fe6dcSGreg Clayton             }
101954979cddSGreg Clayton             else
102054979cddSGreg Clayton             {
10212837b766SJim Ingham                 error.SetErrorStringWithFormat("no variable named '%s' found in this frame",
10222837b766SJim Ingham                                                name_const_string.GetCString());
102354979cddSGreg Clayton             }
102454979cddSGreg Clayton         }
102554979cddSGreg Clayton     }
102654979cddSGreg Clayton     else
102754979cddSGreg Clayton     {
102854979cddSGreg Clayton         error.SetErrorStringWithFormat("invalid variable path '%s'", var_expr_cstr);
10298b2fe6dcSGreg Clayton     }
10308b2fe6dcSGreg Clayton     return ValueObjectSP();
10318b2fe6dcSGreg Clayton }
103230fdc8d8SChris Lattner 
103330fdc8d8SChris Lattner bool
103430fdc8d8SChris Lattner StackFrame::GetFrameBaseValue (Scalar &frame_base, Error *error_ptr)
103530fdc8d8SChris Lattner {
103630fdc8d8SChris Lattner     if (m_flags.IsClear(GOT_FRAME_BASE))
103730fdc8d8SChris Lattner     {
103830fdc8d8SChris Lattner         if (m_sc.function)
103930fdc8d8SChris Lattner         {
104030fdc8d8SChris Lattner             m_frame_base.Clear();
104130fdc8d8SChris Lattner             m_frame_base_error.Clear();
104230fdc8d8SChris Lattner 
104330fdc8d8SChris Lattner             m_flags.Set(GOT_FRAME_BASE);
1044d9e416c0SGreg Clayton             ExecutionContext exe_ctx (shared_from_this());
104530fdc8d8SChris Lattner             Value expr_value;
1046016a95ebSGreg Clayton             addr_t loclist_base_addr = LLDB_INVALID_ADDRESS;
1047016a95ebSGreg Clayton             if (m_sc.function->GetFrameBaseExpression().IsLocationList())
1048d9e416c0SGreg Clayton                 loclist_base_addr = m_sc.function->GetAddressRange().GetBaseAddress().GetLoadAddress (exe_ctx.GetTargetPtr());
1049016a95ebSGreg Clayton 
10501a65ae11SGreg Clayton             if (m_sc.function->GetFrameBaseExpression().Evaluate(&exe_ctx, NULL, NULL, NULL, NULL, loclist_base_addr, NULL, expr_value, &m_frame_base_error) == false)
105130fdc8d8SChris Lattner             {
105230fdc8d8SChris Lattner                 // We should really have an error if evaluate returns, but in case
105330fdc8d8SChris Lattner                 // we don't, lets set the error to something at least.
105430fdc8d8SChris Lattner                 if (m_frame_base_error.Success())
105530fdc8d8SChris Lattner                     m_frame_base_error.SetErrorString("Evaluation of the frame base expression failed.");
105630fdc8d8SChris Lattner             }
105730fdc8d8SChris Lattner             else
105830fdc8d8SChris Lattner             {
105930fdc8d8SChris Lattner                 m_frame_base = expr_value.ResolveValue(&exe_ctx, NULL);
106030fdc8d8SChris Lattner             }
106130fdc8d8SChris Lattner         }
106230fdc8d8SChris Lattner         else
106330fdc8d8SChris Lattner         {
106430fdc8d8SChris Lattner             m_frame_base_error.SetErrorString ("No function in symbol context.");
106530fdc8d8SChris Lattner         }
106630fdc8d8SChris Lattner     }
106730fdc8d8SChris Lattner 
106830fdc8d8SChris Lattner     if (m_frame_base_error.Success())
106930fdc8d8SChris Lattner         frame_base = m_frame_base;
107030fdc8d8SChris Lattner 
107130fdc8d8SChris Lattner     if (error_ptr)
107230fdc8d8SChris Lattner         *error_ptr = m_frame_base_error;
107330fdc8d8SChris Lattner     return m_frame_base_error.Success();
107430fdc8d8SChris Lattner }
107530fdc8d8SChris Lattner 
10765ccbd294SGreg Clayton RegisterContextSP
107730fdc8d8SChris Lattner StackFrame::GetRegisterContext ()
107830fdc8d8SChris Lattner {
10795ccbd294SGreg Clayton     if (!m_reg_context_sp)
1080d9e416c0SGreg Clayton     {
1081d9e416c0SGreg Clayton         ThreadSP thread_sp (GetThread());
1082d9e416c0SGreg Clayton         if (thread_sp)
1083d9e416c0SGreg Clayton             m_reg_context_sp = thread_sp->CreateRegisterContextForFrame (this);
1084d9e416c0SGreg Clayton     }
10855ccbd294SGreg Clayton     return m_reg_context_sp;
108630fdc8d8SChris Lattner }
108730fdc8d8SChris Lattner 
108830fdc8d8SChris Lattner bool
108930fdc8d8SChris Lattner StackFrame::HasDebugInformation ()
109030fdc8d8SChris Lattner {
109130fdc8d8SChris Lattner     GetSymbolContext (eSymbolContextLineEntry);
109230fdc8d8SChris Lattner     return m_sc.line_entry.IsValid();
109330fdc8d8SChris Lattner }
109430fdc8d8SChris Lattner 
1095288bdf9cSGreg Clayton 
1096288bdf9cSGreg Clayton ValueObjectSP
10974d122c40SGreg Clayton StackFrame::GetValueObjectForFrameVariable (const VariableSP &variable_sp, DynamicValueType use_dynamic)
109830fdc8d8SChris Lattner {
1099288bdf9cSGreg Clayton     ValueObjectSP valobj_sp;
1100288bdf9cSGreg Clayton     VariableList *var_list = GetVariableList (true);
1101288bdf9cSGreg Clayton     if (var_list)
1102288bdf9cSGreg Clayton     {
1103288bdf9cSGreg Clayton         // Make sure the variable is a frame variable
1104288bdf9cSGreg Clayton         const uint32_t var_idx = var_list->FindIndexForVariable (variable_sp.get());
1105288bdf9cSGreg Clayton         const uint32_t num_variables = var_list->GetSize();
1106288bdf9cSGreg Clayton         if (var_idx < num_variables)
1107288bdf9cSGreg Clayton         {
1108288bdf9cSGreg Clayton             valobj_sp = m_variable_list_value_objects.GetValueObjectAtIndex (var_idx);
1109288bdf9cSGreg Clayton             if (valobj_sp.get() == NULL)
1110288bdf9cSGreg Clayton             {
1111288bdf9cSGreg Clayton                 if (m_variable_list_value_objects.GetSize() < num_variables)
1112288bdf9cSGreg Clayton                     m_variable_list_value_objects.Resize(num_variables);
111358b59f95SJim Ingham                 valobj_sp = ValueObjectVariable::Create (this, variable_sp);
1114288bdf9cSGreg Clayton                 m_variable_list_value_objects.SetValueObjectAtIndex (var_idx, valobj_sp);
1115288bdf9cSGreg Clayton             }
1116288bdf9cSGreg Clayton         }
1117288bdf9cSGreg Clayton     }
11184d122c40SGreg Clayton     if (use_dynamic != eNoDynamicValues && valobj_sp)
111978a685aaSJim Ingham     {
11202837b766SJim Ingham         ValueObjectSP dynamic_sp = valobj_sp->GetDynamicValue (use_dynamic);
112178a685aaSJim Ingham         if (dynamic_sp)
112278a685aaSJim Ingham             return dynamic_sp;
112378a685aaSJim Ingham     }
1124288bdf9cSGreg Clayton     return valobj_sp;
1125288bdf9cSGreg Clayton }
1126288bdf9cSGreg Clayton 
1127288bdf9cSGreg Clayton ValueObjectSP
11284d122c40SGreg Clayton StackFrame::TrackGlobalVariable (const VariableSP &variable_sp, DynamicValueType use_dynamic)
1129288bdf9cSGreg Clayton {
1130288bdf9cSGreg Clayton     // Check to make sure we aren't already tracking this variable?
113178a685aaSJim Ingham     ValueObjectSP valobj_sp (GetValueObjectForFrameVariable (variable_sp, use_dynamic));
1132288bdf9cSGreg Clayton     if (!valobj_sp)
1133288bdf9cSGreg Clayton     {
1134288bdf9cSGreg Clayton         // We aren't already tracking this global
1135288bdf9cSGreg Clayton         VariableList *var_list = GetVariableList (true);
1136288bdf9cSGreg Clayton         // If this frame has no variables, create a new list
1137288bdf9cSGreg Clayton         if (var_list == NULL)
1138288bdf9cSGreg Clayton             m_variable_list_sp.reset (new VariableList());
1139288bdf9cSGreg Clayton 
1140288bdf9cSGreg Clayton         // Add the global/static variable to this frame
1141288bdf9cSGreg Clayton         m_variable_list_sp->AddVariable (variable_sp);
1142288bdf9cSGreg Clayton 
1143288bdf9cSGreg Clayton         // Now make a value object for it so we can track its changes
114478a685aaSJim Ingham         valobj_sp = GetValueObjectForFrameVariable (variable_sp, use_dynamic);
1145288bdf9cSGreg Clayton     }
1146288bdf9cSGreg Clayton     return valobj_sp;
114730fdc8d8SChris Lattner }
114830fdc8d8SChris Lattner 
11496b8379c4SJim Ingham bool
11506b8379c4SJim Ingham StackFrame::IsInlined ()
11516b8379c4SJim Ingham {
115259e8fc1cSGreg Clayton     if (m_sc.block == NULL)
115359e8fc1cSGreg Clayton         GetSymbolContext (eSymbolContextBlock);
115459e8fc1cSGreg Clayton     if (m_sc.block)
115559e8fc1cSGreg Clayton         return m_sc.block->GetContainingInlinedBlock() != NULL;
115659e8fc1cSGreg Clayton     return false;
11576b8379c4SJim Ingham }
11586b8379c4SJim Ingham 
1159d9e416c0SGreg Clayton TargetSP
116030fdc8d8SChris Lattner StackFrame::CalculateTarget ()
116130fdc8d8SChris Lattner {
1162d9e416c0SGreg Clayton     TargetSP target_sp;
1163d9e416c0SGreg Clayton     ThreadSP thread_sp(GetThread());
1164d9e416c0SGreg Clayton     if (thread_sp)
1165d9e416c0SGreg Clayton     {
1166d9e416c0SGreg Clayton         ProcessSP process_sp (thread_sp->CalculateProcess());
1167d9e416c0SGreg Clayton         if (process_sp)
1168d9e416c0SGreg Clayton             target_sp = process_sp->CalculateTarget();
1169d9e416c0SGreg Clayton     }
1170d9e416c0SGreg Clayton     return target_sp;
117130fdc8d8SChris Lattner }
117230fdc8d8SChris Lattner 
1173d9e416c0SGreg Clayton ProcessSP
117430fdc8d8SChris Lattner StackFrame::CalculateProcess ()
117530fdc8d8SChris Lattner {
1176d9e416c0SGreg Clayton     ProcessSP process_sp;
1177d9e416c0SGreg Clayton     ThreadSP thread_sp(GetThread());
1178d9e416c0SGreg Clayton     if (thread_sp)
1179d9e416c0SGreg Clayton         process_sp = thread_sp->CalculateProcess();
1180d9e416c0SGreg Clayton     return process_sp;
118130fdc8d8SChris Lattner }
118230fdc8d8SChris Lattner 
1183d9e416c0SGreg Clayton ThreadSP
118430fdc8d8SChris Lattner StackFrame::CalculateThread ()
118530fdc8d8SChris Lattner {
1186d9e416c0SGreg Clayton     return GetThread();
118730fdc8d8SChris Lattner }
118830fdc8d8SChris Lattner 
1189d9e416c0SGreg Clayton StackFrameSP
119030fdc8d8SChris Lattner StackFrame::CalculateStackFrame ()
119130fdc8d8SChris Lattner {
1192d9e416c0SGreg Clayton     return shared_from_this();
119330fdc8d8SChris Lattner }
119430fdc8d8SChris Lattner 
119530fdc8d8SChris Lattner 
119630fdc8d8SChris Lattner void
11970603aa9dSGreg Clayton StackFrame::CalculateExecutionContext (ExecutionContext &exe_ctx)
119830fdc8d8SChris Lattner {
1199d9e416c0SGreg Clayton     exe_ctx.SetContext (shared_from_this());
120030fdc8d8SChris Lattner }
120130fdc8d8SChris Lattner 
120230fdc8d8SChris Lattner void
12030603aa9dSGreg Clayton StackFrame::DumpUsingSettingsFormat (Stream *strm)
12040603aa9dSGreg Clayton {
12050603aa9dSGreg Clayton     if (strm == NULL)
12060603aa9dSGreg Clayton         return;
12070603aa9dSGreg Clayton 
12080603aa9dSGreg Clayton     GetSymbolContext(eSymbolContextEverything);
1209d9e416c0SGreg Clayton     ExecutionContext exe_ctx (shared_from_this());
12100603aa9dSGreg Clayton     const char *end = NULL;
12110603aa9dSGreg Clayton     StreamString s;
1212d9e416c0SGreg Clayton     const char *frame_format = NULL;
1213d9e416c0SGreg Clayton     Target *target = exe_ctx.GetTargetPtr();
1214d9e416c0SGreg Clayton     if (target)
1215d9e416c0SGreg Clayton         frame_format = target->GetDebugger().GetFrameFormat();
12160603aa9dSGreg Clayton     if (frame_format && Debugger::FormatPrompt (frame_format, &m_sc, &exe_ctx, NULL, s, &end))
12170603aa9dSGreg Clayton     {
12180603aa9dSGreg Clayton         strm->Write(s.GetData(), s.GetSize());
12190603aa9dSGreg Clayton     }
12200603aa9dSGreg Clayton     else
12210603aa9dSGreg Clayton     {
12220603aa9dSGreg Clayton         Dump (strm, true, false);
12230603aa9dSGreg Clayton         strm->EOL();
12240603aa9dSGreg Clayton     }
12250603aa9dSGreg Clayton }
12260603aa9dSGreg Clayton 
12270603aa9dSGreg Clayton void
12286dadd508SGreg Clayton StackFrame::Dump (Stream *strm, bool show_frame_index, bool show_fullpaths)
122930fdc8d8SChris Lattner {
123030fdc8d8SChris Lattner     if (strm == NULL)
123130fdc8d8SChris Lattner         return;
123230fdc8d8SChris Lattner 
123330fdc8d8SChris Lattner     if (show_frame_index)
12341b72fcb7SGreg Clayton         strm->Printf("frame #%u: ", m_frame_index);
1235d9e416c0SGreg Clayton     ExecutionContext exe_ctx (shared_from_this());
1236d9e416c0SGreg Clayton     Target *target = exe_ctx.GetTargetPtr();
1237d9e416c0SGreg Clayton     strm->Printf("0x%0*llx ",
1238d9e416c0SGreg Clayton                  target ? (target->GetArchitecture().GetAddressByteSize() * 2) : 16,
1239d9e416c0SGreg Clayton                  GetFrameCodeAddress().GetLoadAddress(target));
12409da7bd07SGreg Clayton     GetSymbolContext(eSymbolContextEverything);
12411b72fcb7SGreg Clayton     const bool show_module = true;
12421b72fcb7SGreg Clayton     const bool show_inline = true;
1243d9e416c0SGreg Clayton     m_sc.DumpStopContext (strm,
1244d9e416c0SGreg Clayton                           exe_ctx.GetBestExecutionContextScope(),
1245d9e416c0SGreg Clayton                           GetFrameCodeAddress(),
1246d9e416c0SGreg Clayton                           show_fullpaths,
1247d9e416c0SGreg Clayton                           show_module,
1248d9e416c0SGreg Clayton                           show_inline);
124930fdc8d8SChris Lattner }
125030fdc8d8SChris Lattner 
12515082c5fdSGreg Clayton void
125259e8fc1cSGreg Clayton StackFrame::UpdateCurrentFrameFromPreviousFrame (StackFrame &prev_frame)
12535082c5fdSGreg Clayton {
125459e8fc1cSGreg Clayton     assert (GetStackID() == prev_frame.GetStackID());    // TODO: remove this after some testing
125559e8fc1cSGreg Clayton     m_variable_list_sp = prev_frame.m_variable_list_sp;
1256288bdf9cSGreg Clayton     m_variable_list_value_objects.Swap (prev_frame.m_variable_list_value_objects);
125768275d5eSGreg Clayton     if (!m_disassembly.GetString().empty())
125868275d5eSGreg Clayton         m_disassembly.GetString().swap (m_disassembly.GetString());
12595082c5fdSGreg Clayton }
126068275d5eSGreg Clayton 
126168275d5eSGreg Clayton 
126259e8fc1cSGreg Clayton void
126359e8fc1cSGreg Clayton StackFrame::UpdatePreviousFrameFromCurrentFrame (StackFrame &curr_frame)
126459e8fc1cSGreg Clayton {
126559e8fc1cSGreg Clayton     assert (GetStackID() == curr_frame.GetStackID());        // TODO: remove this after some testing
12662cad65a5SGreg Clayton     m_id.SetPC (curr_frame.m_id.GetPC());       // Update the Stack ID PC value
1267d9e416c0SGreg Clayton     assert (GetThread() == curr_frame.GetThread());
126859e8fc1cSGreg Clayton     m_frame_index = curr_frame.m_frame_index;
12695ccbd294SGreg Clayton     m_concrete_frame_index = curr_frame.m_concrete_frame_index;
127059e8fc1cSGreg Clayton     m_reg_context_sp = curr_frame.m_reg_context_sp;
127159e8fc1cSGreg Clayton     m_frame_code_addr = curr_frame.m_frame_code_addr;
127259e8fc1cSGreg Clayton     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());
127359e8fc1cSGreg Clayton     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());
127459e8fc1cSGreg Clayton     assert (m_sc.comp_unit == NULL || curr_frame.m_sc.comp_unit == NULL || m_sc.comp_unit == curr_frame.m_sc.comp_unit);
127559e8fc1cSGreg Clayton     assert (m_sc.function == NULL || curr_frame.m_sc.function == NULL || m_sc.function == curr_frame.m_sc.function);
127659e8fc1cSGreg Clayton     m_sc = curr_frame.m_sc;
127759e8fc1cSGreg Clayton     m_flags.Clear(GOT_FRAME_BASE | eSymbolContextEverything);
127859e8fc1cSGreg Clayton     m_flags.Set (m_sc.GetResolvedMask());
127959e8fc1cSGreg Clayton     m_frame_base.Clear();
128059e8fc1cSGreg Clayton     m_frame_base_error.Clear();
128159e8fc1cSGreg Clayton }
128259e8fc1cSGreg Clayton 
128359e8fc1cSGreg Clayton 
12842cad65a5SGreg Clayton bool
12852cad65a5SGreg Clayton StackFrame::HasCachedData () const
12862cad65a5SGreg Clayton {
12872cad65a5SGreg Clayton     if (m_variable_list_sp.get())
12882cad65a5SGreg Clayton         return true;
12892cad65a5SGreg Clayton     if (m_variable_list_value_objects.GetSize() > 0)
12902cad65a5SGreg Clayton         return true;
12912cad65a5SGreg Clayton     if (!m_disassembly.GetString().empty())
12922cad65a5SGreg Clayton         return true;
12932cad65a5SGreg Clayton     return false;
12942cad65a5SGreg Clayton }
1295e4284b71SJim Ingham 
12967260f620SGreg Clayton bool
12977260f620SGreg Clayton StackFrame::GetStatus (Stream& strm,
12987260f620SGreg Clayton                        bool show_frame_info,
1299*53eb7ad2SGreg Clayton                        bool show_source)
13007260f620SGreg Clayton {
1301*53eb7ad2SGreg Clayton 
13027260f620SGreg Clayton     if (show_frame_info)
13037260f620SGreg Clayton     {
13047260f620SGreg Clayton         strm.Indent();
13057260f620SGreg Clayton         DumpUsingSettingsFormat (&strm);
13067260f620SGreg Clayton     }
13077260f620SGreg Clayton 
13087260f620SGreg Clayton     if (show_source)
13097260f620SGreg Clayton     {
1310d9e416c0SGreg Clayton         ExecutionContext exe_ctx (shared_from_this());
1311e372b98dSGreg Clayton         bool have_source = false;
1312d9e416c0SGreg Clayton         DebuggerInstanceSettings::StopDisassemblyType disasm_display = DebuggerInstanceSettings::eStopDisassemblyTypeNever;
1313d9e416c0SGreg Clayton         Target *target = exe_ctx.GetTargetPtr();
1314*53eb7ad2SGreg Clayton         if (target)
1315*53eb7ad2SGreg Clayton         {
1316*53eb7ad2SGreg Clayton             Debugger &debugger = target->GetDebugger();
1317*53eb7ad2SGreg Clayton             const uint32_t source_lines_before = debugger.GetStopSourceLineCount(true);
1318*53eb7ad2SGreg Clayton             const uint32_t source_lines_after = debugger.GetStopSourceLineCount(false);
1319*53eb7ad2SGreg Clayton             disasm_display = debugger.GetStopDisassemblyDisplay ();
1320*53eb7ad2SGreg Clayton 
1321*53eb7ad2SGreg Clayton             if (source_lines_before > 0 || source_lines_after > 0)
1322e372b98dSGreg Clayton             {
13237260f620SGreg Clayton                 GetSymbolContext(eSymbolContextCompUnit | eSymbolContextLineEntry);
13247260f620SGreg Clayton 
13257260f620SGreg Clayton                 if (m_sc.comp_unit && m_sc.line_entry.IsValid())
13267260f620SGreg Clayton                 {
1327d9e416c0SGreg Clayton                     if (target->GetSourceManager().DisplaySourceLinesWithLineNumbers (m_sc.line_entry.file,
13287260f620SGreg Clayton                                                                                       m_sc.line_entry.line,
1329d9e416c0SGreg Clayton                                                                                       source_lines_before,
1330d9e416c0SGreg Clayton                                                                                       source_lines_after,
13317260f620SGreg Clayton                                                                                       "->",
1332e372b98dSGreg Clayton                                                                                       &strm))
1333e372b98dSGreg Clayton                     {
1334e372b98dSGreg Clayton                         have_source = true;
1335e372b98dSGreg Clayton                     }
1336e372b98dSGreg Clayton                 }
1337e372b98dSGreg Clayton             }
1338e372b98dSGreg Clayton             switch (disasm_display)
1339e372b98dSGreg Clayton             {
1340e372b98dSGreg Clayton             case DebuggerInstanceSettings::eStopDisassemblyTypeNever:
1341e372b98dSGreg Clayton                 break;
1342e372b98dSGreg Clayton 
1343e372b98dSGreg Clayton             case DebuggerInstanceSettings::eStopDisassemblyTypeNoSource:
1344e372b98dSGreg Clayton                 if (have_source)
1345e372b98dSGreg Clayton                     break;
1346e372b98dSGreg Clayton                 // Fall through to next case
1347e372b98dSGreg Clayton             case DebuggerInstanceSettings::eStopDisassemblyTypeAlways:
1348d9e416c0SGreg Clayton                 if (target)
1349e372b98dSGreg Clayton                 {
1350*53eb7ad2SGreg Clayton                     const uint32_t disasm_lines = debugger.GetDisassemblyLineCount();
1351e372b98dSGreg Clayton                     if (disasm_lines > 0)
1352e372b98dSGreg Clayton                     {
1353d9e416c0SGreg Clayton                         const ArchSpec &target_arch = target->GetArchitecture();
1354e372b98dSGreg Clayton                         AddressRange pc_range;
1355e372b98dSGreg Clayton                         pc_range.GetBaseAddress() = GetFrameCodeAddress();
1356e372b98dSGreg Clayton                         pc_range.SetByteSize(disasm_lines * target_arch.GetMaximumOpcodeByteSize());
1357d9e416c0SGreg Clayton                         Disassembler::Disassemble (target->GetDebugger(),
1358e372b98dSGreg Clayton                                                    target_arch,
1359e372b98dSGreg Clayton                                                    NULL,
1360e372b98dSGreg Clayton                                                    exe_ctx,
1361e372b98dSGreg Clayton                                                    pc_range,
1362e372b98dSGreg Clayton                                                    disasm_lines,
1363e372b98dSGreg Clayton                                                    0,
1364e372b98dSGreg Clayton                                                    Disassembler::eOptionMarkPCAddress,
1365e372b98dSGreg Clayton                                                    strm);
1366e372b98dSGreg Clayton                     }
1367e372b98dSGreg Clayton                 }
1368e372b98dSGreg Clayton                 break;
13697260f620SGreg Clayton             }
13707260f620SGreg Clayton         }
1371*53eb7ad2SGreg Clayton     }
13727260f620SGreg Clayton     return true;
13737260f620SGreg Clayton }
13747260f620SGreg Clayton 
1375