Pass an SBStructuredData to scripted ThreadPlans on use.
This will allow us to write reusable scripted ThreadPlans, since you can use key/value pairs with known keys in the plan to parametrize its behavior. Differential Revision: https://reviews.llvm.org/D68366 llvm-svn: 373675
This commit is contained in:
@@ -11,10 +11,12 @@
|
||||
|
||||
#include "lldb/API/SBFileSpec.h"
|
||||
#include "lldb/API/SBStream.h"
|
||||
#include "lldb/API/SBStructuredData.h"
|
||||
#include "lldb/API/SBSymbolContext.h"
|
||||
#include "lldb/Breakpoint/BreakpointLocation.h"
|
||||
#include "lldb/Core/Debugger.h"
|
||||
#include "lldb/Core/StreamFile.h"
|
||||
#include "lldb/Core/StructuredDataImpl.h"
|
||||
#include "lldb/Interpreter/CommandInterpreter.h"
|
||||
#include "lldb/Symbol/CompileUnit.h"
|
||||
#include "lldb/Symbol/SymbolContext.h"
|
||||
@@ -67,7 +69,20 @@ SBThreadPlan::SBThreadPlan(lldb::SBThread &sb_thread, const char *class_name) {
|
||||
|
||||
Thread *thread = sb_thread.get();
|
||||
if (thread)
|
||||
m_opaque_sp = std::make_shared<ThreadPlanPython>(*thread, class_name);
|
||||
m_opaque_sp = std::make_shared<ThreadPlanPython>(*thread, class_name,
|
||||
nullptr);
|
||||
}
|
||||
|
||||
SBThreadPlan::SBThreadPlan(lldb::SBThread &sb_thread, const char *class_name,
|
||||
lldb::SBStructuredData &args_data) {
|
||||
LLDB_RECORD_CONSTRUCTOR(SBThreadPlan, (lldb::SBThread &, const char *,
|
||||
SBStructuredData &),
|
||||
sb_thread, class_name, args_data);
|
||||
|
||||
Thread *thread = sb_thread.get();
|
||||
if (thread)
|
||||
m_opaque_sp = std::make_shared<ThreadPlanPython>(*thread, class_name,
|
||||
args_data.m_impl_up.get());
|
||||
}
|
||||
|
||||
// Assignment operator
|
||||
@@ -368,9 +383,35 @@ SBThreadPlan::QueueThreadPlanForStepScripted(const char *script_class_name,
|
||||
|
||||
if (m_opaque_sp) {
|
||||
Status plan_status;
|
||||
StructuredData::ObjectSP empty_args;
|
||||
SBThreadPlan plan =
|
||||
SBThreadPlan(m_opaque_sp->GetThread().QueueThreadPlanForStepScripted(
|
||||
false, script_class_name, false, plan_status));
|
||||
false, script_class_name, empty_args, false, plan_status));
|
||||
|
||||
if (plan_status.Fail())
|
||||
error.SetErrorString(plan_status.AsCString());
|
||||
|
||||
return LLDB_RECORD_RESULT(plan);
|
||||
} else {
|
||||
return LLDB_RECORD_RESULT(SBThreadPlan());
|
||||
}
|
||||
}
|
||||
|
||||
SBThreadPlan
|
||||
SBThreadPlan::QueueThreadPlanForStepScripted(const char *script_class_name,
|
||||
lldb::SBStructuredData &args_data,
|
||||
SBError &error) {
|
||||
LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan,
|
||||
QueueThreadPlanForStepScripted,
|
||||
(const char *, lldb::SBStructuredData &, lldb::SBError &),
|
||||
script_class_name, args_data, error);
|
||||
|
||||
if (m_opaque_sp) {
|
||||
Status plan_status;
|
||||
StructuredData::ObjectSP args_obj = args_data.m_impl_up->GetObjectSP();
|
||||
SBThreadPlan plan =
|
||||
SBThreadPlan(m_opaque_sp->GetThread().QueueThreadPlanForStepScripted(
|
||||
false, script_class_name, args_obj, false, plan_status));
|
||||
|
||||
if (plan_status.Fail())
|
||||
error.SetErrorString(plan_status.AsCString());
|
||||
@@ -390,6 +431,8 @@ void RegisterMethods<SBThreadPlan>(Registry &R) {
|
||||
LLDB_REGISTER_CONSTRUCTOR(SBThreadPlan, (const lldb::ThreadPlanSP &));
|
||||
LLDB_REGISTER_CONSTRUCTOR(SBThreadPlan, (const lldb::SBThreadPlan &));
|
||||
LLDB_REGISTER_CONSTRUCTOR(SBThreadPlan, (lldb::SBThread &, const char *));
|
||||
LLDB_REGISTER_CONSTRUCTOR(SBThreadPlan, (lldb::SBThread &, const char *,
|
||||
lldb::SBStructuredData &));
|
||||
LLDB_REGISTER_METHOD(const lldb::SBThreadPlan &,
|
||||
SBThreadPlan, operator=,(const lldb::SBThreadPlan &));
|
||||
LLDB_REGISTER_METHOD_CONST(bool, SBThreadPlan, IsValid, ());
|
||||
@@ -433,6 +476,10 @@ void RegisterMethods<SBThreadPlan>(Registry &R) {
|
||||
LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan,
|
||||
QueueThreadPlanForStepScripted,
|
||||
(const char *, lldb::SBError &));
|
||||
LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan,
|
||||
QueueThreadPlanForStepScripted,
|
||||
(const char *, lldb::SBStructuredData &,
|
||||
lldb::SBError &));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user