Skip to content

Commit 456f271

Browse files
author
Greg Clayton
committed
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
1 parent 0fd9e5f commit 456f271

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

lldb/source/Commands/CommandObjectGUI.cpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,22 @@ CommandObjectGUI::DoExecute (Args& args, CommandReturnObject &result)
4242
if (args.GetArgumentCount() == 0)
4343
{
4444
Debugger &debugger = m_interpreter.GetDebugger();
45-
IOHandlerSP io_handler_sp (new IOHandlerCursesGUI (debugger));
46-
if (io_handler_sp)
47-
debugger.PushIOHandler(io_handler_sp);
48-
result.SetStatus (eReturnStatusSuccessFinishResult);
45+
46+
lldb::StreamFileSP input_sp = debugger.GetInputFile();
47+
if (input_sp &&
48+
input_sp->GetFile().GetIsRealTerminal() &&
49+
input_sp->GetFile().GetIsInteractive())
50+
{
51+
IOHandlerSP io_handler_sp (new IOHandlerCursesGUI (debugger));
52+
if (io_handler_sp)
53+
debugger.PushIOHandler(io_handler_sp);
54+
result.SetStatus (eReturnStatusSuccessFinishResult);
55+
}
56+
else
57+
{
58+
result.AppendError("the gui command requires an interactive terminal.");
59+
result.SetStatus (eReturnStatusFailed);
60+
}
4961
}
5062
else
5163
{

0 commit comments

Comments
 (0)