[Lldb-commits] [lldb] r156627 - in /lldb/trunk: include/lldb/Target/ThreadPlanCallFunction.h source/Expression/ClangFunction.cpp source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp source/Plugins/Process/Utility/InferiorCallPOSIX.cpp source/Target/Thread.cpp source/Target/ThreadPlanCallFunction.cpp source/Target/ThreadPlanCallUserExpression.cpp

Jim Ingham jingham at apple.com
Fri May 11 11:43:38 PDT 2012


Author: jingham
Date: Fri May 11 13:43:38 2012
New Revision: 156627

URL: http://llvm.org/viewvc/llvm-project?rev=156627&view=rev
Log:
Don't try to use "OkayToDiscard" to mean BOTH this plan is a user plan or not AND unwind on error.

rdar://problem/11419156

Modified:
    lldb/trunk/include/lldb/Target/ThreadPlanCallFunction.h
    lldb/trunk/source/Expression/ClangFunction.cpp
    lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
    lldb/trunk/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp
    lldb/trunk/source/Target/Thread.cpp
    lldb/trunk/source/Target/ThreadPlanCallFunction.cpp
    lldb/trunk/source/Target/ThreadPlanCallUserExpression.cpp

Modified: lldb/trunk/include/lldb/Target/ThreadPlanCallFunction.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadPlanCallFunction.h?rev=156627&r1=156626&r2=156627&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/ThreadPlanCallFunction.h (original)
+++ lldb/trunk/include/lldb/Target/ThreadPlanCallFunction.h Fri May 11 13:43:38 2012
@@ -133,7 +133,6 @@
 
     bool
     ConstructorSetup (Thread &thread,
-                      bool discard_on_error,
                       ABI *& abi,
                       lldb::addr_t &start_load_addr,
                       lldb::addr_t &function_load_addr);
@@ -170,6 +169,7 @@
     lldb::ValueObjectSP                             m_return_valobj_sp;  // If this contains a valid pointer, use the ABI to extract values when complete
     bool                                            m_takedown_done;    // We want to ensure we only do the takedown once.  This ensures that.
     lldb::addr_t                                    m_stop_address;     // This is the address we stopped at.  Also set in DoTakedown;
+    bool                                            m_discard_on_error;
 
     DISALLOW_COPY_AND_ASSIGN (ThreadPlanCallFunction);
 };

Modified: lldb/trunk/source/Expression/ClangFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangFunction.cpp?rev=156627&r1=156626&r2=156627&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangFunction.cpp (original)
+++ lldb/trunk/source/Expression/ClangFunction.cpp Fri May 11 13:43:38 2012
@@ -410,6 +410,8 @@
                                                        discard_on_error,
                                                        this_arg,
                                                        cmd_arg);
+    new_plan->SetIsMasterPlan(true);
+    new_plan->SetOkayToDiscard (false);
     return new_plan;
 }
 

Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp?rev=156627&r1=156626&r2=156627&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp Fri May 11 13:43:38 2012
@@ -65,12 +65,8 @@
 void
 AppleThreadPlanStepThroughObjCTrampoline::DidPush ()
 {
-//    StreamString errors;
-//    ExecutionContext exc_ctx;
-//    m_thread.CalculateExecutionContext(exc_ctx);
-//    m_func_sp.reset(m_impl_function->GetThreadPlanToCallFunction (exc_ctx, m_args_addr, errors, m_stop_others));
-//    m_func_sp->SetPrivate(true);
-//    m_thread.QueueThreadPlan (m_func_sp, false);
+    // Setting up the memory space for the called function text might require allocations,
+    // i.e. a nested function call.  This needs to be done as a PreResumeAction.
     m_thread.GetProcess()->AddPreResumeAction (PreResumeInitializeClangFunction, (void *) this);
 }
 
@@ -91,6 +87,7 @@
         m_thread.CalculateExecutionContext(exc_ctx);
         m_func_sp.reset(m_impl_function->GetThreadPlanToCallFunction (exc_ctx, m_args_addr, errors, m_stop_others));
         m_func_sp->SetPrivate(true);
+        m_func_sp->SetOkayToDiscard(true);
         m_thread.QueueThreadPlan (m_func_sp, false);
     }
     return true;

Modified: lldb/trunk/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp?rev=156627&r1=156626&r2=156627&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp Fri May 11 13:43:38 2012
@@ -90,6 +90,10 @@
                 if (call_plan_sp)
                 {
                     StreamFile error_strm;
+                    // This plan is a utility plan, so set it to discard itself when done.
+                    call_plan_sp->SetIsMasterPlan (true);
+                    call_plan_sp->SetOkayToDiscard(true);
+                    
                     StackFrame *frame = thread->GetStackFrameAtIndex (0).get();
                     if (frame)
                     {
@@ -164,6 +168,10 @@
                if (call_plan_sp)
                {
                    StreamFile error_strm;
+                   // This plan is a utility plan, so set it to discard itself when done.
+                   call_plan_sp->SetIsMasterPlan (true);
+                   call_plan_sp->SetOkayToDiscard(true);
+                   
                    StackFrame *frame = thread->GetStackFrameAtIndex (0).get();
                    if (frame)
                    {

Modified: lldb/trunk/source/Target/Thread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=156627&r1=156626&r2=156627&view=diff
==============================================================================
--- lldb/trunk/source/Target/Thread.cpp (original)
+++ lldb/trunk/source/Target/Thread.cpp Fri May 11 13:43:38 2012
@@ -447,7 +447,6 @@
                             break;
                         }
                     }
-
                 }
                 else
                 {

Modified: lldb/trunk/source/Target/ThreadPlanCallFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanCallFunction.cpp?rev=156627&r1=156626&r2=156627&view=diff
==============================================================================
--- lldb/trunk/source/Target/ThreadPlanCallFunction.cpp (original)
+++ lldb/trunk/source/Target/ThreadPlanCallFunction.cpp Fri May 11 13:43:38 2012
@@ -36,15 +36,12 @@
 //----------------------------------------------------------------------
 bool
 ThreadPlanCallFunction::ConstructorSetup (Thread &thread,
-                                          bool discard_on_error,
                                           ABI *& abi,
                                           lldb::addr_t &start_load_addr,
                                           lldb::addr_t &function_load_addr)
 {
-    // Call function thread plans need to be master plans so that they can potentially stay on the stack when
-    // a breakpoint is hit during the function call.
     SetIsMasterPlan (true);
-    SetOkayToDiscard (discard_on_error);
+    SetOkayToDiscard (false);
 
     ProcessSP process_sp (thread.GetProcess());
     if (!process_sp)
@@ -136,12 +133,13 @@
     m_function_sp (NULL),
     m_return_type (return_type),
     m_takedown_done (false),
-    m_stop_address (LLDB_INVALID_ADDRESS)
+    m_stop_address (LLDB_INVALID_ADDRESS),
+    m_discard_on_error (discard_on_error)
 {
     lldb::addr_t start_load_addr;
     ABI *abi;
     lldb::addr_t function_load_addr;
-    if (!ConstructorSetup (thread, discard_on_error, abi, start_load_addr, function_load_addr))
+    if (!ConstructorSetup (thread, abi, start_load_addr, function_load_addr))
         return;
         
     if (this_arg && cmd_arg)
@@ -204,7 +202,7 @@
     lldb::addr_t start_load_addr;
     ABI *abi;
     lldb::addr_t function_load_addr;
-    if (!ConstructorSetup (thread, discard_on_error, abi, start_load_addr, function_load_addr))
+    if (!ConstructorSetup (thread, abi, start_load_addr, function_load_addr))
         return;
     
     if (!abi->PrepareTrivialCall (thread, 
@@ -354,7 +352,7 @@
         return true;
     
     // If we don't want to discard this plan, than any stop we don't understand should be propagated up the stack.
-    if (!OkayToDiscard())
+    if (!m_discard_on_error)
         return false;
             
     // Otherwise, check the case where we stopped for an internal breakpoint, in that case, continue on.
@@ -386,7 +384,13 @@
                 return false;
         }
         
-        return OkayToDiscard();
+        if (m_discard_on_error)
+        {
+            DoTakedown(false);
+            return true;
+        }
+        else
+            return false;
     }
     else
     {
@@ -396,7 +400,7 @@
         // explain the stop.
         if (m_subplan_sp != NULL)
         {
-            if (OkayToDiscard())
+            if (m_discard_on_error)
             {
                 DoTakedown(false);
                 return true;

Modified: lldb/trunk/source/Target/ThreadPlanCallUserExpression.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanCallUserExpression.cpp?rev=156627&r1=156626&r2=156627&view=diff
==============================================================================
--- lldb/trunk/source/Target/ThreadPlanCallUserExpression.cpp (original)
+++ lldb/trunk/source/Target/ThreadPlanCallUserExpression.cpp Fri May 11 13:43:38 2012
@@ -47,6 +47,9 @@
     ThreadPlanCallFunction (thread, function, ClangASTType(), arg, stop_other_threads, discard_on_error, this_arg, cmd_arg),
     m_user_expression_sp (user_expression_sp)
 {
+    // User expressions are generally "User generated" so we should set them up to stop when done.
+    SetIsMasterPlan (true);
+    SetOkayToDiscard(false);
 }
 
 ThreadPlanCallUserExpression::~ThreadPlanCallUserExpression ()





More information about the lldb-commits mailing list