[Lldb-commits] [lldb] r277879 - Add a few more needed bits to the scripted thread plans.

Jim Ingham via lldb-commits lldb-commits at lists.llvm.org
Fri Aug 5 15:06:12 PDT 2016


Author: jingham
Date: Fri Aug  5 17:06:12 2016
New Revision: 277879

URL: http://llvm.org/viewvc/llvm-project?rev=277879&view=rev
Log:
Add a few more needed bits to the scripted thread plans.

Modified:
    lldb/trunk/include/lldb/API/SBThread.h
    lldb/trunk/include/lldb/API/SBThreadPlan.h
    lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h
    lldb/trunk/include/lldb/Target/ThreadPlanPython.h
    lldb/trunk/scripts/interface/SBThread.i
    lldb/trunk/scripts/interface/SBThreadPlan.i
    lldb/trunk/source/API/SBThread.cpp
    lldb/trunk/source/API/SBThreadPlan.cpp
    lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
    lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
    lldb/trunk/source/Target/ThreadPlanPython.cpp

Modified: lldb/trunk/include/lldb/API/SBThread.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBThread.h?rev=277879&r1=277878&r2=277879&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBThread.h (original)
+++ lldb/trunk/include/lldb/API/SBThread.h Fri Aug  5 17:06:12 2016
@@ -142,6 +142,9 @@ public:
     StepUsingScriptedThreadPlan (const char *script_class_name);
 
     SBError
+    StepUsingScriptedThreadPlan (const char *script_class_name, bool resume_immediately);
+
+    SBError
     JumpToLine (lldb::SBFileSpec &file_spec, uint32_t line);
 
     void

Modified: lldb/trunk/include/lldb/API/SBThreadPlan.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBThreadPlan.h?rev=277879&r1=277878&r2=277879&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBThreadPlan.h (original)
+++ lldb/trunk/include/lldb/API/SBThreadPlan.h Fri Aug  5 17:06:12 2016
@@ -81,6 +81,9 @@ public:
 
     bool
     IsPlanComplete();
+    
+    bool
+    IsPlanStale();
 
     bool
     IsValid();

Modified: lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h?rev=277879&r1=277878&r2=277879&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h (original)
+++ lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h Fri Aug  5 17:06:12 2016
@@ -265,6 +265,13 @@ public:
         return true;
     }
 
+    virtual bool
+    ScriptedThreadPlanIsStale(StructuredData::ObjectSP implementor_sp, bool &script_error)
+    {
+        script_error = true;
+        return true;
+    }
+
     virtual lldb::StateType
     ScriptedThreadPlanGetRunState(StructuredData::ObjectSP implementor_sp, bool &script_error)
     {

Modified: lldb/trunk/include/lldb/Target/ThreadPlanPython.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadPlanPython.h?rev=277879&r1=277878&r2=277879&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/ThreadPlanPython.h (original)
+++ lldb/trunk/include/lldb/Target/ThreadPlanPython.h Fri Aug  5 17:06:12 2016
@@ -60,6 +60,9 @@ public:
 
     void
     DidPush() override;
+    
+    bool
+    IsPlanStale() override;
 
 protected:
     bool

Modified: lldb/trunk/scripts/interface/SBThread.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/interface/SBThread.i?rev=277879&r1=277878&r2=277879&view=diff
==============================================================================
--- lldb/trunk/scripts/interface/SBThread.i (original)
+++ lldb/trunk/scripts/interface/SBThread.i Fri Aug  5 17:06:12 2016
@@ -244,6 +244,9 @@ public:
     StepUsingScriptedThreadPlan (const char *script_class_name);
 
     SBError
+    StepUsingScriptedThreadPlan (const char *script_class_name, bool resume_immediately);
+
+    SBError
     JumpToLine (lldb::SBFileSpec &file_spec, uint32_t line);
 
     void

Modified: lldb/trunk/scripts/interface/SBThreadPlan.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/interface/SBThreadPlan.i?rev=277879&r1=277878&r2=277879&view=diff
==============================================================================
--- lldb/trunk/scripts/interface/SBThreadPlan.i (original)
+++ lldb/trunk/scripts/interface/SBThreadPlan.i Fri Aug  5 17:06:12 2016
@@ -86,6 +86,9 @@ public:
     IsPlanComplete();
 
     bool
+    IsPlanStale();
+
+    bool
     IsValid();
 
     // This section allows an SBThreadPlan to push another of the common types of plans...

Modified: lldb/trunk/source/API/SBThread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBThread.cpp?rev=277879&r1=277878&r2=277879&view=diff
==============================================================================
--- lldb/trunk/source/API/SBThread.cpp (original)
+++ lldb/trunk/source/API/SBThread.cpp Fri Aug  5 17:06:12 2016
@@ -1161,6 +1161,12 @@ SBThread::StepOverUntil (lldb::SBFrame &
 SBError
 SBThread::StepUsingScriptedThreadPlan (const char *script_class_name)
 {
+    StepUsingScriptedThreadPlan(script_class_name, true);
+}
+
+SBError
+SBThread::StepUsingScriptedThreadPlan (const char *script_class_name, bool resume_immediately)
+{
     Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     SBError sb_error;
 
@@ -1184,15 +1190,26 @@ SBThread::StepUsingScriptedThreadPlan (c
     Thread *thread = exe_ctx.GetThreadPtr();
     ThreadPlanSP thread_plan_sp = thread->QueueThreadPlanForStepScripted(false, script_class_name, false);
 
+    if (!thread_plan_sp)
+    {
+        sb_error.SetErrorStringWithFormat("Error queueing thread plan for class: %s", script_class_name);
+        return sb_error;
+    }
+    
+    if (!resume_immediately)
+    {
+        return sb_error;
+    }
+    
     if (thread_plan_sp)
         sb_error = ResumeNewPlan(exe_ctx, thread_plan_sp.get());
     else
     {
-        sb_error.SetErrorStringWithFormat("Error queuing thread plan for class: %s.", script_class_name);
+        sb_error.SetErrorStringWithFormat("Error resuming thread plan for class: %s.", script_class_name);
         if (log)
-        log->Printf ("SBThread(%p)::StepUsingScriptedThreadPlan: Error queuing thread plan for class: %s",
-                     static_cast<void*>(exe_ctx.GetThreadPtr()),
-                     script_class_name);
+            log->Printf ("SBThread(%p)::StepUsingScriptedThreadPlan: Error queuing thread plan for class: %s",
+                    static_cast<void*>(exe_ctx.GetThreadPtr()),
+                    script_class_name);
     }
 
     return sb_error;

Modified: lldb/trunk/source/API/SBThreadPlan.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBThreadPlan.cpp?rev=277879&r1=277878&r2=277879&view=diff
==============================================================================
--- lldb/trunk/source/API/SBThreadPlan.cpp (original)
+++ lldb/trunk/source/API/SBThreadPlan.cpp Fri Aug  5 17:06:12 2016
@@ -174,6 +174,15 @@ SBThreadPlan::IsPlanComplete()
 }
 
 bool
+SBThreadPlan::IsPlanStale()
+{
+    if (m_opaque_sp)
+        return m_opaque_sp->IsPlanStale();
+    else
+        return true;
+}
+
+bool
 SBThreadPlan::IsValid()
 {
     if (m_opaque_sp)

Modified: lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp?rev=277879&r1=277878&r2=277879&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp (original)
+++ lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp Fri Aug  5 17:06:12 2016
@@ -1823,6 +1823,23 @@ ScriptInterpreterPython::ScriptedThreadP
     return should_stop;
 }
 
+bool
+ScriptInterpreterPython::ScriptedThreadPlanIsStale(StructuredData::ObjectSP implementor_sp, bool &script_error)
+{
+    bool is_stale = true;
+    StructuredData::Generic *generic = nullptr;
+    if (implementor_sp)
+        generic = implementor_sp->GetAsGeneric();
+    if (generic)
+    {
+        Locker py_lock(this, Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
+        is_stale = g_swig_call_thread_plan(generic->GetValue(), "is_stale", nullptr, script_error);
+        if (script_error)
+            return true;
+    }
+    return is_stale;
+}
+
 lldb::StateType
 ScriptInterpreterPython::ScriptedThreadPlanGetRunState(StructuredData::ObjectSP implementor_sp, bool &script_error)
 {

Modified: lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h?rev=277879&r1=277878&r2=277879&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h (original)
+++ lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h Fri Aug  5 17:06:12 2016
@@ -198,6 +198,8 @@ public:
 
     bool ScriptedThreadPlanShouldStop(StructuredData::ObjectSP implementor_sp, Event *event, bool &script_error) override;
 
+    bool ScriptedThreadPlanIsStale(StructuredData::ObjectSP implementor_sp, bool &script_error) override;
+
     lldb::StateType ScriptedThreadPlanGetRunState(StructuredData::ObjectSP implementor_sp, bool &script_error) override;
 
     StructuredData::GenericSP OSPlugin_CreatePluginObject(const char *class_name, lldb::ProcessSP process_sp) override;

Modified: lldb/trunk/source/Target/ThreadPlanPython.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanPython.cpp?rev=277879&r1=277878&r2=277879&view=diff
==============================================================================
--- lldb/trunk/source/Target/ThreadPlanPython.cpp (original)
+++ lldb/trunk/source/Target/ThreadPlanPython.cpp Fri Aug  5 17:06:12 2016
@@ -101,6 +101,29 @@ ThreadPlanPython::ShouldStop (Event *eve
 }
 
 bool
+ThreadPlanPython::IsPlanStale()
+{
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD));
+    if (log)
+        log->Printf ("%s called on Python Thread Plan: %s )",
+                    __PRETTY_FUNCTION__, m_class_name.c_str());
+
+    bool is_stale = true;
+    if (m_implementation_sp)
+    {
+        ScriptInterpreter *script_interp = m_thread.GetProcess()->GetTarget().GetDebugger().GetCommandInterpreter().GetScriptInterpreter();
+        if (script_interp)
+        {
+            bool script_error;
+            is_stale = script_interp->ScriptedThreadPlanIsStale (m_implementation_sp, script_error);
+            if (script_error)
+                SetPlanComplete(false);
+        }
+    }
+    return is_stale;
+}
+
+bool
 ThreadPlanPython::DoPlanExplainsStop (Event *event_ptr)
 {
     Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD));




More information about the lldb-commits mailing list