summaryrefslogtreecommitdiffstats
path: root/lldb/source/Interpreter
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2019-05-08 01:23:47 +0000
committerJonas Devlieghere <jonas@devlieghere.com>2019-05-08 01:23:47 +0000
commitc0b48ab6318026121241f90430b337ea2c7ee384 (patch)
treeb1d98c9625043e167c8453730ada76b5b34763f5 /lldb/source/Interpreter
parentba670b404e3f05f7c9b9cf483bca89f647a74957 (diff)
downloadbcm5719-llvm-c0b48ab6318026121241f90430b337ea2c7ee384.tar.gz
bcm5719-llvm-c0b48ab6318026121241f90430b337ea2c7ee384.zip
Propagate command interpreter errors from lldlbinit
This patch ensures that we propagate errors coming from the lldbinit file trough the command/script interpreter. Before, if you did something like command script import syntax_error.py, and the python file contained a syntax error, lldb wouldn't tell you about it. This changes with the current patch: errors are now propagated by default. PS: Jim authored this change and I added testing. Differential revision: https://reviews.llvm.org/D61579 llvm-svn: 360216
Diffstat (limited to 'lldb/source/Interpreter')
-rw-r--r--lldb/source/Interpreter/CommandInterpreter.cpp24
1 files changed, 21 insertions, 3 deletions
diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp
index 0811822ff14..df583bc72dc 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -2173,6 +2173,7 @@ void CommandInterpreter::SourceInitFile(bool in_cwd,
const bool saved_batch = SetBatchCommandMode(true);
CommandInterpreterRunOptions options;
options.SetSilent(true);
+ options.SetPrintErrors(true);
options.SetStopOnError(false);
options.SetStopOnContinue(true);
@@ -2364,7 +2365,8 @@ enum {
eHandleCommandFlagEchoCommand = (1u << 2),
eHandleCommandFlagEchoCommentCommand = (1u << 3),
eHandleCommandFlagPrintResult = (1u << 4),
- eHandleCommandFlagStopOnCrash = (1u << 5)
+ eHandleCommandFlagPrintErrors = (1u << 5),
+ eHandleCommandFlagStopOnCrash = (1u << 6)
};
void CommandInterpreter::HandleCommandsFromFile(
@@ -2463,6 +2465,17 @@ void CommandInterpreter::HandleCommandsFromFile(
flags |= eHandleCommandFlagPrintResult;
}
+ if (options.m_print_errors == eLazyBoolCalculate) {
+ if (m_command_source_flags.empty()) {
+ // Print output by default
+ flags |= eHandleCommandFlagPrintErrors;
+ } else if (m_command_source_flags.back() & eHandleCommandFlagPrintErrors) {
+ flags |= eHandleCommandFlagPrintErrors;
+ }
+ } else if (options.m_print_errors == eLazyBoolYes) {
+ flags |= eHandleCommandFlagPrintErrors;
+ }
+
if (flags & eHandleCommandFlagPrintResult) {
debugger.GetOutputFile()->Printf("Executing commands in '%s'.\n",
cmd_file_path.c_str());
@@ -2790,7 +2803,9 @@ void CommandInterpreter::IOHandlerInputComplete(IOHandler &io_handler,
HandleCommand(line.c_str(), eLazyBoolCalculate, result);
// Now emit the command output text from the command we just executed
- if (io_handler.GetFlags().Test(eHandleCommandFlagPrintResult)) {
+ if ((result.Succeeded() &&
+ io_handler.GetFlags().Test(eHandleCommandFlagPrintResult)) ||
+ io_handler.GetFlags().Test(eHandleCommandFlagPrintErrors)) {
// Display any STDOUT/STDERR _prior_ to emitting the command result text
GetProcessOutput();
@@ -2960,8 +2975,11 @@ CommandInterpreter::GetIOHandler(bool force_create,
flags |= eHandleCommandFlagEchoCommentCommand;
if (options->m_print_results != eLazyBoolNo)
flags |= eHandleCommandFlagPrintResult;
+ if (options->m_print_errors != eLazyBoolNo)
+ flags |= eHandleCommandFlagPrintErrors;
} else {
- flags = eHandleCommandFlagEchoCommand | eHandleCommandFlagPrintResult;
+ flags = eHandleCommandFlagEchoCommand | eHandleCommandFlagPrintResult |
+ eHandleCommandFlagPrintErrors;
}
m_command_io_handler_sp = std::make_shared<IOHandlerEditline>(
OpenPOWER on IntegriCloud