diff options
Diffstat (limited to 'lldb/source/Target/ThreadPlanPython.cpp')
-rw-r--r-- | lldb/source/Target/ThreadPlanPython.cpp | 97 |
1 files changed, 43 insertions, 54 deletions
diff --git a/lldb/source/Target/ThreadPlanPython.cpp b/lldb/source/Target/ThreadPlanPython.cpp index 48b3e3a..d6de6b3 100644 --- a/lldb/source/Target/ThreadPlanPython.cpp +++ b/lldb/source/Target/ThreadPlanPython.cpp @@ -32,23 +32,6 @@ ThreadPlanPython::ThreadPlanPython(Thread &thread, const char *class_name, eVoteNoOpinion, eVoteNoOpinion), m_class_name(class_name), m_args_data(args_data), m_did_push(false), m_stop_others(false) { - ScriptInterpreter *interpreter = GetScriptInterpreter(); - if (!interpreter) { - SetPlanComplete(false); - // FIXME: error handling - return; - } - - m_interface = interpreter->CreateScriptedThreadPlanInterface(); - if (!m_interface) { - SetPlanComplete(false); - // FIXME: error handling - // error.SetErrorStringWithFormat( - // "ThreadPlanPython::%s () - ERROR: %s", __FUNCTION__, - // "Script interpreter couldn't create Scripted Thread Plan Interface"); - return; - } - SetIsControllingPlan(true); SetOkayToDiscard(true); SetPrivate(false); @@ -77,14 +60,13 @@ void ThreadPlanPython::DidPush() { // We set up the script side in DidPush, so that it can push other plans in // the constructor, and doesn't have to care about the details of DidPush. m_did_push = true; - if (m_interface) { - auto obj_or_err = m_interface->CreatePluginObject( - m_class_name, this->shared_from_this(), m_args_data); - if (!obj_or_err) { - m_error_str = llvm::toString(obj_or_err.takeError()); - SetPlanComplete(false); - } else - m_implementation_sp = *obj_or_err; + if (!m_class_name.empty()) { + ScriptInterpreter *script_interp = GetScriptInterpreter(); + if (script_interp) { + m_implementation_sp = script_interp->CreateScriptedThreadPlan( + m_class_name.c_str(), m_args_data, m_error_str, + this->shared_from_this()); + } } } @@ -95,13 +77,14 @@ bool ThreadPlanPython::ShouldStop(Event *event_ptr) { bool should_stop = true; if (m_implementation_sp) { - auto should_stop_or_err = m_interface->ShouldStop(event_ptr); - if (!should_stop_or_err) { - LLDB_LOG_ERROR(GetLog(LLDBLog::Thread), should_stop_or_err.takeError(), - "Can't call ScriptedThreadPlan::ShouldStop."); - SetPlanComplete(false); - } else - should_stop = *should_stop_or_err; + ScriptInterpreter *script_interp = GetScriptInterpreter(); + if (script_interp) { + bool script_error; + should_stop = script_interp->ScriptedThreadPlanShouldStop( + m_implementation_sp, event_ptr, script_error); + if (script_error) + SetPlanComplete(false); + } } return should_stop; } @@ -113,13 +96,14 @@ bool ThreadPlanPython::IsPlanStale() { bool is_stale = true; if (m_implementation_sp) { - auto is_stale_or_err = m_interface->IsStale(); - if (!is_stale_or_err) { - LLDB_LOG_ERROR(GetLog(LLDBLog::Thread), is_stale_or_err.takeError(), - "Can't call ScriptedThreadPlan::IsStale."); - SetPlanComplete(false); - } else - is_stale = *is_stale_or_err; + ScriptInterpreter *script_interp = 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; } @@ -131,14 +115,14 @@ bool ThreadPlanPython::DoPlanExplainsStop(Event *event_ptr) { bool explains_stop = true; if (m_implementation_sp) { - auto explains_stop_or_error = m_interface->ExplainsStop(event_ptr); - if (!explains_stop_or_error) { - LLDB_LOG_ERROR(GetLog(LLDBLog::Thread), - explains_stop_or_error.takeError(), - "Can't call ScriptedThreadPlan::ExplainsStop."); - SetPlanComplete(false); - } else - explains_stop = *explains_stop_or_error; + ScriptInterpreter *script_interp = GetScriptInterpreter(); + if (script_interp) { + bool script_error; + explains_stop = script_interp->ScriptedThreadPlanExplainsStop( + m_implementation_sp, event_ptr, script_error); + if (script_error) + SetPlanComplete(false); + } } return explains_stop; } @@ -166,8 +150,14 @@ lldb::StateType ThreadPlanPython::GetPlanRunState() { LLDB_LOGF(log, "%s called on Python Thread Plan: %s )", LLVM_PRETTY_FUNCTION, m_class_name.c_str()); lldb::StateType run_state = eStateRunning; - if (m_implementation_sp) - run_state = m_interface->GetRunState(); + if (m_implementation_sp) { + ScriptInterpreter *script_interp = GetScriptInterpreter(); + if (script_interp) { + bool script_error; + run_state = script_interp->ScriptedThreadPlanGetRunState( + m_implementation_sp, script_error); + } + } return run_state; } @@ -178,13 +168,12 @@ void ThreadPlanPython::GetDescription(Stream *s, lldb::DescriptionLevel level) { if (m_implementation_sp) { ScriptInterpreter *script_interp = GetScriptInterpreter(); if (script_interp) { - auto desc_or_err = m_interface->GetStopDescription(s); - if (!desc_or_err || !*desc_or_err) { - LLDB_LOG_ERROR(GetLog(LLDBLog::Thread), desc_or_err.takeError(), - "Can't call ScriptedThreadPlan::GetStopDescription."); + bool script_error; + bool added_desc = script_interp->ScriptedThreadPlanGetStopDescription( + m_implementation_sp, s, script_error); + if (script_error || !added_desc) s->Printf("Python thread plan implemented by class %s.", m_class_name.c_str()); - } } return; } |