[lldb/script] Add scripting extension template generator (#209647)
This patch adds a `scripting extension generate <ExtensionType>...` command that introspects a Python extension base class and emits a skeleton subclass with `# TODO: Implement` stubs for its abstract methods (or, with `-a`, every method), then opens the result in an editor. Generated imports use `from <module> import <class>`, and the generated `__init__` forwards its arguments to `super().__init__(...)` since every base class relies on its constructor to set up attributes (`self.target`, `self.process`, ...) that inherited, non-overridden methods depend on. When the host can't open an external editor (e.g. non-macOS), the command reports that as a message rather than an error, since the file is already written. To catch regressions in the generator itself instead of just checking that a file was produced, this patch adds `TestScriptingExtensionGenerate.py`, which generates a template for every extension kind on the fly and drives it through a live lldb session (`process launch -C`, `breakpoint set -P`, `target stop-hook add -P`, etc.). Signed-off-by: Med Ismail Bennani <ismail@bennani.ma> (cherry picked from commit c4962f5721a36e198234019b846d3788738f766a)
This commit is contained in:
1 parent
e28ea20ce0
commit
3df0bbdc25
13 files changed
+961
-12
No files matched your search
@@ -251,10 +251,15 @@ public:
|
||||
size_t num_args = sizeof...(Args);
|
||||
if (arg_info->max_positional_args != PythonCallable::ArgInfo::UNBOUNDED &&
|
||||
num_args != arg_info->max_positional_args) {
|
||||
if (num_args != arg_info->max_positional_args - 1)
|
||||
if (num_args != arg_info->max_positional_args - 1) {
|
||||
// `expected_return_object` starts in an error state; consume it
|
||||
// before we return with a different error, or its destructor
|
||||
// will abort.
|
||||
llvm::consumeError(expected_return_object.takeError());
|
||||
return create_error("Passed arguments ({0}) doesn't match the number "
|
||||
"of expected arguments ({1}).",
|
||||
num_args, arg_info->max_positional_args);
|
||||
}
|
||||
|
||||
std::apply(
|
||||
[&init, &expected_return_object](auto &&...args) {
|
||||
|
||||
Reference in new issue
Block a user