[Lldb-commits] [lldb] r187094 - Handle the case where we are stepping through code with no symbols, so we can't really find the function start PC

Jim Ingham jingham at apple.com
Wed Jul 24 17:59:01 PDT 2013


Author: jingham
Date: Wed Jul 24 19:59:01 2013
New Revision: 187094

URL: http://llvm.org/viewvc/llvm-project?rev=187094&view=rev
Log:
Handle the case where we are stepping through code with no symbols, so we can't really find the function start PC 
and so the StackID changes with every step.  Do so by checking the parent frame ID, and if it hasn't changed,
then we haven't stepped in.

rdar://problem/14516227

Modified:
    lldb/trunk/include/lldb/Target/ThreadPlanStepInstruction.h
    lldb/trunk/source/Target/ThreadPlanStepInstruction.cpp

Modified: lldb/trunk/include/lldb/Target/ThreadPlanStepInstruction.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadPlanStepInstruction.h?rev=187094&r1=187093&r2=187094&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/ThreadPlanStepInstruction.h (original)
+++ lldb/trunk/include/lldb/Target/ThreadPlanStepInstruction.h Wed Jul 24 19:59:01 2013
@@ -49,8 +49,9 @@ private:
     lldb::addr_t m_instruction_addr;
     bool m_stop_other_threads;
     bool m_step_over;
-    // This is used only for the step over case.
+    // These two are used only for the step over case.
     StackID m_stack_id;
+    StackID m_parent_frame_id;
 
     DISALLOW_COPY_AND_ASSIGN (ThreadPlanStepInstruction);
 

Modified: lldb/trunk/source/Target/ThreadPlanStepInstruction.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanStepInstruction.cpp?rev=187094&r1=187093&r2=187094&view=diff
==============================================================================
--- lldb/trunk/source/Target/ThreadPlanStepInstruction.cpp (original)
+++ lldb/trunk/source/Target/ThreadPlanStepInstruction.cpp Wed Jul 24 19:59:01 2013
@@ -45,6 +45,9 @@ ThreadPlanStepInstruction::ThreadPlanSte
 {
     m_instruction_addr = m_thread.GetRegisterContext()->GetPC(0);
     m_stack_id = m_thread.GetStackFrameAtIndex(0)->GetStackID();
+    StackFrameSP parent_frame_sp = m_thread.GetStackFrameAtIndex(1);
+    if (parent_frame_sp)
+        m_parent_frame_id = parent_frame_sp->GetStackID();
 }
 
 ThreadPlanStepInstruction::~ThreadPlanStepInstruction ()
@@ -120,29 +123,42 @@ ThreadPlanStepInstruction::ShouldStop (E
             StackFrame *return_frame = m_thread.GetStackFrameAtIndex(1).get();
             if (return_frame)
             {
-                if (log)
+                if (return_frame->GetStackID() != m_parent_frame_id)
                 {
-                    StreamString s;
-                    s.PutCString ("Stepped in to: ");
-                    addr_t stop_addr = m_thread.GetStackFrameAtIndex(0)->GetRegisterContext()->GetPC();
-                    s.Address (stop_addr, m_thread.CalculateTarget()->GetArchitecture().GetAddressByteSize());
-                    s.PutCString (" stepping out to: ");
-                    addr_t return_addr = return_frame->GetRegisterContext()->GetPC();
-                    s.Address (return_addr, m_thread.CalculateTarget()->GetArchitecture().GetAddressByteSize());
-                    log->Printf("%s.", s.GetData());
+                    if (log)
+                    {
+                        StreamString s;
+                        s.PutCString ("Stepped in to: ");
+                        addr_t stop_addr = m_thread.GetStackFrameAtIndex(0)->GetRegisterContext()->GetPC();
+                        s.Address (stop_addr, m_thread.CalculateTarget()->GetArchitecture().GetAddressByteSize());
+                        s.PutCString (" stepping out to: ");
+                        addr_t return_addr = return_frame->GetRegisterContext()->GetPC();
+                        s.Address (return_addr, m_thread.CalculateTarget()->GetArchitecture().GetAddressByteSize());
+                        log->Printf("%s.", s.GetData());
+                    }
+                    
+                    // StepInstruction should probably have the tri-state RunMode, but for now it is safer to
+                    // run others.
+                    const bool stop_others = false;
+                    m_thread.QueueThreadPlanForStepOut(false,
+                                                       NULL,
+                                                       true,
+                                                       stop_others,
+                                                       eVoteNo,
+                                                       eVoteNoOpinion,
+                                                       0);
+                    return false;
+                }
+                else
+                {
+                    if (log)
+                    {
+                        log->PutCString("The stack id we are stepping in changed, but our parent frame did not.  "
+                        "We are probably just confused about where we are, stopping.");
+                    }
+                    SetPlanComplete();
+                    return true;
                 }
-                
-                // StepInstruction should probably have the tri-state RunMode, but for now it is safer to
-                // run others.
-                const bool stop_others = false;
-                m_thread.QueueThreadPlanForStepOut(false,
-                                                   NULL,
-                                                   true,
-                                                   stop_others,
-                                                   eVoteNo,
-                                                   eVoteNoOpinion,
-                                                   0);
-                return false;
             }
             else
             {





More information about the lldb-commits mailing list