]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm-project/lldb/source/Commands/CommandObjectGUI.cpp
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
[FreeBSD/FreeBSD.git] / contrib / llvm-project / lldb / source / Commands / CommandObjectGUI.cpp
1 //===-- CommandObjectGUI.cpp ------------------------------------*- C++ -*-===//
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 //===----------------------------------------------------------------------===//
8
9 #include "CommandObjectGUI.h"
10
11 #include "lldb/Interpreter/CommandInterpreter.h"
12 #include "lldb/Interpreter/CommandReturnObject.h"
13 #include "lldb/lldb-private.h"
14
15 using namespace lldb;
16 using namespace lldb_private;
17
18 // CommandObjectGUI
19
20 CommandObjectGUI::CommandObjectGUI(CommandInterpreter &interpreter)
21     : CommandObjectParsed(interpreter, "gui",
22                           "Switch into the curses based GUI mode.", "gui") {}
23
24 CommandObjectGUI::~CommandObjectGUI() {}
25
26 bool CommandObjectGUI::DoExecute(Args &args, CommandReturnObject &result) {
27 #ifndef LLDB_DISABLE_CURSES
28   if (args.GetArgumentCount() == 0) {
29     Debugger &debugger = GetDebugger();
30
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));
35       if (io_handler_sp)
36         debugger.PushIOHandler(io_handler_sp);
37       result.SetStatus(eReturnStatusSuccessFinishResult);
38     } else {
39       result.AppendError("the gui command requires an interactive terminal.");
40       result.SetStatus(eReturnStatusFailed);
41     }
42   } else {
43     result.AppendError("the gui command takes no arguments.");
44     result.SetStatus(eReturnStatusFailed);
45   }
46   return true;
47 #else
48   result.AppendError("lldb was not build with gui support");
49   return false;
50 #endif
51 }