[lldb/Driver] Exit with a non-zero exit code in case of error in batch mode.
We have the option to stop running commands in batch mode when an error occurs. When that happens we should exit the driver with a non-zero exit code. Differential revision: https://reviews.llvm.org/D78825
This commit is contained in:
@@ -2816,8 +2816,10 @@ void CommandInterpreter::IOHandlerInputComplete(IOHandler &io_handler,
|
||||
|
||||
case eReturnStatusFailed:
|
||||
m_result.IncrementNumberOfErrors();
|
||||
if (io_handler.GetFlags().Test(eHandleCommandFlagStopOnError))
|
||||
if (io_handler.GetFlags().Test(eHandleCommandFlagStopOnError)) {
|
||||
m_result.SetResult(lldb::eCommandInterpreterResultCommandError);
|
||||
io_handler.SetIsDone(true);
|
||||
}
|
||||
break;
|
||||
|
||||
case eReturnStatusQuit:
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
# Check that stop command source on error.
|
||||
|
||||
# RUN: %lldb -x -b -o "command source -e 1 %s" 2>&1 | FileCheck %s --check-prefix STOP
|
||||
# RUN: not %lldb -x -b -o "command source -e 1 %s" 2>&1 | FileCheck %s --check-prefix STOP
|
||||
# RUN: %lldb -x -b -o "command source -e 0 %s" 2>&1 | FileCheck %s --check-prefix CONTINUE
|
||||
# RUN: %lldb -x -b -o 'settings set interpreter.stop-command-source-on-error true' -o "command source %s" 2>&1 | FileCheck %s --check-prefix STOP
|
||||
# RUN: not %lldb -x -b -o 'settings set interpreter.stop-command-source-on-error true' -o "command source %s" 2>&1 | FileCheck %s --check-prefix STOP
|
||||
# RUN: %lldb -x -b -o 'settings set interpreter.stop-command-source-on-error false' -o "command source %s" 2>&1 | FileCheck %s --check-prefix CONTINUE
|
||||
|
||||
bogus
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
# RUN: %lldb -x -b -S %S/Inputs/process_attach_pid.in 2>&1 | FileCheck %s
|
||||
# RUN: not %lldb -x -b -S %S/Inputs/process_attach_pid.in 2>&1 | FileCheck %s
|
||||
# CHECK: last option requires an argument
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
# XFAIL: system-openbsd
|
||||
|
||||
# RUN: %clang_host %S/Inputs/simple.c -g -o %t.out
|
||||
# RUN: SHELL=bogus %lldb %t.out -b -o 'run' 2>&1 | FileCheck %s --check-prefix ERROR
|
||||
# RUN: SHELL=bogus not %lldb %t.out -b -o 'run' 2>&1 | FileCheck %s --check-prefix ERROR
|
||||
# RUN: env -i %lldb %t.out -b -o 'run' 2>&1 | FileCheck %s
|
||||
|
||||
# ERROR: error: shell expansion failed
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# UNSUPPORTED: system-windows
|
||||
# RUN: %lldb -b -s %s 2>&1 | FileCheck %s
|
||||
# RUN: not %lldb -b -s %s 2>&1 | FileCheck %s
|
||||
q str
|
||||
// CHECK: Couldn't parse 'str'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# UNSUPPORTED: system-windows
|
||||
# RUN: %lldb -b -s %s 2>&1 | FileCheck %s
|
||||
# RUN: not %lldb -b -s %s 2>&1 | FileCheck %s
|
||||
q 1 2
|
||||
// CHECK: Too many arguments for 'quit'
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
# RUN: %clang_host %S/Inputs/simple.c -g -o %t/reproducer.out
|
||||
|
||||
# Capture but don't generate the reproducer.
|
||||
# RUN: %lldb -x -b -s %S/Inputs/Discard.in --capture --capture-path %t.repro %t/reproducer.out
|
||||
# RUN: not %lldb -x -b -s %S/Inputs/Discard.in --capture --capture-path %t.repro %t/reproducer.out
|
||||
|
||||
# Make sure the directory doesn't exist.
|
||||
# RUN: mkdir %t.repro
|
||||
|
||||
@@ -25,9 +25,9 @@
|
||||
# RUN: %lldb --replay %t.repro | FileCheck %s --check-prefix FILES
|
||||
|
||||
# RUN: rm %t.repro/gdb-remote.yaml
|
||||
# RUN: %lldb -b -o 'reproducer dump -p gdb -f %t.repro' 2>&1 | FileCheck %s --check-prefix GDB-ERROR
|
||||
# RUN: not %lldb -b -o 'reproducer dump -p gdb -f %t.repro' 2>&1 | FileCheck %s --check-prefix GDB-ERROR
|
||||
# GDB-ERROR: error: Unable to create GDB loader.
|
||||
|
||||
# RUN: rm %t.repro/command-interpreter.yaml
|
||||
# RUN: %lldb -b -o 'reproducer dump -p commands -f %t.repro' 2>&1 | FileCheck %s --check-prefix COMMANDS-ERROR
|
||||
# RUN: not %lldb -b -o 'reproducer dump -p commands -f %t.repro' 2>&1 | FileCheck %s --check-prefix COMMANDS-ERROR
|
||||
# COMMANDS-ERROR: error: Unable to create command loader.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# This tests setting setting values.
|
||||
|
||||
# Check that setting an empty value with -f(orce) clears the value.
|
||||
# RUN: %lldb -b -s %s 2>&1 | FileCheck %s
|
||||
# RUN: not %lldb -b -s %s 2>&1 | FileCheck %s
|
||||
|
||||
settings set tab-size 16
|
||||
settings show tab-size
|
||||
|
||||
@@ -12,13 +12,13 @@
|
||||
# RUN: %lldb -b -o 'settings set interpreter.stop-command-source-on-error false' -s %S/Inputs/StopCommandSource.in | FileCheck %s --check-prefix CONTINUE
|
||||
|
||||
# FIXME: Should continue
|
||||
# RUN: %lldb -b -s %S/Inputs/DontStopCommandSource.in -o 'bogus' -o 'print 111100000 + 11111' | FileCheck %s --check-prefix STOP
|
||||
# RUN: not %lldb -b -s %S/Inputs/DontStopCommandSource.in -o 'bogus' -o 'print 111100000 + 11111' | FileCheck %s --check-prefix STOP
|
||||
|
||||
# FIXME: Should continue
|
||||
# RUN: %lldb -b -o 'settings set interpreter.stop-command-source-on-error false' -o 'bogus' -o 'print 123400000 + 56789' | FileCheck %s --check-prefix STOP
|
||||
# RUN: not %lldb -b -o 'settings set interpreter.stop-command-source-on-error false' -o 'bogus' -o 'print 123400000 + 56789' | FileCheck %s --check-prefix STOP
|
||||
|
||||
# FIXME: Should continue
|
||||
# RUN: %lldb -b -s %S/Inputs/DontStopCommandSource.in | FileCheck %s --check-prefix STOP
|
||||
# RUN: not %lldb -b -s %S/Inputs/DontStopCommandSource.in | FileCheck %s --check-prefix STOP
|
||||
|
||||
# FIXME: Should continue
|
||||
# RUN: %lldb -b -o 'settings set interpreter.stop-command-source-on-error true' -s %S/Inputs/DontStopCommandSource.in | FileCheck %s --check-prefix STOP
|
||||
# RUN: not %lldb -b -o 'settings set interpreter.stop-command-source-on-error true' -s %S/Inputs/DontStopCommandSource.in | FileCheck %s --check-prefix STOP
|
||||
|
||||
@@ -14,10 +14,10 @@ LOOKUPE: no type was found matching 'E'
|
||||
RUN: %lldb %t -b -o "type lookup EC" | FileCheck --check-prefix=LOOKUPEC %s
|
||||
LOOKUPEC: no type was found matching 'EC'
|
||||
|
||||
RUN: %lldb %t -b -o "print (E) 1" 2>&1 | FileCheck --check-prefix=PRINTE %s
|
||||
RUN: not %lldb %t -b -o "print (E) 1" 2>&1 | FileCheck --check-prefix=PRINTE %s
|
||||
PRINTE: use of undeclared identifier 'E'
|
||||
|
||||
RUN: %lldb %t -b -o "print (EC) 1" 2>&1 | FileCheck --check-prefix=PRINTEC %s
|
||||
RUN: not %lldb %t -b -o "print (EC) 1" 2>&1 | FileCheck --check-prefix=PRINTEC %s
|
||||
PRINTEC: use of undeclared identifier 'EC'
|
||||
|
||||
RUN: %lldb %t -b -o "target variable a e ec" | FileCheck --check-prefix=VARS %s
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
# UNSUPPORTED: system-windows
|
||||
|
||||
# RUN: %clang_host %p/Inputs/call-asm.c -x assembler-with-cpp %p/Inputs/thread-step-out-ret-addr-check.s -o %t
|
||||
# RUN: %lldb %t -s %s -b 2>&1 | FileCheck %s
|
||||
# RUN: not %lldb %t -s %s -b 2>&1 | FileCheck %s
|
||||
|
||||
breakpoint set -n nonstandard_stub
|
||||
# CHECK: Breakpoint 1: where = {{.*}}`nonstandard_stub
|
||||
|
||||
@@ -619,6 +619,12 @@ int Driver::MainLoop() {
|
||||
results.GetResult() != lldb::eCommandInterpreterResultInferiorCrash)
|
||||
go_interactive = false;
|
||||
|
||||
// When running in batch mode and stopped because of an error, exit with a
|
||||
// non-zero exit status.
|
||||
if (m_option_data.m_batch &&
|
||||
results.GetResult() == lldb::eCommandInterpreterResultCommandError)
|
||||
exit(1);
|
||||
|
||||
if (m_option_data.m_batch &&
|
||||
results.GetResult() == lldb::eCommandInterpreterResultInferiorCrash &&
|
||||
!m_option_data.m_after_crash_commands.empty()) {
|
||||
@@ -636,6 +642,13 @@ int Driver::MainLoop() {
|
||||
if (local_results.GetResult() ==
|
||||
lldb::eCommandInterpreterResultQuitRequested)
|
||||
go_interactive = false;
|
||||
|
||||
// When running in batch mode and an error occurred while sourcing
|
||||
// the crash commands, exit with a non-zero exit status.
|
||||
if (m_option_data.m_batch &&
|
||||
local_results.GetResult() ==
|
||||
lldb::eCommandInterpreterResultCommandError)
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
m_debugger.SetAsync(old_async);
|
||||
|
||||
Reference in New Issue
Block a user