Skip to content

Commit

Permalink
[LLDB] Clean up after command fails
Browse files Browse the repository at this point in the history
`CommandObject::CheckRequirements()` requires m_exe_ctx being cleaned up.

Differential Revision: https://reviews.llvm.org/D132397
  • Loading branch information
ZequanWu committed Aug 24, 2022
1 parent 0473ac8 commit b6d56dd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions lldb/source/Interpreter/CommandObject.cpp
Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions lldb/test/Shell/Error/Inputs/cleanup.lldbinit
@@ -0,0 +1,5 @@
b main
run
dis a
dis -a $pc
exit
5 changes: 5 additions & 0 deletions 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; }

0 comments on commit b6d56dd

Please sign in to comment.