1*0b57cec5SDimitry Andric //===-- CommandObjectGUI.cpp ------------------------------------*- C++ -*-===// 2*0b57cec5SDimitry Andric // 3*0b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*0b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 5*0b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*0b57cec5SDimitry Andric // 7*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 8*0b57cec5SDimitry Andric 9*0b57cec5SDimitry Andric #include "CommandObjectGUI.h" 10*0b57cec5SDimitry Andric 11*0b57cec5SDimitry Andric #include "lldb/Interpreter/CommandInterpreter.h" 12*0b57cec5SDimitry Andric #include "lldb/Interpreter/CommandReturnObject.h" 13*0b57cec5SDimitry Andric #include "lldb/lldb-private.h" 14*0b57cec5SDimitry Andric 15*0b57cec5SDimitry Andric using namespace lldb; 16*0b57cec5SDimitry Andric using namespace lldb_private; 17*0b57cec5SDimitry Andric 18*0b57cec5SDimitry Andric // CommandObjectGUI 19*0b57cec5SDimitry Andric 20*0b57cec5SDimitry Andric CommandObjectGUI::CommandObjectGUI(CommandInterpreter &interpreter) 21*0b57cec5SDimitry Andric : CommandObjectParsed(interpreter, "gui", 22*0b57cec5SDimitry Andric "Switch into the curses based GUI mode.", "gui") {} 23*0b57cec5SDimitry Andric 24*0b57cec5SDimitry Andric CommandObjectGUI::~CommandObjectGUI() {} 25*0b57cec5SDimitry Andric 26*0b57cec5SDimitry Andric bool CommandObjectGUI::DoExecute(Args &args, CommandReturnObject &result) { 27*0b57cec5SDimitry Andric #ifndef LLDB_DISABLE_CURSES 28*0b57cec5SDimitry Andric if (args.GetArgumentCount() == 0) { 29*0b57cec5SDimitry Andric Debugger &debugger = GetDebugger(); 30*0b57cec5SDimitry Andric 31*0b57cec5SDimitry Andric lldb::StreamFileSP input_sp = debugger.GetInputFile(); 32*0b57cec5SDimitry Andric if (input_sp && input_sp->GetFile().GetIsRealTerminal() && 33*0b57cec5SDimitry Andric input_sp->GetFile().GetIsInteractive()) { 34*0b57cec5SDimitry Andric IOHandlerSP io_handler_sp(new IOHandlerCursesGUI(debugger)); 35*0b57cec5SDimitry Andric if (io_handler_sp) 36*0b57cec5SDimitry Andric debugger.PushIOHandler(io_handler_sp); 37*0b57cec5SDimitry Andric result.SetStatus(eReturnStatusSuccessFinishResult); 38*0b57cec5SDimitry Andric } else { 39*0b57cec5SDimitry Andric result.AppendError("the gui command requires an interactive terminal."); 40*0b57cec5SDimitry Andric result.SetStatus(eReturnStatusFailed); 41*0b57cec5SDimitry Andric } 42*0b57cec5SDimitry Andric } else { 43*0b57cec5SDimitry Andric result.AppendError("the gui command takes no arguments."); 44*0b57cec5SDimitry Andric result.SetStatus(eReturnStatusFailed); 45*0b57cec5SDimitry Andric } 46*0b57cec5SDimitry Andric return true; 47*0b57cec5SDimitry Andric #else 48*0b57cec5SDimitry Andric result.AppendError("lldb was not build with gui support"); 49*0b57cec5SDimitry Andric return false; 50*0b57cec5SDimitry Andric #endif 51*0b57cec5SDimitry Andric } 52