aboutsummaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorJim Ingham <jingham@apple.com>2019-10-03 22:50:18 +0000
committerJim Ingham <jingham@apple.com>2019-10-03 22:50:18 +0000
commit4e263b1f0e34a572e391a440aabf42d8183084d1 (patch)
tree59e782cbee15a812ad6bdc2d5386b3036dad177f /source
parent6e8d041bb9d025b2310130fff045ba539de99f55 (diff)
downloadlldb-4e263b1f0e34a572e391a440aabf42d8183084d1.tar.gz
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 git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@373675 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'source')
-rw-r--r--source/API/SBThread.cpp25
-rw-r--r--source/API/SBThreadPlan.cpp51
-rw-r--r--source/Commands/CommandObjectThread.cpp246
-rw-r--r--source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp17
-rw-r--r--source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h4
-rw-r--r--source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp6
-rw-r--r--source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h1
-rw-r--r--source/Target/Thread.cpp14
-rw-r--r--source/Target/ThreadPlanPython.cpp8
9 files changed, 244 insertions, 128 deletions
diff --git a/source/API/SBThread.cpp b/source/API/SBThread.cpp
index 85e9a6b47..8d4930bf6 100644
--- a/source/API/SBThread.cpp
+++ b/source/API/SBThread.cpp
@@ -16,6 +16,7 @@
#include "lldb/API/SBFrame.h"
#include "lldb/API/SBProcess.h"
#include "lldb/API/SBStream.h"
+#include "lldb/API/SBStructuredData.h"
#include "lldb/API/SBSymbolContext.h"
#include "lldb/API/SBThreadCollection.h"
#include "lldb/API/SBThreadPlan.h"
@@ -23,6 +24,7 @@
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/StreamFile.h"
+#include "lldb/Core/StructuredDataImpl.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Symbol/CompileUnit.h"
@@ -965,9 +967,24 @@ SBError SBThread::StepUsingScriptedThreadPlan(const char *script_class_name) {
}
SBError SBThread::StepUsingScriptedThreadPlan(const char *script_class_name,
+ bool resume_immediately) {
+ LLDB_RECORD_METHOD(lldb::SBError, SBThread, StepUsingScriptedThreadPlan,
+ (const char *, bool), script_class_name,
+ resume_immediately);
+
+ lldb::SBStructuredData no_data;
+ return LLDB_RECORD_RESULT(
+ StepUsingScriptedThreadPlan(script_class_name,
+ no_data,
+ resume_immediately));
+}
+
+SBError SBThread::StepUsingScriptedThreadPlan(const char *script_class_name,
+ SBStructuredData &args_data,
bool resume_immediately) {
LLDB_RECORD_METHOD(lldb::SBError, SBThread, StepUsingScriptedThreadPlan,
- (const char *, bool), script_class_name,
+ (const char *, lldb::SBStructuredData &, bool),
+ script_class_name, args_data,
resume_immediately);
SBError error;
@@ -982,8 +999,10 @@ SBError SBThread::StepUsingScriptedThreadPlan(const char *script_class_name,
Thread *thread = exe_ctx.GetThreadPtr();
Status new_plan_status;
+ StructuredData::ObjectSP obj_sp = args_data.m_impl_up->GetObjectSP();
+
ThreadPlanSP new_plan_sp = thread->QueueThreadPlanForStepScripted(
- false, script_class_name, false, new_plan_status);
+ false, script_class_name, obj_sp, false, new_plan_status);
if (new_plan_status.Fail()) {
error.SetErrorString(new_plan_status.AsCString());
@@ -1460,6 +1479,8 @@ void RegisterMethods<SBThread>(Registry &R) {
(const char *));
LLDB_REGISTER_METHOD(lldb::SBError, SBThread, StepUsingScriptedThreadPlan,
(const char *, bool));
+ LLDB_REGISTER_METHOD(lldb::SBError, SBThread, StepUsingScriptedThreadPlan,
+ (const char *, SBStructuredData &, bool));
LLDB_REGISTER_METHOD(lldb::SBError, SBThread, JumpToLine,
(lldb::SBFileSpec &, uint32_t));
LLDB_REGISTER_METHOD(lldb::SBError, SBThread, ReturnFromFrame,
diff --git a/source/API/SBThreadPlan.cpp b/source/API/SBThreadPlan.cpp
index 8f6802fe9..eed4d1bfb 100644
--- a/source/API/SBThreadPlan.cpp
+++ b/source/API/SBThreadPlan.cpp
@@ -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 &));
}
}
diff --git a/source/Commands/CommandObjectThread.cpp b/source/Commands/CommandObjectThread.cpp
index 3fb69b87d..8c5274553 100644
--- a/source/Commands/CommandObjectThread.cpp
+++ b/source/Commands/CommandObjectThread.cpp
@@ -16,6 +16,7 @@
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/OptionArgParser.h"
+#include "lldb/Interpreter/OptionGroupPythonClassWithDict.h"
#include "lldb/Interpreter/Options.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/Function.h"
@@ -401,127 +402,122 @@ static constexpr OptionEnumValues TriRunningModes() {
#define LLDB_OPTIONS_thread_step_scope
#include "CommandOptions.inc"
-class CommandObjectThreadStepWithTypeAndScope : public CommandObjectParsed {
+class ThreadStepScopeOptionGroup : public OptionGroup {
public:
- class CommandOptions : public Options {
- public:
- CommandOptions() : Options() {
- // Keep default values of all options in one place: OptionParsingStarting
- // ()
- OptionParsingStarting(nullptr);
- }
-
- ~CommandOptions() override = default;
-
- Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
- ExecutionContext *execution_context) override {
- Status error;
- const int short_option = m_getopt_table[option_idx].val;
-
- switch (short_option) {
- case 'a': {
- bool success;
- bool avoid_no_debug =
- OptionArgParser::ToBoolean(option_arg, true, &success);
- if (!success)
- error.SetErrorStringWithFormat(
- "invalid boolean value for option '%c'", short_option);
- else {
- m_step_in_avoid_no_debug =
- avoid_no_debug ? eLazyBoolYes : eLazyBoolNo;
- }
- } break;
-
- case 'A': {
- bool success;
- bool avoid_no_debug =
- OptionArgParser::ToBoolean(option_arg, true, &success);
- if (!success)
- error.SetErrorStringWithFormat(
- "invalid boolean value for option '%c'", short_option);
- else {
- m_step_out_avoid_no_debug =
- avoid_no_debug ? eLazyBoolYes : eLazyBoolNo;
- }
- } break;
-
- case 'c':
- if (option_arg.getAsInteger(0, m_step_count))
- error.SetErrorStringWithFormat("invalid step count '%s'",
- option_arg.str().c_str());
- break;
-
- case 'C':
- m_class_name.clear();
- m_class_name.assign(option_arg);
- break;
-
- case 'm': {
- auto enum_values = GetDefinitions()[option_idx].enum_values;
- m_run_mode = (lldb::RunMode)OptionArgParser::ToOptionEnum(
- option_arg, enum_values, eOnlyDuringStepping, error);
- } break;
+ ThreadStepScopeOptionGroup() : OptionGroup() {
+ // Keep default values of all options in one place: OptionParsingStarting
+ // ()
+ OptionParsingStarting(nullptr);
+ }
- case 'e':
- if (option_arg == "block") {
- m_end_line_is_block_end = true;
- break;
- }
- if (option_arg.getAsInteger(0, m_end_line))
- error.SetErrorStringWithFormat("invalid end line number '%s'",
- option_arg.str().c_str());
- break;
+ ~ThreadStepScopeOptionGroup() override = default;
- case 'r':
- m_avoid_regexp.clear();
- m_avoid_regexp.assign(option_arg);
- break;
+ llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
+ return llvm::makeArrayRef(g_thread_step_scope_options);
+ }
- case 't':
- m_step_in_target.clear();
- m_step_in_target.assign(option_arg);
+ Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
+ ExecutionContext *execution_context) override {
+ Status error;
+ const int short_option
+ = g_thread_step_scope_options[option_idx].short_option;
+
+ switch (short_option) {
+ case 'a': {
+ bool success;
+ bool avoid_no_debug =
+ OptionArgParser::ToBoolean(option_arg, true, &success);
+ if (!success)
+ error.SetErrorStringWithFormat(
+ "invalid boolean value for option '%c'", short_option);
+ else {
+ m_step_in_avoid_no_debug =
+ avoid_no_debug ? eLazyBoolYes : eLazyBoolNo;
+ }
+ } break;
+
+ case 'A': {
+ bool success;
+ bool avoid_no_debug =
+ OptionArgParser::ToBoolean(option_arg, true, &success);
+ if (!success)
+ error.SetErrorStringWithFormat(
+ "invalid boolean value for option '%c'", short_option);
+ else {
+ m_step_out_avoid_no_debug =
+ avoid_no_debug ? eLazyBoolYes : eLazyBoolNo;
+ }
+ } break;
+
+ case 'c':
+ if (option_arg.getAsInteger(0, m_step_count))
+ error.SetErrorStringWithFormat("invalid step count '%s'",
+ option_arg.str().c_str());
+ break;
+
+ case 'm': {
+ auto enum_values = GetDefinitions()[option_idx].enum_values;
+ m_run_mode = (lldb::RunMode)OptionArgParser::ToOptionEnum(
+ option_arg, enum_values, eOnlyDuringStepping, error);
+ } break;
+
+ case 'e':
+ if (option_arg == "block") {
+ m_end_line_is_block_end = true;
break;
-
- default:
- llvm_unreachable("Unimplemented option");
}
- return error;
- }
-
- void OptionParsingStarting(ExecutionContext *execution_context) override {
- m_step_in_avoid_no_debug = eLazyBoolCalculate;
- m_step_out_avoid_no_debug = eLazyBoolCalculate;
- m_run_mode = eOnlyDuringStepping;
-
- // Check if we are in Non-Stop mode
- TargetSP target_sp =
- execution_context ? execution_context->GetTargetSP() : TargetSP();
- if (target_sp && target_sp->GetNonStopModeEnabled())
- m_run_mode = eOnlyThisThread;
+ if (option_arg.getAsInteger(0, m_end_line))
+ error.SetErrorStringWithFormat("invalid end line number '%s'",
+ option_arg.str().c_str());
+ break;
+ case 'r':
m_avoid_regexp.clear();
+ m_avoid_regexp.assign(option_arg);
+ break;
+
+ case 't':
m_step_in_target.clear();
- m_class_name.clear();
- m_step_count = 1;
- m_end_line = LLDB_INVALID_LINE_NUMBER;
- m_end_line_is_block_end = false;
- }
+ m_step_in_target.assign(option_arg);
+ break;
- llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
- return llvm::makeArrayRef(g_thread_step_scope_options);
+ default:
+ llvm_unreachable("Unimplemented option");
}
+ return error;
+ }
- // Instance variables to hold the values for command options.
- LazyBool m_step_in_avoid_no_debug;
- LazyBool m_step_out_avoid_no_debug;
- RunMode m_run_mode;
- std::string m_avoid_regexp;
- std::string m_step_in_target;
- std::string m_class_name;
- uint32_t m_step_count;
- uint32_t m_end_line;
- bool m_end_line_is_block_end;
- };
+ void OptionParsingStarting(ExecutionContext *execution_context) override {
+ m_step_in_avoid_no_debug = eLazyBoolCalculate;
+ m_step_out_avoid_no_debug = eLazyBoolCalculate;
+ m_run_mode = eOnlyDuringStepping;
+
+ // Check if we are in Non-Stop mode
+ TargetSP target_sp =
+ execution_context ? execution_context->GetTargetSP() : TargetSP();
+ if (target_sp && target_sp->GetNonStopModeEnabled())
+ m_run_mode = eOnlyThisThread;
+
+ m_avoid_regexp.clear();
+ m_step_in_target.clear();
+ m_step_count = 1;
+ m_end_line = LLDB_INVALID_LINE_NUMBER;
+ m_end_line_is_block_end = false;
+ }
+
+ // Instance variables to hold the values for command options.
+ LazyBool m_step_in_avoid_no_debug;
+ LazyBool m_step_out_avoid_no_debug;
+ RunMode m_run_mode;
+ std::string m_avoid_regexp;
+ std::string m_step_in_target;
+ uint32_t m_step_count;
+ uint32_t m_end_line;
+ bool m_end_line_is_block_end;
+};
+
+class CommandObjectThreadStepWithTypeAndScope : public CommandObjectParsed {
+public:
CommandObjectThreadStepWithTypeAndScope(CommandInterpreter &interpreter,
const char *name, const char *help,
@@ -533,7 +529,8 @@ public:
eCommandTryTargetAPILock |
eCommandProcessMustBeLaunched |
eCommandProcessMustBePaused),
- m_step_type(step_type), m_step_scope(step_scope), m_options() {
+ m_step_type(step_type), m_step_scope(step_scope), m_options(),
+ m_class_options("scripted step", 'C') {
CommandArgumentEntry arg;
CommandArgumentData thread_id_arg;
@@ -547,11 +544,19 @@ public:
// Push the data for the first argument into the m_arguments vector.
m_arguments.push_back(arg);
+
+ if (step_type == eStepTypeScripted) {
+ m_all_options.Append(&m_class_options, LLDB_OPT_SET_1, LLDB_OPT_SET_1);
+ }
+ m_all_options.Append(&m_options);
+ m_all_options.Finalize();
}
~CommandObjectThreadStepWithTypeAndScope() override = default;
- Options *GetOptions() override { return &m_options; }
+ Options *GetOptions() override {
+ return &m_all_options;
+ }
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
@@ -591,15 +596,15 @@ protected:
}
if (m_step_type == eStepTypeScripted) {
- if (m_options.m_class_name.empty()) {
+ if (m_class_options.GetClassName().empty()) {
result.AppendErrorWithFormat("empty class name for scripted step.");
result.SetStatus(eReturnStatusFailed);
return false;
} else if (!GetDebugger().GetScriptInterpreter()->CheckObjectExists(
- m_options.m_class_name.c_str())) {
+ m_class_options.GetClassName().c_str())) {
result.AppendErrorWithFormat(
"class for scripted step: \"%s\" does not exist.",
- m_options.m_class_name.c_str());
+ m_class_options.GetClassName().c_str());
result.SetStatus(eReturnStatusFailed);
return false;
}
@@ -715,7 +720,8 @@ protected:
m_options.m_step_out_avoid_no_debug);
} else if (m_step_type == eStepTypeScripted) {
new_plan_sp = thread->QueueThreadPlanForStepScripted(
- abort_other_plans, m_options.m_class_name.c_str(),
+ abort_other_plans, m_class_options.GetClassName().c_str(),
+ m_class_options.GetStructuredData(),
bool_stop_other_threads, new_plan_status);
} else {
result.AppendError("step type is not supported");
@@ -783,7 +789,9 @@ protected:
protected:
StepType m_step_type;
StepScope m_step_scope;
- CommandOptions m_options;
+ ThreadStepScopeOptionGroup m_options;
+ OptionGroupPythonClassWithDict m_class_options;
+ OptionGroupOptions m_all_options;
};
// CommandObjectThreadContinue
@@ -2060,7 +2068,11 @@ CommandObjectMultiwordThread::CommandObjectMultiwordThread(
"step-scripted",
CommandObjectSP(new CommandObjectThreadStepWithTypeAndScope(
interpreter, "thread step-scripted",
- "Step as instructed by the script class passed in the -C option.",
+ "Step as instructed by the script class passed in the -C option. "
+ "You can also specify a dictionary of key (-k) and value (-v) pairs "
+ "that will be used to populate an SBStructuredData Dictionary, which "
+ "will be passed to the constructor of the class implementing the "
+ "scripted step. See the Python Reference for more details.",
nullptr, eStepTypeScripted, eStepScopeSource)));
LoadSubCommand("plan", CommandObjectSP(new CommandObjectMultiwordThreadPlan(
diff --git a/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp b/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
index fedd8f66a..1862bbd92 100644
--- a/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
+++ b/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
@@ -887,6 +887,23 @@ void PythonCallable::Reset(PyRefType type, PyObject *py_obj) {
PythonObject::Reset(PyRefType::Borrowed, result.get());
}
+PythonCallable::ArgInfo PythonCallable::GetNumInitArguments() const {
+ ArgInfo result = {0, false, false, false};
+ if (!IsValid())
+ return result;
+ PyObject *py_func_obj = m_py_obj;
+ if (!PyClass_Check(m_py_obj))
+ return result;
+
+ PythonObject __init__ = GetAttributeValue("__init__");
+ if (__init__.IsValid() ) {
+ auto __init_callable__ = __init__.AsType<PythonCallable>();
+ if (__init_callable__.IsValid())
+ return __init_callable__.GetNumArguments();
+ }
+ return result;
+}
+
PythonCallable::ArgInfo PythonCallable::GetNumArguments() const {
ArgInfo result = {0, false, false, false};
if (!IsValid())
diff --git a/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h b/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
index 8fd2be146..9e4a120f2 100644
--- a/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
+++ b/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
@@ -438,6 +438,10 @@ public:
void Reset(PyRefType type, PyObject *py_obj) override;
ArgInfo GetNumArguments() const;
+
+ // If the callable is a Py_Class, then find the number of arguments
+ // of the __init__ method.
+ ArgInfo GetNumInitArguments() const;
PythonObject operator()();
diff --git a/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp b/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
index dc13ed71c..e5000bfd4 100644
--- a/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ b/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -97,6 +97,7 @@ LLDBSwigPythonCreateCommandObject(const char *python_class_name,
extern "C" void *LLDBSwigPythonCreateScriptedThreadPlan(
const char *python_class_name, const char *session_dictionary_name,
+ StructuredDataImpl *args_data,
std::string &error_string,
const lldb::ThreadPlanSP &thread_plan_sp);
@@ -1845,7 +1846,8 @@ StructuredData::DictionarySP ScriptInterpreterPythonImpl::OSPlugin_CreateThread(
}
StructuredData::ObjectSP ScriptInterpreterPythonImpl::CreateScriptedThreadPlan(
- const char *class_name, std::string &error_str,
+ const char *class_name, StructuredDataImpl *args_data,
+ std::string &error_str,
lldb::ThreadPlanSP thread_plan_sp) {
if (class_name == nullptr || class_name[0] == '\0')
return StructuredData::ObjectSP();
@@ -1868,7 +1870,7 @@ StructuredData::ObjectSP ScriptInterpreterPythonImpl::CreateScriptedThreadPlan(
Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
ret_val = LLDBSwigPythonCreateScriptedThreadPlan(
class_name, python_interpreter->m_dictionary_name.c_str(),
- error_str, thread_plan_sp);
+ args_data, error_str, thread_plan_sp);
if (!ret_val)
return {};
}
diff --git a/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h b/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
index 9cf32059a..1b3a1bf0b 100644
--- a/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
+++ b/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
@@ -78,6 +78,7 @@ public:
StructuredData::ObjectSP
CreateScriptedThreadPlan(const char *class_name,
+ StructuredDataImpl *args_data,
std::string &error_str,
lldb::ThreadPlanSP thread_plan) override;
diff --git a/source/Target/Thread.cpp b/source/Target/Thread.cpp
index ce4c4aa4b..be6150630 100644
--- a/source/Target/Thread.cpp
+++ b/source/Target/Thread.cpp
@@ -13,6 +13,7 @@
#include "lldb/Core/Debugger.h"
#include "lldb/Core/FormatEntity.h"
#include "lldb/Core/Module.h"
+#include "lldb/Core/StructuredDataImpl.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Host/Host.h"
#include "lldb/Interpreter/OptionValueFileSpecList.h"
@@ -1482,9 +1483,18 @@ ThreadPlanSP Thread::QueueThreadPlanForStepUntil(
}
lldb::ThreadPlanSP Thread::QueueThreadPlanForStepScripted(
- bool abort_other_plans, const char *class_name, bool stop_other_threads,
+ bool abort_other_plans, const char *class_name,
+ StructuredData::ObjectSP extra_args_sp, bool stop_other_threads,
Status &status) {
- ThreadPlanSP thread_plan_sp(new ThreadPlanPython(*this, class_name));
+
+ StructuredDataImpl *extra_args_impl = nullptr;
+ if (extra_args_sp) {
+ extra_args_impl = new StructuredDataImpl();
+ extra_args_impl->SetObjectSP(extra_args_sp);
+ }
+
+ ThreadPlanSP thread_plan_sp(new ThreadPlanPython(*this, class_name,
+ extra_args_impl));
status = QueueThreadPlan(thread_plan_sp, abort_other_plans);
return thread_plan_sp;
diff --git a/source/Target/ThreadPlanPython.cpp b/source/Target/ThreadPlanPython.cpp
index ff57e0a25..df432a0af 100644
--- a/source/Target/ThreadPlanPython.cpp
+++ b/source/Target/ThreadPlanPython.cpp
@@ -25,10 +25,11 @@ using namespace lldb_private;
// ThreadPlanPython
-ThreadPlanPython::ThreadPlanPython(Thread &thread, const char *class_name)
+ThreadPlanPython::ThreadPlanPython(Thread &thread, const char *class_name,
+ StructuredDataImpl *args_data)
: ThreadPlan(ThreadPlan::eKindPython, "Python based Thread Plan", thread,
eVoteNoOpinion, eVoteNoOpinion),
- m_class_name(class_name), m_did_push(false) {
+ m_class_name(class_name), m_args_data(args_data), m_did_push(false) {
SetIsMasterPlan(true);
SetOkayToDiscard(true);
SetPrivate(false);
@@ -65,7 +66,8 @@ void ThreadPlanPython::DidPush() {
.GetScriptInterpreter();
if (script_interp) {
m_implementation_sp = script_interp->CreateScriptedThreadPlan(
- m_class_name.c_str(), m_error_str, this->shared_from_this());
+ m_class_name.c_str(), m_args_data, m_error_str,
+ this->shared_from_this());
}
}
}