[llvm-branch-commits] [lldb] release/23.x: [lldb] Fix crash when adding a python ParsedCommand (#215807) (PR #216097)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Aug 13 09:01:04 PDT 2026
https://github.com/llvmbot created https://github.com/llvm/llvm-project/pull/216097
Backport 58e4198eab3b7437b5ffc2e8adb21ed8fc2d8866
Requested by: @da-viper
>From 8308ce0dfb680c1e9d6e40b8270c13cbcc493472 Mon Sep 17 00:00:00 2001
From: Ebuka Ezike <e_ezike at apple.com>
Date: Thu, 13 Aug 2026 10:44:04 +0100
Subject: [PATCH] [lldb] Fix crash when adding a python ParsedCommand (#215807)
The expected result of `ParsedCommand.get_args_definition` is a List of
Lists and should not crash when it is not the case.
(cherry picked from commit 58e4198eab3b7437b5ffc2e8adb21ed8fc2d8866)
---
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 8f006768ecc9a..bb25b8ed70234 100644
--- a/lldb/source/Commands/CommandObjectCommands.cpp
+++ b/lldb/source/Commands/CommandObjectCommands.cpp
@@ -1972,6 +1972,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__]):
More information about the llvm-branch-commits
mailing list