[Lldb-commits] [lldb] r111964 - in /lldb/trunk: include/lldb/Core/ include/lldb/Expression/ include/lldb/Symbol/ include/lldb/Target/ source/API/ source/Commands/ source/Core/ source/Expression/ source/Plugins/Process/MacOSX-User/source/MacOSX/ source/Plugins/Process/Utility/ source/Symbol/ source/Target/

Greg Clayton gclayton at apple.com
Tue Aug 24 14:05:24 PDT 2010


Author: gclayton
Date: Tue Aug 24 16:05:24 2010
New Revision: 111964

URL: http://llvm.org/viewvc/llvm-project?rev=111964&view=rev
Log:
Got a lot of the kinks worked out in the inline support after debugging more
complex inlined examples.

StackFrame classes don't have a "GetPC" anymore, they have "GetFrameCodeAddress()".
This is because inlined frames will have a PC value that is the same as the 
concrete frame that owns the inlined frame, yet the code locations for the
frame can be different. We also need to be able to get the real PC value for
a given frame so that variables evaluate correctly. To get the actual PC
value for a frame you can use:

    addr_t pc = frame->GetRegisterContext()->GetPC();

Some issues with the StackFrame stomping on its own symbol context were 
resolved which were causing the information to change for a frame when the
stack ID was calculated. Also the StackFrame will now correctly store the
symbol context resolve flags for any extra bits of information that were 
looked up (if you ask for a block only and you find one, you will alwasy have
the compile unit and function).


Modified:
    lldb/trunk/include/lldb/Core/ModuleList.h
    lldb/trunk/include/lldb/Core/VMRange.h
    lldb/trunk/include/lldb/Expression/DWARFExpression.h
    lldb/trunk/include/lldb/Symbol/Block.h
    lldb/trunk/include/lldb/Target/StackFrame.h
    lldb/trunk/source/API/SBFrame.cpp
    lldb/trunk/source/Commands/CommandObjectArgs.cpp
    lldb/trunk/source/Commands/CommandObjectDisassemble.cpp
    lldb/trunk/source/Core/Disassembler.cpp
    lldb/trunk/source/Core/ModuleList.cpp
    lldb/trunk/source/Expression/DWARFExpression.cpp
    lldb/trunk/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_i386.cpp
    lldb/trunk/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_x86_64.cpp
    lldb/trunk/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.cpp
    lldb/trunk/source/Symbol/Block.cpp
    lldb/trunk/source/Symbol/SymbolContext.cpp
    lldb/trunk/source/Symbol/Variable.cpp
    lldb/trunk/source/Target/StackFrame.cpp
    lldb/trunk/source/Target/Thread.cpp
    lldb/trunk/source/Target/ThreadPlanStepInstruction.cpp
    lldb/trunk/source/Target/ThreadPlanStepOut.cpp
    lldb/trunk/source/Target/ThreadPlanStepUntil.cpp

Modified: lldb/trunk/include/lldb/Core/ModuleList.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ModuleList.h?rev=111964&r1=111963&r2=111964&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ModuleList.h (original)
+++ lldb/trunk/include/lldb/Core/ModuleList.h Tue Aug 24 16:05:24 2010
@@ -259,7 +259,7 @@
                  ModuleList& matching_module_list) const;
 
     lldb::ModuleSP
-    FindModule (lldb_private::Module *module_ptr);
+    FindModule (const Module *module_ptr);
 
     lldb::ModuleSP
     FindFirstModuleForFileSpec (const FileSpec &file_spec,
@@ -355,7 +355,7 @@
     GetSize () const;
 
     static const lldb::ModuleSP
-    GetModuleSP (lldb_private::Module *module_ptr);
+    GetModuleSP (const Module *module_ptr);
 
     static Error
     GetSharedModule (const FileSpec& file_spec,

Modified: lldb/trunk/include/lldb/Core/VMRange.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/VMRange.h?rev=111964&r1=111963&r2=111964&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/VMRange.h (original)
+++ lldb/trunk/include/lldb/Core/VMRange.h Tue Aug 24 16:05:24 2010
@@ -43,20 +43,30 @@
     {
     }
 
+    void
+    Clear ()
+    {
+        m_base_addr = 0;
+        m_byte_size = 0;  
+    }
+
     // Set the start and end values
-    void Reset (lldb::addr_t start_addr, lldb::addr_t end_addr)
+    void 
+    Reset (lldb::addr_t start_addr, lldb::addr_t end_addr)
     {
         SetBaseAddress (start_addr);
         SetEndAddress (end_addr);
     }
 
     // Set the start value for the range, and keep the same size
-    void SetBaseAddress (lldb::addr_t base_addr)
+    void
+    SetBaseAddress (lldb::addr_t base_addr)
     {
         m_base_addr = base_addr;
     }
 
-    void SetEndAddress (lldb::addr_t end_addr)
+    void
+    SetEndAddress (lldb::addr_t end_addr)
     {
         const lldb::addr_t base_addr = GetBaseAddress();
         if (end_addr > base_addr)
@@ -92,7 +102,7 @@
     bool
     IsValid() const
     {
-        return GetByteSize() > 0;
+        return m_byte_size > 0;
     }
 
     bool
@@ -101,7 +111,8 @@
         return (GetBaseAddress() <= addr) && (addr < GetEndAddress());
     }
 
-    bool Contains (const VMRange& range) const
+    bool 
+    Contains (const VMRange& range) const
     {
         if (Contains(range.GetBaseAddress()))
         {

Modified: lldb/trunk/include/lldb/Expression/DWARFExpression.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/DWARFExpression.h?rev=111964&r1=111963&r2=111964&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Expression/DWARFExpression.h (original)
+++ lldb/trunk/include/lldb/Expression/DWARFExpression.h Tue Aug 24 16:05:24 2010
@@ -118,6 +118,9 @@
     bool
     LocationListContainsLoadAddress (Process* process, const Address &addr) const;
 
+    bool
+    LocationListContainsLoadAddress (Process* process, lldb::addr_t load_addr) const;
+    
     //------------------------------------------------------------------
     /// Make the expression parser read its location information from a
     /// given data source.  Does not change the offset and length

Modified: lldb/trunk/include/lldb/Symbol/Block.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Block.h?rev=111964&r1=111963&r2=111964&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/Block.h (original)
+++ lldb/trunk/include/lldb/Symbol/Block.h Tue Aug 24 16:05:24 2010
@@ -182,8 +182,28 @@
     Block *
     GetParent () const;
     
+    
+    //------------------------------------------------------------------
+    /// Get the inlined block that contains this block.
+    ///
+    /// @return
+    ///     If this block contains inlined function info, it will return
+    ///     this block, else parent blocks will be searched to see if
+    ///     any contain this block. NULL will be returned if this block
+    ///     nor any parent blocks are inlined function blocks.
+    //------------------------------------------------------------------
     Block *
-    GetInlinedParent () const;
+    GetContainingInlinedBlock ();
+
+    //------------------------------------------------------------------
+    /// Get the inlined parent block for this block.
+    ///
+    /// @return
+    ///     The parent block pointer, or NULL if this block has no 
+    ///     parent.
+    //------------------------------------------------------------------
+    Block *
+    GetInlinedParent ();
 
     //------------------------------------------------------------------
     /// Get the sibling block for this block.
@@ -206,7 +226,12 @@
     ///     children.
     //------------------------------------------------------------------
     Block *
-    GetFirstChild () const;
+    GetFirstChild () const
+    {
+        if (m_children.empty())
+            return NULL;
+        return m_children.front().get();
+    }
 
     //------------------------------------------------------------------
     /// Get the variable list for this block and optionally all child
@@ -266,16 +291,6 @@
                      VariableList *variable_list);
 
     //------------------------------------------------------------------
-    /// Get accessor for any inlined function information.
-    ///
-    /// @return
-    ///     A pointer to any inlined function information, or NULL if
-    ///     this is a regular block.
-    //------------------------------------------------------------------
-    InlineFunctionInfo*
-    InlinedFunctionInfo ();
-
-    //------------------------------------------------------------------
     /// Get const accessor for any inlined function information.
     ///
     /// @return
@@ -283,7 +298,10 @@
     ///     if this is a regular block.
     //------------------------------------------------------------------
     const InlineFunctionInfo*
-    InlinedFunctionInfo () const;
+    InlinedFunctionInfo () const
+    {
+        return m_inlineInfoSP.get();
+    }
 
     //------------------------------------------------------------------
     /// Get the memory cost of this object.
@@ -348,7 +366,11 @@
     ///     A shared pointer to a VariableList.
     //------------------------------------------------------------------
     void
-    SetVariableList (lldb::VariableListSP& variable_list_sp);
+    SetVariableList (lldb::VariableListSP& variable_list_sp)
+    {
+        m_variable_list_sp = variable_list_sp;
+    }
+
 
 
     bool
@@ -364,6 +386,9 @@
     FindBlockByID (lldb::user_id_t block_id);
 
     bool
+    GetRangeContainingOffset (const lldb::addr_t offset, VMRange &range);
+
+    bool
     GetRangeContainingAddress (const Address& addr, AddressRange &range);
 
     
@@ -377,7 +402,7 @@
     collection m_children;
     VMRange::collection m_ranges; ///< A list of address offset ranges relative to the function's section/offset address.
     lldb::InlineFunctionInfoSP m_inlineInfoSP; ///< Inlined function information.
-    lldb::VariableListSP m_variables; ///< The variable list for all local, static and paramter variables scoped to this block.
+    lldb::VariableListSP m_variable_list_sp; ///< The variable list for all local, static and paramter variables scoped to this block.
     bool m_parsed_block_info:1,         ///< Set to true if this block and it's children have all been parsed
          m_parsed_block_variables:1,
          m_parsed_child_blocks:1;

Modified: lldb/trunk/include/lldb/Target/StackFrame.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/StackFrame.h?rev=111964&r1=111963&r2=111964&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/StackFrame.h (original)
+++ lldb/trunk/include/lldb/Target/StackFrame.h Tue Aug 24 16:05:24 2010
@@ -50,7 +50,7 @@
     GetStackID();
 
     Address&
-    GetPC();
+    GetFrameCodeAddress();
     
     void
     ChangePC (lldb::addr_t pc);

Modified: lldb/trunk/source/API/SBFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFrame.cpp?rev=111964&r1=111963&r2=111964&view=diff
==============================================================================
--- lldb/trunk/source/API/SBFrame.cpp (original)
+++ lldb/trunk/source/API/SBFrame.cpp Tue Aug 24 16:05:24 2010
@@ -121,12 +121,11 @@
         return UINT32_MAX;
 }
 
-
 lldb::addr_t
 SBFrame::GetPC () const
 {
     if (m_opaque_sp)
-        return m_opaque_sp->GetPC().GetLoadAddress (&m_opaque_sp->GetThread().GetProcess());
+        return m_opaque_sp->GetFrameCodeAddress().GetLoadAddress (&m_opaque_sp->GetThread().GetProcess());
     return LLDB_INVALID_ADDRESS;
 }
 
@@ -161,7 +160,7 @@
 {
     SBAddress sb_addr;
     if (m_opaque_sp)
-        sb_addr.SetAddress (&m_opaque_sp->GetPC());
+        sb_addr.SetAddress (&m_opaque_sp->GetFrameCodeAddress());
     return sb_addr;
 }
 

Modified: lldb/trunk/source/Commands/CommandObjectArgs.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectArgs.cpp?rev=111964&r1=111963&r2=111964&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectArgs.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectArgs.cpp Tue Aug 24 16:05:24 2010
@@ -148,7 +148,7 @@
         return false;
     }
     
-    Module *thread_module = thread_cur_frame->GetPC ().GetModule ();
+    Module *thread_module = thread_cur_frame->GetFrameCodeAddress ().GetModule ();
     if (!thread_module)
     {
         result.AppendError ("The PC has no associated module.");

Modified: lldb/trunk/source/Commands/CommandObjectDisassemble.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectDisassemble.cpp?rev=111964&r1=111963&r2=111964&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectDisassemble.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectDisassemble.cpp Tue Aug 24 16:05:24 2010
@@ -248,7 +248,7 @@
                 else if (sc.symbol && sc.symbol->GetAddressRangePtr())
                     range = *sc.symbol->GetAddressRangePtr();
                 else
-                    range.GetBaseAddress() = exe_ctx.frame->GetPC();
+                    range.GetBaseAddress() = exe_ctx.frame->GetFrameCodeAddress();
             }
             else
             {

Modified: lldb/trunk/source/Core/Disassembler.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Disassembler.cpp?rev=111964&r1=111963&r2=111964&view=diff
==============================================================================
--- lldb/trunk/source/Core/Disassembler.cpp (original)
+++ lldb/trunk/source/Core/Disassembler.cpp Tue Aug 24 16:05:24 2010
@@ -311,7 +311,7 @@
         }
         else
         {
-            range.GetBaseAddress() = exe_ctx.frame->GetPC();
+            range.GetBaseAddress() = exe_ctx.frame->GetFrameCodeAddress();
         }
 
         if (range.GetBaseAddress().IsValid() && range.GetByteSize() == 0)

Modified: lldb/trunk/source/Core/ModuleList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ModuleList.cpp?rev=111964&r1=111963&r2=111964&view=diff
==============================================================================
--- lldb/trunk/source/Core/ModuleList.cpp (original)
+++ lldb/trunk/source/Core/ModuleList.cpp Tue Aug 24 16:05:24 2010
@@ -267,7 +267,7 @@
 }
 
 ModuleSP
-ModuleList::FindModule (lldb_private::Module *module_ptr)
+ModuleList::FindModule (const Module *module_ptr)
 {
     ModuleSP module_sp;
 
@@ -450,7 +450,7 @@
 }
 
 const lldb::ModuleSP
-ModuleList::GetModuleSP (lldb_private::Module *module_ptr)
+ModuleList::GetModuleSP (const Module *module_ptr)
 {
     lldb::ModuleSP module_sp;
     if (module_ptr)

Modified: lldb/trunk/source/Expression/DWARFExpression.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/DWARFExpression.cpp?rev=111964&r1=111963&r2=111964&view=diff
==============================================================================
--- lldb/trunk/source/Expression/DWARFExpression.cpp (original)
+++ lldb/trunk/source/Expression/DWARFExpression.cpp Tue Aug 24 16:05:24 2010
@@ -688,13 +688,18 @@
 bool
 DWARFExpression::LocationListContainsLoadAddress (Process* process, const Address &addr) const
 {
+    return LocationListContainsLoadAddress(process, addr.GetLoadAddress(process));
+}
+
+bool
+DWARFExpression::LocationListContainsLoadAddress (Process* process, addr_t load_addr) const
+{
+    if (load_addr == LLDB_INVALID_ADDRESS)
+        return false;
+
     if (IsLocationList())
     {
         uint32_t offset = 0;
-        const addr_t load_addr = addr.GetLoadAddress(process);
-
-        if (load_addr == LLDB_INVALID_ADDRESS)
-            return false;
 
         addr_t loc_list_base_addr = m_loclist_base_addr.GetLoadAddress(process);
 
@@ -722,6 +727,7 @@
     }
     return false;
 }
+
 bool
 DWARFExpression::Evaluate
 (
@@ -749,7 +755,7 @@
     if (IsLocationList())
     {
         uint32_t offset = 0;
-        addr_t pc = exe_ctx->frame->GetPC().GetLoadAddress(exe_ctx->process);
+        addr_t pc = exe_ctx->frame->GetRegisterContext()->GetPC();
 
         if (pc == LLDB_INVALID_ADDRESS)
         {

Modified: lldb/trunk/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_i386.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_i386.cpp?rev=111964&r1=111963&r2=111964&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_i386.cpp (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_i386.cpp Tue Aug 24 16:05:24 2010
@@ -210,7 +210,7 @@
 
             if (addr_range_ptr)
             {
-                if (first_frame->GetPC() == addr_range_ptr->GetBaseAddress())
+                if (first_frame->GetFrameCodeAddress() == addr_range_ptr->GetBaseAddress())
                 {
                     // We are at the first instruction, so we can recover the
                     // previous PC by dereferencing the SP

Modified: lldb/trunk/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_x86_64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_x86_64.cpp?rev=111964&r1=111963&r2=111964&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_x86_64.cpp (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-User/source/MacOSX/MachThreadContext_x86_64.cpp Tue Aug 24 16:05:24 2010
@@ -221,7 +221,7 @@
 
             if (addr_range_ptr)
             {
-                if (first_frame->GetPC() == addr_range_ptr->GetBaseAddress())
+                if (first_frame->GetFrameCodeAddress() == addr_range_ptr->GetBaseAddress())
                 {
                     // We are at the first instruction, so we can recover the
                     // previous PC by dereferencing the SP

Modified: lldb/trunk/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.cpp?rev=111964&r1=111963&r2=111964&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.cpp Tue Aug 24 16:05:24 2010
@@ -130,7 +130,7 @@
 
             if (addr_range_ptr)
             {
-                if (first_frame->GetPC() == addr_range_ptr->GetBaseAddress())
+                if (first_frame->GetFrameCodeAddress() == addr_range_ptr->GetBaseAddress())
                 {
                     // We are at the first instruction, so we can recover the
                     // previous PC by dereferencing the SP
@@ -218,7 +218,7 @@
 
             if (addr_range_ptr)
             {
-                if (first_frame->GetPC() == addr_range_ptr->GetBaseAddress())
+                if (first_frame->GetFrameCodeAddress() == addr_range_ptr->GetBaseAddress())
                 {
                     // We are at the first instruction, so we can recover the
                     // previous PC by dereferencing the SP

Modified: lldb/trunk/source/Symbol/Block.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Block.cpp?rev=111964&r1=111963&r2=111964&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/Block.cpp (original)
+++ lldb/trunk/source/Symbol/Block.cpp Tue Aug 24 16:05:24 2010
@@ -24,7 +24,7 @@
     m_children (),
     m_ranges (),
     m_inlineInfoSP (),
-    m_variables (),
+    m_variable_list_sp (),
     m_parsed_block_info (false),
     m_parsed_block_variables (false),
     m_parsed_child_blocks (false)
@@ -104,9 +104,9 @@
     {
         s->IndentMore();
 
-        if (m_variables.get())
+        if (m_variable_list_sp.get())
         {
-            m_variables->Dump(s, show_context);
+            m_variable_list_sp->Dump(s, show_context);
         }
 
         for (Block *child_block = GetFirstChild(); child_block != NULL; child_block = child_block->GetSibling())
@@ -137,7 +137,7 @@
 }
 
 void
-Block::CalculateSymbolContext(SymbolContext* sc)
+Block::CalculateSymbolContext (SymbolContext* sc)
 {
     if (m_parent_scope)
         m_parent_scope->CalculateSymbolContext(sc);
@@ -149,7 +149,7 @@
 {
     Block* parent_block = GetParent();
 
-    InlineFunctionInfo* inline_info = InlinedFunctionInfo ();
+    const InlineFunctionInfo* inline_info = InlinedFunctionInfo ();
     if (inline_info)
     {
         const Declaration &call_site = inline_info->GetCallSite();
@@ -226,7 +226,15 @@
 }
 
 Block *
-Block::GetInlinedParent () const
+Block::GetContainingInlinedBlock ()
+{
+    if (InlinedFunctionInfo())
+        return this;
+    return GetInlinedParent ();
+}
+
+Block *
+Block::GetInlinedParent ()
 {
     Block *parent_block = GetParent ();
     if (parent_block)
@@ -241,6 +249,20 @@
 
 
 bool
+Block::GetRangeContainingOffset (const addr_t offset, VMRange &range)
+{
+    uint32_t range_idx = VMRange::FindRangeIndexThatContainsValue (m_ranges, offset);
+    if (range_idx < m_ranges.size())
+    {
+        range = m_ranges[range_idx];
+        return true;
+    }
+    range.Clear();
+    return false;
+}
+
+
+bool
 Block::GetRangeContainingAddress (const Address& addr, AddressRange &range)
 {
     SymbolContext sc;
@@ -278,18 +300,6 @@
     m_ranges.back().Reset(start_offset, end_offset);
 }
 
-InlineFunctionInfo*
-Block::InlinedFunctionInfo ()
-{
-    return m_inlineInfoSP.get();
-}
-
-const InlineFunctionInfo*
-Block::InlinedFunctionInfo () const
-{
-    return m_inlineInfoSP.get();
-}
-
 // Return the current number of bytes that this object occupies in memory
 size_t
 Block::MemorySize() const
@@ -297,20 +307,12 @@
     size_t mem_size = sizeof(Block) + m_ranges.size() * sizeof(VMRange);
     if (m_inlineInfoSP.get())
         mem_size += m_inlineInfoSP->MemorySize();
-    if (m_variables.get())
-        mem_size += m_variables->MemorySize();
+    if (m_variable_list_sp.get())
+        mem_size += m_variable_list_sp->MemorySize();
     return mem_size;
 
 }
 
-Block *
-Block::GetFirstChild () const
-{
-    if (m_children.empty())
-        return NULL;
-    return m_children.front().get();
-}
-
 void
 Block::AddChild(const BlockSP &child_block_sp)
 {
@@ -343,7 +345,7 @@
     VariableListSP variable_list_sp;
     if (m_parsed_block_variables == false)
     {
-        if (m_variables.get() == NULL && can_create)
+        if (m_variable_list_sp.get() == NULL && can_create)
         {
             m_parsed_block_variables = true;
             SymbolContext sc;
@@ -353,11 +355,11 @@
         }
     }
 
-    if (m_variables.get())
+    if (m_variable_list_sp.get())
     {
         variable_list_sp.reset(new VariableList());
         if (variable_list_sp.get())
-            variable_list_sp->AddVariables(m_variables.get());
+            variable_list_sp->AddVariables(m_variable_list_sp.get());
 
         if (get_child_variables)
         {
@@ -406,13 +408,6 @@
     return num_variables_added;
 }
 
-
-void
-Block::SetVariableList(VariableListSP& variables)
-{
-    m_variables = variables;
-}
-
 void
 Block::SetBlockInfoHasBeenParsed (bool b, bool set_children)
 {

Modified: lldb/trunk/source/Symbol/SymbolContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/SymbolContext.cpp?rev=111964&r1=111963&r2=111964&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/SymbolContext.cpp (original)
+++ lldb/trunk/source/Symbol/SymbolContext.cpp Tue Aug 24 16:05:24 2010
@@ -131,10 +131,10 @@
 
         if (show_inlined_frames && block)
         {
-            InlineFunctionInfo *inline_info = block->InlinedFunctionInfo();
+            const InlineFunctionInfo *inline_info = block->InlinedFunctionInfo();
             if (inline_info == NULL)
             {
-                Block *parent_inline_block = block->GetInlinedParent();
+                const Block *parent_inline_block = block->GetInlinedParent();
                 if (parent_inline_block)
                     inline_info = parent_inline_block->InlinedFunctionInfo();
             }

Modified: lldb/trunk/source/Symbol/Variable.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Variable.cpp?rev=111964&r1=111963&r2=111964&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/Variable.cpp (original)
+++ lldb/trunk/source/Symbol/Variable.cpp Tue Aug 24 16:05:24 2010
@@ -14,6 +14,7 @@
 #include "lldb/Symbol/Function.h"
 #include "lldb/Symbol/SymbolContext.h"
 #include "lldb/Symbol/Type.h"
+#include "lldb/Target/RegisterContext.h"
 #include "lldb/Target/StackFrame.h"
 #include "lldb/Target/Thread.h"
 
@@ -142,7 +143,7 @@
             // It is a location list. We just need to tell if the location
             // list contains the current address when converted to a load
             // address
-            return m_location.LocationListContainsLoadAddress (&frame->GetThread().GetProcess(), frame->GetPC());
+            return m_location.LocationListContainsLoadAddress (&frame->GetThread().GetProcess(), frame->GetRegisterContext()->GetPC());
         }
         else
         {

Modified: lldb/trunk/source/Target/StackFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StackFrame.cpp?rev=111964&r1=111963&r2=111964&view=diff
==============================================================================
--- lldb/trunk/source/Target/StackFrame.cpp (original)
+++ lldb/trunk/source/Target/StackFrame.cpp Tue Aug 24 16:05:24 2010
@@ -29,8 +29,8 @@
 // The first bits in the flags are reserved for the SymbolContext::Scope bits
 // so we know if we have tried to look up information in our internal symbol
 // context (m_sc) already.
-#define RESOLVED_PC_SO_ADDR (uint32_t(eSymbolContextEverything + 1))
-#define RESOLVED_FRAME_ID   (RESOLVED_PC_SO_ADDR << 1)
+#define RESOLVED_FRAME_ADDR (uint32_t(eSymbolContextEverything + 1))
+#define RESOLVED_FRAME_ID   (RESOLVED_FRAME_ADDR << 1)
 #define GOT_FRAME_BASE      (RESOLVED_FRAME_ID << 1)
 #define FRAME_IS_OBSOLETE   (GOT_FRAME_BASE << 1)
 #define RESOLVED_VARIABLES  (FRAME_IS_OBSOLETE << 1)
@@ -169,53 +169,29 @@
         // Resolve our PC to section offset if we haven't alreday done so
         // and if we don't have a module. The resolved address section will
         // contain the module to which it belongs.
-        if (!m_sc.module_sp && m_flags.IsClear(RESOLVED_PC_SO_ADDR))
-            GetPC();
+        if (!m_sc.module_sp && m_flags.IsClear(RESOLVED_FRAME_ADDR))
+            GetFrameCodeAddress();
 
-        const uint32_t resolve_scope = eSymbolContextModule |
-                                       eSymbolContextCompUnit |
-                                       eSymbolContextFunction;
-
-        if (m_sc.module_sp)
+        if (GetSymbolContext (eSymbolContextFunction).function)
         {
-            if (m_sc.module_sp->ResolveSymbolContextForAddress (GetPC(), resolve_scope, m_sc) & eSymbolContextFunction)
-            {
-                assert (m_sc.function);
-                m_id.SetStartAddress(m_sc.function->GetAddressRange().GetBaseAddress());
-            }
-            else if (m_sc.module_sp->ResolveSymbolContextForAddress (GetPC(), resolve_scope, m_sc) & eSymbolContextSymbol)
-            {
-                assert (m_sc.symbol);
-                AddressRange *symbol_range_ptr = m_sc.symbol->GetAddressRangePtr();
-                if (symbol_range_ptr)
-                    m_id.SetStartAddress(symbol_range_ptr->GetBaseAddress());
-            }
+            m_id.SetStartAddress (m_sc.function->GetAddressRange().GetBaseAddress());
+        }
+        else if (GetSymbolContext (eSymbolContextSymbol).symbol)
+        {
+            AddressRange *symbol_range_ptr = m_sc.symbol->GetAddressRangePtr();
+            if (symbol_range_ptr)
+                m_id.SetStartAddress(symbol_range_ptr->GetBaseAddress());
         }
-//      else if (m_sc.target != NULL)
-//      {
-//          if (m_sc.target->GetImages().ResolveSymbolContextForAddress (GetPC(), resolve_scope, m_sc) & eSymbolContextFunction)
-//          {
-//              assert (m_sc.function);
-//              m_id.GetAddressRange() = m_sc.function->GetAddressRange();
-//          }
-//          else if (m_sc.target->GetImages().ResolveSymbolContextForAddress (GetPC(), resolve_scope, m_sc) & eSymbolContextSymbol)
-//          {
-//              assert (m_sc.symbol);
-//              AddressRange *symbol_range_ptr = m_sc.symbol->GetAddressRange();
-//              if (symbol_range_ptr)
-//                  m_id.GetAddressRange() = *symbol_range_ptr;
-//          }
-//      }
     }
     return m_id;
 }
 
 Address&
-StackFrame::GetPC()
+StackFrame::GetFrameCodeAddress()
 {
-    if (m_flags.IsClear(RESOLVED_PC_SO_ADDR) && !m_pc.IsSectionOffset())
+    if (m_flags.IsClear(RESOLVED_FRAME_ADDR) && !m_pc.IsSectionOffset())
     {
-        m_flags.Set (RESOLVED_PC_SO_ADDR);
+        m_flags.Set (RESOLVED_FRAME_ADDR);
 
         // Resolve the PC into a temporary address because if ResolveLoadAddress
         // fails to resolve the address, it will clear the address object...
@@ -279,20 +255,19 @@
 StackFrame::GetSymbolContext (uint32_t resolve_scope)
 {
     // Copy our internal symbol context into "sc".
-
     if ((m_flags.GetAllFlagBits() & resolve_scope) != resolve_scope)
     {
         // Resolve our PC to section offset if we haven't alreday done so
         // and if we don't have a module. The resolved address section will
         // contain the module to which it belongs
-        if (!m_sc.module_sp && m_flags.IsClear(RESOLVED_PC_SO_ADDR))
-            GetPC();
+        if (!m_sc.module_sp && m_flags.IsClear(RESOLVED_FRAME_ADDR))
+            GetFrameCodeAddress();
 
         // If this is not frame zero, then we need to subtract 1 from the PC
         // value when doing address lookups since the PC will be on the 
         // instruction following the function call instruction...
         
-        Address lookup_addr(GetPC());
+        Address lookup_addr(GetFrameCodeAddress());
         if (m_frame_index > 0 && lookup_addr.IsValid())
         {
             addr_t offset = lookup_addr.GetOffset();
@@ -300,6 +275,8 @@
                 lookup_addr.SetOffset(offset - 1);
         }
 
+
+        uint32_t resolved = 0;
         if (m_sc.module_sp)
         {
             // We have something in our stack frame symbol context, lets check
@@ -313,7 +290,7 @@
                 if (m_flags.IsClear (eSymbolContextCompUnit))
                 {
                     if (m_sc.comp_unit)
-                        m_flags.Set (eSymbolContextCompUnit);
+                        resolved |= eSymbolContextCompUnit;
                     else
                         actual_resolve_scope |= eSymbolContextCompUnit;
                 }
@@ -324,7 +301,7 @@
                 if (m_flags.IsClear (eSymbolContextFunction))
                 {
                     if (m_sc.function)
-                        m_flags.Set (eSymbolContextFunction);
+                        resolved |= eSymbolContextFunction;
                     else
                         actual_resolve_scope |= eSymbolContextFunction;
                 }
@@ -335,7 +312,7 @@
                 if (m_flags.IsClear (eSymbolContextBlock))
                 {
                     if (m_sc.block)
-                        m_flags.Set (eSymbolContextBlock);
+                        resolved |= eSymbolContextBlock;
                     else
                         actual_resolve_scope |= eSymbolContextBlock;
                 }
@@ -346,7 +323,7 @@
                 if (m_flags.IsClear (eSymbolContextSymbol))
                 {
                     if (m_sc.symbol)
-                        m_flags.Set (eSymbolContextSymbol);
+                        resolved |= eSymbolContextSymbol;
                     else
                         actual_resolve_scope |= eSymbolContextSymbol;
                 }
@@ -357,7 +334,7 @@
                 if (m_flags.IsClear (eSymbolContextLineEntry))
                 {
                     if (m_sc.line_entry.IsValid())
-                        m_flags.Set (eSymbolContextLineEntry);
+                        resolved |= eSymbolContextLineEntry;
                     else
                         actual_resolve_scope |= eSymbolContextLineEntry;
                 }
@@ -371,15 +348,21 @@
                 // already found in "m_sc"
                 SymbolContext sc;
                 // Set flags that indicate what we have tried to resolve
-                const uint32_t resolved = m_sc.module_sp->ResolveSymbolContextForAddress (lookup_addr, actual_resolve_scope, sc);
+                resolved |= m_sc.module_sp->ResolveSymbolContextForAddress (lookup_addr, actual_resolve_scope, sc);
                 // Only replace what we didn't already have as we may have 
                 // information for an inlined function scope that won't match
                 // what a standard lookup by address would match
-                if (resolved & eSymbolContextCompUnit)  m_sc.comp_unit  = sc.comp_unit;
-                if (resolved & eSymbolContextFunction)  m_sc.function   = sc.function;
-                if (resolved & eSymbolContextBlock)     m_sc.block      = sc.block;
-                if (resolved & eSymbolContextSymbol)    m_sc.symbol     = sc.symbol;
-                if (resolved & eSymbolContextLineEntry) m_sc.line_entry = sc.line_entry;
+                if ((resolved & eSymbolContextCompUnit)  && m_sc.comp_unit == NULL)  
+                    m_sc.comp_unit = sc.comp_unit;
+                if ((resolved & eSymbolContextFunction)  && m_sc.function == NULL)  
+                    m_sc.function = sc.function;
+                if ((resolved & eSymbolContextBlock)     && m_sc.block == NULL)  
+                    m_sc.block = sc.block;
+                if ((resolved & eSymbolContextSymbol)    && m_sc.symbol == NULL)  
+                    m_sc.symbol = sc.symbol;
+                if ((resolved & eSymbolContextLineEntry) && !m_sc.line_entry.IsValid()) 
+                    m_sc.line_entry = sc.line_entry;
+
             }
         }
         else
@@ -387,16 +370,23 @@
             // If we don't have a module, then we can't have the compile unit,
             // function, block, line entry or symbol, so we can safely call
             // ResolveSymbolContextForAddress with our symbol context member m_sc.
-            m_thread.GetProcess().GetTarget().GetImages().ResolveSymbolContextForAddress (lookup_addr, resolve_scope, m_sc);
+            resolved |= m_thread.GetProcess().GetTarget().GetImages().ResolveSymbolContextForAddress (lookup_addr, resolve_scope, m_sc);
         }
 
         // If the target was requested add that:
         if (m_sc.target_sp.get() == NULL)
+        {
             m_sc.target_sp = CalculateProcess()->GetTarget().GetSP();
+            if (m_sc.target_sp)
+                resolved |= eSymbolContextTarget;
+        }
 
         // Update our internal flags so we remember what we have tried to locate so
         // we don't have to keep trying when more calls to this function are made.
-        m_flags.Set(resolve_scope);
+        // We might have dug up more information that was requested (for example
+        // if we were asked to only get the block, we will have gotten the 
+        // compile unit, and function) so set any additional bits that we resolved
+        m_flags.Set (resolve_scope | resolved);
     }
 
     // Return the symbol context with everything that was possible to resolve
@@ -412,8 +402,7 @@
     {
         m_flags.Set(RESOLVED_VARIABLES);
 
-        GetSymbolContext(eSymbolContextFunction);
-        if (m_sc.function)
+        if (GetSymbolContext (eSymbolContextFunction).function)
         {
             bool get_child_variables = true;
             bool can_create = true;
@@ -474,7 +463,7 @@
 bool
 StackFrame::HasDebugInformation ()
 {
-    GetSymbolContext(eSymbolContextLineEntry);
+    GetSymbolContext (eSymbolContextLineEntry);
     return m_sc.line_entry.IsValid();
 }
 
@@ -525,12 +514,12 @@
 
     if (show_frame_index)
         strm->Printf("frame #%u: ", m_frame_index);
-    strm->Printf("pc = 0x%0*llx", m_thread.GetProcess().GetAddressByteSize() * 2, GetRegisterContext()->GetPC());
-    SymbolContext sc (GetSymbolContext(eSymbolContextEverything));
+    strm->Printf("0x%0*llx", m_thread.GetProcess().GetAddressByteSize() * 2, GetFrameCodeAddress().GetLoadAddress(&m_thread.GetProcess()));
+    GetSymbolContext(eSymbolContextEverything);
     strm->PutCString(", where = ");
     // TODO: need to get the
     const bool show_module = true;
     const bool show_inline = true;
-    sc.DumpStopContext(strm, &m_thread.GetProcess(), GetPC(), show_module, show_inline);
+    m_sc.DumpStopContext(strm, &m_thread.GetProcess(), GetFrameCodeAddress(), show_module, show_inline);
 }
 

Modified: lldb/trunk/source/Target/Thread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=111964&r1=111963&r2=111964&view=diff
==============================================================================
--- lldb/trunk/source/Target/Thread.cpp (original)
+++ lldb/trunk/source/Target/Thread.cpp Tue Aug 24 16:05:24 2010
@@ -926,18 +926,21 @@
                     Block *parent_block = m_inlined_frame_info[idx].block->GetParent();
                     parent_block->CalculateSymbolContext(&inline_sc);
                 }
+
+                Address backed_up_pc (previous_frame_sp->GetFrameCodeAddress());
+                backed_up_pc.SetOffset(backed_up_pc.GetOffset()-1);
+                AddressRange range;
+                m_inlined_frame_info[idx].block->GetRangeContainingAddress (backed_up_pc, range);
                     
-                InlineFunctionInfo* inline_info = m_inlined_frame_info[idx].block->InlinedFunctionInfo();
+                const InlineFunctionInfo* inline_info = m_inlined_frame_info[idx].block->InlinedFunctionInfo();
                 assert (inline_info);
-                inline_sc.line_entry.range.GetBaseAddress() = previous_frame_sp->GetPC();
+                inline_sc.line_entry.range.GetBaseAddress() = previous_frame_sp->GetFrameCodeAddress();
                 inline_sc.line_entry.file = inline_info->GetCallSite().GetFile();
                 inline_sc.line_entry.line = inline_info->GetCallSite().GetLine();
                 inline_sc.line_entry.column = inline_info->GetCallSite().GetColumn();
 
                 StackFrameSP concrete_frame_sp (m_concrete_frames.GetFrameAtIndex (m_inlined_frame_info[idx].concrete_frame_index));
                 assert (previous_frame_sp.get());
-                AddressRange range;
-                m_inlined_frame_info[idx].block->GetRangeContainingAddress (previous_frame_sp->GetPC(), range);
                 
                 frame_sp.reset (new StackFrame (idx, 
                                                 m_inlined_frame_info[idx].concrete_frame_index,
@@ -949,7 +952,6 @@
                                                 &inline_sc));                                           // The symbol context for this inline frame
                 
             }
-
         }
         else
         {

Modified: lldb/trunk/source/Target/ThreadPlanStepInstruction.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanStepInstruction.cpp?rev=111964&r1=111963&r2=111964&view=diff
==============================================================================
--- lldb/trunk/source/Target/ThreadPlanStepInstruction.cpp (original)
+++ lldb/trunk/source/Target/ThreadPlanStepInstruction.cpp Tue Aug 24 16:05:24 2010
@@ -122,10 +122,10 @@
                 {
                     StreamString s;
                     s.PutCString ("Stepped in to: ");
-                    addr_t stop_addr = m_thread.GetStackFrameAtIndex(0)->GetPC().GetLoadAddress(&m_thread.GetProcess());
+                    addr_t stop_addr = m_thread.GetStackFrameAtIndex(0)->GetRegisterContext()->GetPC();
                     s.Address (stop_addr, m_thread.GetProcess().GetAddressByteSize());
                     s.PutCString (" stepping out to: ");
-                    addr_t return_addr = return_frame->GetPC().GetLoadAddress(&m_thread.GetProcess());
+                    addr_t return_addr = return_frame->GetRegisterContext()->GetPC();
                     s.Address (return_addr, m_thread.GetProcess().GetAddressByteSize());
                     log->Printf("%s.", s.GetData());
                 }

Modified: lldb/trunk/source/Target/ThreadPlanStepOut.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanStepOut.cpp?rev=111964&r1=111963&r2=111964&view=diff
==============================================================================
--- lldb/trunk/source/Target/ThreadPlanStepOut.cpp (original)
+++ lldb/trunk/source/Target/ThreadPlanStepOut.cpp Tue Aug 24 16:05:24 2010
@@ -53,7 +53,8 @@
     StackFrame *return_frame = m_thread.GetStackFrameAtIndex(1).get();
     if (return_frame)
     {
-        m_return_addr = return_frame->GetPC().GetLoadAddress(&m_thread.GetProcess());
+        // TODO: check for inlined frames and do the right thing...
+        m_return_addr = return_frame->GetRegisterContext()->GetPC();
         Breakpoint *return_bp = m_thread.GetProcess().GetTarget().CreateBreakpoint (m_return_addr, true).get();
         if (return_bp != NULL)
         {

Modified: lldb/trunk/source/Target/ThreadPlanStepUntil.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanStepUntil.cpp?rev=111964&r1=111963&r2=111964&view=diff
==============================================================================
--- lldb/trunk/source/Target/ThreadPlanStepUntil.cpp (original)
+++ lldb/trunk/source/Target/ThreadPlanStepUntil.cpp Tue Aug 24 16:05:24 2010
@@ -63,7 +63,8 @@
     // FIXME - can we do this more securely if we know first_insn?
 
     StackFrame *return_frame = m_thread.GetStackFrameAtIndex(1).get();
-    m_return_addr = return_frame->GetPC().GetLoadAddress(&m_thread.GetProcess());
+    // TODO: add inline functionality
+    m_return_addr = return_frame->GetRegisterContext()->GetPC();
     Breakpoint *return_bp = target.CreateBreakpoint (m_return_addr, true).get();
     if (return_bp != NULL)
     {





More information about the lldb-commits mailing list