1 //===-- CommandObjectGUI.cpp ------------------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #include "CommandObjectGUI.h"
11 #include "lldb/Interpreter/CommandInterpreter.h"
12 #include "lldb/Interpreter/CommandReturnObject.h"
13 #include "lldb/lldb-private.h"
16 using namespace lldb_private;
20 CommandObjectGUI::CommandObjectGUI(CommandInterpreter &interpreter)
21 : CommandObjectParsed(interpreter, "gui",
22 "Switch into the curses based GUI mode.", "gui") {}
24 CommandObjectGUI::~CommandObjectGUI() {}
26 bool CommandObjectGUI::DoExecute(Args &args, CommandReturnObject &result) {
27 #ifndef LLDB_DISABLE_CURSES
28 if (args.GetArgumentCount() == 0) {
29 Debugger &debugger = GetDebugger();
31 lldb::StreamFileSP input_sp = debugger.GetInputFile();
32 if (input_sp && input_sp->GetFile().GetIsRealTerminal() &&
33 input_sp->GetFile().GetIsInteractive()) {
34 IOHandlerSP io_handler_sp(new IOHandlerCursesGUI(debugger));
36 debugger.PushIOHandler(io_handler_sp);
37 result.SetStatus(eReturnStatusSuccessFinishResult);
39 result.AppendError("the gui command requires an interactive terminal.");
40 result.SetStatus(eReturnStatusFailed);
43 result.AppendError("the gui command takes no arguments.");
44 result.SetStatus(eReturnStatusFailed);
48 result.AppendError("lldb was not build with gui support");