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 25fe6060f1SDimitry Andric CommandObjectGUI::~CommandObjectGUI() = default; 260b57cec5SDimitry Andric DoExecute(Args & args,CommandReturnObject & result)27*5f757f3fSDimitry Andricvoid CommandObjectGUI::DoExecute(Args &args, CommandReturnObject &result) { 28480093f4SDimitry Andric #if LLDB_ENABLE_CURSES 290b57cec5SDimitry Andric Debugger &debugger = GetDebugger(); 300b57cec5SDimitry Andric 319dba64beSDimitry Andric File &input = debugger.GetInputFile(); 329dba64beSDimitry Andric File &output = debugger.GetOutputFile(); 339dba64beSDimitry Andric if (input.GetStream() && output.GetStream() && input.GetIsRealTerminal() && 349dba64beSDimitry Andric input.GetIsInteractive()) { 350b57cec5SDimitry Andric IOHandlerSP io_handler_sp(new IOHandlerCursesGUI(debugger)); 360b57cec5SDimitry Andric if (io_handler_sp) 375ffd83dbSDimitry Andric debugger.RunIOHandlerAsync(io_handler_sp); 380b57cec5SDimitry Andric result.SetStatus(eReturnStatusSuccessFinishResult); 390b57cec5SDimitry Andric } else { 400b57cec5SDimitry Andric result.AppendError("the gui command requires an interactive terminal."); 410b57cec5SDimitry Andric } 420b57cec5SDimitry Andric #else 435ffd83dbSDimitry Andric result.AppendError("lldb was not built with gui support"); 440b57cec5SDimitry Andric #endif 450b57cec5SDimitry Andric } 46