https://github.com/da-viper created https://github.com/llvm/llvm-project/pull/215807
The expected result of `ParsedCommand.get_args_definition` is a List of Lists and should not crash when it is not the case. >From 6e5c63700f2d2372da21cf11687393bd2188bf7b Mon Sep 17 00:00:00 2001 From: Ebuka Ezike <[email protected]> Date: Tue, 11 Aug 2026 16:21:08 +0100 Subject: [PATCH] [lldb] Fix crash when adding a python ParsedCommand The expected result of ParsedCommand.get_args_definition is a List of lists and should not crash when it is not the case. --- lldb/source/Commands/CommandObjectCommands.cpp | 1 + .../command/script/add/TestAddParsedCommand.py | 5 +++++ .../commands/command/script/add/test_commands.py | 13 +++++++++++++ 3 files changed, 19 insertions(+) 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__]): _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
