diff --git a/lldb/source/Interpreter/CommandObject.cpp b/lldb/source/Interpreter/CommandObject.cpp --- a/lldb/source/Interpreter/CommandObject.cpp +++ b/lldb/source/Interpreter/CommandObject.cpp @@ -741,6 +741,7 @@ if (cmd_args.GetArgumentCount() != 0 && m_arguments.empty()) { result.AppendErrorWithFormatv("'{0}' doesn't take any arguments.", GetCommandName()); + Cleanup(); return false; } handled = DoExecute(cmd_args, result); diff --git a/lldb/test/Shell/Error/Inputs/cleanup.lldbinit b/lldb/test/Shell/Error/Inputs/cleanup.lldbinit new file mode 100644 --- /dev/null +++ b/lldb/test/Shell/Error/Inputs/cleanup.lldbinit @@ -0,0 +1,5 @@ +b main +run +dis a +dis -a $pc +exit diff --git a/lldb/test/Shell/Error/cleanup.cpp b/lldb/test/Shell/Error/cleanup.cpp new file mode 100644 --- /dev/null +++ b/lldb/test/Shell/Error/cleanup.cpp @@ -0,0 +1,5 @@ +// Test CommandObject is cleaned up even after commands fail due to not taking any argument. +// RUN: %clang_host -g %s -o %t +// RUN: %lldb -f %t -o "settings set interpreter.stop-command-source-on-error false" -s \ +// RUN: %S/Inputs/cleanup.lldbinit +int main() { return 0; }