blob: d65e12e30982297a93070345a4271e78493bbc09 [file] [log] [blame]
Greg Clayton44d93782014-01-27 23:43:24 +00001//===-- CommandObjectGUI.cpp ------------------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
Greg Clayton44d93782014-01-27 23:43:24 +000010#include "CommandObjectGUI.h"
11
12// C Includes
13// C++ Includes
14// Other libraries and framework includes
15// Project includes
Greg Clayton44d93782014-01-27 23:43:24 +000016#include "lldb/Interpreter/CommandInterpreter.h"
17#include "lldb/Interpreter/CommandReturnObject.h"
Kate Stoneb9c1b512016-09-06 20:57:50 +000018#include "lldb/lldb-private.h"
Greg Clayton44d93782014-01-27 23:43:24 +000019
20using namespace lldb;
21using namespace lldb_private;
22
23//-------------------------------------------------------------------------
24// CommandObjectGUI
25//-------------------------------------------------------------------------
26
Kate Stoneb9c1b512016-09-06 20:57:50 +000027CommandObjectGUI::CommandObjectGUI(CommandInterpreter &interpreter)
28 : CommandObjectParsed(interpreter, "gui",
29 "Switch into the curses based GUI mode.", "gui") {}
Greg Clayton44d93782014-01-27 23:43:24 +000030
Kate Stoneb9c1b512016-09-06 20:57:50 +000031CommandObjectGUI::~CommandObjectGUI() {}
Greg Clayton44d93782014-01-27 23:43:24 +000032
Kate Stoneb9c1b512016-09-06 20:57:50 +000033bool CommandObjectGUI::DoExecute(Args &args, CommandReturnObject &result) {
Deepak Panickal914b8d92014-01-31 18:48:46 +000034#ifndef LLDB_DISABLE_CURSES
Kate Stoneb9c1b512016-09-06 20:57:50 +000035 if (args.GetArgumentCount() == 0) {
36 Debugger &debugger = m_interpreter.GetDebugger();
Greg Clayton456f2712015-01-14 19:45:21 +000037
Kate Stoneb9c1b512016-09-06 20:57:50 +000038 lldb::StreamFileSP input_sp = debugger.GetInputFile();
39 if (input_sp && input_sp->GetFile().GetIsRealTerminal() &&
40 input_sp->GetFile().GetIsInteractive()) {
41 IOHandlerSP io_handler_sp(new IOHandlerCursesGUI(debugger));
42 if (io_handler_sp)
43 debugger.PushIOHandler(io_handler_sp);
44 result.SetStatus(eReturnStatusSuccessFinishResult);
45 } else {
46 result.AppendError("the gui command requires an interactive terminal.");
47 result.SetStatus(eReturnStatusFailed);
Greg Clayton44d93782014-01-27 23:43:24 +000048 }
Kate Stoneb9c1b512016-09-06 20:57:50 +000049 } else {
50 result.AppendError("the gui command takes no arguments.");
51 result.SetStatus(eReturnStatusFailed);
52 }
53 return true;
Deepak Panickal914b8d92014-01-31 18:48:46 +000054#else
Kate Stoneb9c1b512016-09-06 20:57:50 +000055 result.AppendError("lldb was not build with gui support");
56 return false;
Deepak Panickal914b8d92014-01-31 18:48:46 +000057#endif
Greg Clayton44d93782014-01-27 23:43:24 +000058}