summaryrefslogtreecommitdiffstats
path: root/lldb/tools/driver/Driver.cpp
diff options
context:
space:
mode:
authorJim Ingham <jingham@apple.com>2014-10-11 00:38:27 +0000
committerJim Ingham <jingham@apple.com>2014-10-11 00:38:27 +0000
commit26c7bf9312939025f710bd4c4e0174488da25c7c (patch)
treea4c57cdaba6967e417a24316a9d92f932dbf01f9 /lldb/tools/driver/Driver.cpp
parent41c79d934ba10ba61beef70534ec3fed410f5ab0 (diff)
downloadbcm5719-llvm-26c7bf9312939025f710bd4c4e0174488da25c7c.tar.gz
bcm5719-llvm-26c7bf9312939025f710bd4c4e0174488da25c7c.zip
Rework the way we pass "run multiple command" options to the various API's that
do that (RunCommandInterpreter, HandleCommands, HandleCommandsFromFile) to gather the options into an options class. Also expose that to the SB API's. Change the way the "-o" options to the lldb driver are processed so: 1) They are run synchronously - didn't really make any sense to run the asynchronously. 2) The stop on error 3) "quit" in one of the -o commands will not quit lldb - not the command interpreter that was running the -o commands. I added an entry to the run options to stop-on-crash, but I haven't implemented that yet. llvm-svn: 219553
Diffstat (limited to 'lldb/tools/driver/Driver.cpp')
-rw-r--r--lldb/tools/driver/Driver.cpp24
1 files changed, 21 insertions, 3 deletions
diff --git a/lldb/tools/driver/Driver.cpp b/lldb/tools/driver/Driver.cpp
index 0b5809c8355..e4fdc77caea 100644
--- a/lldb/tools/driver/Driver.cpp
+++ b/lldb/tools/driver/Driver.cpp
@@ -921,6 +921,9 @@ Driver::MainLoop ()
// so we can then run the command interpreter using the file contents.
const char *commands_data = commands_stream.GetData();
const size_t commands_size = commands_stream.GetSize();
+
+ // The command file might have requested that we quit, this variable will track that.
+ bool quit_requested = false;
if (commands_data && commands_size)
{
enum PIPES { READ, WRITE }; // Constants 0 and 1 for READ and WRITE
@@ -961,7 +964,18 @@ Driver::MainLoop ()
fds[READ] = -1; // The FILE * 'commands_file' now owns the read descriptor
// Hand ownership if the FILE * over to the debugger for "commands_file".
m_debugger.SetInputFileHandle (commands_file, true);
- m_debugger.RunCommandInterpreter(handle_events, spawn_thread);
+
+ // Set the debugger into Sync mode when running the command file. Otherwise command files
+ // that run the target won't run in a sensible way.
+ bool old_async = m_debugger.GetAsync();
+ m_debugger.SetAsync(false);
+ int num_errors;
+
+ SBCommandInterpreterRunOptions options;
+ options.SetStopOnError (true);
+
+ m_debugger.RunCommandInterpreter(handle_events, spawn_thread, options, num_errors, quit_requested);
+ m_debugger.SetAsync(old_async);
}
else
{
@@ -1015,8 +1029,12 @@ Driver::MainLoop ()
// Now set the input file handle to STDIN and run the command
// interpreter again in interactive mode and let the debugger
// take ownership of stdin
- m_debugger.SetInputFileHandle (stdin, true);
- m_debugger.RunCommandInterpreter(handle_events, spawn_thread);
+
+ if (!quit_requested)
+ {
+ m_debugger.SetInputFileHandle (stdin, true);
+ m_debugger.RunCommandInterpreter(handle_events, spawn_thread);
+ }
reset_stdin_termios();
fclose (stdin);
OpenPOWER on IntegriCloud