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