-
Notifications
You must be signed in to change notification settings - Fork 14.3k
Add the ability to define a Python based command that uses CommandObjectParsed #70734
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a0c72c0
580f68d
48eaf17
6c24cc6
e1b7cee
ebc5cee
d396962
2137361
ea2b242
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -287,12 +287,12 @@ PythonObject lldb_private::python::SWIGBridge::LLDBSwigPythonCreateScriptedThrea | |
} | ||
|
||
bool lldb_private::python::SWIGBridge::LLDBSWIGPythonCallThreadPlan( | ||
void *implementor, const char *method_name, lldb_private::Event *event, | ||
void *implementer, const char *method_name, lldb_private::Event *event, | ||
bool &got_error) { | ||
got_error = false; | ||
|
||
PyErr_Cleaner py_err_cleaner(false); | ||
PythonObject self(PyRefType::Borrowed, static_cast<PyObject *>(implementor)); | ||
PythonObject self(PyRefType::Borrowed, static_cast<PyObject *>(implementer)); | ||
auto pfunc = self.ResolveName<PythonCallable>(method_name); | ||
|
||
if (!pfunc.IsAllocated()) | ||
|
@@ -325,12 +325,12 @@ bool lldb_private::python::SWIGBridge::LLDBSWIGPythonCallThreadPlan( | |
} | ||
|
||
bool lldb_private::python::SWIGBridge::LLDBSWIGPythonCallThreadPlan( | ||
void *implementor, const char *method_name, lldb_private::Stream *stream, | ||
void *implementer, const char *method_name, lldb_private::Stream *stream, | ||
bool &got_error) { | ||
got_error = false; | ||
|
||
PyErr_Cleaner py_err_cleaner(false); | ||
PythonObject self(PyRefType::Borrowed, static_cast<PyObject *>(implementor)); | ||
PythonObject self(PyRefType::Borrowed, static_cast<PyObject *>(implementer)); | ||
auto pfunc = self.ResolveName<PythonCallable>(method_name); | ||
|
||
if (!pfunc.IsAllocated()) | ||
|
@@ -831,6 +831,29 @@ bool lldb_private::python::SWIGBridge::LLDBSwigPythonCallCommandObject( | |
return true; | ||
} | ||
|
||
#include "lldb/Interpreter/CommandReturnObject.h" | ||
|
||
bool lldb_private::python::SWIGBridge::LLDBSwigPythonCallParsedCommandObject( | ||
PyObject *implementor, lldb::DebuggerSP debugger, lldb_private::StructuredDataImpl &args_impl, | ||
lldb_private::CommandReturnObject &cmd_retobj, | ||
lldb::ExecutionContextRefSP exe_ctx_ref_sp) { | ||
|
||
PyErr_Cleaner py_err_cleaner(true); | ||
|
||
PythonObject self(PyRefType::Borrowed, implementor); | ||
auto pfunc = self.ResolveName<PythonCallable>("__call__"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we add some other safety checks to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't do any checking for arguments in any of the |
||
|
||
if (!pfunc.IsAllocated()) { | ||
cmd_retobj.AppendError("Could not find '__call__' method in implementation class"); | ||
return false; | ||
} | ||
|
||
pfunc(SWIGBridge::ToSWIGWrapper(std::move(debugger)), SWIGBridge::ToSWIGWrapper(args_impl), | ||
SWIGBridge::ToSWIGWrapper(exe_ctx_ref_sp), SWIGBridge::ToSWIGWrapper(cmd_retobj).obj()); | ||
|
||
return true; | ||
} | ||
|
||
PythonObject lldb_private::python::SWIGBridge::LLDBSWIGPythonCreateOSPlugin( | ||
const char *python_class_name, const char *session_dictionary_name, | ||
const lldb::ProcessSP &process_sp) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spelling mistake:
implementor
->implementer
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll get rid of function altogether later this week, replacing by a call to the
ScriptedPythonInterface
methodsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's spelled incorrectly in the whole rest of this file except for the thread plan instances. We should either get rid of all of these by using ScriptedPythonInterface, or fix all the spellings to be consistent, but that seems better as a separate commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's fix the rest of the spellings in a follow up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note, whoever spelt this originally was sure implementor was what they wanted to use, the C++ files use the same spelling.