Author: Jim Ingham Date: 2022-12-09T10:58:15-08:00 New Revision: 9c5877f33d9f7fd317c07920fd24a041ad69077a
URL: https://github.com/llvm/llvm-project/commit/9c5877f33d9f7fd317c07920fd24a041ad69077a DIFF: https://github.com/llvm/llvm-project/commit/9c5877f33d9f7fd317c07920fd24a041ad69077a.diff LOG: Switch the "command script add" interactive input to use the new command form. We're suggesting people use the form of the command that takes an exe_ctx - it is both more convenient and more correct - since you should not be using GetSelected{Target, Process, etc.} in commands. Added: lldb/test/Shell/Commands/command-script-add.test Modified: lldb/source/Commands/CommandObjectCommands.cpp lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp Removed: ################################################################################ diff --git a/lldb/source/Commands/CommandObjectCommands.cpp b/lldb/source/Commands/CommandObjectCommands.cpp index 9bf07f3eba780..422291f1cd5a5 100644 --- a/lldb/source/Commands/CommandObjectCommands.cpp +++ b/lldb/source/Commands/CommandObjectCommands.cpp @@ -201,7 +201,7 @@ class CommandObjectCommandsSource : public CommandObjectParsed { static const char *g_python_command_instructions = "Enter your Python command(s). Type 'DONE' to end.\n" "You must define a Python function with this signature:\n" - "def my_command_impl(debugger, args, result, internal_dict):\n"; + "def my_command_impl(debugger, args, exe_ctx, result, internal_dict):\n"; class CommandObjectCommandsAlias : public CommandObjectRaw { protected: diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp index 810c77925f5b7..117a057d8d7c5 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp @@ -1369,7 +1369,7 @@ bool ScriptInterpreterPythonImpl::GenerateScriptAliasFunction( std::string auto_generated_function_name(GenerateUniqueName( "lldb_autogen_python_cmd_alias_func", num_created_functions)); - sstr.Printf("def %s (debugger, args, result, internal_dict):", + sstr.Printf("def %s (debugger, args, exe_ctx, result, internal_dict):", auto_generated_function_name.c_str()); if (!GenerateFunction(sstr.GetData(), user_input).Success()) diff --git a/lldb/test/Shell/Commands/command-script-add.test b/lldb/test/Shell/Commands/command-script-add.test new file mode 100644 index 0000000000000..5ffada069a610 --- /dev/null +++ b/lldb/test/Shell/Commands/command-script-add.test @@ -0,0 +1,9 @@ +# Test that command script add with no arguments prompts for +# and generates the modern (exe_ctx) version of the command. + +# RUN: %lldb < %s | FileCheck %s +command script add doit +print(exe_ctx.target) +DONE +doit +# CHECK: No value _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits