[Lldb-commits] [lldb] r226027 - Typing "gui" will crash programs that don't give LLDB a real terminal.

Greg Clayton gclayton at apple.com
Wed Jan 14 11:45:21 PST 2015


Author: gclayton
Date: Wed Jan 14 13:45:21 2015
New Revision: 226027

URL: http://llvm.org/viewvc/llvm-project?rev=226027&view=rev
Log:
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>

Modified:
    lldb/trunk/source/Commands/CommandObjectGUI.cpp

Modified: lldb/trunk/source/Commands/CommandObjectGUI.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectGUI.cpp?rev=226027&r1=226026&r2=226027&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectGUI.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectGUI.cpp Wed Jan 14 13:45:21 2015
@@ -42,10 +42,22 @@ CommandObjectGUI::DoExecute (Args& args,
     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
     {





More information about the lldb-commits mailing list