[NFC][Coroutines] Use structured binding with llvm::enumerate in CoroSplit (#116879)
[llvm-project.git] / lldb / source / Commands / CommandObjectGUI.cpp
blobb56e49b073b03eb9635ad8955a24f5662c0a0613
1 //===-- CommandObjectGUI.cpp ----------------------------------------------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
9 #include "CommandObjectGUI.h"
11 #include "lldb/Core/IOHandlerCursesGUI.h"
12 #include "lldb/Host/Config.h"
13 #include "lldb/Interpreter/CommandInterpreter.h"
14 #include "lldb/Interpreter/CommandReturnObject.h"
16 using namespace lldb;
17 using namespace lldb_private;
19 // CommandObjectGUI
21 CommandObjectGUI::CommandObjectGUI(CommandInterpreter &interpreter)
22 : CommandObjectParsed(interpreter, "gui",
23 "Switch into the curses based GUI mode.", "gui") {}
25 CommandObjectGUI::~CommandObjectGUI() = default;
27 void CommandObjectGUI::DoExecute(Args &args, CommandReturnObject &result) {
28 #if LLDB_ENABLE_CURSES
29 Debugger &debugger = GetDebugger();
31 File &input = debugger.GetInputFile();
32 File &output = debugger.GetOutputFile();
33 if (input.GetStream() && output.GetStream() && input.GetIsRealTerminal() &&
34 input.GetIsInteractive()) {
35 IOHandlerSP io_handler_sp(new IOHandlerCursesGUI(debugger));
36 if (io_handler_sp)
37 debugger.RunIOHandlerAsync(io_handler_sp);
38 result.SetStatus(eReturnStatusSuccessFinishResult);
39 } else {
40 result.AppendError("the gui command requires an interactive terminal.");
42 #else
43 result.AppendError("lldb was not built with gui support");
44 #endif