15ffd83dbSDimitry Andric //===-- CommandObjectGUI.cpp ----------------------------------------------===// 20b57cec5SDimitry Andric // 30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric // 70b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric 90b57cec5SDimitry Andric #include "CommandObjectGUI.h" 100b57cec5SDimitry Andric 11480093f4SDimitry Andric #include "lldb/Core/IOHandlerCursesGUI.h" 12480093f4SDimitry Andric #include "lldb/Host/Config.h" 130b57cec5SDimitry Andric #include "lldb/Interpreter/CommandInterpreter.h" 140b57cec5SDimitry Andric #include "lldb/Interpreter/CommandReturnObject.h" 150b57cec5SDimitry Andric 160b57cec5SDimitry Andric using namespace lldb; 170b57cec5SDimitry Andric using namespace lldb_private; 180b57cec5SDimitry Andric 190b57cec5SDimitry Andric // CommandObjectGUI 200b57cec5SDimitry Andric CommandObjectGUI(CommandInterpreter & interpreter)210b57cec5SDimitry AndricCommandObjectGUI::CommandObjectGUI(CommandInterpreter &interpreter) 220b57cec5SDimitry Andric : CommandObjectParsed(interpreter, "gui", 230b57cec5SDimitry Andric "Switch into the curses based GUI mode.", "gui") {} 240b57cec5SDimitry Andric 25*5f7ddb14SDimitry Andric CommandObjectGUI::~CommandObjectGUI() = default; 260b57cec5SDimitry Andric DoExecute(Args & args,CommandReturnObject & result)270b57cec5SDimitry Andricbool CommandObjectGUI::DoExecute(Args &args, CommandReturnObject &result) { 28480093f4SDimitry Andric #if LLDB_ENABLE_CURSES 290b57cec5SDimitry Andric if (args.GetArgumentCount() == 0) { 300b57cec5SDimitry Andric Debugger &debugger = GetDebugger(); 310b57cec5SDimitry Andric 329dba64beSDimitry Andric File &input = debugger.GetInputFile(); 339dba64beSDimitry Andric File &output = debugger.GetOutputFile(); 349dba64beSDimitry Andric if (input.GetStream() && output.GetStream() && input.GetIsRealTerminal() && 359dba64beSDimitry Andric input.GetIsInteractive()) { 360b57cec5SDimitry Andric IOHandlerSP io_handler_sp(new IOHandlerCursesGUI(debugger)); 370b57cec5SDimitry Andric if (io_handler_sp) 385ffd83dbSDimitry Andric debugger.RunIOHandlerAsync(io_handler_sp); 390b57cec5SDimitry Andric result.SetStatus(eReturnStatusSuccessFinishResult); 400b57cec5SDimitry Andric } else { 410b57cec5SDimitry Andric result.AppendError("the gui command requires an interactive terminal."); 420b57cec5SDimitry Andric } 430b57cec5SDimitry Andric } else { 440b57cec5SDimitry Andric result.AppendError("the gui command takes no arguments."); 450b57cec5SDimitry Andric } 460b57cec5SDimitry Andric return true; 470b57cec5SDimitry Andric #else 485ffd83dbSDimitry Andric result.AppendError("lldb was not built with gui support"); 490b57cec5SDimitry Andric return false; 500b57cec5SDimitry Andric #endif 510b57cec5SDimitry Andric } 52