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:
Jim Ingham
2019-10-03 22:50:18 +00:00
parent 145cdad119
commit 27a14f19c8
22 changed files with 346 additions and 147 deletions

View File

@@ -250,6 +250,7 @@ LLDBSwigPythonCreateScriptedThreadPlan
(
const char *python_class_name,
const char *session_dictionary_name,
lldb_private::StructuredDataImpl *args_impl,
std::string &error_string,
const lldb::ThreadPlanSP& thread_plan_sp
)
@@ -279,7 +280,23 @@ LLDBSwigPythonCreateScriptedThreadPlan
if (!tp_arg.IsAllocated())
Py_RETURN_NONE;
PythonObject result = pfunc(tp_arg, dict);
PythonObject result = {};
size_t init_num_args = pfunc.GetNumInitArguments().count;
if (init_num_args == 3) {
if (args_impl != nullptr) {
error_string.assign("args passed, but __init__ does not take an args dictionary");
Py_RETURN_NONE;
}
result = pfunc(tp_arg, dict);
} else if (init_num_args = 4) {
lldb::SBStructuredData *args_value = new lldb::SBStructuredData(args_impl);
PythonObject args_arg(PyRefType::Owned, SBTypeToSWIGWrapper(args_value));
result = pfunc(tp_arg, args_arg, dict);
} else {
error_string.assign("wrong number of arguments in __init__, should be 1 or 2 (not including self & dict)");
Py_RETURN_NONE;
}
// FIXME: At this point we should check that the class we found supports all the methods
// that we need.