From b6d56ddac1bf50d532abdc86a84f9bc8e3e7a266 Mon Sep 17 00:00:00 2001 From: Zequan Wu Date: Mon, 22 Aug 2022 10:26:00 -0700 Subject: [PATCH] [LLDB] Clean up after command fails `CommandObject::CheckRequirements()` requires m_exe_ctx being cleaned up. Differential Revision: https://reviews.llvm.org/D132397 --- lldb/source/Interpreter/CommandObject.cpp | 1 + lldb/test/Shell/Error/Inputs/cleanup.lldbinit | 5 +++++ lldb/test/Shell/Error/cleanup.cpp | 5 +++++ 3 files changed, 11 insertions(+) create mode 100644 lldb/test/Shell/Error/Inputs/cleanup.lldbinit create mode 100644 lldb/test/Shell/Error/cleanup.cpp diff --git a/lldb/source/Interpreter/CommandObject.cpp b/lldb/source/Interpreter/CommandObject.cpp index 719cfbc9e80233..5ab3392040c9eb 100644 --- a/lldb/source/Interpreter/CommandObject.cpp +++ b/lldb/source/Interpreter/CommandObject.cpp @@ -741,6 +741,7 @@ bool CommandObjectParsed::Execute(const char *args_string, 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 index 00000000000000..56a323ca74ff73 --- /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 index 00000000000000..6abc62dc4af996 --- /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; }