llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-lldb Author: Ebuka Ezike (da-viper) <details> <summary>Changes</summary> The expected result of `ParsedCommand.get_args_definition` is a List of Lists and should not crash when it is not the case. --- Full diff: https://github.com/llvm/llvm-project/pull/215807.diff 3 Files Affected: - (modified) lldb/source/Commands/CommandObjectCommands.cpp (+1) - (modified) lldb/test/API/commands/command/script/add/TestAddParsedCommand.py (+5) - (modified) lldb/test/API/commands/command/script/add/test_commands.py (+13) ``````````diff diff --git a/lldb/source/Commands/CommandObjectCommands.cpp b/lldb/source/Commands/CommandObjectCommands.cpp index 2acbbda4e8553..f069b7e27df9a 100644 --- a/lldb/source/Commands/CommandObjectCommands.cpp +++ b/lldb/source/Commands/CommandObjectCommands.cpp @@ -1949,6 +1949,7 @@ class CommandObjectScriptingObjectParsed : public CommandObjectParsed { Status::FromErrorStringWithFormatv("Argument definition element " "{0} is not an array", counter); + return false; } args_array->ForEach(args_adder); diff --git a/lldb/test/API/commands/command/script/add/TestAddParsedCommand.py b/lldb/test/API/commands/command/script/add/TestAddParsedCommand.py index da150499a53a2..d5553dce189f7 100644 --- a/lldb/test/API/commands/command/script/add/TestAddParsedCommand.py +++ b/lldb/test/API/commands/command/script/add/TestAddParsedCommand.py @@ -331,3 +331,8 @@ def cleanup(): results.count("SECOND_ARG"), 2, "Passed second arg to both commands" ) self.assertEqual(results.count("THIRD_ARG"), 1, "Passed third arg in repeat") + + # Verify lldb did not register the 'fail_cmd'. + self.expect( + "fail_cmd", substrs=["'fail_cmd' is not a valid command"], error=True + ) diff --git a/lldb/test/API/commands/command/script/add/test_commands.py b/lldb/test/API/commands/command/script/add/test_commands.py index db302796819ad..0d8acaed9e611 100644 --- a/lldb/test/API/commands/command/script/add/test_commands.py +++ b/lldb/test/API/commands/command/script/add/test_commands.py @@ -254,6 +254,19 @@ def get_long_help(self): return self.help_string +class FailCommand(ParsedCommand): + program: str = "fail_cmd" + + def __call__(self, debugger, args_list, exe_ctx, result): + result.AppendMessage("hello world") + + def setup_command_definition(self): + parser = self.get_parser() + # add_argument_set is expecting a list not dict. + parser.add_argument_set( + parser.make_argument_element(lldb.eArgTypeSymbol, "plain") + ) + def __lldb_init_module(debugger, dict): # Register all classes that have a register_lldb_command method for _name, cls in inspect.getmembers(sys.modules[__name__]): `````````` </details> https://github.com/llvm/llvm-project/pull/215807 _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
