[Lldb-commits] [lldb] r111989 - in /lldb/trunk: include/lldb/Core/Address.h include/lldb/Target/StackFrame.h include/lldb/Target/Thread.h source/Core/Address.cpp source/Target/StackFrame.cpp source/Target/Thread.cpp

Greg Clayton gclayton at apple.com
Tue Aug 24 15:59:52 PDT 2010


Author: gclayton
Date: Tue Aug 24 17:59:52 2010
New Revision: 111989

URL: http://llvm.org/viewvc/llvm-project?rev=111989&view=rev
Log:
Fixed another issue with the inline stack frames where if the first frame
has inlined functions that all started at the same address, then the inlined
backtrace would not produce correct stack frames.

Also cleaned up and inlined a lot of stuff in lldb_private::Address.

Added a function to StackFrame to detect if the frame is a concrete frame so
we can detect the difference between actual frames and inlined frames.


Modified:
    lldb/trunk/include/lldb/Core/Address.h
    lldb/trunk/include/lldb/Target/StackFrame.h
    lldb/trunk/include/lldb/Target/Thread.h
    lldb/trunk/source/Core/Address.cpp
    lldb/trunk/source/Target/StackFrame.cpp
    lldb/trunk/source/Target/Thread.cpp

Modified: lldb/trunk/include/lldb/Core/Address.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Address.h?rev=111989&r1=111988&r2=111989&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Address.h (original)
+++ lldb/trunk/include/lldb/Core/Address.h Tue Aug 24 17:59:52 2010
@@ -97,7 +97,13 @@
     /// Initialize with a invalid section (NULL) and an invalid
     /// offset (LLDB_INVALID_ADDRESS).
     //------------------------------------------------------------------
-    Address ();
+    Address () :
+        SymbolContextScope(),
+        m_section (NULL),
+        m_offset (LLDB_INVALID_ADDRESS)
+    {
+    }
+
 
     //------------------------------------------------------------------
     /// Copy constructor
@@ -107,7 +113,12 @@
     /// @param[in] rhs
     ///     A const Address object reference to copy.
     //------------------------------------------------------------------
-    Address (const Address& rhs);
+    Address (const Address& rhs) :
+        SymbolContextScope(rhs),
+        m_section (rhs.m_section),
+        m_offset (rhs.m_offset)
+    {
+    }
 
     //------------------------------------------------------------------
     /// Construct with a section pointer and offset.
@@ -122,7 +133,12 @@
     /// @param[in] offset
     ///     The offset in bytes into \a section.
     //------------------------------------------------------------------
-    Address (const Section* section, lldb::addr_t offset);
+    Address (const Section* section, lldb::addr_t offset) :
+        SymbolContextScope(),
+        m_section (section),
+        m_offset (offset)
+    {
+    }
 
     //------------------------------------------------------------------
     /// Construct with a virtual address and section list.
@@ -161,7 +177,11 @@
     /// offset (LLDB_INVALID_ADDRESS).
     //------------------------------------------------------------------
     void
-    Clear ();
+    Clear ()
+    {
+        m_section = NULL;
+        m_offset = LLDB_INVALID_ADDRESS;
+    }
 
     //------------------------------------------------------------------
     /// Compare two Address objects.
@@ -301,7 +321,10 @@
     ///     offset, \b false otherwise.
     //------------------------------------------------------------------
     bool
-    IsSectionOffset() const;
+    IsSectionOffset() const
+    {
+        return m_section != NULL && IsValid();
+    }
 
     //------------------------------------------------------------------
     /// Check if the object state is valid.
@@ -315,7 +338,11 @@
     ///     otherwise.
     //------------------------------------------------------------------
     bool
-    IsValid() const;
+    IsValid() const
+    {
+        return m_offset != LLDB_INVALID_ADDRESS;
+    }
+
 
     //------------------------------------------------------------------
     /// Get the memory cost of this object.
@@ -376,7 +403,23 @@
     ///     Returns \b true if the offset changed, \b false otherwise.
     //------------------------------------------------------------------
     bool
-    SetOffset (lldb::addr_t offset);
+    SetOffset (lldb::addr_t offset)
+    {
+        bool changed = m_offset != offset;
+        m_offset = offset;
+        return changed;
+    }
+
+    bool
+    Slide (int64_t offset)
+    {
+        if (m_offset != LLDB_INVALID_ADDRESS)
+        {
+            m_offset += offset;
+            return true;
+        }
+        return false;
+    }
 
     //------------------------------------------------------------------
     /// Set accessor for the section.

Modified: lldb/trunk/include/lldb/Target/StackFrame.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/StackFrame.h?rev=111989&r1=111988&r2=111989&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/StackFrame.h (original)
+++ lldb/trunk/include/lldb/Target/StackFrame.h Tue Aug 24 17:59:52 2010
@@ -96,6 +96,10 @@
     {
         return m_concrete_frame_index;
     }
+    
+    bool
+    IsConcrete () const;
+
     //------------------------------------------------------------------
     // lldb::ExecutionContextScope pure virtual functions
     //------------------------------------------------------------------

Modified: lldb/trunk/include/lldb/Target/Thread.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Thread.h?rev=111989&r1=111988&r2=111989&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Thread.h (original)
+++ lldb/trunk/include/lldb/Target/Thread.h Tue Aug 24 17:59:52 2010
@@ -28,135 +28,7 @@
     public UserID,
     public ExecutionContextScope
 {
-friend class ThreadPlan;
 public:
-//    //----------------------------------------------------------------------
-//    // StopInfo
-//    //
-//    // Describes the reason the thread it was created with stopped.
-//    //----------------------------------------------------------------------
-//    class StopInfo
-//    {
-//    public:
-//        StopInfo(Thread *thread = NULL);
-//
-//        ~StopInfo();
-//
-//        // Clear clears the stop reason, but it does not clear the thread this
-//        // StopInfo is tied to.
-//        void
-//        Clear();
-//
-//        lldb::StopReason
-//        GetStopReason() const;
-//
-//        void
-//        SetThread (Thread *thread);
-//
-//        Thread *
-//        GetThread ();
-//
-//        void
-//        SetStopReasonWithBreakpointSiteID (lldb::user_id_t break_id);
-//
-//        void
-//        SetStopReasonWithWatchpointID (lldb::user_id_t watch_id);
-//
-//        void
-//        SetStopReasonWithSignal (int signo);
-//
-//        void
-//        SetStopReasonToTrace ();
-//
-//        void
-//        SetStopReasonWithGenericException (uint32_t exc_type, size_t exc_data_count);
-//
-//        void
-//        SetStopReasonWithPlan (lldb::ThreadPlanSP &plan);
-//
-//        void
-//        SetStopReasonToNone ();
-//
-//        const char *
-//        GetStopDescription() const;
-//
-//        void
-//        SetStopDescription(const char *desc);
-//        
-//        void
-//        SetStopReasonWithMachException (uint32_t exc_type, 
-//                                        size_t exc_data_count, 
-//                                        const lldb::addr_t *exc_data);
-//
-//        lldb::user_id_t
-//        GetBreakpointSiteID() const;
-//
-//        lldb::user_id_t
-//        GetWatchpointID() const;
-//
-//        int
-//        GetSignal() const;
-//
-//        lldb::user_id_t
-//        GetPlanID () const;
-//
-//        uint32_t
-//        GetExceptionType() const;
-//
-//        size_t
-//        GetExceptionDataCount() const;
-//
-//        lldb::addr_t
-//        GetExceptionDataAtIndex (uint32_t idx) const;
-//
-//        bool
-//        SetExceptionDataAtIndex (uint32_t idx, lldb::addr_t data);
-//
-//        void
-//        Dump (Stream *s) const;
-//
-//    protected:
-//        lldb::StopReason m_reason;
-//        //--------------------------------------------------------------
-//        // For eStopReasonPlan the completed plan is stored in this shared pointer.
-//        //--------------------------------------------------------------
-//        lldb::ThreadPlanSP m_completed_plan_sp;
-//        Thread *m_thread;
-//        char m_description[256];
-//        union
-//        {
-//            //--------------------------------------------------------------
-//            // eStopReasonBreakpoint
-//            //--------------------------------------------------------------
-//            struct
-//            {
-//                lldb::user_id_t bp_site_id;
-//            } breakpoint;
-//            //--------------------------------------------------------------
-//            // eStopReasonWatchpoint
-//            //--------------------------------------------------------------
-//            struct
-//            {
-//                lldb::user_id_t watch_id;
-//            } watchpoint;
-//            //--------------------------------------------------------------
-//            // eStopReasonSignal
-//            //--------------------------------------------------------------
-//            struct
-//            {
-//                int signo;
-//            } signal;
-//            //--------------------------------------------------------------
-//            // eStopReasonException
-//            //--------------------------------------------------------------
-//            struct
-//            {
-//                uint32_t type;
-//                size_t data_count;
-//                lldb::addr_t data[LLDB_THREAD_MAX_STOP_EXC_DATA];
-//            } exception;
-//        } m_details;
-//    };
 
     class RegisterCheckpoint
     {
@@ -648,6 +520,9 @@
     Calculate (ExecutionContext &exe_ctx);
 
 protected:
+
+    friend class ThreadPlan;
+
     void
     PushPlan (lldb::ThreadPlanSP &plan_sp);
 

Modified: lldb/trunk/source/Core/Address.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Address.cpp?rev=111989&r1=111988&r2=111989&view=diff
==============================================================================
--- lldb/trunk/source/Core/Address.cpp (original)
+++ lldb/trunk/source/Core/Address.cpp Tue Aug 24 17:59:52 2010
@@ -240,27 +240,6 @@
     return total_len;
 }
 
-Address::Address () :
-    SymbolContextScope(),
-    m_section (NULL),
-    m_offset (LLDB_INVALID_ADDRESS)
-{
-}
-
-Address::Address (const Address& rhs) :
-    SymbolContextScope(rhs),
-    m_section (rhs.m_section),
-    m_offset (rhs.m_offset)
-{
-}
-
-Address::Address (const Section* section, addr_t offset) :
-    SymbolContextScope(),
-    m_section (section),
-    m_offset (offset)
-{
-}
-
 Address::Address (addr_t address, const SectionList * sections) :
     SymbolContextScope(),
     m_section (NULL),
@@ -281,18 +260,6 @@
 }
 
 bool
-Address::IsValid() const
-{
-    return m_offset != LLDB_INVALID_ADDRESS;
-}
-
-bool
-Address::IsSectionOffset() const
-{
-    return m_section != NULL && IsValid();
-}
-
-bool
 Address::ResolveAddressUsingFileSections (addr_t addr, const SectionList *sections)
 {
     if (sections)
@@ -392,22 +359,6 @@
 }
 
 bool
-Address::SetOffset (addr_t offset)
-{
-    bool changed = m_offset != offset;
-    m_offset = offset;
-    return changed;
-}
-
-void
-Address::Clear()
-{
-    m_section = NULL;
-    m_offset = LLDB_INVALID_ADDRESS;
-}
-
-
-bool
 Address::Dump (Stream *s, ExecutionContextScope *exe_scope, DumpStyle style, DumpStyle fallback_style, uint32_t addr_size) const
 {
     // If the section was NULL, only load address is going to work.

Modified: lldb/trunk/source/Target/StackFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StackFrame.cpp?rev=111989&r1=111988&r2=111989&view=diff
==============================================================================
--- lldb/trunk/source/Target/StackFrame.cpp (original)
+++ lldb/trunk/source/Target/StackFrame.cpp Tue Aug 24 17:59:52 2010
@@ -473,6 +473,11 @@
     return m_value_object_list;
 }
 
+bool
+StackFrame::IsConcrete () const
+{
+    return m_id.GetInlineHeight () == 0;
+}
 
 Target *
 StackFrame::CalculateTarget ()

Modified: lldb/trunk/source/Target/Thread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=111989&r1=111988&r2=111989&view=diff
==============================================================================
--- lldb/trunk/source/Target/Thread.cpp (original)
+++ lldb/trunk/source/Target/Thread.cpp Tue Aug 24 17:59:52 2010
@@ -926,11 +926,13 @@
                     Block *parent_block = m_inlined_frame_info[idx].block->GetParent();
                     parent_block->CalculateSymbolContext(&inline_sc);
                 }
+                
+                Address previous_frame_lookup_addr (previous_frame_sp->GetFrameCodeAddress());
+                if (previous_frame_sp->IsConcrete () && previous_frame_sp->GetFrameIndex() > 0)
+                    previous_frame_lookup_addr.Slide (-1);
 
-                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);
+                m_inlined_frame_info[idx].block->GetRangeContainingAddress (previous_frame_lookup_addr, range);
                     
                 const InlineFunctionInfo* inline_info = m_inlined_frame_info[idx].block->InlinedFunctionInfo();
                 assert (inline_info);





More information about the lldb-commits mailing list