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/Core/IOHandlerCursesGUI.h" 12 #include "lldb/Host/Config.h" 13 #include "lldb/Interpreter/CommandInterpreter.h" 14 #include "lldb/Interpreter/CommandReturnObject.h" 15 #include "lldb/lldb-private.h" 16 17 using namespace lldb; 18 using namespace lldb_private; 19 20 // CommandObjectGUI 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 #if LLDB_ENABLE_CURSES 30 if (args.GetArgumentCount() == 0) { 31 Debugger &debugger = GetDebugger(); 32 33 File &input = debugger.GetInputFile(); 34 File &output = debugger.GetOutputFile(); 35 if (input.GetStream() && output.GetStream() && input.GetIsRealTerminal() && 36 input.GetIsInteractive()) { 37 IOHandlerSP io_handler_sp(new IOHandlerCursesGUI(debugger)); 38 if (io_handler_sp) 39 debugger.PushIOHandler(io_handler_sp); 40 result.SetStatus(eReturnStatusSuccessFinishResult); 41 } else { 42 result.AppendError("the gui command requires an interactive terminal."); 43 result.SetStatus(eReturnStatusFailed); 44 } 45 } else { 46 result.AppendError("the gui command takes no arguments."); 47 result.SetStatus(eReturnStatusFailed); 48 } 49 return true; 50 #else 51 result.AppendError("lldb was not build with gui support"); 52 return false; 53 #endif 54 } 55