144d93782SGreg Clayton //===-- CommandObjectGUI.cpp ------------------------------------*- C++ -*-===// 244d93782SGreg Clayton // 32946cd70SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 42946cd70SChandler Carruth // See https://llvm.org/LICENSE.txt for license information. 52946cd70SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 644d93782SGreg Clayton // 744d93782SGreg Clayton //===----------------------------------------------------------------------===// 844d93782SGreg Clayton 944d93782SGreg Clayton #include "CommandObjectGUI.h" 1044d93782SGreg Clayton 117caa17caSRaphael Isemann #include "lldb/Core/IOHandlerCursesGUI.h" 1259998b7bSJonas Devlieghere #include "lldb/Host/Config.h" 1344d93782SGreg Clayton #include "lldb/Interpreter/CommandInterpreter.h" 1444d93782SGreg Clayton #include "lldb/Interpreter/CommandReturnObject.h" 15b9c1b51eSKate Stone #include "lldb/lldb-private.h" 1644d93782SGreg Clayton 1744d93782SGreg Clayton using namespace lldb; 1844d93782SGreg Clayton using namespace lldb_private; 1944d93782SGreg Clayton 2044d93782SGreg Clayton // CommandObjectGUI 2144d93782SGreg Clayton 22b9c1b51eSKate Stone CommandObjectGUI::CommandObjectGUI(CommandInterpreter &interpreter) 23b9c1b51eSKate Stone : CommandObjectParsed(interpreter, "gui", 24b9c1b51eSKate Stone "Switch into the curses based GUI mode.", "gui") {} 2544d93782SGreg Clayton 26b9c1b51eSKate Stone CommandObjectGUI::~CommandObjectGUI() {} 2744d93782SGreg Clayton 28b9c1b51eSKate Stone bool CommandObjectGUI::DoExecute(Args &args, CommandReturnObject &result) { 29*a4304f96SJonas Devlieghere #if LLDB_ENABLE_CURSES 30b9c1b51eSKate Stone if (args.GetArgumentCount() == 0) { 3157179860SJonas Devlieghere Debugger &debugger = GetDebugger(); 32456f2712SGreg Clayton 337ca15ba7SLawrence D'Anna File &input = debugger.GetInputFile(); 34609010d0SLawrence D'Anna File &output = debugger.GetOutputFile(); 35609010d0SLawrence D'Anna if (input.GetStream() && output.GetStream() && input.GetIsRealTerminal() && 36609010d0SLawrence D'Anna input.GetIsInteractive()) { 3744d93782SGreg Clayton IOHandlerSP io_handler_sp(new IOHandlerCursesGUI(debugger)); 3844d93782SGreg Clayton if (io_handler_sp) 3944d93782SGreg Clayton debugger.PushIOHandler(io_handler_sp); 4044d93782SGreg Clayton result.SetStatus(eReturnStatusSuccessFinishResult); 41b9c1b51eSKate Stone } else { 42456f2712SGreg Clayton result.AppendError("the gui command requires an interactive terminal."); 43456f2712SGreg Clayton result.SetStatus(eReturnStatusFailed); 44456f2712SGreg Clayton } 45b9c1b51eSKate Stone } else { 4644d93782SGreg Clayton result.AppendError("the gui command takes no arguments."); 4744d93782SGreg Clayton result.SetStatus(eReturnStatusFailed); 4844d93782SGreg Clayton } 4944d93782SGreg Clayton return true; 50914b8d98SDeepak Panickal #else 51914b8d98SDeepak Panickal result.AppendError("lldb was not build with gui support"); 52914b8d98SDeepak Panickal return false; 53914b8d98SDeepak Panickal #endif 5444d93782SGreg Clayton } 55