1cfca06d7SDimitry Andric //===-- CommandObjectGUI.cpp ----------------------------------------------===// 2866dcdacSEd Maste // 35f29bb8aSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 45f29bb8aSDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 55f29bb8aSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6866dcdacSEd Maste // 7866dcdacSEd Maste //===----------------------------------------------------------------------===// 8866dcdacSEd Maste 9866dcdacSEd Maste #include "CommandObjectGUI.h" 10866dcdacSEd Maste 11706b4fc4SDimitry Andric #include "lldb/Core/IOHandlerCursesGUI.h" 12706b4fc4SDimitry Andric #include "lldb/Host/Config.h" 13866dcdacSEd Maste #include "lldb/Interpreter/CommandInterpreter.h" 14866dcdacSEd Maste #include "lldb/Interpreter/CommandReturnObject.h" 15866dcdacSEd Maste 16866dcdacSEd Maste using namespace lldb; 17866dcdacSEd Maste using namespace lldb_private; 18866dcdacSEd Maste 19866dcdacSEd Maste // CommandObjectGUI 20866dcdacSEd Maste CommandObjectGUI(CommandInterpreter & interpreter)2114f1b3e8SDimitry AndricCommandObjectGUI::CommandObjectGUI(CommandInterpreter &interpreter) 2214f1b3e8SDimitry Andric : CommandObjectParsed(interpreter, "gui", 2314f1b3e8SDimitry Andric "Switch into the curses based GUI mode.", "gui") {} 24866dcdacSEd Maste 25344a3780SDimitry Andric CommandObjectGUI::~CommandObjectGUI() = default; 26866dcdacSEd Maste DoExecute(Args & args,CommandReturnObject & result)27b1c73532SDimitry Andricvoid CommandObjectGUI::DoExecute(Args &args, CommandReturnObject &result) { 28706b4fc4SDimitry Andric #if LLDB_ENABLE_CURSES 295f29bb8aSDimitry Andric Debugger &debugger = GetDebugger(); 3012bd4897SEd Maste 31ead24645SDimitry Andric File &input = debugger.GetInputFile(); 32ead24645SDimitry Andric File &output = debugger.GetOutputFile(); 33ead24645SDimitry Andric if (input.GetStream() && output.GetStream() && input.GetIsRealTerminal() && 34ead24645SDimitry Andric input.GetIsInteractive()) { 35866dcdacSEd Maste IOHandlerSP io_handler_sp(new IOHandlerCursesGUI(debugger)); 36866dcdacSEd Maste if (io_handler_sp) 37cfca06d7SDimitry Andric debugger.RunIOHandlerAsync(io_handler_sp); 38866dcdacSEd Maste result.SetStatus(eReturnStatusSuccessFinishResult); 3914f1b3e8SDimitry Andric } else { 4012bd4897SEd Maste result.AppendError("the gui command requires an interactive terminal."); 4112bd4897SEd Maste } 42866dcdacSEd Maste #else 43cfca06d7SDimitry Andric result.AppendError("lldb was not built with gui support"); 44866dcdacSEd Maste #endif 45866dcdacSEd Maste } 46