xref: /freebsd-src/contrib/llvm-project/lldb/source/Commands/CommandObjectGUI.cpp (revision 9dba64be9536c28e4800e06512b7f29b43ade345)
10b57cec5SDimitry Andric //===-- CommandObjectGUI.cpp ------------------------------------*- C++ -*-===//
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 
110b57cec5SDimitry Andric #include "lldb/Interpreter/CommandInterpreter.h"
120b57cec5SDimitry Andric #include "lldb/Interpreter/CommandReturnObject.h"
130b57cec5SDimitry Andric #include "lldb/lldb-private.h"
140b57cec5SDimitry Andric 
150b57cec5SDimitry Andric using namespace lldb;
160b57cec5SDimitry Andric using namespace lldb_private;
170b57cec5SDimitry Andric 
180b57cec5SDimitry Andric // CommandObjectGUI
190b57cec5SDimitry Andric 
200b57cec5SDimitry Andric CommandObjectGUI::CommandObjectGUI(CommandInterpreter &interpreter)
210b57cec5SDimitry Andric     : CommandObjectParsed(interpreter, "gui",
220b57cec5SDimitry Andric                           "Switch into the curses based GUI mode.", "gui") {}
230b57cec5SDimitry Andric 
240b57cec5SDimitry Andric CommandObjectGUI::~CommandObjectGUI() {}
250b57cec5SDimitry Andric 
260b57cec5SDimitry Andric bool CommandObjectGUI::DoExecute(Args &args, CommandReturnObject &result) {
270b57cec5SDimitry Andric #ifndef LLDB_DISABLE_CURSES
280b57cec5SDimitry Andric   if (args.GetArgumentCount() == 0) {
290b57cec5SDimitry Andric     Debugger &debugger = GetDebugger();
300b57cec5SDimitry Andric 
31*9dba64beSDimitry Andric     File &input = debugger.GetInputFile();
32*9dba64beSDimitry Andric     File &output = debugger.GetOutputFile();
33*9dba64beSDimitry Andric     if (input.GetStream() && output.GetStream() && input.GetIsRealTerminal() &&
34*9dba64beSDimitry Andric         input.GetIsInteractive()) {
350b57cec5SDimitry Andric       IOHandlerSP io_handler_sp(new IOHandlerCursesGUI(debugger));
360b57cec5SDimitry Andric       if (io_handler_sp)
370b57cec5SDimitry Andric         debugger.PushIOHandler(io_handler_sp);
380b57cec5SDimitry Andric       result.SetStatus(eReturnStatusSuccessFinishResult);
390b57cec5SDimitry Andric     } else {
400b57cec5SDimitry Andric       result.AppendError("the gui command requires an interactive terminal.");
410b57cec5SDimitry Andric       result.SetStatus(eReturnStatusFailed);
420b57cec5SDimitry Andric     }
430b57cec5SDimitry Andric   } else {
440b57cec5SDimitry Andric     result.AppendError("the gui command takes no arguments.");
450b57cec5SDimitry Andric     result.SetStatus(eReturnStatusFailed);
460b57cec5SDimitry Andric   }
470b57cec5SDimitry Andric   return true;
480b57cec5SDimitry Andric #else
490b57cec5SDimitry Andric   result.AppendError("lldb was not build with gui support");
500b57cec5SDimitry Andric   return false;
510b57cec5SDimitry Andric #endif
520b57cec5SDimitry Andric }
53