[Lldb-commits] [lldb] r114055 - in /lldb/trunk: include/lldb/Target/ThreadPlanStepInRange.h source/Target/ThreadPlanStepInRange.cpp source/Target/ThreadPlanStepRange.cpp

Jim Ingham jingham at apple.com
Wed Sep 15 17:58:09 PDT 2010


Author: jingham
Date: Wed Sep 15 19:58:09 2010
New Revision: 114055

URL: http://llvm.org/viewvc/llvm-project?rev=114055&view=rev
Log:
Step past prologues when we step into functions.

Modified:
    lldb/trunk/include/lldb/Target/ThreadPlanStepInRange.h
    lldb/trunk/source/Target/ThreadPlanStepInRange.cpp
    lldb/trunk/source/Target/ThreadPlanStepRange.cpp

Modified: lldb/trunk/include/lldb/Target/ThreadPlanStepInRange.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadPlanStepInRange.h?rev=114055&r1=114054&r2=114055&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/ThreadPlanStepInRange.h (original)
+++ lldb/trunk/include/lldb/Target/ThreadPlanStepInRange.h Wed Sep 15 19:58:09 2010
@@ -73,6 +73,8 @@
 
     static uint32_t s_default_flag_values;
     std::auto_ptr<RegularExpression> m_avoid_regexp_ap;
+    bool m_step_past_prologue;  // FIXME: For now hard-coded to true, we could put a switch in for this if there's
+                                // demand for that.
 
     DISALLOW_COPY_AND_ASSIGN (ThreadPlanStepInRange);
 

Modified: lldb/trunk/source/Target/ThreadPlanStepInRange.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanStepInRange.cpp?rev=114055&r1=114054&r2=114055&view=diff
==============================================================================
--- lldb/trunk/source/Target/ThreadPlanStepInRange.cpp (original)
+++ lldb/trunk/source/Target/ThreadPlanStepInRange.cpp Wed Sep 15 19:58:09 2010
@@ -18,6 +18,7 @@
 #include "lldb/Core/Log.h"
 #include "lldb/Core/Stream.h"
 #include "lldb/Symbol/Symbol.h"
+#include "lldb/Symbol/Function.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/RegisterContext.h"
 #include "lldb/Target/Thread.h"
@@ -43,10 +44,10 @@
     lldb::RunMode stop_others
 ) :
     ThreadPlanStepRange (ThreadPlan::eKindStepInRange, "Step Range stepping in", thread, range, addr_context, stop_others),
-    ThreadPlanShouldStopHere (this, ThreadPlanStepInRange::DefaultShouldStopHereCallback, NULL)
+    ThreadPlanShouldStopHere (this, ThreadPlanStepInRange::DefaultShouldStopHereCallback, NULL),
+    m_step_past_prologue (true)
 {
     SetFlagsToDefault ();
-    // SetAvoidRegexp("^std\\:\\:.*");
 }
 
 ThreadPlanStepInRange::~ThreadPlanStepInRange ()
@@ -125,8 +126,46 @@
     if (!new_plan && FrameIsYounger())
         new_plan = InvokeShouldStopHereCallback();
 
-    if (new_plan == NULL)
+    // If we've stepped in and we are going to stop here, check to see if we were asked to
+    // run past the prologue, and if so do that.
+    
+    if (new_plan == NULL && FrameIsYounger() && m_step_past_prologue)
     {
+        lldb::StackFrameSP curr_frame = m_thread.GetStackFrameAtIndex(0);
+        if (curr_frame)
+        {
+            size_t bytes_to_skip = 0;
+            lldb::addr_t curr_addr = m_thread.GetRegisterContext()->GetPC();
+            Address func_start_address;
+            
+            SymbolContext sc = curr_frame->GetSymbolContext (eSymbolContextFunction | eSymbolContextSymbol);
+            
+            if (sc.function)
+            {
+                func_start_address = sc.function->GetAddressRange().GetBaseAddress();
+                if (curr_addr == func_start_address.GetLoadAddress(m_thread.CalculateTarget()))
+                    bytes_to_skip = sc.function->GetPrologueByteSize();
+            }
+            else if (sc.symbol)
+            {
+                func_start_address = sc.symbol->GetValue();
+                if (curr_addr == func_start_address.GetLoadAddress(m_thread.CalculateTarget()))
+                    bytes_to_skip = sc.symbol->GetPrologueByteSize();
+            }
+            
+            if (bytes_to_skip != 0)
+            {
+                func_start_address.Slide (bytes_to_skip);
+                if (log)
+                    log->Printf ("Pushing past prologue ");
+                    
+                new_plan = m_thread.QueueThreadPlanForRunToAddress(false, func_start_address,true);
+            }
+        }
+    }
+    
+     if (new_plan == NULL)
+     {
         m_no_more_plans = true;
         SetPlanComplete();
         return true;

Modified: lldb/trunk/source/Target/ThreadPlanStepRange.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanStepRange.cpp?rev=114055&r1=114054&r2=114055&view=diff
==============================================================================
--- lldb/trunk/source/Target/ThreadPlanStepRange.cpp (original)
+++ lldb/trunk/source/Target/ThreadPlanStepRange.cpp Wed Sep 15 19:58:09 2010
@@ -159,6 +159,10 @@
 ThreadPlanStepRange::FrameIsYounger ()
 {
     Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP);
+    
+    // FIXME: Might be better to do this by storing the FrameID we started in and seeing if that is still above
+    // us on the stack.  Counting the whole stack could be expensive.
+    
     uint32_t current_depth = m_thread.GetStackFrameCount();
     if (current_depth == m_stack_depth)
     {





More information about the lldb-commits mailing list