diff options
author | Greg Clayton <gclayton@apple.com> | 2015-01-14 19:45:21 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2015-01-14 19:45:21 +0000 |
commit | 456f2712b373750b57fd3783a0bfed0e5b4f2449 (patch) | |
tree | 8d729040b6a6cb7ae5ad9597d7250986b7407d38 /lldb/source/Commands/CommandObjectGUI.cpp | |
parent | 0fd9e5f719d6a703f9bcf9bcb86ca88c73ea1acc (diff) | |
download | bcm5719-llvm-456f2712b373750b57fd3783a0bfed0e5b4f2449.tar.gz bcm5719-llvm-456f2712b373750b57fd3783a0bfed0e5b4f2449.zip |
Typing "gui" will crash programs that don't give LLDB a real terminal.
We now verify that the debugger's input file is a valid terminal file descriptor before allowing the "gui" command to try to run.
Xcode would crash if you typed "gui" at the command line prior to this fix.
<rdar://problem/18775851>
llvm-svn: 226027
Diffstat (limited to 'lldb/source/Commands/CommandObjectGUI.cpp')
-rw-r--r-- | lldb/source/Commands/CommandObjectGUI.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/lldb/source/Commands/CommandObjectGUI.cpp b/lldb/source/Commands/CommandObjectGUI.cpp index 3d05335e92e..359d6d2892d 100644 --- a/lldb/source/Commands/CommandObjectGUI.cpp +++ b/lldb/source/Commands/CommandObjectGUI.cpp @@ -42,10 +42,22 @@ CommandObjectGUI::DoExecute (Args& args, CommandReturnObject &result) if (args.GetArgumentCount() == 0) { Debugger &debugger = m_interpreter.GetDebugger(); - IOHandlerSP io_handler_sp (new IOHandlerCursesGUI (debugger)); - if (io_handler_sp) - debugger.PushIOHandler(io_handler_sp); - result.SetStatus (eReturnStatusSuccessFinishResult); + + lldb::StreamFileSP input_sp = debugger.GetInputFile(); + if (input_sp && + input_sp->GetFile().GetIsRealTerminal() && + input_sp->GetFile().GetIsInteractive()) + { + IOHandlerSP io_handler_sp (new IOHandlerCursesGUI (debugger)); + if (io_handler_sp) + debugger.PushIOHandler(io_handler_sp); + result.SetStatus (eReturnStatusSuccessFinishResult); + } + else + { + result.AppendError("the gui command requires an interactive terminal."); + result.SetStatus (eReturnStatusFailed); + } } else { |